Skip to content

Commit

Permalink
wamr_cmake(sync):fix wamr not export header compile error in cmake
Browse files Browse the repository at this point in the history
VELAPLATFO-41263

Change-Id: Ia198f593160b69ebf4b694f5046cbcb26c6a5d6a
Signed-off-by: xuxin19 <[email protected]>
  • Loading branch information
xuxin930 authored and xiaoxiang781216 committed Oct 26, 2024
1 parent 95d31c9 commit 44a8572
Showing 1 changed file with 61 additions and 19 deletions.
80 changes: 61 additions & 19 deletions interpreters/wamr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,37 @@ if(CONFIG_INTERPRETERS_WAMR)

nuttx_add_library(wamr STATIC)

set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/wamr/core/iwasm/include)

include(${WAMR_DIR}/product-mini/platforms/nuttx/CMakeLists.txt)
target_sources(wamr PRIVATE ${WAMR_SOURCES})
target_compile_options(wamr PRIVATE ${WAMR_CFLAGS})
# the WAMR_INCDIRS and WAMR_DEFINITIONS already exist in the directory domain
nuttx_add_application(
MODULE
${CONFIG_INTERPRETERS_WAMR}
NAME
iwasm
STACKSIZE
${CONFIG_INTERPRETERS_WAMR_STACKSIZE}
PRIORITY
${CONFIG_INTERPRETERS_WAMR_PRIORITY}
SRCS
${WAMR_DIR}/product-mini/platforms/nuttx/main.c
COMPILE_FLAGS
${WAMR_CFLAGS}
DEFINITIONS
${WAMR_DEFINITIONS}
INCLUDE_DIRECTORIES
${WAMR_INCDIRS}
DEPENDS
wamr)
if(CONFIG_INTERPRETERS_IWASM_TASK)
nuttx_add_application(
MODULE
${CONFIG_INTERPRETERS_WAMR}
NAME
iwasm
STACKSIZE
${CONFIG_INTERPRETERS_WAMR_STACKSIZE}
PRIORITY
${CONFIG_INTERPRETERS_WAMR_PRIORITY}
SRCS
${WAMR_DIR}/product-mini/platforms/nuttx/main.c
COMPILE_FLAGS
${WAMR_CFLAGS}
DEFINITIONS
${WAMR_DEFINITIONS}
INCLUDE_DIRECTORIES
${WAMR_INCDIRS}
DEPENDS
wamr)
endif()

if(CONFIG_INTERPRETERS_WAMR_LIBC_NUTTX
OR CONFIG_INTERPRETERS_WAMR_EXTERNAL_MODULE_REGISTRY)
Expand All @@ -79,9 +87,43 @@ if(CONFIG_INTERPRETERS_WAMR)
target_sources(wamr PRIVATE wamr_custom_init.c)
endif()

if(CONFIG_INTERPRETERS_WAMR_EXTERNAL_MODULE_REGISTRY)
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/include)
endif()

# Add ${CMAKE_BINARY_DIR}/wamrmod to the include directories
if(CONFIG_INTERPRETERS_WAMR_EXTERNAL_MODULE_REGISTRY)
target_include_directories(wamr PRIVATE ${CMAKE_BINARY_DIR}/wamrmod)
endif()

if(CONFIG_INTERPRETERS_WAMR_LIBC_NUTTX)
target_sources(wamr PRIVATE libc_nuttx.c)

set(GLUECSRCS
${CMAKE_CURRENT_BINARY_DIR}/syscall_glue.c
${CMAKE_CURRENT_BINARY_DIR}/libc_glue.c
${CMAKE_CURRENT_BINARY_DIR}/libm_glue.c)

add_custom_command(
OUTPUT ${GLUECSRCS}
COMMAND
${NUTTX_DIR}/tools/mkwamrglue.py -i ${NUTTX_DIR}/syscall/syscall.csv -o
${CMAKE_CURRENT_BINARY_DIR}/syscall_glue.c
COMMAND
${NUTTX_DIR}/tools/mkwamrglue.py -i ${NUTTX_DIR}/libs/libc/libc.csv -o
${CMAKE_CURRENT_BINARY_DIR}/libc_glue.c
COMMAND
${NUTTX_DIR}/tools/mkwamrglue.py -i ${NUTTX_DIR}/libs/libm/libm.csv -o
${CMAKE_CURRENT_BINARY_DIR}/libm_glue.c
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
DEPENDS ${NUTTX_DIR}/tools/mkwamrglue.py ${NUTTX_DIR}/syscall/syscall.csv
${NUTTX_DIR}/libs/libc/libc.csv ${NUTTX_DIR}/libs/libm/libm.csv
VERBATIM
COMMENT "WAMR:Gen and Updating ${GLUECSRCS}")
target_sources(wamr PRIVATE ${GLUECSRCS})
endif()

endif()

0 comments on commit 44a8572

Please sign in to comment.