Skip to content

Commit

Permalink
feat: re-enable release builds for some mips-* targets
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
zonyitoo committed Nov 25, 2024
1 parent 4f952be commit 2392cd0
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 161 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/build-nightly-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
target:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- mipsel-unknown-linux-gnu

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -51,8 +52,17 @@ jobs:
fi

This comment has been minimized.

Copy link
@qwerttvv

qwerttvv Nov 26, 2024

又有mips支持了真带劲,感谢大佬,不过这48行到53行跟下边重复啦

fi
if [[ "$compile_target" == "mips-"* || "$compile_target" == "mipsel-"* || "$compile_target" == "mips64-"* || "$compile_target" == "mips64el-"* ]]; then
sudo apt-get update -y && sudo apt-get install -y upx;
if [[ "$?" == "0" ]]; then
compile_compress="-u"
fi
compile_nightly="-n"
fi
cd build
./build-release -t ${{ matrix.target }} $compile_features $compile_compress
./build-release -t ${{ matrix.target }} $compile_features $compile_compress $compile_nightly
- name: Upload Artifacts
uses: actions/upload-artifact@v4
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ jobs:
- arm-unknown-linux-musleabihf
- aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl
- mips-unknown-linux-gnu
- mipsel-unknown-linux-gnu
- mips64-unknown-linux-gnuabi64
- mips64el-unknown-linux-gnuabi64

steps:
- uses: actions/checkout@v4
Expand All @@ -47,7 +51,7 @@ jobs:
rustup target add --toolchain stable ${{ matrix.target }}
- name: Install cross
run: cargo install cross
run: cargo install cross --git https://github.com/cross-rs/cross.git

- name: Build ${{ matrix.target }}
timeout-minutes: 120
Expand All @@ -65,10 +69,12 @@ jobs:
if [[ "$?" == "0" ]]; then
compile_compress="-u"
fi
compile_nightly="-n"
fi
cd build
./build-release -t ${{ matrix.target }} $compile_features $compile_compress
./build-release -t ${{ matrix.target }} $compile_features $compile_compress $compile_nightly
- name: Upload Github Assets
uses: softprops/action-gh-release@v2
Expand Down
33 changes: 25 additions & 8 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
[build]
dockerfile = "./docker/linux-cross/Dockerfile"
pre-build = [
"curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable",
". $HOME/.cargo/env",
"cargo install --force --locked bindgen-cli && mv $HOME/.cargo/bin/bindgen /usr/bin",
"rm -rf $HOME/.cargo"
]

# dockerfile = "./docker/linux-cross/Dockerfile"
# pre-build = [
# "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable",
# ". $HOME/.cargo/env",
# "cargo install --force --locked bindgen-cli && mv $HOME/.cargo/bin/bindgen /usr/bin",
# "rm -rf $HOME/.cargo"
# ]

[build.env]
passthrough = ["RUSTFLAGS"]

# MIPS targets are dropped to Tier 3
# https://github.com/rust-lang/compiler-team/issues/648
[target.mips-unknown-linux-gnu]
build-std = ["std", "panic_abort", "proc_macro"]
[target.mips-unknown-linux-musl]
build-std = ["std", "panic_abort", "proc_macro"]
[target.mips64-unknown-linux-gnuabi64]
build-std = ["std", "panic_abort", "proc_macro"]
[target.mips64-unknown-linux-muslabi64]
build-std = ["std", "panic_abort", "proc_macro"]
[target.mips64el-unknown-linux-gnuabi64]
build-std = ["std", "panic_abort", "proc_macro"]
[target.mips64el-unknown-linux-muslabi64]
build-std = ["std", "panic_abort", "proc_macro"]
[target.mipsel-unknown-linux-gnu]
build-std = ["std", "panic_abort", "proc_macro"]
[target.mipsel-unknown-linux-musl]
build-std = ["std", "panic_abort", "proc_macro"]
22 changes: 11 additions & 11 deletions build/build-host-release
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,6 @@ if [[ "${BUILD_TARGET}" == "" ]]; then
BUILD_TARGET=$HOST_TRIPLE
fi

