Просмотр исходного кода

Simplify build setup for zephyr (#789)

Zephyr can apply board specific .conf and .overlay automatically,
move .conf to boards to make it easy to support different board without
addition command parameters.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Huang Qi 4 лет назад
Родитель
Сommit
a121e45a1e

+ 2 - 5
doc/build_wamr.md

@@ -302,11 +302,8 @@ Zephyr
 You need to download the Zephyr source code first and embed WAMR into it.
 ``` Bash
 git clone https://github.com/zephyrproject-rtos/zephyr.git
-cd zephyr/samples/
-cp -a <wamr_root_dir>/product-mini/platforms/zephyr/simple .
-cd simple
-ln -s <wamr_root_dir> wamr
-source ../../zephyr-env.sh
+source ../zephyr-env.sh
+cd <wamr_root_dir>/product-mini/platforms/zephyr/simple
 # Execute the ./build_and_run.sh script with board name as parameter. Here take x86 as example:
 ./build_and_run.sh x86
 

+ 3 - 3
product-mini/platforms/zephyr/simple/CMakeLists.txt

@@ -3,8 +3,8 @@
 
 cmake_minimum_required(VERSION 3.8.2)
 
-include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
-project(NONE)
+find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
+project(wamr)
 
 enable_language (ASM)
 
@@ -40,7 +40,7 @@ if (WAMR_BUILD_TARGET STREQUAL "RISCV64_LP64" OR WAMR_BUILD_TARGET STREQUAL "RIS
   set (WAMR_BUILD_FAST_INTERP 1)
 endif ()
 
-set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/wamr)
+set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../..)
 
 include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
 

+ 0 - 0
product-mini/platforms/zephyr/simple/prj_esp32.conf → product-mini/platforms/zephyr/simple/boards/esp32.conf


+ 0 - 0
product-mini/platforms/zephyr/simple/prj_nucleo767zi.conf → product-mini/platforms/zephyr/simple/boards/nucleo767zi.conf


+ 0 - 0
product-mini/platforms/zephyr/simple/prj_qemu_arc.conf → product-mini/platforms/zephyr/simple/boards/qemu_arc.conf


+ 0 - 0
product-mini/platforms/zephyr/simple/prj_qemu_cortex_a53.conf → product-mini/platforms/zephyr/simple/boards/qemu_cortex_a53.conf


+ 0 - 0
product-mini/platforms/zephyr/simple/prj_qemu_riscv32.conf → product-mini/platforms/zephyr/simple/boards/qemu_riscv32.conf


+ 0 - 0
product-mini/platforms/zephyr/simple/prj_qemu_riscv64.conf → product-mini/platforms/zephyr/simple/boards/qemu_riscv64.conf


+ 0 - 0
product-mini/platforms/zephyr/simple/prj_qemu_x86_nommu.conf → product-mini/platforms/zephyr/simple/boards/qemu_x86_nommu.conf


+ 0 - 0
product-mini/platforms/zephyr/simple/prj_qemu_xtensa.conf → product-mini/platforms/zephyr/simple/boards/qemu_xtensa.conf


+ 0 - 8
product-mini/platforms/zephyr/simple/build_and_run.sh

@@ -37,14 +37,12 @@ case $TARGET in
         $X86_TARGET)
                 west build -b qemu_x86_nommu \
                            . -p always -- \
-                           -DCONF_FILE=prj_qemu_x86_nommu.conf \
                            -DWAMR_BUILD_TARGET=X86_32
                 west build -t run
                 ;;
         $STM32_TARGET)
                 west build -b nucleo_f767zi \
                            . -p always -- \
-                           -DCONF_FILE=prj_nucleo767zi.conf \
                            -DWAMR_BUILD_TARGET=THUMBV7
                 west flash
                 ;;
@@ -53,7 +51,6 @@ case $TARGET in
                 west build -b esp32 \
                            . -p always -- \
                            -DESP_IDF_PATH=$ESP_IDF_PATH \
-                           -DCONF_FILE=prj_esp32.conf \
                            -DWAMR_BUILD_TARGET=XTENSA
                 # suppose the serial port is /dev/ttyUSB1 and you should change to
                 # the real name accordingly
@@ -62,21 +59,18 @@ case $TARGET in
         $QEMU_XTENSA_TARGET)
                 west build -b qemu_xtensa \
                            . -p always -- \
-                           -DCONF_FILE=prj_qemu_xtensa.conf \
                            -DWAMR_BUILD_TARGET=XTENSA
                 west build -t run
                 ;;
         $QEMU_CORTEX_A53)
                 west build -b qemu_cortex_a53 \
                            . -p always -- \
-                           -DCONF_FILE=prj_qemu_cortex_a53.conf \
                            -DWAMR_BUILD_TARGET=AARCH64
                 west build -t run
                 ;;
         $QEMU_RISCV64_TARGET)
                 west build -b qemu_riscv64 \
                             . -p always -- \
-                            -DCONF_FILE=prj_qemu_riscv64.conf \
                             -DWAMR_BUILD_TARGET=RISCV64_LP64 \
                             -DWAMR_BUILD_AOT=0
                 west build -t run
@@ -84,7 +78,6 @@ case $TARGET in
         $QEMU_RISCV32_TARGET)
                 west build -b qemu_riscv32 \
                             . -p always -- \
-                            -DCONF_FILE=prj_qemu_riscv32.conf \
                             -DWAMR_BUILD_TARGET=RISCV32_ILP32 \
                             -DWAMR_BUILD_AOT=0
                 west build -t run
@@ -92,7 +85,6 @@ case $TARGET in
         $QEMU_ARC_TARGET)
                 west build -b qemu_arc_em \
                             . -p always -- \
-                            -DCONF_FILE=prj_qemu_arc.conf \
                             -DWAMR_BUILD_TARGET=ARC \
                             -DWAMR_BUILD_AOT=0
                 west build -t run