Skip to content

Commit 385a103

Browse files
committed
fix: add Zig setup and configuration for multiple environments in build.yml
1 parent d868d45 commit 385a103

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
runs-on: ubuntu-24.04
2121
container:
2222
image: alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/alinux3:latest
23+
env:
24+
ZIG_TARGET: x86_64-linux-gnu
2325
steps:
2426
- name: Install prerequisites
2527
run: yum install -y git curl wget xz tar unzip rsync which python3 python3-pip python3-setuptools autoconf automake libtool pkgconfig gcc gcc-c++ make ninja-build cmake file vim procps-ng iputils
@@ -32,6 +34,25 @@ jobs:
3234
curl -fsSL https://rpm.nodesource.com/setup_18.x | bash -
3335
yum install -y nodejs
3436
37+
- name: Setup Zig
38+
uses: mlugg/setup-zig@v2
39+
with:
40+
version: 0.15.2
41+
42+
- name: Configure Zig environment
43+
run: |
44+
ZIG_BIN=$(command -v zig)
45+
if [ -z "$ZIG_BIN" ]; then
46+
echo "zig binary not found" >&2
47+
exit 1
48+
fi
49+
echo "ZIG_BIN=$ZIG_BIN" >> "$GITHUB_ENV"
50+
echo "CC=$ZIG_BIN cc -target $ZIG_TARGET -fno-sanitize=undefined" >> "$GITHUB_ENV"
51+
echo "CXX=$ZIG_BIN c++ -target $ZIG_TARGET -fno-sanitize=undefined" >> "$GITHUB_ENV"
52+
echo "CFLAGS=-fPIC -fno-sanitize=undefined" >> "$GITHUB_ENV"
53+
echo "CXXFLAGS=-fPIC -fno-sanitize=undefined" >> "$GITHUB_ENV"
54+
echo "LDFLAGS=-static-libstdc++ -static-libgcc -fno-sanitize=undefined" >> "$GITHUB_ENV"
55+
3556
- name: Install npm dependencies
3657
run: npm install --no-audit --prefer-offline
3758

@@ -57,6 +78,8 @@ jobs:
5778
runs-on: ubuntu-24.04-arm
5879
container:
5980
image: alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/alinux3:latest
81+
env:
82+
ZIG_TARGET: aarch64-linux-gnu
6083
steps:
6184
- name: Install prerequisites
6285
run: yum install -y git curl wget xz tar unzip rsync which python3 python3-pip python3-setuptools autoconf automake libtool pkgconfig gcc gcc-c++ make ninja-build cmake file vim procps-ng iputils
@@ -69,6 +92,25 @@ jobs:
6992
curl -fsSL https://rpm.nodesource.com/setup_18.x | bash -
7093
yum install -y nodejs
7194
95+
- name: Setup Zig
96+
uses: mlugg/setup-zig@v2
97+
with:
98+
version: 0.15.2
99+
100+
- name: Configure Zig environment
101+
run: |
102+
ZIG_BIN=$(command -v zig)
103+
if [ -z "$ZIG_BIN" ]; then
104+
echo "zig binary not found" >&2
105+
exit 1
106+
fi
107+
echo "ZIG_BIN=$ZIG_BIN" >> "$GITHUB_ENV"
108+
echo "CC=$ZIG_BIN cc -target $ZIG_TARGET -fno-sanitize=undefined" >> "$GITHUB_ENV"
109+
echo "CXX=$ZIG_BIN c++ -target $ZIG_TARGET -fno-sanitize=undefined" >> "$GITHUB_ENV"
110+
echo "CFLAGS=-fPIC -fno-sanitize=undefined" >> "$GITHUB_ENV"
111+
echo "CXXFLAGS=-fPIC -fno-sanitize=undefined" >> "$GITHUB_ENV"
112+
echo "LDFLAGS=-static-libstdc++ -static-libgcc -fno-sanitize=undefined" >> "$GITHUB_ENV"
113+
72114
- name: Install npm dependencies
73115
run: npm install --no-audit --prefer-offline
74116

@@ -94,13 +136,34 @@ jobs:
94136
runs-on: ubuntu-24.04
95137
container:
96138
image: alpine:latest
139+
env:
140+
ZIG_TARGET: x86_64-linux-musl
97141
steps:
98142
- name: Checkout
99143
uses: actions/checkout@v4
100144

101145
- name: Install system dependencies
102146
run: apk add --no-cache nodejs npm bash build-base cmake ninja python3 curl unzip git autoconf automake libtool pkgconfig
103147

148+
- name: Setup Zig
149+
uses: mlugg/setup-zig@v2
150+
with:
151+
version: 0.15.2
152+
153+
- name: Configure Zig environment
154+
run: |
155+
ZIG_BIN=$(command -v zig)
156+
if [ -z "$ZIG_BIN" ]; then
157+
echo "zig binary not found" >&2
158+
exit 1
159+
fi
160+
echo "ZIG_BIN=$ZIG_BIN" >> "$GITHUB_ENV"
161+
echo "CC=$ZIG_BIN cc -target $ZIG_TARGET -fno-sanitize=undefined" >> "$GITHUB_ENV"
162+
echo "CXX=$ZIG_BIN c++ -target $ZIG_TARGET -fno-sanitize=undefined" >> "$GITHUB_ENV"
163+
echo "CFLAGS=-fPIC -fno-sanitize=undefined" >> "$GITHUB_ENV"
164+
echo "CXXFLAGS=-fPIC -fno-sanitize=undefined" >> "$GITHUB_ENV"
165+
echo "LDFLAGS=-static-libstdc++ -static-libgcc -fno-sanitize=undefined" >> "$GITHUB_ENV"
166+
104167
- name: Install npm dependencies
105168
run: npm install --no-audit --prefer-offline
106169

@@ -126,13 +189,34 @@ jobs:
126189
runs-on: ubuntu-24.04-arm
127190
container:
128191
image: alpine:latest
192+
env:
193+
ZIG_TARGET: aarch64-linux-musl
129194
steps:
130195
- name: Checkout
131196
uses: actions/checkout@v4
132197

133198
- name: Install system dependencies
134199
run: apk add --no-cache nodejs npm bash build-base cmake ninja python3 curl unzip git autoconf automake libtool pkgconfig
135200

201+
- name: Setup Zig
202+
uses: mlugg/setup-zig@v2
203+
with:
204+
version: 0.15.2
205+
206+
- name: Configure Zig environment
207+
run: |
208+
ZIG_BIN=$(command -v zig)
209+
if [ -z "$ZIG_BIN" ]; then
210+
echo "zig binary not found" >&2
211+
exit 1
212+
fi
213+
echo "ZIG_BIN=$ZIG_BIN" >> "$GITHUB_ENV"
214+
echo "CC=$ZIG_BIN cc -target $ZIG_TARGET -fno-sanitize=undefined" >> "$GITHUB_ENV"
215+
echo "CXX=$ZIG_BIN c++ -target $ZIG_TARGET -fno-sanitize=undefined" >> "$GITHUB_ENV"
216+
echo "CFLAGS=-fPIC -fno-sanitize=undefined" >> "$GITHUB_ENV"
217+
echo "CXXFLAGS=-fPIC -fno-sanitize=undefined" >> "$GITHUB_ENV"
218+
echo "LDFLAGS=-static-libstdc++ -static-libgcc -fno-sanitize=undefined" >> "$GITHUB_ENV"
219+
136220
- name: Install npm dependencies
137221
run: npm install --no-audit --prefer-offline
138222

0 commit comments

Comments
 (0)