mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2024-11-26 07:21:54 +00:00
Enable specifying out-of-source platform configuration cmake file (#1941)
Resolve #1935, enable specifying out-of-source platform folder with `cmake .. -DWAMR_BUILD_PLATFORM=new-os -DSHARED_PLATFORM_CONFIG=/path/to/new-os/shared_platform.cmake`
This commit is contained in:
parent
f3c1ad4864
commit
251e63f3ec
|
@ -19,6 +19,11 @@ endif ()
|
|||
if (NOT DEFINED DEPS_DIR)
|
||||
set (DEPS_DIR ${WAMR_ROOT_DIR}/core/deps)
|
||||
endif ()
|
||||
if (NOT DEFINED SHARED_PLATFORM_CONFIG)
|
||||
# CMake file for platform configuration. The PLATFORM_SHARED_SOURCE varable
|
||||
# should point to a list of platform-specfic source files to compile.
|
||||
set (SHARED_PLATFORM_CONFIG ${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake)
|
||||
endif ()
|
||||
|
||||
if (DEFINED EXTRA_SDK_INCLUDE_PATH)
|
||||
message(STATUS, "EXTRA_SDK_INCLUDE_PATH = ${EXTRA_SDK_INCLUDE_PATH} ")
|
||||
|
@ -165,7 +170,7 @@ LIST (APPEND RUNTIME_LIB_HEADER_LIST ${header})
|
|||
|
||||
enable_language (ASM)
|
||||
|
||||
include (${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake)
|
||||
include (${SHARED_PLATFORM_CONFIG})
|
||||
include (${SHARED_DIR}/mem-alloc/mem_alloc.cmake)
|
||||
include (${IWASM_DIR}/common/iwasm_common.cmake)
|
||||
include (${SHARED_DIR}/utils/shared_utils.cmake)
|
||||
|
|
|
@ -10,9 +10,13 @@ This document describes how to port WAMR to a new platform "**new-os**"
|
|||
# Step 1: Implement platform API layer
|
||||
|
||||
-------------------------
|
||||
Firstly create the folder **`core/shared/platform/new-os`** for platform API layer implementations. In the folder you just created, you must provide the following files:
|
||||
Firstly create the folder for platform API layer implementations:
|
||||
* for common platforms, create a folder in **`core/shared/platform/new-os`** in WAMR repository folder, so the implementation can be upstreamed
|
||||
* for platforms that are internal and its implementation shouldn't be published, it's recommended to create a folder outside of the WAMR repository folder (e.g. have separate repository for platform API layer implementation)
|
||||
|
||||
- `platform_internal.h`: It can be used for any platform specific definitions such as macros, data types and internal APIs.
|
||||
In the folder you just created, you must provide the following files:
|
||||
|
||||
- `platform_internal.h`: It can be used for any platform-specific definitions such as macros, data types and internal APIs.
|
||||
|
||||
- `shared_platform.cmake`: the cmake file will be included by the building script. It is recommended to add a definition for your platform:
|
||||
|
||||
|
@ -20,29 +24,29 @@ Firstly create the folder **`core/shared/platform/new-os`** for platform API lay
|
|||
add_definitions(-DBH_PLATFORM_YOUR_NAME)
|
||||
```
|
||||
|
||||
Then go to implement the APIs defined in following header files for the platform abstraction layer:
|
||||
Then go to implement the APIs defined in the following header files for the platform abstraction layer:
|
||||
|
||||
- [`platform_api_vmcore.h`](../core/shared/platform/include/platform_api_vmcore.h): mandatory for building mini-product (vmcore only). Part of APIs are needed only for Ahead of Time compilation support.
|
||||
- [`platform_api_vmcore.h`](../core/shared/platform/include/platform_api_vmcore.h): mandatory for building mini-product (vmcore only). Part of the APIs is needed only for Ahead of Time compilation support.
|
||||
- [`platform_api_extension.h`](../core/shared/platform/include/platform_api_extension.h): mandatory for app-mgr and app-framework. Given that the app-mgr and app-framework are not required for your target platform, you won't have to implement the API defined in the `platform_api_extension.h`.
|
||||
|
||||
|
||||
|
||||
**common/posix:**
|
||||
|
||||
There is posix based implementation of the platform API located in the `platform/common/posix` folder. You can include it if your platform support posix API. refer to platform linux implementation.
|
||||
There is posix based implementation of the platform API located in the `platform/common/posix` folder. You can include it if your platform supports posix API. refer to platform linux implementation.
|
||||
|
||||
|
||||
|
||||
**common/math:**
|
||||
|
||||
Some platforms such as ZephyrOS don't provide math functions e.g. sqrt, fabs and isnan, then you should include source files under the folder `platform/common/math`.
|
||||
Some platforms such as ZephyrOS don't provide math functions e.g. sqrt, fabs and isnan, then you should include source files under the folder `platform/common/math`.
|
||||
|
||||
|
||||
|
||||
# Step 2: Create the mini product for the platform
|
||||
|
||||
-------------------------
|
||||
You can build a mini WAMR product which is only the vmcore for you platform. Normally you need to implement the main function which loads a WASM file and run it with the WASM runtime. You don't have to do this step if there is no mini-product need for your platform porting.
|
||||
You can build a mini WAMR product which is only the vmcore for your platform. Normally you need to implement the main function which loads a WASM file and run it with the WASM runtime. You don't have to do this step if there is no mini-product need for your platform porting.
|
||||
|
||||
|
||||
|
||||
|
@ -55,9 +59,14 @@ You should set cmake variable `WAMR_BUILD_PLATFORM` to your platform name while
|
|||
```
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DWAMR_BUILD_PLATFORM=new-os
|
||||
cmake .. -DWAMR_BUILD_PLATFORM=new-os
|
||||
```
|
||||
|
||||
For platform implementations that are outside of the WAMR repository (e.g. internal platforms), you also need to provide `SHARED_PLATFORM_CONFIG` path:
|
||||
|
||||
```
|
||||
cmake .. -DWAMR_BUILD_PLATFORM=new-os -DSHARED_PLATFORM_CONFIG=/path/to/new-os/shared_platform.cmake
|
||||
```
|
||||
|
||||
|
||||
Refer to [build_wamr.md](./build_wamr.md) for the building configurations and parameters.
|
||||
|
|
Loading…
Reference in New Issue
Block a user