forked from bytecodealliance/wasm-micro-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_framework.cmake
89 lines (70 loc) · 2.83 KB
/
app_framework.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
add_definitions (-DWASM_ENABLE_APP_FRAMEWORK=1)
set (APP_FRAMEWORK_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})
if ( NOT DEFINED APP_FRAMEWORK_INCLUDE_TYPE )
LIST (APPEND WASM_APP_LIB_SOURCE_ALL ${CMAKE_CURRENT_LIST_DIR}/app_ext_lib_export.c)
endif()
# app-native-shared and base are required
include (${APP_FRAMEWORK_ROOT_DIR}/app-native-shared/native_interface.cmake)
LIST (APPEND WASM_APP_SOURCE_ALL ${NATIVE_INTERFACE_SOURCE})
MACRO(SUBDIRLIST result curdir)
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
SET(dirlist "")
FOREACH(child ${children})
IF(IS_DIRECTORY ${curdir}/${child})
LIST(APPEND dirlist ${child})
ENDIF()
ENDFOREACH()
SET(${result} ${dirlist})
ENDMACRO()
function (add_module_native arg)
message ("Add native module ${ARGV0}")
include (${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/native/wasm_lib.cmake)
file (GLOB header
${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/native/*.h
${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/native/*.inl
)
LIST (APPEND RUNTIME_LIB_HEADER_LIST ${header})
set (RUNTIME_LIB_HEADER_LIST ${RUNTIME_LIB_HEADER_LIST} PARENT_SCOPE)
LIST (APPEND WASM_APP_LIB_SOURCE_ALL ${WASM_APP_LIB_CURRENT_SOURCE})
set (WASM_APP_LIB_SOURCE_ALL ${WASM_APP_LIB_SOURCE_ALL} PARENT_SCOPE)
endfunction ()
function (add_module_app arg)
message ("Add app module ${ARGV0}")
include (${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/app/wasm_app.cmake)
LIST (APPEND WASM_APP_WA_INC_DIR_LIST "${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/app/wa-inc")
set (WASM_APP_WA_INC_DIR_LIST ${WASM_APP_WA_INC_DIR_LIST} PARENT_SCOPE)
LIST (APPEND WASM_APP_NAME ${ARGV0})
set (WASM_APP_NAME ${WASM_APP_NAME} PARENT_SCOPE)
LIST (APPEND WASM_APP_SOURCE_ALL ${WASM_APP_CURRENT_SOURCE})
set (WASM_APP_SOURCE_ALL ${WASM_APP_SOURCE_ALL} PARENT_SCOPE)
endfunction ()
if ("${WAMR_BUILD_APP_LIST}" STREQUAL "WAMR_APP_BUILD_ALL")
# add all modules under this folder
SUBDIRLIST(SUBDIRS ${APP_FRAMEWORK_ROOT_DIR})
FOREACH(subdir ${SUBDIRS})
if ("${subdir}" STREQUAL "app-native-shared")
continue()
endif ()
if ("${subdir}" STREQUAL "template")
continue()
endif ()
if ( NOT DEFINED APP_FRAMEWORK_INCLUDE_TYPE )
add_module_native (${subdir})
else ()
add_module_app (${subdir})
endif ()
ENDFOREACH()
else ()
# add each module in the list
FOREACH (dir IN LISTS WAMR_BUILD_APP_LIST)
string(REPLACE "WAMR_APP_BUILD_" "" dir ${dir})
string(TOLOWER ${dir} dir)
if ( NOT DEFINED APP_FRAMEWORK_INCLUDE_TYPE )
add_module_native (${dir})
else ()
add_module_app (${dir})
endif ()
ENDFOREACH (dir)
endif()