Skip to content
This repository was archived by the owner on Aug 18, 2025. It is now read-only.

Commit d75e875

Browse files
Merge pull request #1 from HelloAIXIAOJI/master
CodeNothing: GitHub Action adds CodeNothing release compilations for more platforms
2 parents f5af534 + 9f86270 commit d75e875

2 files changed

Lines changed: 346 additions & 67 deletions

File tree

.github/workflows/build_interpreter.yml

Lines changed: 151 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ on:
66
paths-ignore:
77
- 'library_*/**'
88
- '**.md'
9-
tags:
10-
- 'v*' # 添加标签触发
119
pull_request:
1210
branches: [ main ]
1311
paths-ignore:
@@ -28,37 +26,170 @@ jobs:
2826
build:
2927
name: 构建解释器
3028
runs-on: ${{ matrix.os }}
29+
continue-on-error: true
3130
strategy:
31+
fail-fast: false
3232
matrix:
33-
os: [windows-latest, ubuntu-latest, macos-latest]
3433
include:
34+
# Windows 平台
3535
- os: windows-latest
36-
artifact_name: codenothing-windows
37-
asset_name: codenothing-windows.zip
38-
release_name: Windows
36+
target: x86_64-pc-windows-msvc
37+
artifact_name: codenothing-windows-x64
38+
asset_name: codenothing-windows-x64.zip
39+
release_name: Windows x64
40+
exe_name: CodeNothing.exe
41+
- os: windows-latest
42+
target: i686-pc-windows-msvc
43+
artifact_name: codenothing-windows-x32
44+
asset_name: codenothing-windows-x32.zip
45+
release_name: Windows x32
46+
exe_name: CodeNothing.exe
47+
- os: windows-latest
48+
target: aarch64-pc-windows-msvc
49+
artifact_name: codenothing-windows-arm64
50+
asset_name: codenothing-windows-arm64.zip
51+
release_name: Windows ARM64
52+
exe_name: CodeNothing.exe
53+
# Linux 平台
54+
- os: ubuntu-latest
55+
target: x86_64-unknown-linux-gnu
56+
artifact_name: codenothing-linux-x64
57+
asset_name: codenothing-linux-x64.tar.gz
58+
release_name: Linux x64
59+
exe_name: CodeNothing
60+
- os: ubuntu-latest
61+
target: i686-unknown-linux-gnu
62+
artifact_name: codenothing-linux-x32
63+
asset_name: codenothing-linux-x32.tar.gz
64+
release_name: Linux x32
65+
exe_name: CodeNothing
3966
- os: ubuntu-latest
40-
artifact_name: codenothing-linux
41-
asset_name: codenothing-linux.tar.gz
42-
release_name: Linux
67+
target: aarch64-unknown-linux-gnu
68+
artifact_name: codenothing-linux-arm64
69+
asset_name: codenothing-linux-arm64.tar.gz
70+
release_name: Linux ARM64
71+
exe_name: CodeNothing
72+
# Android 平台
73+
- os: ubuntu-latest
74+
target: aarch64-linux-android
75+
artifact_name: codenothing-android-arm64
76+
asset_name: codenothing-android-arm64.tar.gz
77+
release_name: Android ARM64
78+
exe_name: CodeNothing
79+
# macOS 平台
80+
- os: macos-latest
81+
target: x86_64-apple-darwin
82+
artifact_name: codenothing-macos-intel
83+
asset_name: codenothing-macos-intel.tar.gz
84+
release_name: macOS Intel
85+
exe_name: CodeNothing
4386
- os: macos-latest
44-
artifact_name: codenothing-macos
45-
asset_name: codenothing-macos.tar.gz
46-
release_name: macOS
87+
target: aarch64-apple-darwin
88+
artifact_name: codenothing-macos-silicon
89+
asset_name: codenothing-macos-silicon.tar.gz
90+
release_name: macOS Apple Silicon
91+
exe_name: CodeNothing
4792