TARGET_SUFFIX=""
if [[ "${BUILD_TARGET}" == *"-windows-"* ]]; then
TARGET_SUFFIX=".exe"
fi

TARGETS=("sslocal${TARGET_SUFFIX}" "ssserver${TARGET_SUFFIX}" "ssurl${TARGET_SUFFIX}" "ssmanager${TARGET_SUFFIX}" "ssservice${TARGET_SUFFIX}")

if [[ "${BUILD_FEATURES}" == *"winservice"* ]]; then
TARGETS+=("sswinservice${TARGET_SUFFIX}")
fi

RELEASE_FOLDER="${ROOT_DIR}/release"
RELEASE_PACKAGE_NAME="shadowsocks-v${VERSION}.${BUILD_TARGET}"

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

TARGET_SUFFIX=""
if [[ "${BUILD_TARGET}" == *"-windows-"* ]]; then
TARGET_SUFFIX=".exe"
fi

TARGETS=("sslocal${TARGET_SUFFIX}" "ssserver${TARGET_SUFFIX}" "ssurl${TARGET_SUFFIX}" "ssmanager${TARGET_SUFFIX}" "ssservice${TARGET_SUFFIX}")

if [ -e "sswinservice${TARGET_SUFFIX}" ]; then
TARGETS+=("sswinservice${TARGET_SUFFIX}")
fi

if [[ "${BUILD_TARGET}" == *"-windows-"* ]]; then
# For Windows, use zip

Expand Down
2 changes: 1 addition & 1 deletion build/build-host-release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ $CompressParam = @{
LiteralPath = "sslocal.exe", "ssserver.exe", "ssurl.exe", "ssmanager.exe", "ssservice.exe"
DestinationPath = "${PackagePath}"
}
if ((${Features}).Contains("winservice")) {
if ([System.IO.File]::Exists("sswinservice.exe")) {
$CompressParam.LiteralPath += "sswinservice.exe"
}
Compress-Archive @CompressParam
Expand Down
38 changes: 30 additions & 8 deletions build/build-release
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ fi
targets=()
features=()
use_upx=false
use_nightly=false
cargo_flags=""

while getopts "t:f:u" opt; do
while getopts "t:f:unZ:" opt; do
case $opt in
t)
targets+=($OPTARG)
Expand All @@ -23,8 +25,14 @@ while getopts "t:f:u" opt; do
u)
use_upx=true
;;
n)
use_nightly=true
;;
Z)
cargo_flags="-Z $OPTARG"
;;
?)
echo "Usage: $(basename $0) [-t <target-triple>] [-f features] [-u]"
echo "Usage: $(basename $0) [-t <target-triple>] [-f features] [-u] [-n]"
;;
esac
done
Expand All @@ -47,6 +55,11 @@ if [[ "${use_upx}" = true ]]; then
fi
fi

build_command="cross"
if [[ "${use_nightly}" = true ]]; then
build_command="$build_command +nightly"
fi


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

cross build --target "${TARGET}" \
--features "${TARGET_FEATURES}" \
--release
$build_command build --target "${TARGET}" \
--features "${TARGET_FEATURES}" \
--release \
${cargo_flags}
else
echo "* Building ${TARGET} package ${VERSION} ..."

cross build --target "${TARGET}" \
--release
$build_command build --target "${TARGET}" \
--release \
${cargo_flags}
fi

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

echo "* Packaging ZIP in ${PKG_PATH} ..."
cd ${RELEASE_DIR}

sswinservice=""
if [ -e "sswinservice.exe" ]; then
sswinservice="sswinservice.exe"
fi

zip ${PKG_PATH} \
"sslocal.exe" \
"ssserver.exe" \
"ssurl.exe" \
"ssmanager.exe" \
"ssservice.exe"
"ssservice.exe" \
"${sswinservice}"

if [[ $? != "0" ]]; then
exit 1
Expand Down
130 changes: 0 additions & 130 deletions build/build-release-zigbuild

This file was deleted.

0 comments on commit 2392cd0

Please sign in to comment.