mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-11-06 08:14:07 +00:00
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
This commit is contained in:
@@ -18,6 +18,7 @@ jobs:
|
||||
target:
|
||||
- x86_64-unknown-linux-musl
|
||||
- aarch64-unknown-linux-musl
|
||||
- mipsel-unknown-linux-gnu
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -51,8 +52,17 @@ jobs:
|
||||
fi
|
||||
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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
+25
-8
@@ -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"]
|
||||
|
||||
+11
-11
@@ -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}"
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
+30
-8
@@ -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)
|
||||
@@ -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
|
||||
@@ -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/.."
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
CUR_DIR=$( cd $( dirname $0 ) && pwd )
|
||||
VERSION=$(grep -E '^version' ${CUR_DIR}/../Cargo.toml | awk '{print $3}' | sed 's/"//g')
|
||||
|
||||
## Disable macos ACL file
|
||||
if [[ "$(uname -s)" == "Darwin" ]]; then
|
||||
export COPYFILE_DISABLE=1
|
||||
fi
|
||||
|
||||
targets=()
|
||||
features=()
|
||||
use_upx=false
|
||||
|
||||
while getopts "t:f:u" opt; do
|
||||
case $opt in
|
||||
t)
|
||||
targets+=($OPTARG)
|
||||
;;
|
||||
f)
|
||||
features+=($OPTARG)
|
||||
;;
|
||||
u)
|
||||
use_upx=true
|
||||
;;
|
||||
?)
|
||||
echo "Usage: $(basename $0) [-t <target-triple>] [-f features] [-u]"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
features+=${EXTRA_FEATURES}
|
||||
|
||||
if [[ "${#targets[@]}" == "0" ]]; then
|
||||
echo "Specifying compile target with -t <target-triple>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "${use_upx}" = true ]]; then
|
||||
if [[ -z "$upx" ]] && command -v upx &> /dev/null; then
|
||||
upx="upx -9"
|
||||
fi
|
||||
|
||||
if [[ "x$upx" == "x" ]]; then
|
||||
echo "Couldn't find upx in PATH, consider specifying it with variable \$upx"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
function build() {
|
||||
cd "$CUR_DIR/.."
|
||||
|
||||
TARGET=$1
|
||||
|
||||
RELEASE_DIR="target/${TARGET}/release"
|
||||
TARGET_FEATURES="${features[@]}"
|
||||
|
||||
if [[ "${TARGET_FEATURES}" != "" ]]; then
|
||||
echo "* Building ${TARGET} package ${VERSION} with features \"${TARGET_FEATURES}\" ..."
|
||||
|
||||
cargo zigbuild --target "${TARGET}" \
|
||||
--features "${TARGET_FEATURES}" \
|
||||
--release
|
||||
else
|
||||
echo "* Building ${TARGET} package ${VERSION} ..."
|
||||
|
||||
cargo zigbuild --target "${TARGET}" \
|
||||
--release
|
||||
fi
|
||||
|
||||
if [[ $? != "0" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PKG_DIR="${CUR_DIR}/release"
|
||||
mkdir -p "${PKG_DIR}"
|
||||
|
||||
if [[ "$TARGET" == *"-linux-"* ]]; then
|
||||
PKG_NAME="shadowsocks-v${VERSION}.${TARGET}.tar.xz"
|
||||
PKG_PATH="${PKG_DIR}/${PKG_NAME}"
|
||||
|
||||
cd ${RELEASE_DIR}
|
||||
|
||||
if [[ "${use_upx}" = true ]]; then
|
||||
# Enable upx for MIPS.
|
||||
$upx sslocal ssserver ssurl ssmanager ssservice #>/dev/null
|
||||
fi
|
||||
|
||||
echo "* Packaging XZ in ${PKG_PATH} ..."
|
||||
tar -cJf ${PKG_PATH} \
|
||||
"sslocal" \
|
||||
"ssserver" \
|
||||
"ssurl" \
|
||||
"ssmanager" \
|
||||
"ssservice"
|
||||
|
||||
if [[ $? != "0" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "${PKG_DIR}"
|
||||
shasum -a 256 "${PKG_NAME}" > "${PKG_NAME}.sha256"
|
||||
elif [[ "$TARGET" == *"-windows-"* ]]; then
|
||||
PKG_NAME="shadowsocks-v${VERSION}.${TARGET}.zip"
|
||||
PKG_PATH="${PKG_DIR}/${PKG_NAME}"
|
||||
|
||||
echo "* Packaging ZIP in ${PKG_PATH} ..."
|
||||
cd ${RELEASE_DIR}
|
||||
zip ${PKG_PATH} \
|
||||
"sslocal.exe" \
|
||||
"ssserver.exe" \
|
||||
"ssurl.exe" \
|
||||
"ssmanager.exe" \
|
||||
"ssservice.exe"
|
||||
|
||||
if [[ $? != "0" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "${PKG_DIR}"
|
||||
shasum -a 256 "${PKG_NAME}" > "${PKG_NAME}.sha256"
|
||||
fi
|
||||
|
||||
echo "* Done build package ${PKG_NAME}"
|
||||
}
|
||||
|
||||
for target in "${targets[@]}"; do
|
||||
build "$target";
|
||||
done
|
||||
Reference in New Issue
Block a user