preparation.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/bash
  2. #
  3. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  4. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  5. #
  6. readonly BUILD_CONTENT="/tmp/build_content"
  7. readonly WABT_VER=1.0.31
  8. readonly WABT_FILE="wabt-${WABT_VER}-ubuntu.tar.gz"
  9. readonly CMAKE_VER=3.25.1
  10. readonly CMAKE_FILE="cmake-${CMAKE_VER}-Linux-x86_64.sh"
  11. readonly BINARYEN_VER=version_111
  12. readonly BINARYEN_FILE="binaryen-${BINARYEN_VER}-x86_64-linux.tar.gz"
  13. readonly BAZEL_VER=6.0.0
  14. readonly BAZEL_FILE=bazel-${BAZEL_VER}-installer-linux-x86_64.sh
  15. function DEBUG() {
  16. env | grep -q "\<DEBUG\>"
  17. }
  18. #
  19. # install dependency
  20. function install_deps() {
  21. apt update
  22. apt install -y lsb-release wget software-properties-common \
  23. build-essential git tree zip unzip
  24. }
  25. #
  26. # install wabt
  27. function install_wabt() {
  28. if [[ ! -f ${WABT_FILE} ]]; then
  29. wget https://github.com/WebAssembly/wabt/releases/download/${WABT_VER}/${WABT_FILE}
  30. fi
  31. tar zxf ${WABT_FILE} -C /opt
  32. ln -sf /opt/wabt-${WABT_VER} /opt/wabt
  33. }
  34. #
  35. # install cmake
  36. function install_cmake() {
  37. if [[ ! -f cmake-${CMAKE_VER}-Linux-x86_64.sh ]]; then
  38. wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/${CMAKE_FILE}
  39. fi
  40. chmod a+x ${CMAKE_FILE}
  41. mkdir /opt/cmake
  42. ./${CMAKE_FILE} --prefix=/opt/cmake --skip-license
  43. ln -sf /opt/cmake/bin/cmake /usr/local/bin/cmake
  44. }
  45. #
  46. # install emsdk
  47. function install_emsdk() {
  48. cd /opt
  49. git clone https://github.com/emscripten-core/emsdk.git
  50. cd emsdk
  51. git pull
  52. ./emsdk install 3.1.28
  53. ./emsdk activate 3.1.28
  54. echo "source /opt/emsdk/emsdk_env.sh" >> "${HOME}"/.bashrc
  55. }
  56. #
  57. # install binaryen
  58. function install_binaryen() {
  59. if [[ ! -f ${BINARYEN_FILE} ]]; then
  60. wget https://github.com/WebAssembly/binaryen/releases/download/${BINARYEN_VER}/${BINARYEN_FILE}
  61. fi
  62. tar zxf ${BINARYEN_FILE} -C /opt
  63. ln -sf /opt/binaryen-${BINARYEN_VER} /opt/binaryen
  64. }
  65. #
  66. # install bazel
  67. function install_bazel() {
  68. if [[ ! -f ${BAZEL_FILE} ]]; then
  69. wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VER}/${BAZEL_FILE}
  70. fi
  71. chmod a+x ${BAZEL_FILE}
  72. ./${BAZEL_FILE}
  73. }
  74. #
  75. # MAIN
  76. DEBUG && set -xevu
  77. if [[ ! -d ${BUILD_CONTENT} ]]; then
  78. mkdir ${BUILD_CONTENT}
  79. fi
  80. cd ${BUILD_CONTENT} || exit
  81. if DEBUG; then
  82. "$@"
  83. else
  84. install_deps \
  85. && install_bazel \
  86. && install_binaryen \
  87. && install_cmake \
  88. && install_emsdk \
  89. && install_wabt \
  90. && install_wasi-sdk
  91. fi
  92. cd - > /dev/null || exit
  93. DEBUG && set +xevu