-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (115 loc) · 4.28 KB
/
Copy pathci.yml
File metadata and controls
131 lines (115 loc) · 4.28 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: CI/CD
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build-and-test:
name: "${{ matrix.os }} | ${{ matrix.compiler }} | ${{ matrix.backend }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# ======================= Ubuntu (Linux) =======================
- os: ubuntu-latest
compiler: gcc
backend: quickjs
- os: ubuntu-latest
compiler: gcc
backend: v8
v8_url: https://github.com/kuoruan/libv8/releases/download/v12.9.202.27/v8_Linux_x64.tar.xz
v8_inc: deps/v8/include
v8_lib: deps/v8/libv8_monolith.a
- os: ubuntu-latest
compiler: clang
backend: quickjs
- os: ubuntu-latest
compiler: clang
backend: v8
v8_url: https://github.com/kuoruan/libv8/releases/download/v12.9.202.27/v8_Linux_x64.tar.xz
v8_inc: deps/v8/include
v8_lib: deps/v8/libv8_monolith.a
# =========================== macOS ===========================
# 注意:目前的 macos-latest 默认是 ARM64(M1) 架构
- os: macos-latest
compiler: appleclang
backend: quickjs
- os: macos-latest
compiler: appleclang
backend: v8
v8_url: https://github.com/kuoruan/libv8/releases/download/v12.9.202.27/v8_macOS_arm64.tar.xz
v8_inc: deps/v8/include
v8_lib: deps/v8/libv8_monolith.a
# ========================== Windows ==========================
- os: windows-latest
compiler: msvc
backend: quickjs
- os: windows-latest
compiler: msvc
backend: v8
v8_url: https://github.com/kuoruan/libv8/releases/download/v12.9.202.27/v8_Windows_x64.7z
v8_inc: deps/v8
v8_lib: deps/v8/v8_monolith.lib
- os: windows-latest
compiler: clang-cl
backend: quickjs
- os: windows-latest
compiler: clang-cl
backend: v8
v8_url: https://github.com/kuoruan/libv8/releases/download/v12.9.202.27/v8_Windows_x64.7z
v8_inc: deps/v8
v8_lib: deps/v8/v8_monolith.lib
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Fetch QuickJS-NG
if: matrix.backend == 'quickjs'
shell: bash
run: |
git clone --depth 1 --branch v0.14.0 https://github.com/quickjs-ng/quickjs.git deps/quickjs-ng
- name: Fetch V8
if: matrix.backend == 'v8'
shell: bash
run: |
mkdir -p deps/v8
if [ "$RUNNER_OS" == "Windows" ]; then
curl -L -o v8.7z ${{ matrix.v8_url }}
7z x v8.7z -odeps/v8
else
curl -L -o v8.tar.xz ${{ matrix.v8_url }}
tar -xf v8.tar.xz -C deps/v8
fi
- name: Configure CMake
shell: bash
run: |
# 修复 Windows 下路径的转义问题
WORKSPACE_PATH="${GITHUB_WORKSPACE//\\//}"
CMAKE_ARGS="-DJSPP_BACKEND=${{ matrix.backend }} -DJSPP_BUILD_TESTS=ON"
# 根据矩阵配置编译器
if [ "${{ matrix.compiler }}" == "gcc" ]; then
export CC=gcc
export CXX=g++
elif [ "${{ matrix.compiler }}" == "clang" ]; then
export CC=clang
export CXX=clang++
elif [ "${{ matrix.compiler }}" == "clang-cl" ]; then
# Windows 的 MSBuild 生成器支持通过 -T ClangCL 切换成 clang-cl 工具链
CMAKE_ARGS="$CMAKE_ARGS -T ClangCL"
fi
# 挂载预构建的 V8 头文件和静态库
if [ "${{ matrix.backend }}" == "v8" ]; then
CMAKE_ARGS="$CMAKE_ARGS -DJSPP_EXTERNAL_INC=$WORKSPACE_PATH/${{ matrix.v8_inc }} -DJSPP_EXTERNAL_LIB=$WORKSPACE_PATH/${{ matrix.v8_lib }}"
fi
cmake -S . -B build $CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build build --config Release --parallel 4
- name: Run Tests
shell: bash
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
./bin/Release/jspp_test.exe
else
./bin/jspp_test
fi