build.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/bash
  2. CURR_DIR=$PWD
  3. WAMR_DIR=${PWD}/../..
  4. OUT_DIR=${PWD}/out
  5. BUILD_DIR=${PWD}/build
  6. IWASM_ROOT=${PWD}/../../core/iwasm
  7. APP_LIBS=${IWASM_ROOT}/lib/app-libs
  8. NATIVE_LIBS=${IWASM_ROOT}/lib/native-interface
  9. APP_LIB_SRC="${APP_LIBS}/base/*.c ${APP_LIBS}/extension/sensor/*.c ${APP_LIBS}/extension/connection/*.c ${APP_LIBS}/extension/gui/src/*.c ${NATIVE_LIBS}/*.c"
  10. WASM_APPS=${PWD}/wasm-apps
  11. rm -rf ${OUT_DIR}
  12. mkdir ${OUT_DIR}
  13. mkdir ${OUT_DIR}/wasm-apps
  14. cd ${WAMR_DIR}/core/shared-lib/mem-alloc
  15. if [ ! -d "tlsf" ]; then
  16. git clone https://github.com/mattconte/tlsf
  17. fi
  18. cd ${WAMR_DIR}/core/iwasm/lib/3rdparty
  19. if [ ! -d "lvgl" ]; then
  20. git clone https://github.com/littlevgl/lvgl.git --branch v6.0.1
  21. fi
  22. if [ ! -d "lv_drivers" ]; then
  23. git clone https://github.com/littlevgl/lv_drivers.git
  24. fi
  25. echo "#####################build simple project"
  26. cd ${CURR_DIR}
  27. mkdir -p cmake_build
  28. cd cmake_build
  29. cmake -DENABLE_GUI=YES ..
  30. make
  31. if [ $? != 0 ];then
  32. echo "BUILD_FAIL simple exit as $?\n"
  33. exit 2
  34. fi
  35. cp -a simple ${OUT_DIR}
  36. echo "#####################build simple project success"
  37. echo "#####################build host-tool"
  38. cd ${WAMR_DIR}/test-tools/host-tool
  39. mkdir -p bin
  40. cd bin
  41. cmake ..
  42. make
  43. if [ $? != 0 ];then
  44. echo "BUILD_FAIL host tool exit as $?\n"
  45. exit 2
  46. fi
  47. cp host_tool ${OUT_DIR}
  48. echo "#####################build host-tool success"
  49. echo "#####################build wasm apps"
  50. cd ${WASM_APPS}
  51. for i in `ls *.c`
  52. do
  53. APP_SRC="$i ${APP_LIB_SRC}"
  54. OUT_FILE=${i%.*}.wasm
  55. clang-8 -I${APP_LIBS}/base -I${APP_LIBS}/extension/sensor -I${NATIVE_LIBS} \
  56. -I${APP_LIBS}/extension/connection \
  57. -I${APP_LIBS}/extension/gui \
  58. -DENABLE_WGL=1 \
  59. --target=wasm32 -O3 -z stack-size=4096 -Wl,--initial-memory=65536 \
  60. -Wl,--allow-undefined \
  61. -Wl,--no-threads,--strip-all,--no-entry -nostdlib \
  62. -Wl,--export=on_init -Wl,--export=on_destroy \
  63. -Wl,--export=on_request -Wl,--export=on_response \
  64. -Wl,--export=on_sensor_event -Wl,--export=on_timer_callback \
  65. -Wl,--export=on_connection_data -Wl,--export=on_widget_event \
  66. -o ${OUT_DIR}/wasm-apps/${OUT_FILE} ${APP_SRC}
  67. if [ -f ${OUT_DIR}/wasm-apps/${OUT_FILE} ]; then
  68. echo "build ${OUT_FILE} success"
  69. else
  70. echo "build ${OUT_FILE} fail"
  71. fi
  72. done
  73. echo "#####################build wasm apps done"