diff --git a/.github/workflows/build-nightly-release.yml b/.github/workflows/build-nightly-release.yml index 2160347f318e..e746a2e0d693 100644 --- a/.github/workflows/build-nightly-release.yml +++ b/.github/workflows/build-nightly-release.yml @@ -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 diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index c9958c02580f..4e2408b43cda 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -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 diff --git a/Cross.toml b/Cross.toml index 3035805387f2..363d9f84c9a7 100644 --- a/Cross.toml +++ b/Cross.toml @@ -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"] diff --git a/build/build-host-release b/build/build-host-release index 34580f510ba2..265d6cedace5 100755 --- a/build/build-host-release +++ b/build/build-host-release @@ -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 diff --git a/build/build-host-release.ps1 b/build/build-host-release.ps1 index b1e8660568c8..b8cbd4912032 100644 --- a/build/build-host-release.ps1 +++ b/build/build-host-release.ps1 @@ -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 diff --git a/build/build-release b/build/build-release index 73be4a2cd35f..f58037164e92 100755 --- a/build/build-release +++ b/build/build-release @@ -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 ] [-f features] [-u]" + echo "Usage: $(basename $0) [-t ] [-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 diff --git a/build/build-release-zigbuild b/build/build-release-zigbuild deleted file mode 100755 index 0cd17fa04492..000000000000 --- a/build/build-release-zigbuild +++ /dev/null @@ -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 ] [-f features] [-u]" - ;; - esac -done - -features+=${EXTRA_FEATURES} - -if [[ "${#targets[@]}" == "0" ]]; then - echo "Specifying compile target with -t " - 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