Skip to content

Commit 2392cd0

Browse files
committed
feat: re-enable release builds for some mips-* targets
- mips-* targets are moved to Tier-3 rust-lang/compiler-team#648 - cargo nightly provides -Zbuild-std to build libstd while compiling - cross supports build-std
1 parent 4f952be commit 2392cd0

7 files changed

+86
-161
lines changed

.github/workflows/build-nightly-release.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
target:
1919
- x86_64-unknown-linux-musl
2020
- aarch64-unknown-linux-musl
21+
- mipsel-unknown-linux-gnu
2122

2223
steps:
2324
- uses: actions/checkout@v4
@@ -51,8 +52,17 @@ jobs:
5152
fi
5253
fi
5354
55+
if [[ "$compile_target" == "mips-"* || "$compile_target" == "mipsel-"* || "$compile_target" == "mips64-"* || "$compile_target" == "mips64el-"* ]]; then
56+
sudo apt-get update -y && sudo apt-get install -y upx;
57+
if [[ "$?" == "0" ]]; then
58+
compile_compress="-u"
59+
fi
60+
61+
compile_nightly="-n"
62+
fi
63+
5464
cd build
55-
./build-release -t ${{ matrix.target }} $compile_features $compile_compress
65+
./build-release -t ${{ matrix.target }} $compile_features $compile_compress $compile_nightly
5666
5767
- name: Upload Artifacts
5868
uses: actions/upload-artifact@v4

.github/workflows/build-release.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ jobs:
3434
- arm-unknown-linux-musleabihf
3535
- aarch64-unknown-linux-gnu
3636
- aarch64-unknown-linux-musl
37+
- mips-unknown-linux-gnu
38+
- mipsel-unknown-linux-gnu
39+
- mips64-unknown-linux-gnuabi64
40+
- mips64el-unknown-linux-gnuabi64
3741

3842
steps:
3943
- uses: actions/checkout@v4
@@ -47,7 +51,7 @@ jobs:
4751
rustup target add --toolchain stable ${{ matrix.target }}
4852
4953
- name: Install cross
50-
run: cargo install cross
54+
run: cargo install cross --git https://github.com/cross-rs/cross.git
5155

5256
- name: Build ${{ matrix.target }}
5357
timeout-minutes: 120
@@ -65,10 +69,12 @@ jobs:
6569
if [[ "$?" == "0" ]]; then
6670
compile_compress="-u"
6771
fi
72+
73+
compile_nightly="-n"
6874
fi
6975
7076
cd build
71-
./build-release -t ${{ matrix.target }} $compile_features $compile_compress
77+
./build-release -t ${{ matrix.target }} $compile_features $compile_compress $compile_nightly
7278
7379
- name: Upload Github Assets
7480
uses: softprops/action-gh-release@v2

Cross.toml

+25-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
[build]
2-
dockerfile = "./docker/linux-cross/Dockerfile"
3-
pre-build = [
4-
"curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable",
5-
". $HOME/.cargo/env",
6-
"cargo install --force --locked bindgen-cli && mv $HOME/.cargo/bin/bindgen /usr/bin",
7-
"rm -rf $HOME/.cargo"
8-
]
9-
2+
# dockerfile = "./docker/linux-cross/Dockerfile"
3+
# pre-build = [
4+
# "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable",
5+
# ". $HOME/.cargo/env",
6+
# "cargo install --force --locked bindgen-cli && mv $HOME/.cargo/bin/bindgen /usr/bin",
7+
# "rm -rf $HOME/.cargo"
8+
# ]
109

1110
[build.env]
1211
passthrough = ["RUSTFLAGS"]
1312

13+
# MIPS targets are dropped to Tier 3
14+
# https://github.com/rust-lang/compiler-team/issues/648
15+
[target.mips-unknown-linux-gnu]
16+
build-std = ["std", "panic_abort", "proc_macro"]
17+
[target.mips-unknown-linux-musl]
18+
build-std = ["std", "panic_abort", "proc_macro"]
19+
[target.mips64-unknown-linux-gnuabi64]
20+
build-std = ["std", "panic_abort", "proc_macro"]
21+
[target.mips64-unknown-linux-muslabi64]
22+
build-std = ["std", "panic_abort", "proc_macro"]
23+
[target.mips64el-unknown-linux-gnuabi64]
24+
build-std = ["std", "panic_abort", "proc_macro"]
25+
[target.mips64el-unknown-linux-muslabi64]
26+
build-std = ["std", "panic_abort", "proc_macro"]
27+
[target.mipsel-unknown-linux-gnu]
28+
build-std = ["std", "panic_abort", "proc_macro"]
29+
[target.mipsel-unknown-linux-musl]
30+
build-std = ["std", "panic_abort", "proc_macro"]

build/build-host-release

+11-11
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,6 @@ if [[ "${BUILD_TARGET}" == "" ]]; then
4646
BUILD_TARGET=$HOST_TRIPLE
4747
fi
4848

