Skip to content

Commit d23b990

Browse files
committed
ci: cross-compile in linux container
1 parent fd392db commit d23b990

File tree

6 files changed

+158
-53
lines changed

6 files changed

+158
-53
lines changed

.cargo/config.toml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
11
[alias]
22
xtask = "run --package xtask --"
3-
4-
[target.i686-pc-windows-msvc]
5-
rustflags = ["-C", "target-feature=+crt-static"]
6-
linker = "rust-lld"
7-
8-
[target.x86_64-pc-windows-msvc]
9-
rustflags = ["-C", "target-feature=+crt-static"]
10-
linker = "rust-lld"

.github/workflows/ci.yml

Lines changed: 58 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,22 @@ on:
2525
value: ${{ jobs.build.outputs.unsigned-artifact-id }}
2626

2727
jobs:
28-
build:
29-
runs-on: windows-latest
30-
name: Build
31-
outputs:
32-
unsigned-artifact-id: ${{ steps.upload-unsigned.outputs.artifact-id }}
33-
28+
cross-build:
29+
runs-on: ubuntu-latest
30+
container: quay.io/fedora/fedora:42
31+
name: Cross Build
3432
steps:
33+
- name: Install build dependencies
34+
run: |
35+
sudo dnf -y install clang sqlite-devel rustup git
36+
sudo dnf -y install mingw32-binutils mingw32-gcc mingw32-sqlite-static mingw32-zlib-static
37+
sudo dnf -y install mingw64-binutils mingw64-gcc mingw64-sqlite-static mingw64-zlib-static
38+
rustup-init -y
39+
source "$HOME/.cargo/env"
40+
rustup set auto-self-update disable
41+
rustup target add i686-pc-windows-gnu
42+
rustup target add x86_64-pc-windows-gnu
43+
3544
- uses: actions/checkout@v4
3645
with:
3746
submodules: true
@@ -40,10 +49,43 @@ jobs:
4049
if: ${{ inputs.nightly }}
4150
run: git submodule update --remote
4251

43-
- name: Setup rustup
52+
- name: Generate nightly version info
53+
if: ${{ inputs.nightly }}
4454
run: |
45-
rustup install stable
46-
rustup target add i686-pc-windows-msvc
55+
source "$HOME/.cargo/env"
56+
cargo xtask update-version --major $VER_MAJOR --minor $VER_MINOR --patch $VER_PATCH -b $GITHUB_RUN_NUMBER
57+
cat version.rc
58+
cat installer/version.wxi
59+
60+
- name: Generate pull_request version info
61+
if: github.event_name == 'pull_request'
62+
env:
63+
PR_NUMBER: ${{ github.event.number }}
64+
run: |
65+
source "$HOME/.cargo/env"
66+
cargo xtask update-version --major 0 --minor 0 --patch $PR_NUMBER -b $GITHUB_RUN_NUMBER
67+
cat version.rc
68+
cat installer/version.wxi
69+
70+
- name: Build
71+
run: |
72+
source "$HOME/.cargo/env"
73+
sh scripts/cross_build.sh
74+
75+
- uses: actions/upload-artifact@v4
76+
with:
77+
name: Installer Artifact
78+
path: build/installer
79+
80+
build:
81+
runs-on: windows-latest
82+
name: Package
83+
outputs:
84+
unsigned-artifact-id: ${{ steps.upload-unsigned.outputs.artifact-id }}
85+
needs: [cross-build]
86+
87+
steps:
88+
- uses: actions/checkout@v4
4789

4890
- name: Add msbuild to PATH
4991
uses: microsoft/setup-msbuild@v2
@@ -55,36 +97,16 @@ jobs:
5597
# SSH_PASS: ${{ secrets.SSH_PASS }}
5698
# NGROK_REGION: jp
5799

58-
- name: Setup vcpkg
59-
shell: cmd
60-
run: |
61-
set VCPKG_ROOT=%VCPKG_INSTALLATION_ROOT%
62-
vcpkg install --triplet x86-windows-static sqlite3
63-
vcpkg install --triplet x64-windows-static sqlite3
64-
65-
- name: Generate nightly version info
66-
if: ${{ inputs.nightly }}
67-
run: |
68-
cargo xtask update-version --major $env:VER_MAJOR --minor $env:VER_MINOR --patch $env:VER_PATCH -b $env:GITHUB_RUN_NUMBER
69-
type version.rc
70-
type installer/version.wxi
71-
72-
- name: Generate pull_request version info
73-
if: github.event_name == 'pull_request'
74-
env:
75-
PR_NUMBER: ${{ github.event.number }}
76-
run: |
77-
cargo xtask update-version --major 0 --minor 0 --patch $env:PR_NUMBER -b $env:GITHUB_RUN_NUMBER
78-
type version.rc
79-
type installer/version.wxi
100+
- name: Download Installer Artifact
101+
uses: actions/download-artifact@v4
102+
with:
103+
name: Installer Artifact
104+
path: build/installer
80105

