Skip to content

Commit c3dd378

Browse files
authored
Merge branch 'web-devkits:main' into dev_ganjing
2 parents 69c1e23 + 355cd3d commit c3dd378

File tree

107 files changed

+6362
-610
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+6362
-610
lines changed

.github/workflows/ts2wasm_macos.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#
2+
# Copyright (C) 2023 Intel Corporation. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
#
5+
6+
name: ts2wasm-compiler CI MacOS
7+
8+
on:
9+
push:
10+
paths-ignore:
11+
- "doc/**"
12+
- "README.md"
13+
pull_request:
14+
types:
15+
- opened
16+
- synchronize
17+
paths-ignore:
18+
- "doc/**"
19+
- "README.md"
20+
# allow to be triggered manually
21+
workflow_dispatch:
22+
23+
# Cancel any in-flight jobs for the same PR/branch so there's only one active
24+
# at a time
25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.ref }}
27+
cancel-in-progress: true
28+
29+
jobs:
30+
install_dependencies:
31+
runs-on: ${{ matrix.os }}
32+
strategy:
33+
matrix:
34+
# node-version: [10.x, 12.x, 14.x, 15.x, 16.x]
35+
# Test the latest version of Node.js plus the last two LTS versions.
36+
# node-version:
37+
# - "*"
38+
# - lts/*
39+
# - lts/-1
40+
node-version: [16.x, 18.x]
41+
os: [macos-12]
42+
steps:
43+
- uses: actions/checkout@v3
44+
with:
45+
fetch-depth: 5
46+
47+
- name: Use node version ${{ matrix.node-version }}
48+
uses: actions/setup-node@v3
49+
- run: npm install
50+
51+
- name: Linter
52+
run: npx lint-staged
53+
54+
validate_compilation:
55+
strategy:
56+
matrix:
57+
# node-version: [10.x, 12.x, 14.x, 15.x, 16.x]
58+
# Test the latest version of Node.js plus the last two LTS versions.
59+
# node-version:
60+
# - "*"
61+
# - lts/*
62+
# - lts/-1
63+
os: [macos-12]
64+
runs-on: ${{ matrix.os }}
65+
66+
steps:
67+
- uses: actions/checkout@v3
68+
with:
69+
fetch-depth: 5
70+
- run: npm install
71+
72+
- name: build the compiler
73+
run: npm run build
74+
75+
- name: compile single file
76+
run: node build/cli/ts2wasm.js tests/samples/any_as_string.ts -o test.wasm
77+
78+
- name: Test compilation
79+
run:
80+
npm run test
81+
82+
validate_execution:
83+
needs:
84+
[install_dependencies]
85+
runs-on: macos-latest
86+
strategy:
87+
matrix:
88+
target: [
89+
"X86_64"
90+
]
91+
92+
steps:
93+
- uses: actions/checkout@v3
94+
with:
95+
fetch-depth: 5
96+
97+
- name: Use node version node-16
98+
uses: actions/setup-node@v3
99+
with:
100+
node-version: 16.x
101+
102+
- name: download dependencies
103+
run: |
104+
./download.sh
105+
working-directory: runtime-library/deps
106+
107+
- name: Build runtime
108+
run: |
109+
mkdir build && cd build
110+
cmake .. -DWAMR_BUILD_PLATFORM="darwin" -DWAMR_BUILD_TARGET=${{ matrix.target }} -DWAMR_GC_IN_EVERY_ALLOCATION=1 && make -j$(nproc)
111+
working-directory: runtime-library/
112+
113+
# TODO: fix validation for MacOS CI
114+
# - name: Validate execution
115+
# run:
116+
# npm start
117+
# working-directory: tools/validate/wamr

