build.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #
  2. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #
  5. #!/bin/bash
  6. CURR_DIR=$PWD
  7. WAMR_DIR=${PWD}/../..
  8. OUT_DIR=${PWD}/out
  9. WASM_APPS=${PWD}/wasm-apps
  10. rm -rf ${OUT_DIR}
  11. mkdir ${OUT_DIR}
  12. mkdir ${OUT_DIR}/wasm-apps
  13. echo "#####################build inst-context project"
  14. cd ${CURR_DIR}
  15. mkdir -p cmake_build
  16. cd cmake_build
  17. cmake ..
  18. make -j ${nproc}
  19. if [ $? != 0 ];then
  20. echo "BUILD_FAIL inst-context exit as $?\n"
  21. exit 2
  22. fi
  23. cp -a inst-context ${OUT_DIR}
  24. echo -e "\n"
  25. echo "#####################build wasm apps"
  26. cd ${WASM_APPS}
  27. for i in `ls *.c`
  28. do
  29. APP_SRC="$i"
  30. OUT_FILE=${i%.*}.wasm
  31. # use WAMR SDK to build out the .wasm binary
  32. # require wasi-sdk with wasi-threads support. (wasi-sdk-20.0 or later)
  33. /opt/wasi-sdk/bin/clang \
  34. --target=wasm32-wasi-threads \
  35. -pthread \
  36. -Wl,--import-memory \
  37. -Wl,--export-memory \
  38. -Wl,--max-memory=655360 \
  39. -o ${OUT_DIR}/wasm-apps/${OUT_FILE} ${APP_SRC}
  40. if [ -f ${OUT_DIR}/wasm-apps/${OUT_FILE} ]; then
  41. echo "build ${OUT_FILE} success"
  42. else
  43. echo "build ${OUT_FILE} fail"
  44. fi
  45. done
  46. echo "####################build wasm apps done"