49-
TARGET_SUFFIX=""
50-
if [[ "${BUILD_TARGET}" == *"-windows-"* ]]; then
51-
TARGET_SUFFIX=".exe"
52-
fi
53-
54-
TARGETS=("sslocal${TARGET_SUFFIX}" "ssserver${TARGET_SUFFIX}" "ssurl${TARGET_SUFFIX}" "ssmanager${TARGET_SUFFIX}" "ssservice${TARGET_SUFFIX}")
55-
56-
if [[ "${BUILD_FEATURES}" == *"winservice"* ]]; then
57-
TARGETS+=("sswinservice${TARGET_SUFFIX}")
58-
fi
59-
6049
RELEASE_FOLDER="${ROOT_DIR}/release"
6150
RELEASE_PACKAGE_NAME="shadowsocks-v${VERSION}.${BUILD_TARGET}"
6251

@@ -69,6 +58,17 @@ else
6958
cd "${ROOT_DIR}/../target/release"
7059
fi
7160

61+
TARGET_SUFFIX=""
62+
if [[ "${BUILD_TARGET}" == *"-windows-"* ]]; then
63+
TARGET_SUFFIX=".exe"
64+
fi
65+
66+
TARGETS=("sslocal${TARGET_SUFFIX}" "ssserver${TARGET_SUFFIX}" "ssurl${TARGET_SUFFIX}" "ssmanager${TARGET_SUFFIX}" "ssservice${TARGET_SUFFIX}")
67+
68+
if [ -e "sswinservice${TARGET_SUFFIX}" ]; then
69+
TARGETS+=("sswinservice${TARGET_SUFFIX}")
70+
fi
71+
7272
if [[ "${BUILD_TARGET}" == *"-windows-"* ]]; then
7373
# For Windows, use zip
7474

build/build-host-release.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ $CompressParam = @{
4848
LiteralPath = "sslocal.exe", "ssserver.exe", "ssurl.exe", "ssmanager.exe", "ssservice.exe"
4949
DestinationPath = "${PackagePath}"
5050
}
51-
if ((${Features}).Contains("winservice")) {
51+
if ([System.IO.File]::Exists("sswinservice.exe")) {
5252
$CompressParam.LiteralPath += "sswinservice.exe"
5353
}
5454
Compress-Archive @CompressParam

build/build-release

+30-8
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ fi
1111
targets=()
1212
features=()
1313
use_upx=false
14+
use_nightly=false
15+
cargo_flags=""
1416

15-
while getopts "t:f:u" opt; do
17+
while getopts "t:f:unZ:" opt; do
1618
case $opt in
1719
t)
1820
targets+=($OPTARG)
@@ -23,8 +25,14 @@ while getopts "t:f:u" opt; do
2325
u)
2426
use_upx=true
2527
;;
28+
n)
29+
use_nightly=true
30+
;;
31+
Z)
32+
cargo_flags="-Z $OPTARG"
33+
;;
2634
?)
27-
echo "Usage: $(basename $0) [-t <target-triple>] [-f features] [-u]"
35+
echo "Usage: $(basename $0) [-t <target-triple>] [-f features] [-u] [-n]"
2836
;;
2937
esac
3038
done
@@ -47,6 +55,11 @@ if [[ "${use_upx}" = true ]]; then
4755
fi
4856
fi
4957

58+
build_command="cross"
59+
if [[ "${use_nightly}" = true ]]; then
60+
build_command="$build_command +nightly"
61+
fi
62+
5063

5164
function build() {
5265
cd "$CUR_DIR/.."
@@ -59,14 +72,16 @@ function build() {
5972
if [[ "${TARGET_FEATURES}" != "" ]]; then
6073
echo "* Building ${TARGET} package ${VERSION} with features \"${TARGET_FEATURES}\" ..."
6174

62-
cross build --target "${TARGET}" \
63-
--features "${TARGET_FEATURES}" \
64-
--release
75+
$build_command build --target "${TARGET}" \
76+
--features "${TARGET_FEATURES}" \
77+
--release \
78+
${cargo_flags}
6579
else
6680
echo "* Building ${TARGET} package ${VERSION} ..."
6781

68-
cross build --target "${TARGET}" \
69-
--release
82+
$build_command build --target "${TARGET}" \
83+
--release \
84+
${cargo_flags}
7085
fi
7186

7287
if [[ $? != "0" ]]; then
@@ -107,12 +122,19 @@ function build() {
107122

108123
echo "* Packaging ZIP in ${PKG_PATH} ..."
109124
cd ${RELEASE_DIR}
125+
126+
sswinservice=""
127+
if [ -e "sswinservice.exe" ]; then
128+
sswinservice="sswinservice.exe"
129+
fi
130+
110131
zip ${PKG_PATH} \
111132
"sslocal.exe" \
112133
"ssserver.exe" \
113134
"ssurl.exe" \
114135
"ssmanager.exe" \
115-
"ssservice.exe"
136+
"ssservice.exe" \
137+
"${sswinservice}"
116138

117139
if [[ $? != "0" ]]; then
118140
exit 1

build/build-release-zigbuild

-130
This file was deleted.

0 commit comments

Comments
 (0)