.github/workflows/ts2wasm_windows.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#
2+
# Copyright (C) 2023 Intel Corporation. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
#
5+
6+
name: ts2wasm-compiler windows
7+
8+
on:
9+
push:
10+
paths-ignore:
11+
- "doc/**"
12+
- "README.md"
13+
pull_request:
14+
types:
15+
- opened
16+
- synchronize
17+
paths-ignore:
18+
- "doc/**"
19+
- "README.md"
20+
# allow to be triggered manually
21+
workflow_dispatch:
22+
23+
# Cancel any in-flight jobs for the same PR/branch so there's only one active
24+
# at a time
25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.ref }}
27+
cancel-in-progress: true
28+
29+
jobs:
30+
install_dependencies:
31+
runs-on: windows-latest
32+
strategy:
33+
matrix:
34+
# node-version: [10.x, 12.x, 14.x, 15.x, 16.x]
35+
# Test the latest version of Node.js plus the last two LTS versions.
36+
# node-version:
37+
# - "*"
38+
# - lts/*
39+
# - lts/-1
40+
node-version: [16.x]
41+
steps:
42+
- uses: actions/checkout@v3
43+
with:
44+
fetch-depth: 5
45+
46+
- name: Use node version ${{ matrix.node-version }}
47+
uses: actions/setup-node@v3
48+
with:
49+
node-version: ${{ matrix.node-version }}
50+
51+
- run: npm install
52+
53+
validate_compilation:
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- uses: actions/checkout@v3
58+
with:
59+
fetch-depth: 5
60+
- run: npm install
61+
62+
- name: Test compilation
63+
run:
64+
npm run test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ logs
1313
*.wasm
1414
*.log
1515
*.swo
16+
example/app-framework/cmake-build/
17+
example/app-framework/out/

