You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/port_wamr.md
+17-8Lines changed: 17 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,39 +10,43 @@ This document describes how to port WAMR to a new platform "**new-os**"
10
10
# Step 1: Implement platform API layer
11
11
12
12
-------------------------
13
-
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:
13
+
Firstly create the folder for platform API layer implementations:
14
+
* for common platforms, create a folder in **`core/shared/platform/new-os`** in WAMR repository folder, so the implementation can be upstreamed
15
+
* 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)
14
16
15
-
-`platform_internal.h`: It can be used for any platform specific definitions such as macros, data types and internal APIs.
17
+
In the folder you just created, you must provide the following files:
18
+
19
+
-`platform_internal.h`: It can be used for any platform-specific definitions such as macros, data types and internal APIs.
16
20
17
21
-`shared_platform.cmake`: the cmake file will be included by the building script. It is recommended to add a definition for your platform:
18
22
19
23
-```cmake
20
24
add_definitions(-DBH_PLATFORM_YOUR_NAME)
21
25
```
22
26
23
-
Then go to implement the APIs defined in following header files for the platform abstraction layer:
27
+
Then go to implement the APIs defined in the following header files for the platform abstraction layer:
24
28
25
-
- [`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.
29
+
- [`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.
26
30
- [`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`.
27
31
28
32
29
33
30
34
**common/posix:**
31
35
32
-
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.
36
+
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.
33
37
34
38
35
39
36
40
**common/math:**
37
41
38
-
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`.
42
+
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`.
39
43
40
44
41
45
42
46
# Step 2: Create the mini product for the platform
43
47
44
48
-------------------------
45
-
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.
49
+
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.
46
50
47
51
48
52
@@ -55,9 +59,14 @@ You should set cmake variable `WAMR_BUILD_PLATFORM` to your platform name while
55
59
```
56
60
mkdir build
57
61
cd build
58
-
cmake .. -DWAMR_BUILD_PLATFORM=new-os
62
+
cmake .. -DWAMR_BUILD_PLATFORM=new-os
59
63
```
60
64
65
+
For platform implementations that are outside of the WAMR repository (e.g. internal platforms), you also need to provide `SHARED_PLATFORM_CONFIG` path:
0 commit comments