81-
- name: Build
106+
- name: Build Package
82107
shell: cmd
83108
run: |
84-
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\vsdevcmd.bat"
85-
set VCPKG_ROOT=%VCPKG_INSTALLATION_ROOT%
86-
set CMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake
87-
scripts/build_installer.bat
109+
scripts/package_installer.bat
88110
89111
- id: upload-unsigned
90112
uses: actions/upload-artifact@v4

Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/build_installer.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/sh
2+
3+
set -x
4+
set -e
5+
6+
set SQLITE3_STATIC=1
7+
8+
export MINGW_CHOST=x86_64-w64-mingw32
9+
export SQLITE3_LIB_DIR=/ucrt64/lib
10+
11+
cargo +stable-x86_64-pc-windows-gnu build -p chewing_tip --release --target x86_64-pc-windows-gnu
12+
13+
export MINGW_CHOST=i686-w64-mingw32
14+
export SQLITE3_LIB_DIR=/mingw32/lib
15+
16+
cargo +stable-i686-pc-windows-gnu install chewing-cli --target i686-pc-windows-gnu --root build
17+
cargo +stable-i686-pc-windows-gnu build -p chewing_tip --release --target i686-pc-windows-gnu
18+
cargo +stable-i686-pc-windows-gnu build -p chewing-preferences --release --target i686-pc-windows-gnu
19+
cargo +stable-i686-pc-windows-gnu build -p tsfreg --release --target i686-pc-windows-gnu
20+
21+
rm -rf dist build/installer
22+
mkdir -p build/installer/assets
23+
cp assets/* build/installer/assets/
24+
cp installer/* build/installer/
25+
cp chewing_tip/rc/im.chewing.Chewing.ico build/installer/chewing.ico
26+
27+
mkdir -p build/installer/Dictionary
28+
cp libchewing/data/*.dat build/installer/Dictionary/
29+
cp build/x86/libchewing/data/*.dat build/installer/Dictionary/
30+
build/bin/chewing-cli init-database -t trie -n 內建詞庫 libchewing/data/tsi.src build/installer/Dictionary/tsi.dat
31+
build/bin/chewing-cli init-database -t trie -n 內建字庫 libchewing/data/word.src build/installer/Dictionary/word.dat
32+
33+
mkdir -p build\installer\x86
34+
cp target/i686-pc-windows-gnu/release/chewing_tip.dll build/installer/x86/
35+
cp target/i686-pc-windows-gnu/release/ChewingPreferences.exe build/installer/
36+
cp target/i686-pc-windows-gnu/release/tsfreg.exe build/installer/
37+
cp build/bin/chewing-cli.exe build/installer/
38+
39+
mkdir build/installer/x64
40+
cp target/x86_64-pc-windows-gnu/release/chewing_tip.dll build/installer/x64
41+
42+
pushd build/installer
43+
/c/'Program Files (x86)'/'Microsoft Visual Studio'/2022/BuildTools//MSBuild/Current/Bin/amd64/MSBuild.exe -p:Configuration=Release -restore windows-chewing-tsf.wixproj
44+
popd
45+
cp build/installer/bin/Release/zh-TW/windows-chewing-tsf.msi dist/windows-chewing-tsf-unsigned.msi

scripts/cross_build.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/sh
2+
3+
set -x
4+
set -e
5+
6+
export SQLITE3_STATIC=1
7+
8+
cargo install chewing-cli
9+
cargo install chewing-cli --root build --target i686-pc-windows-gnu
10+
cargo build -p chewing_tip --release --target x86_64-pc-windows-gnu
11+
cargo build -p chewing_tip --release --target i686-pc-windows-gnu
12+
cargo build -p chewing-preferences --release --target i686-pc-windows-gnu
13+
cargo build -p tsfreg --release --target i686-pc-windows-gnu
14+
15+
rm -rf dist build/installer
16+
mkdir -p build/installer/assets
17+
cp assets/* build/installer/assets/
18+
cp installer/* build/installer/
19+
cp chewing_tip/rc/im.chewing.Chewing.ico build/installer/chewing.ico
20+
21+
mkdir -p build/installer/Dictionary
22+
cp libchewing/data/*.dat build/installer/Dictionary/
23+
chewing-cli init-database \
24+
-c "Copyright (c) 2025 libchewing Core Team" \
25+
-l "LGPL-2.1-or-later" \
26+
-r "2025.04.11" \
27+
-t trie -n 內建詞庫 libchewing/data/tsi.src build/installer/Dictionary/tsi.dat
28+
chewing-cli init-database \
29+
-c "Copyright (c) 2025 libchewing Core Team" \
30+
-l "LGPL-2.1-or-later" \
31+
-r "2025.04.11" \
32+
-t trie -n 內建字庫 libchewing/data/word.src build/installer/Dictionary/word.dat
33+
34+
mkdir -p build/installer/x86
35+
cp target/i686-pc-windows-gnu/release/chewing_tip.dll build/installer/x86/
36+
cp target/i686-pc-windows-gnu/release/ChewingPreferences.exe build/installer/
37+
cp target/i686-pc-windows-gnu/release/tsfreg.exe build/installer/
38+
cp build/bin/chewing-cli.exe build/installer/
39+
40+
mkdir build/installer/x64
41+
cp target/x86_64-pc-windows-gnu/release/chewing_tip.dll build/installer/x64

scripts/package_installer.bat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
mkdir dist
2+
pushd build\installer
3+
msbuild -p:Configuration=Release -restore windows-chewing-tsf.wixproj
4+
popd
5+
copy build\installer\bin\Release\zh-TW\windows-chewing-tsf.msi dist\windows-chewing-tsf-unsigned.msi

0 commit comments

Comments
 (0)