cli/options.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@
6363
"description": "Specify the entry function, default is _entry",
6464
"default": "_entry"
6565
},
66+
"startSection": {
67+
"category": "Compile",
68+
"description": "Whether to use start section to do initialization, default is false",
69+
"default": false
70+
},
6671
"dumpSemanticTree": {
6772
"category": "Debug",
6873
"description": "dump semantic tree, default is false",

config/config_mgr.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface ConfigMgr {
1010
enableException: boolean;
1111
enableStringRef: boolean;
1212
entry: string;
13+
startSection: boolean;
1314
dumpSemanticTree: boolean;
1415
}
1516

@@ -20,6 +21,7 @@ const defaultConfig: ConfigMgr = {
2021
enableException: false,
2122
enableStringRef: true,
2223
entry: '_entry',
24+
startSection: false,
2325
dumpSemanticTree: false,
2426
};
2527

doc/developer-guide/basic_concepts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ As shown in the graph above, the fundamental processing principles for different
3030
- `user defined interface` is widely used in TypeScript, treating it as dynamic will largely influence the performance, so we introduced `meta` to apply static compilation
3131
- `builtin objects` are objects provided by JavaScript runtime, TypeScript defines them as interface for type checking purpose.
3232

33-
- Implementing these built-in objects demands a significant amount of effort, so we treat them as `any` by default, this allows us to immediately use the standard library implementation already available in external environment. (see [fallback](../fallback.md))
33+
- Implementing these built-in objects demands a significant amount of effort, so we treat them as `any` by default, this allows us to immediately use the standard library implementation already available in external environment. (see [fallback](./fallback.md))
3434

3535
- Simultaneously, we are working on static compilation solutions for selected built-in objects (e.g. `String`, `Array`) to improve performance. The priority of static compilation for these objects is determined based on their actual usage frequency.
3636

example/app-framework/CMakeLists.txt

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Copyright (C) 2023 Intel Corporation. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
cmake_minimum_required (VERSION 2.9)
5+
6+
project (simple)
7+
8+
################ wamr runtime settings ################
9+
message(STATUS "WAMR_BUILD_SDK_PROFILE=${WAMR_BUILD_SDK_PROFILE}")
10+
11+
# Reset default linker flags
12+
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
13+
set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
14+
15+
if ("$ENV{COLLECT_CODE_COVERAGE}" STREQUAL "1" OR COLLECT_CODE_COVERAGE EQUAL 1)
16+
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
17+
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
18+
endif ()
19+
20+
set (RUNTIMR_DIR ${CMAKE_CURRENT_LIST_DIR}/../../runtime-library)
21+
set (WAMR_ROOT_DIR ${RUNTIMR_DIR}/deps/wamr-gc)
22+
23+
## use library and headers in the SDK
24+
link_directories(${WAMR_ROOT_DIR}/wamr-sdk/out/${WAMR_BUILD_SDK_PROFILE}/runtime-sdk/lib)
25+
include_directories(
26+
${WAMR_ROOT_DIR}/wamr-sdk/out/${WAMR_BUILD_SDK_PROFILE}/runtime-sdk/include
27+
${WAMR_ROOT_DIR}/core/shared/utils
28+
${WAMR_ROOT_DIR}/core/shared/platform/linux
29+
)
30+
31+
################ application related ################
32+
33+
include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
34+
35+
#Note: uncomment below line to use UART mode
36+
#add_definitions (-DCONNECTION_UART)
37+
38+
39+
## wamr
40+
# include(${CMAKE_CURRENT_LIST_DIR}/wamr_config_wasmnizer_ts.cmake)
41+
# add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE})
42+
set (WAMR_BUILD_PLATFORM "linux")
43+
set (WAMR_BUILD_TARGET X86_64)
44+
set (WAMR_BUILD_INTERP 1)
45+
set (WAMR_BUILD_AOT 1)
46+
set (WAMR_BUILD_JIT 0)
47+
set (WAMR_BUILD_LIBC_BUILTIN 1)
48+
set (WAMR_BUILD_LIBC_WASI 0)
49+
set (WAMR_BUILD_GC 1)
50+
set (WAMR_BUILD_GC_BINARYEN 1)
51+
set (WAMR_BUILD_STRINGREF 1)
52+
set (USE_SIMPLE_LIBDYNTYPE 1)
53+
54+
## stringref
55+
set(STRINGREF_DIR ${RUNTIMR_DIR}/stringref)
56+
set(WAMR_STRINGREF_IMPL_SOURCE
57+
${STRINGREF_DIR}/stringref_simple.c
58+
)
59+
60+
include(${RUNTIMR_DIR}/deps/wamr-gc/build-scripts/runtime_lib.cmake)
61+
62+
## libdyntype
63+
set(LIBDYNTYPE_DIR ${RUNTIMR_DIR}/libdyntype)
64+
include (${LIBDYNTYPE_DIR}/libdyntype.cmake)
65+
66+
## stdlib
67+
set(STDLIB_DIR ${RUNTIMR_DIR}/stdlib)
68+
include_directories(${STDLIB_DIR})
69+
set(STDLIB_SOURCE
70+
${STDLIB_DIR}/lib_console.c
71+
${STDLIB_DIR}/lib_array.c
72+
${STDLIB_DIR}/lib_timer.c
73+
)
74+
75+
## struct-indirect
76+
set(STRUCT_INDIRECT_DIR ${RUNTIMR_DIR}/struct-indirect)
77+
include_directories(${STRUCT_INDIRECT_DIR})
78+
set(STRUCT_INDIRECT_SOURCE
79+
${STRUCT_INDIRECT_DIR}/lib_struct_indirect.c
80+
)
81+
82+
## utils
83+
set(UTILS_DIR ${RUNTIMR_DIR}/utils)
84+
include_directories(${UTILS_DIR})
85+
set(TYPE_UTILS_SOURCE
86+
${UTILS_DIR}/type_utils.c
87+
)
88+
set(OBJECT_UTILS_SOURCE
89+
${UTILS_DIR}/object_utils.c
90+
)
91+
set(WAMR_UTILS_SOURCE
92+
${UTILS_DIR}/wamr_utils.c
93+
)
94+
# Ignore warnings of QuickJS
95+
set_source_files_properties(
96+
${QUICKJS_SOURCE}
97+
PROPERTIES
98+
COMPILE_FLAGS "-w"
99+
)
100+
101+
add_executable (simple src/main.c src/iwasm_main.c
102+
${QUICKJS_SOURCE}
103+
${LIBDYNTYPE_SRC}
104+
${STDLIB_SOURCE}
105+
${STRUCT_INDIRECT_SOURCE}
106+
${TYPE_UTILS_SOURCE}
107+
${OBJECT_UTILS_SOURCE}
108+
${WAMR_UTILS_SOURCE}
109+
)
110+
target_link_libraries (simple vmlib -lm -ldl -lpthread -lrt)
111+
112+
113+

0 commit comments

Comments
 (0)