-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (170 loc) · 5.95 KB
/
build_node_shared.yml
File metadata and controls
189 lines (170 loc) · 5.95 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Build Node.js Shared Library
on:
release:
types: [created]
pull_request:
types: [opened, synchronize, reopened]
paths:
- '.github/workflows/build_node_shared.yml'
jobs:
build:
timeout-minutes: 720 # 12 hours (QEMU ARM64 builds are slow)
strategy:
matrix:
include:
# Linux x64 builds
- os: ubuntu-latest
platform: linux
arch: x64
compiler: gcc
container: ghcr.io/ten-framework/ten_building_ubuntu2204
lib_name: libnode.so.127
nproc_cmd: nproc
- os: ubuntu-latest
platform: linux
arch: x64
compiler: clang
container: ghcr.io/ten-framework/ten_building_ubuntu2204
lib_name: libnode.so.127
nproc_cmd: nproc
# Linux ARM64 builds (using cross-compilation)
- os: ubuntu-latest
platform: linux
arch: arm64
compiler: gcc
container: ghcr.io/ten-framework/ten_building_ubuntu2204
lib_name: libnode.so.127
nproc_cmd: nproc
- os: ubuntu-latest
platform: linux
arch: arm64
compiler: clang
container: ghcr.io/ten-framework/ten_building_ubuntu2204
lib_name: libnode.so.127
nproc_cmd: nproc
# macOS x64 builds
# Note: macOS should use Clang (Apple's official toolchain), GCC has compatibility issues
- os: macos-13
platform: mac
arch: x64
compiler: clang
container: ""
lib_name: libnode.127.dylib
nproc_cmd: sysctl -n hw.ncpu
# macOS ARM64 builds
# Note: Apple Silicon only supports Clang
- os: macos-14
platform: mac
arch: arm64
compiler: clang
container: ""
lib_name: libnode.127.dylib
nproc_cmd: sysctl -n hw.ncpu
# Windows x64 builds
- os: windows-latest
platform: win
arch: x64
compiler: msvc
container: ""
lib_name: libnode.dll
nproc_cmd: $env:NUMBER_OF_PROCESSORS
# Windows ARM64 builds (cross-compilation)
- os: windows-latest
platform: win
arch: arm64
compiler: msvc
container: ""
lib_name: libnode.dll
nproc_cmd: $env:NUMBER_OF_PROCESSORS
runs-on: ${{ matrix.os }}
container: ${{ matrix.container != '' && matrix.container || null }}
steps:
- name: Checkout Node.js
uses: actions/checkout@v4
with:
repository: nodejs/node
ref: v22.12.0
- name: Setup cross-compilation toolchain (Linux ARM64)
if: matrix.platform == 'linux' && matrix.arch == 'arm64'
run: |
apt-get update
apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
if [ "${{ matrix.compiler }}" = "clang" ]; then
apt-get install -y clang llvm
fi
- name: Setup Python (macOS)
if: matrix.platform == 'mac'
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Setup Python (Windows)
if: matrix.platform == 'win'
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Setup MSVC (Windows)
if: matrix.platform == 'win'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- name: Configure and Build (Linux ARM64 with cross-compilation)
if: matrix.platform == 'linux' && matrix.arch == 'arm64'
run: |
if [ "${{ matrix.compiler }}" = "gcc" ]; then
export CC=aarch64-linux-gnu-gcc
export CXX=aarch64-linux-gnu-g++
export CC_host=gcc
export CXX_host=g++
else
export CC="clang --target=aarch64-linux-gnu"
export CXX="clang++ --target=aarch64-linux-gnu"
export CC_host=clang
export CXX_host=clang++
fi
./configure --shared \
--dest-cpu=arm64 \
--cross-compiling \
--without-npm \
--without-corepack
make -j$(nproc)
- name: Configure and Build (Linux x64 and macOS)
if: matrix.platform != 'win' && (matrix.platform != 'linux' || matrix.arch != 'arm64')
run: |
if [ "${{ matrix.compiler }}" = "gcc" ]; then
export CC=gcc
export CXX=g++
else
export CC=clang
export CXX=clang++
fi
./configure --shared
make -j$(${{ matrix.nproc_cmd }})
- name: Configure and Build (Windows)
if: matrix.platform == 'win'
shell: cmd
run: |
if "${{ matrix.arch }}" == "arm64" (
vcbuild.bat dll arm64
) else (
vcbuild.bat dll x64
)
- name: Package assets
if: startsWith(github.ref, 'refs/tags/')
run: |
if [ "${{ matrix.platform }}" = "win" ]; then
cd Release
# Package shared libraries into zip archive
7z a node-shared-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.compiler }}.zip ${{ matrix.lib_name }} libnode.lib node.lib
else
cd out/Release
# Package shared libraries into zip archive
zip node-shared-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.compiler }}.zip ${{ matrix.lib_name }}
fi
shell: bash
- name: Publish to release assets
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
out/Release/node-shared-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.compiler }}.zip
Release/node-shared-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.compiler }}.zip