forked from KonghaYao/cn-font-split
-
Notifications
You must be signed in to change notification settings - Fork 0
206 lines (176 loc) · 6.85 KB
/
cross-build.yml
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: Rust Cross Build
on:
push:
branches:
- 'test'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
cross-build:
name: Release - ${{ matrix.platform.os-name }}
strategy:
fail-fast: false
matrix:
platform:
- os-name: FreeBSD-x86_64
runs-on: ubuntu-24.04
target: x86_64-unknown-freebsd
- os-name: aarch64-unknown-linux-gnu
runs-on: ubuntu-24.04
target: aarch64-unknown-linux-gnu
- os-name: x86_64-unknown-linux-gnu
runs-on: ubuntu-24.04
target: x86_64-unknown-linux-gnu
# - os-name: Linux-x86_64-musl
# runs-on: ubuntu-20.04
# target: x86_64-unknown-linux-musl
# - os-name: Linux-aarch64-musl
# runs-on: ubuntu-20.04
# target: aarch64-unknown-linux-musl
- os-name: Linux-riscv64
runs-on: ubuntu-20.04
target: riscv64gc-unknown-linux-gnu
- os-name: Linux-s390x
runs-on: ubuntu-20.04
target: s390x-unknown-linux-gnu
- os-name: Windows-x86_64-msvc
runs-on: windows-latest
target: x86_64-pc-windows-msvc
- os-name: Windows-x86_64-aarch64
runs-on: windows-latest
target: aarch64-pc-windows-msvc
- os-name: Windows-x86_64-gnu
runs-on: windows-latest
target: x86_64-pc-windows-gnu
- os-name: macOS-x86_64
runs-on: macOS-latest
target: x86_64-apple-darwin
- os-name: macOS-aarch64
runs-on: macOS-latest
target: aarch64-apple-darwin
# more targets here ...
env:
TZ: Asia/Shanghai
runs-on: ${{ matrix.platform.runs-on }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Windows Environment
if: ${{ runner.os == 'Windows' }}
shell: pwsh
run: |
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
scoop install main/llvm
scoop install main/mingw
scoop install main/nodejs
pip install opencc --target $HOME
echo " OPENCC_BIN=$HOME/opencc/clib/bin/opencc " | Out-File -FilePath $env:GITHUB_ENV -Append
echo " OPENCC_DATA_PATH=$HOME/opencc/clib/share/opencc/ " | Out-File -FilePath $env:GITHUB_ENV -Append
$env:Path += ";$HOME/opencc/clib/bin"
opencc --version
${{ matrix.platform.setup }}
- name: Setup Linux Environment
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt update
sudo apt install -y nodejs llvm clang pkg-config libssl-dev opencc
${{ matrix.platform.setup }}
- name: Set up Homebrew
id: set-up-homebrew
if: ${{ runner.os == 'macOS' }}
uses: Homebrew/actions/setup-homebrew@master
- name: Setup MacOS Environment
if: ${{ runner.os == 'macOS' }}
run: |
brew install llvm protobuf opencc automake libtool
${{ matrix.platform.setup }}
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "23.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Build lang_unicodes
run: |
echo $PATH
cargo build -p lang-unicodes
- name: BUILD PROTO
run: |
cargo build -p cn-font-proto
- name: Build binary
uses: houseabsolute/actions-rust-cross@v0
with:
command: build
target: ${{ matrix.platform.target }}
args: "--locked --release -p ffi"
strip: false
env:
CARGO_WITH_NO_EXTRA: "True"
HARFBUZZ_SYS_NO_PKG_CONFIG: "True"
- name: Rename Package On Mac
if: ${{ runner.os == 'macOS'}}
working-directory: ./target/${{ matrix.platform.target }}/release
run: |
mv ./libffi.dylib ./libffi-${{ matrix.platform.target }}.dylib
- name: Rename Package On Linux
if: ${{ runner.os == 'Linux'}}
working-directory: ./target/${{ matrix.platform.target }}/release
run: |
mv ./libffi.so ./libffi-${{ matrix.platform.target }}.so
- name: Rename Package on Windows
if: ${{ runner.os == 'Windows' }}
working-directory: ./target/${{ matrix.platform.target }}/release
run: |
ren ffi.dll libffi-${{ matrix.platform.target }}.dll
# 这里先不重命名,因为每个环境的架构不一样,操作繁琐
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.platform.target }}
path: ./target/${{ matrix.platform.target }}/release/libffi-${{ matrix.platform.target }}.*
if-no-files-found: error
build-wasm:
name: Release - WASM
runs-on: ubuntu-24.04
env:
TZ: Asia/Shanghai
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Environment
run: |
sudo apt update
sudo apt upgrade
sudo apt install -y llvm clang pkg-config libssl-dev protobuf-compiler opencc
- name: Setup WASI Environment
working-directory: .
run: |
sudo sh ./.devcontainer/wasi-install.sh
sudo sh ./.devcontainer/wasm-opt-install.sh
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Update Rust
run: /home/runner/.cargo/bin/rustup target add wasm32-wasip1
- name: Build
working-directory: ./packages/wasm-edge
run: |
export WASI_SYSROOT="/opt/wasi-sdk/wasi-sdk-24.0-x86_64-linux/share/wasi-sysroot/"
export PATH=$PATH:/opt/binaryen/binaryen-version_119/bin
sh build-wasi.sh
- name: Rename Package
working-directory: .
run: |
mv ./target/wasm32-wasip1/release/wasm_edge.Oz.wasm ./target/wasm32-wasip1/release/libffi-wasm32-wasip1.wasm
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-wasm32-wasip1
path: ./target/wasm32-wasip1/release/libffi-wasm32-wasip1.wasm
if-no-files-found: error