|
|
3 年 前 | |
|---|---|---|
| .. | ||
| app-native-shared | 4 年 前 | |
| base | 3 年 前 | |
| connection | 4 年 前 | |
| sensor | 3 年 前 | |
| template | 6 年 前 | |
| wgl | 4 年 前 | |
| README.md | 5 年 前 | |
| app_ext_lib_export.c | 4 年 前 | |
| app_framework.cmake | 5 年 前 | |
This folder "app-native-shared" is for the source files shared by both WASM APP and native runtime
This folder "template" contains a pre-defined directory structure for a framework component. The developers can copy the template folder to create new components to the application framework.
Every other subfolder is framework component. Each component contains two library parts: app and native.
The app framework is built on top of two fundamental operations:
Asynchronized programming model is supported for WASM applications
Every WASM app has its own sandbox and thread
Queue and messaging
A component can be compilation configurable to the runtime. The wamr SDK tool "build_sdk.sh" supports menu config to select app components for building a customized runtime.
A number of CMAKE variables are defined to control build of framework and components. You can create a cmake file for defining these variables and include it in the CMakeList.txt for your software, or pass it in "-x" argument when run the build_sdk.sh for building the runtime SDK.
set (WAMR_BUILD_APP_FRAMEWORK 1)
set (WAMR_BUILD_APP_LIST WAMR_APP_BUILD_BASE)
Variables:
The configuration file can be generated through the wamr-sdk menu config:
cd wamr-sdk
./build_sdk -n [profile] -i
Generally you should follow following steps to create a new component:
Copy the “template” for creating a new folder
Implement the app part
Implement the native part
If your native function is exported to WASM, you need to create an inl file for the registration. It can be any file name, assuming the file name is "my_component.inl" here:
//use right signature for your functions
EXPORT_WASM_API_WITH_SIG(wasm_my_component_api_1, "(i*~)i"),
EXPORT_WASM_API_WITH_SIG(wasm_my_component_api_2, "(i)i"),
Ensure "wasm_lib.cmake" is provided as it will be included by the WAMR SDK building script
Add a definition in "wasm_lib.cmake" for your component, e.g.
add_definitions (-DAPP_FRAMEWORK_MY_COMPONENT)
Modify the file app_ext_lib_export.c to register native APIs exported for the new introduced component. Skip it if not exporting native functions.
#include "lib_export.h"
...
#ifdef APP_FRAMEWORK_MY_COMPONENT // this definition is created in wasm_lib.cmake
#include "my_component_native_api.h"
#endif
static NativeSymbol extended_native_symbol_defs[] = {
...
#ifdef APP_FRAMEWORK_MY_COMPONENT
#include "my_component.inl"
#endif
};