4893
steps:
4994
- uses: actions/checkout@v3
50-
95+
5196
- name: 设置Rust工具链
5297
uses: actions-rs/toolchain@v1
5398
with:
5499
toolchain: stable
100+
target: ${{ matrix.target }}
55101
override: true
102+
103+
- name: 安装 Windows 交叉编译工具
104+
if: matrix.os == 'windows-latest' && matrix.target != 'x86_64-pc-windows-msvc'
105+
run: |
106+
# Windows 交叉编译通常由 Rust 工具链自动处理
107+
echo "Windows 交叉编译目标: ${{ matrix.target }}"
108+
109+
- name: 安装交叉编译依赖 (Linux)
110+
if: matrix.os == 'ubuntu-latest'
111+
run: |
112+
case ${{ matrix.target }} in
113+
i686-unknown-linux-gnu)
114+
sudo apt-get update
115+
sudo apt-get install -y gcc-multilib g++-multilib
116+
echo "CC_i686_unknown_linux_gnu=i686-linux-gnu-gcc" >> $GITHUB_ENV
117+
echo "CXX_i686_unknown_linux_gnu=i686-linux-gnu-g++" >> $GITHUB_ENV
118+
echo "CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=i686-linux-gnu-gcc" >> $GITHUB_ENV
119+
;;
120+
aarch64-unknown-linux-gnu)
121+
sudo apt-get update
122+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
123+
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
124+
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
125+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
126+
;;
127+
aarch64-linux-android)
128+
# Android NDK 通过 setup-ndk 安装
129+
;;
130+
esac
131+
132+
- name: 验证交叉编译工具
133+
if: matrix.os == 'ubuntu-latest' && matrix.target != 'x86_64-unknown-linux-gnu'
134+
run: |
135+
case ${{ matrix.target }} in
136+
i686-unknown-linux-gnu)
137+
which i686-linux-gnu-gcc || echo "警告: i686-linux-gnu-gcc 未找到"
138+
;;
139+
aarch64-unknown-linux-gnu)
140+
which aarch64-linux-gnu-gcc || echo "警告: aarch64-linux-gnu-gcc 未找到"
141+
;;
142+
esac
143+
144+
- name: 设置 Android NDK
145+
if: matrix.target == 'aarch64-linux-android'
146+
uses: nttld/setup-ndk@v1
147+
with:
148+
ndk-version: r25c
149+
add-to-path: false
150+
151+
- name: 配置 Android 环境变量
152+
if: matrix.target == 'aarch64-linux-android'
153+
run: |
154+
echo "CC_aarch64_linux_android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang" >> $GITHUB_ENV
155+
echo "CXX_aarch64_linux_android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++" >> $GITHUB_ENV
156+
echo "AR_aarch64_linux_android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" >> $GITHUB_ENV
157+
echo "CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang" >> $GITHUB_ENV
158+
# 配置 OpenSSL 相关环境变量以避免交叉编译问题
159+
echo "OPENSSL_NO_VENDOR=1" >> $GITHUB_ENV
160+
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
161+
162+
56163
57-
- name: 构建
164+
- name: 显示构建环境信息
165+
run: |
166+
echo "构建目标: ${{ matrix.target }}"
167+
echo "运行环境: ${{ matrix.os }}"
168+
rustc --version
169+
cargo --version
170+
echo "已安装的目标:"
171+
rustup target list --installed
172+
shell: bash
173+
174+
- name: 构建 (交叉编译平台 - 跳过有问题的依赖)
175+
if: contains(matrix.target, 'android') || matrix.target == 'i686-unknown-linux-gnu' || matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'i686-pc-windows-msvc' || matrix.target == 'aarch64-pc-windows-msvc'
176+
uses: actions-rs/cargo@v1
177+
with:
178+
command: build
179+
args: --release --target ${{ matrix.target }} --no-default-features --features minimal
180+
env:
181+
RUST_BACKTRACE: 1
182+
OPENSSL_NO_VENDOR: 1
183+
PKG_CONFIG_ALLOW_CROSS: 1
184+
185+
- name: 构建 (原生平台)
186+
if: "!contains(matrix.target, 'android') && matrix.target != 'i686-unknown-linux-gnu' && matrix.target != 'aarch64-unknown-linux-gnu' && matrix.target != 'i686-pc-windows-msvc' && matrix.target != 'aarch64-pc-windows-msvc'"
58187
uses: actions-rs/cargo@v1
59188
with:
60189
command: build
61-
args: --release
190+
args: --release --target ${{ matrix.target }}
191+
env:
192+
RUST_BACKTRACE: 1
62193

63194
- name: 创建输出目录
64195
run: mkdir -p release-package
@@ -67,7 +198,7 @@ jobs:
67198
- name: 打包Windows
68199
if: matrix.os == 'windows-latest'
69200
run: |
70-
cp target/release/codenothing.exe release-package/
201+
cp target/${{ matrix.target }}/release/${{ matrix.exe_name }} release-package/
71202
# 如果examples目录存在,则复制
72203
if [ -d "examples" ]; then
73204
cp -r examples release-package/
@@ -80,10 +211,10 @@ jobs:
80211
7z a ${{ matrix.asset_name }} ./release-package/*
81212
shell: bash
82213

83-
- name: 打包Linux/macOS
214+
- name: 打包Linux/macOS/Android
84215
if: matrix.os != 'windows-latest'
85216
run: |
86-
cp target/release/CodeNothing release-package/
217+
cp target/${{ matrix.target }}/release/${{ matrix.exe_name }} release-package/
87218
# 如果examples目录存在,则复制
88219
if [ -d "examples" ]; then
89220
cp -r examples release-package/
@@ -104,9 +235,9 @@ jobs:
104235

105236
- name: 创建发布
106237
uses: softprops/action-gh-release@v1
107-
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
238+
if: github.event_name == 'release'
108239
with:
109240
files: ${{ matrix.asset_name }}
110241
tag_name: ${{ github.ref_name }}
111242
draft: false
112-
generate_release_notes: true
243+
generate_release_notes: true

0 commit comments

Comments
 (0)