From 9e0a3b6936194a2f7c76ad7e49147200aa47e800 Mon Sep 17 00:00:00 2001 From: Luna Yao <40349250+ZnqbuZ@users.noreply.github.com> Date: Sun, 12 Apr 2026 16:14:41 +0200 Subject: [PATCH] ci: rewrite build workflows (#2089) --- .cargo/config.toml | 89 ++++---- .github/actions/prepare-build/action.yml | 75 +++++-- .github/workflows/core.yml | 252 ++++++++++------------- .github/workflows/gui.yml | 107 +++------- .github/workflows/install_gui_dep.sh | 11 - .github/workflows/install_rust.sh | 61 ------ .github/workflows/mobile.yml | 61 +++--- .github/workflows/ohos.yml | 38 ++-- .github/workflows/test.yml | 15 +- Cargo.lock | 6 +- easytier-gui/src-tauri/Cargo.toml | 17 +- easytier-gui/src-tauri/build.rs | 24 +-- easytier-web/Cargo.toml | 12 +- easytier-web/build.rs | 10 +- easytier/Cargo.toml | 14 +- easytier/build.rs | 8 +- 16 files changed, 338 insertions(+), 462 deletions(-) delete mode 100644 .github/workflows/install_gui_dep.sh delete mode 100644 .github/workflows/install_rust.sh diff --git a/.cargo/config.toml b/.cargo/config.toml index 17288931..2548b156 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,29 +1,40 @@ -[target.x86_64-unknown-linux-musl] -linker = "rust-lld" -rustflags = ["-C", "linker-flavor=ld.lld"] +# region Native + +[target.x86_64-unknown-linux-gnu] +rustflags = ["-C", "link-arg=-fuse-ld=mold"] [target.aarch64-unknown-linux-gnu] -linker = "aarch64-linux-gnu-gcc" +rustflags = ["-C", "link-arg=-fuse-ld=mold"] -[target.aarch64-unknown-linux-ohos] -ar = "/usr/local/ohos-sdk/linux/native/llvm/bin/llvm-ar" -linker = "/home/runner/sdk/native/llvm/aarch64-unknown-linux-ohos-clang.sh" +[target.'cfg(all(windows, target_env = "msvc"))'] +rustflags = ["-C", "target-feature=+crt-static"] -[target.aarch64-unknown-linux-ohos.env] -PKG_CONFIG_PATH = "/usr/local/ohos-sdk/linux/native/sysroot/usr/lib/pkgconfig:/usr/local/ohos-sdk/linux/native/sysroot/usr/local/lib/pkgconfig" -PKG_CONFIG_LIBDIR = "/usr/local/ohos-sdk/linux/native/sysroot/usr/lib:/usr/local/ohos-sdk/linux/native/sysroot/usr/local/lib" -PKG_CONFIG_SYSROOT_DIR = "/usr/local/ohos-sdk/linux/native/sysroot" -SYSROOT = "/usr/local/ohos-sdk/linux/native/sysroot" +# region + +# region CI + +[target.x86_64-unknown-linux-musl] +rustflags = ["-C", "target-feature=+crt-static"] [target.aarch64-unknown-linux-musl] -linker = "aarch64-unknown-linux-musl-gcc" rustflags = ["-C", "target-feature=+crt-static"] [target.riscv64gc-unknown-linux-musl] -linker = "riscv64-unknown-linux-musl-gcc" rustflags = ["-C", "target-feature=+crt-static"] -[target.'cfg(all(windows, target_env = "msvc"))'] +[target.armv7-unknown-linux-musleabihf] +rustflags = ["-C", "target-feature=+crt-static"] + +[target.armv7-unknown-linux-musleabi] +rustflags = ["-C", "target-feature=+crt-static"] + +[target.arm-unknown-linux-musleabihf] +rustflags = ["-C", "target-feature=+crt-static"] + +[target.arm-unknown-linux-musleabi] +rustflags = ["-C", "target-feature=+crt-static"] + +[target.loongarch64-unknown-linux-musl] rustflags = ["-C", "target-feature=+crt-static"] [target.mipsel-unknown-linux-musl] @@ -64,44 +75,14 @@ rustflags = [ "gcc", ] -[target.armv7-unknown-linux-musleabihf] -linker = "armv7-unknown-linux-musleabihf-gcc" -rustflags = ["-C", "target-feature=+crt-static"] +[target.aarch64-unknown-linux-ohos] +ar = "/usr/local/ohos-sdk/linux/native/llvm/bin/llvm-ar" +linker = "/home/runner/sdk/native/llvm/aarch64-unknown-linux-ohos-clang.sh" -[target.armv7-unknown-linux-musleabi] -linker = "armv7-unknown-linux-musleabi-gcc" -rustflags = ["-C", "target-feature=+crt-static"] +[target.aarch64-unknown-linux-ohos.env] +PKG_CONFIG_PATH = "/usr/local/ohos-sdk/linux/native/sysroot/usr/lib/pkgconfig:/usr/local/ohos-sdk/linux/native/sysroot/usr/local/lib/pkgconfig" +PKG_CONFIG_LIBDIR = "/usr/local/ohos-sdk/linux/native/sysroot/usr/lib:/usr/local/ohos-sdk/linux/native/sysroot/usr/local/lib" +PKG_CONFIG_SYSROOT_DIR = "/usr/local/ohos-sdk/linux/native/sysroot" +SYSROOT = "/usr/local/ohos-sdk/linux/native/sysroot" -[target.loongarch64-unknown-linux-musl] -linker = "loongarch64-unknown-linux-musl-gcc" -rustflags = ["-C", "target-feature=+crt-static"] - -[target.arm-unknown-linux-musleabihf] -linker = "arm-unknown-linux-musleabihf-gcc" -rustflags = [ - "-C", - "target-feature=+crt-static", - "-L", - "./musl_gcc/arm-unknown-linux-musleabihf/arm-unknown-linux-musleabihf/lib", - "-L", - "./musl_gcc/arm-unknown-linux-musleabihf/lib/gcc/arm-unknown-linux-musleabihf/15.1.0", - "-l", - "atomic", - "-l", - "gcc", -] - -[target.arm-unknown-linux-musleabi] -linker = "arm-unknown-linux-musleabi-gcc" -rustflags = [ - "-C", - "target-feature=+crt-static", - "-L", - "./musl_gcc/arm-unknown-linux-musleabi/arm-unknown-linux-musleabi/lib", - "-L", - "./musl_gcc/arm-unknown-linux-musleabi/lib/gcc/arm-unknown-linux-musleabi/15.1.0", - "-l", - "atomic", - "-l", - "gcc", -] +# endregion diff --git a/.github/actions/prepare-build/action.yml b/.github/actions/prepare-build/action.yml index 33885c6d..57699603 100644 --- a/.github/actions/prepare-build/action.yml +++ b/.github/actions/prepare-build/action.yml @@ -2,10 +2,17 @@ name: prepare-build author: Luna description: Prepare build environment inputs: - web: - description: 'Whether to prepare the web build environment' + target: + description: 'The target to build for' + required: false + pnpm: + description: 'Whether to run pnpm build' required: true default: 'true' + pnpm-build-filter: + description: 'The filter argument for pnpm build (e.g. ./easytier-web/*)' + required: false + default: './easytier-web/*' gui: description: 'Whether to prepare the GUI build environment' required: true @@ -19,21 +26,63 @@ runs: - run: mkdir -p easytier-gui/dist shell: bash - - name: Setup Frontend Environment - if: ${{ inputs.web == 'true' }} - uses: ./.github/actions/prepare-pnpm - with: - build-filter: './easytier-web/*' - - - name: Install GUI dependencies (Used by clippy) - if: ${{ inputs.gui == 'true' }} + - name: Install dependencies + if: ${{ runner.os == 'Linux' }} run: | - bash ./.github/workflows/install_gui_dep.sh + sudo apt-get update + sudo apt-get install -qqy build-essential mold musl-tools shell: bash - - name: Install Rust + - name: Setup Frontend Environment + if: ${{ inputs.pnpm == 'true' }} + uses: ./.github/actions/prepare-pnpm + with: + build-filter: ${{ inputs.pnpm-build-filter }} + + - name: Install GUI dependencies (Linux) + if: ${{ inputs.gui == 'true' && runner.os == 'Linux' }} run: | - bash ./.github/workflows/install_rust.sh + sudo apt-get install -qq xdg-utils \ + libappindicator3-dev \ + libgtk-3-dev \ + librsvg2-dev \ + libwebkit2gtk-4.1-dev \ + libxdo-dev + shell: bash + + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + target: ${{ !contains(inputs.target, 'mips') && inputs.target || '' }} + cache: false + rustflags: '' + + - name: Install Rust (MIPS) + if: ${{ contains(inputs.target, 'mips') }} + run: | + rustup toolchain install nightly-2026-02-02-x86_64-unknown-linux-gnu + rustup component add rust-src --toolchain nightly-2026-02-02-x86_64-unknown-linux-gnu + + MUSL_TARGET=${{ inputs.target }}sf + mkdir -p ./musl_gcc + wget --inet4-only -c https://github.com/cross-tools/musl-cross/releases/download/20250520/${MUSL_TARGET}.tar.xz -P ./musl_gcc/ + tar xf ./musl_gcc/${MUSL_TARGET}.tar.xz -C ./musl_gcc/ + sudo ln -sf $(pwd)/musl_gcc/${MUSL_TARGET}/bin/*gcc /usr/bin/ + sudo ln -sf $(pwd)/musl_gcc/${MUSL_TARGET}/include/ /usr/include/musl-cross + sudo ln -sf $(pwd)/musl_gcc/${MUSL_TARGET}/${MUSL_TARGET}/sysroot/ ./musl_gcc/sysroot + sudo chmod -R a+rwx ./musl_gcc + + if [[ -d "./musl_gcc/sysroot" ]]; then + echo "BINDGEN_EXTRA_CLANG_ARGS=--sysroot=$(readlink -f ./musl_gcc/sysroot)" >> $GITHUB_ENV + fi + + cd "$PWD/musl_gcc/${MUSL_TARGET}/lib/gcc/${MUSL_TARGET}/15.1.0" || exit 255 + # for panic-abort + cp libgcc_eh.a libunwind.a + + # for mimalloc + ar x libgcc.a _ctzsi2.o _clz.o _bswapsi2.o + ar rcs libctz.a _ctzsi2.o _clz.o _bswapsi2.o shell: bash - name: Setup protoc diff --git a/.github/workflows/core.yml b/.github/workflows/core.yml index f2df8fb5..e2f5cb39 100644 --- a/.github/workflows/core.yml +++ b/.github/workflows/core.yml @@ -2,10 +2,10 @@ name: EasyTier Core on: push: - branches: ["develop", "main", "releases/**"] + branches: [ "develop", "main", "releases/**" ] pull_request: - branches: ["develop", "main"] - types: [opened, synchronize, reopened, ready_for_review] + branches: [ "develop", "main" ] + types: [ opened, synchronize, reopened, ready_for_review ] concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -36,7 +36,7 @@ jobs: concurrent_skipping: 'same_content_newer' skip_after_successful_duplicate: 'true' cancel_others: 'true' - paths: '["Cargo.toml", "Cargo.lock", "easytier/**", ".github/workflows/core.yml", ".github/workflows/install_rust.sh", "easytier-web/**"]' + paths: '["Cargo.toml", "Cargo.lock", "easytier/**", ".github/workflows/core.yml", ".github/actions/**", "easytier-web/**"]' build_web: runs-on: ubuntu-latest needs: pre_job @@ -60,38 +60,45 @@ jobs: fail-fast: true matrix: include: - - TARGET: aarch64-unknown-linux-musl - OS: ubuntu-22.04 - ARTIFACT_NAME: linux-aarch64 - TARGET: x86_64-unknown-linux-musl - OS: ubuntu-22.04 + OS: ubuntu-24.04 ARTIFACT_NAME: linux-x86_64 - - TARGET: riscv64gc-unknown-linux-musl - OS: ubuntu-22.04 - ARTIFACT_NAME: linux-riscv64 - - TARGET: mips-unknown-linux-musl - OS: ubuntu-22.04 - ARTIFACT_NAME: linux-mips - - TARGET: mipsel-unknown-linux-musl - OS: ubuntu-22.04 - ARTIFACT_NAME: linux-mipsel - - TARGET: armv7-unknown-linux-musleabihf # raspberry pi 2-3-4, not tested - OS: ubuntu-22.04 - ARTIFACT_NAME: linux-armv7hf - - TARGET: armv7-unknown-linux-musleabi # raspberry pi 2-3-4, not tested - OS: ubuntu-22.04 - ARTIFACT_NAME: linux-armv7 - - TARGET: arm-unknown-linux-musleabihf # raspberry pi 0-1, not tested - OS: ubuntu-22.04 - ARTIFACT_NAME: linux-armhf - - TARGET: arm-unknown-linux-musleabi # raspberry pi 0-1, not tested - OS: ubuntu-22.04 - ARTIFACT_NAME: linux-arm + - TARGET: aarch64-unknown-linux-musl + OS: ubuntu-24.04-arm + ARTIFACT_NAME: linux-aarch64 + - TARGET: riscv64gc-unknown-linux-musl + OS: ubuntu-24.04 + ARTIFACT_NAME: linux-riscv64 - TARGET: loongarch64-unknown-linux-musl OS: ubuntu-24.04 ARTIFACT_NAME: linux-loongarch64 + - TARGET: armv7-unknown-linux-musleabihf # raspberry pi 2-3-4, not tested + OS: ubuntu-24.04 + ARTIFACT_NAME: linux-armv7hf + - TARGET: armv7-unknown-linux-musleabi # raspberry pi 2-3-4, not tested + OS: ubuntu-24.04 + ARTIFACT_NAME: linux-armv7 + - TARGET: arm-unknown-linux-musleabihf # raspberry pi 0-1, not tested + OS: ubuntu-24.04 + ARTIFACT_NAME: linux-armhf + - TARGET: arm-unknown-linux-musleabi # raspberry pi 0-1, not tested + OS: ubuntu-24.04 + ARTIFACT_NAME: linux-arm + + - TARGET: mips-unknown-linux-musl + OS: ubuntu-24.04 + ARTIFACT_NAME: linux-mips + - TARGET: mipsel-unknown-linux-musl + OS: ubuntu-24.04 + ARTIFACT_NAME: linux-mipsel + + - TARGET: x86_64-unknown-freebsd + OS: ubuntu-24.04 + ARTIFACT_NAME: freebsd-13.2-x86_64 + BSD_VERSION: 13.2 + - TARGET: x86_64-apple-darwin OS: macos-latest ARTIFACT_NAME: macos-x86_64 @@ -102,17 +109,12 @@ jobs: - TARGET: x86_64-pc-windows-msvc OS: windows-latest ARTIFACT_NAME: windows-x86_64 - - TARGET: aarch64-pc-windows-msvc - OS: windows-latest - ARTIFACT_NAME: windows-arm64 - TARGET: i686-pc-windows-msvc OS: windows-latest ARTIFACT_NAME: windows-i686 - - - TARGET: x86_64-unknown-freebsd - OS: ubuntu-22.04 - ARTIFACT_NAME: freebsd-13.2-x86_64 - BSD_VERSION: 13.2 + - TARGET: aarch64-pc-windows-msvc + OS: windows-11-arm + ARTIFACT_NAME: windows-arm64 runs-on: ${{ matrix.OS }} env: @@ -137,8 +139,15 @@ jobs: name: easytier-web-dashboard path: easytier-web/frontend/dist/ + - name: Prepare build environment + uses: ./.github/actions/prepare-build + with: + target: ${{ matrix.TARGET }} + gui: true + pnpm: true + token: ${{ secrets.GITHUB_TOKEN }} + - uses: Swatinem/rust-cache@v2 - if: ${{ ! endsWith(matrix.TARGET, 'freebsd') }} with: # The prefix cache key, this can be changed to start a new cache manually. # default: "v0-rust" @@ -146,96 +155,49 @@ jobs: shared-key: "core-registry" cache-targets: "false" - - name: Setup protoc - uses: arduino/setup-protoc@v3 + - uses: mlugg/setup-zig@v2 + if: ${{ contains(matrix.OS, 'ubuntu') }} + + - uses: taiki-e/install-action@v2 + if: ${{ contains(matrix.OS, 'ubuntu') }} with: - # GitHub repo token to use to avoid rate limiter - repo-token: ${{ secrets.GITHUB_TOKEN }} + tool: cargo-zigbuild - - name: Build Core & Cli - if: ${{ ! endsWith(matrix.TARGET, 'freebsd') }} - run: | - bash ./.github/workflows/install_rust.sh - - # loongarch need llvm-18 - if [[ $TARGET =~ ^loongarch.*$ ]]; then - sudo apt-get install -qq llvm-18 clang-18 - export LLVM_CONFIG_PATH=/usr/lib/llvm-18/bin/llvm-config - fi - # we set the sysroot when sysroot is a dir - # this dir is a soft link generated by install_rust.sh - # kcp-sys need this to gen ffi bindings. without this clang may fail to find some libc headers such as bits/libc-header-start.h - if [[ -d "./musl_gcc/sysroot" ]]; then - export BINDGEN_EXTRA_CLANG_ARGS=--sysroot=$(readlink -f ./musl_gcc/sysroot) - fi - - if [[ $OS =~ ^ubuntu.*$ && $TARGET =~ ^mips.*$ ]]; then - cargo +nightly-2026-02-02 build -r --target $TARGET -Z build-std=std,panic_abort --package=easytier --features=jemalloc + - name: Build + if: ${{ !contains(matrix.TARGET, 'mips') }} + run: | + if [[ "$TARGET" == *windows* ]]; then + SUFFIX=.exe else - if [[ $OS =~ ^windows.*$ ]]; then - SUFFIX=.exe - CORE_FEATURES="--features=mimalloc" - elif [[ $TARGET =~ ^riscv64.*$ || $TARGET =~ ^loongarch64.*$ || $TARGET =~ ^aarch64.*$ ]]; then - CORE_FEATURES="--features=mimalloc" - else - CORE_FEATURES="--features=jemalloc" - fi - cargo build --release --target $TARGET --package=easytier-web --features=embed - mv ./target/$TARGET/release/easytier-web"$SUFFIX" ./target/$TARGET/release/easytier-web-embed"$SUFFIX" - cargo build --release --target $TARGET $CORE_FEATURES + SUFFIX="" fi - # Copied and slightly modified from @lmq8267 (https://github.com/lmq8267) - - name: Build Core & Cli (X86_64 FreeBSD) - uses: vmactions/freebsd-vm@670398e4236735b8b65805c3da44b7a511fb8b27 - if: ${{ endsWith(matrix.TARGET, 'freebsd') }} - env: - TARGET: ${{ matrix.TARGET }} - with: - envs: TARGET - release: ${{ matrix.BSD_VERSION }} - arch: x86_64 - usesh: true - mem: 6144 - cpu: 4 - run: | - uname -a - echo $SHELL - pwd - ls -lah - whoami - env | sort + if [[ "$TARGET" =~ (x86_64-unknown-linux-musl|aarch64-unknown-linux-musl|windows|darwin) ]]; then + BUILD=build + else + BUILD=zigbuild + fi - pkg install -y git protobuf llvm-devel sudo curl - curl --proto 'https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - . $HOME/.cargo/env + if [[ "$TARGET" =~ ^(riscv64|loongarch64|aarch64).*$ || "$TARGET" =~ windows ]]; then + FEATURES="mimalloc" + else + FEATURES="jemalloc" + fi + + cargo $BUILD --release --target $TARGET --package=easytier-web --features=embed + mv ./target/$TARGET/release/easytier-web"$SUFFIX" ./target/$TARGET/release/easytier-web-embed"$SUFFIX" + + cargo $BUILD --release --target $TARGET --features=$FEATURES - rustup set auto-self-update disable - - rustup install 1.93 - rustup default 1.93 - - export CC=clang - export CXX=clang++ - export CARGO_TERM_COLOR=always - - cargo build --release --verbose --target $TARGET --package=easytier-web --features=embed - mv ./target/$TARGET/release/easytier-web ./target/$TARGET/release/easytier-web-embed - cargo build --release --verbose --target $TARGET --features=mimalloc - - mkdir -p built-bins/$TARGET/release/ - mv ./target/$TARGET/release/easytier-web-embed ./built-bins/$TARGET/release/easytier-web-embed - mv ./target/$TARGET/release/easytier-web ./built-bins/$TARGET/release/easytier-web - mv ./target/$TARGET/release/easytier-core ./built-bins/$TARGET/release/easytier-core - mv ./target/$TARGET/release/easytier-cli ./built-bins/$TARGET/release/easytier-cli - - # remove dirs to avoid copy many files back - rm -rf ./target ~/.cargo - mv ./built-bins ./target + - name: Build (MIPS) + if: ${{ contains(matrix.TARGET, 'mips') }} + run: | + cargo +nightly-2026-02-02 build -r --target $TARGET -Z build-std=std,panic_abort --package=easytier --features=jemalloc - name: Compress run: | mkdir -p ./artifacts/objects/ + # windows is the only OS using a different convention for executable file name if [[ $OS =~ ^windows.*$ ]]; then SUFFIX=.exe @@ -248,26 +210,37 @@ jobs: find "easytier/third_party/${ARCH_DIR}" -maxdepth 1 -type f \( -name "*.dll" -o -name "*.sys" \) -exec cp {} ./artifacts/objects/ \; fi fi + if [[ $GITHUB_REF_TYPE =~ ^tag$ ]]; then TAG=$GITHUB_REF_NAME else TAG=$GITHUB_SHA fi + + if [[ $OS =~ ^ubuntu.*$ && ! $TARGET =~ (loongarch|freebsd) ]]; then + HOST_ARCH=$(uname -m) + case $HOST_ARCH in + x86_64) UPX_ARCH="amd64" ;; + aarch64) UPX_ARCH="arm64" ;; + *) UPX_ARCH="amd64" ;; + esac - if [[ $OS =~ ^ubuntu.*$ && ! $TARGET =~ ^.*freebsd$ && ! $TARGET =~ ^loongarch.*$ && ! $TARGET =~ ^riscv64.*$ ]]; then - UPX_VERSION=4.2.4 - curl -L https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-amd64_linux.tar.xz -s | tar xJvf - - cp upx-${UPX_VERSION}-amd64_linux/upx . - ./upx --lzma --best ./target/$TARGET/release/easytier-core"$SUFFIX" - ./upx --lzma --best ./target/$TARGET/release/easytier-cli"$SUFFIX" + UPX_VERSION=5.1.1 + UPX_PKG="upx-${UPX_VERSION}-${UPX_ARCH}_linux" + curl -L "https://github.com/upx/upx/releases/download/v${UPX_VERSION}/${UPX_PKG}.tar.xz" -s | tar xJvf - + cp "${UPX_PKG}/upx" . + UPX_BIN=./upx fi - mv ./target/$TARGET/release/easytier-core"$SUFFIX" ./artifacts/objects/ - mv ./target/$TARGET/release/easytier-cli"$SUFFIX" ./artifacts/objects/ - if [[ ! $TARGET =~ ^mips.*$ ]]; then - mv ./target/$TARGET/release/easytier-web"$SUFFIX" ./artifacts/objects/ - mv ./target/$TARGET/release/easytier-web-embed"$SUFFIX" ./artifacts/objects/ - fi + for BIN in ./target/$TARGET/release/easytier-{core,cli,web,web-embed}"$SUFFIX"; do + if [[ -f "$BIN" ]]; then + if [[ -n "$UPX_BIN" ]]; then + $UPX_BIN --lzma --best "$BIN" || true + fi + + mv "$BIN" ./artifacts/objects/ + fi + done mv ./artifacts/objects/* ./artifacts/ rm -rf ./artifacts/objects/ @@ -279,16 +252,7 @@ jobs: path: | ./artifacts/* - core-result: - runs-on: ubuntu-latest - needs: [ pre_job, build_web, build ] - if: needs.pre_job.result == 'success' && needs.pre_job.outputs.should_skip != 'true' && !cancelled() - steps: - - name: Mark result as failed - if: contains(needs.*.result, 'failure') - run: exit 1 - - magisk_build: + build_magisk: runs-on: ubuntu-latest needs: [ pre_job, build_web, build ] if: needs.pre_job.result == 'success' && needs.pre_job.outputs.should_skip != 'true' && !cancelled() @@ -311,7 +275,6 @@ jobs: cp ./downloaded-binaries/easytier-cli ./easytier-contrib/easytier-magisk/ cp ./downloaded-binaries/easytier-web ./easytier-contrib/easytier-magisk/ - # 上传生成的模块 - name: Upload Magisk Module uses: actions/upload-artifact@v5 @@ -322,3 +285,12 @@ jobs: !./easytier-contrib/easytier-magisk/build.sh !./easytier-contrib/easytier-magisk/magisk_update.json if-no-files-found: error + + core-result: + runs-on: ubuntu-latest + needs: [ pre_job, build_web, build, build_magisk ] + if: needs.pre_job.result == 'success' && needs.pre_job.outputs.should_skip != 'true' && !cancelled() + steps: + - name: Mark result as failed + if: contains(needs.*.result, 'failure') + run: exit 1 diff --git a/.github/workflows/gui.yml b/.github/workflows/gui.yml index 77c75496..39a27759 100644 --- a/.github/workflows/gui.yml +++ b/.github/workflows/gui.yml @@ -35,20 +35,20 @@ jobs: concurrent_skipping: 'same_content_newer' skip_after_successful_duplicate: 'true' cancel_others: 'true' - paths: '["Cargo.toml", "Cargo.lock", "easytier/**", "easytier-gui/**", ".github/workflows/gui.yml", ".github/workflows/install_rust.sh", ".github/workflows/install_gui_dep.sh", "easytier-web/frontend-lib/**"]' + paths: '["Cargo.toml", "Cargo.lock", "easytier/**", "easytier-gui/**", ".github/workflows/gui.yml", ".github/actions/**", "easytier-web/frontend-lib/**"]' build-gui: strategy: fail-fast: true matrix: include: - - TARGET: aarch64-unknown-linux-musl - OS: ubuntu-22.04 - GUI_TARGET: aarch64-unknown-linux-gnu - ARTIFACT_NAME: linux-aarch64 - TARGET: x86_64-unknown-linux-musl - OS: ubuntu-22.04 + OS: ubuntu-24.04 GUI_TARGET: x86_64-unknown-linux-gnu ARTIFACT_NAME: linux-x86_64 + - TARGET: aarch64-unknown-linux-musl + OS: ubuntu-24.04-arm + GUI_TARGET: aarch64-unknown-linux-gnu + ARTIFACT_NAME: linux-aarch64 - TARGET: x86_64-apple-darwin OS: macos-latest @@ -63,16 +63,14 @@ jobs: OS: windows-latest GUI_TARGET: x86_64-pc-windows-msvc ARTIFACT_NAME: windows-x86_64 - - - TARGET: aarch64-pc-windows-msvc - OS: windows-latest - GUI_TARGET: aarch64-pc-windows-msvc - ARTIFACT_NAME: windows-arm64 - - TARGET: i686-pc-windows-msvc OS: windows-latest GUI_TARGET: i686-pc-windows-msvc ARTIFACT_NAME: windows-i686 + - TARGET: aarch64-pc-windows-msvc + OS: windows-11-arm + GUI_TARGET: aarch64-pc-windows-msvc + ARTIFACT_NAME: windows-arm64 runs-on: ${{ matrix.OS }} env: @@ -86,75 +84,29 @@ jobs: steps: - uses: actions/checkout@v5 - - name: Install GUI dependencies (x86 only) - if: ${{ matrix.TARGET == 'x86_64-unknown-linux-musl' }} - run: bash ./.github/workflows/install_gui_dep.sh - - - name: Install GUI cross compile (aarch64 only) - if: ${{ matrix.TARGET == 'aarch64-unknown-linux-musl' }} - run: | - # see https://tauri.app/v1/guides/building/linux/ - echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy main restricted" | sudo tee /etc/apt/sources.list - echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy universe" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates universe" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy multiverse" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security main restricted" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security universe" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security multiverse" | sudo tee -a /etc/apt/sources.list - - echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricted" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy universe" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates universe" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy multiverse" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates multiverse" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security universe" | sudo tee -a /etc/apt/sources.list - echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security multiverse" | sudo tee -a /etc/apt/sources.list - - sudo dpkg --add-architecture arm64 - sudo apt update - sudo apt install aptitude - sudo aptitude install -y libgstreamer1.0-0:arm64 gstreamer1.0-plugins-base:arm64 gstreamer1.0-plugins-good:arm64 \ - libgstreamer-gl1.0-0:arm64 libgstreamer-plugins-base1.0-0:arm64 libgstreamer-plugins-good1.0-0:arm64 libwebkit2gtk-4.1-0:arm64 \ - libwebkit2gtk-4.1-dev:arm64 libssl-dev:arm64 gcc-aarch64-linux-gnu libsoup-3.0-dev:arm64 libjavascriptcoregtk-4.1-dev:arm64 - echo "PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu/" >> "$GITHUB_ENV" - echo "PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig/" >> "$GITHUB_ENV" - - - name: Install rpm package (Linux target only) - if: ${{ contains(matrix.TARGET, '-linux-') }} - run: | - sudo apt update - sudo apt install -y rpm - - name: Set current ref as env variable run: | echo "GIT_DESC=$(git log -1 --format=%cd.%h --date=format:%Y-%m-%d_%H:%M:%S)" >> $GITHUB_ENV - - name: Setup Frontend Environment - uses: ./.github/actions/prepare-pnpm + - name: Prepare build environment + uses: ./.github/actions/prepare-build + with: + target: ${{ matrix.TARGET }} + gui: true + pnpm: true + pnpm-build-filter: '' + token: ${{ secrets.GITHUB_TOKEN }} - uses: Swatinem/rust-cache@v2 with: # The prefix cache key, this can be changed to start a new cache manually. # default: "v0-rust" prefix-key: "" - - - name: Install rust target - run: bash ./.github/workflows/install_rust.sh - - - name: Setup protoc - uses: arduino/setup-protoc@v3 - with: - # GitHub repo token to use to avoid rate limiter - repo-token: ${{ secrets.GITHUB_TOKEN }} + shared-key: "gui-registry" + cache-targets: "false" - name: copy correct DLLs - if: ${{ matrix.OS == 'windows-latest' }} + if: ${{ contains(matrix.GUI_TARGET, 'windows') }} run: | case $TARGET in x86_64*) ARCH_DIR=x86_64 ;; @@ -170,10 +122,9 @@ jobs: uses: tauri-apps/tauri-action@v0 with: projectPath: ./easytier-gui - # https://tauri.app/v1/guides/building/linux/#cross-compiling-tauri-applications-for-arm-based-devices - args: --verbose --target ${{ matrix.GUI_TARGET }} ${{ contains(matrix.TARGET, '-linux-') && contains(matrix.TARGET, 'aarch64') && '--bundles deb,rpm' || '' }} + args: --verbose --target ${{ matrix.GUI_TARGET }} - - name: Compress + - name: Collect artifact run: | mkdir -p ./artifacts/objects/ @@ -182,18 +133,16 @@ jobs: else TAG=$GITHUB_SHA fi + # copy gui bundle, gui is built without specific target - if [[ $OS =~ ^windows.*$ ]]; then + if [[ $GUI_TARGET =~ windows ]]; then mv ./target/$GUI_TARGET/release/bundle/nsis/*.exe ./artifacts/objects/ - elif [[ $OS =~ ^macos.*$ ]]; then + elif [[ $GUI_TARGET =~ darwin ]]; then mv ./target/$GUI_TARGET/release/bundle/dmg/*.dmg ./artifacts/objects/ - elif [[ $OS =~ ^ubuntu.*$ && ! $TARGET =~ ^mips.*$ ]]; then + elif [[ $GUI_TARGET =~ linux ]]; then mv ./target/$GUI_TARGET/release/bundle/deb/*.deb ./artifacts/objects/ mv ./target/$GUI_TARGET/release/bundle/rpm/*.rpm ./artifacts/objects/ - if [[ $GUI_TARGET =~ ^x86_64.*$ ]]; then - # currently only x86 appimage is supported - mv ./target/$GUI_TARGET/release/bundle/appimage/*.AppImage ./artifacts/objects/ - fi + mv ./target/$GUI_TARGET/release/bundle/appimage/*.AppImage ./artifacts/objects/ fi mv ./artifacts/objects/* ./artifacts/ diff --git a/.github/workflows/install_gui_dep.sh b/.github/workflows/install_gui_dep.sh deleted file mode 100644 index aa61b198..00000000 --- a/.github/workflows/install_gui_dep.sh +++ /dev/null @@ -1,11 +0,0 @@ -sudo apt update -sudo apt install -qq libwebkit2gtk-4.1-dev \ - build-essential \ - curl \ - wget \ - file \ - libgtk-3-dev \ - librsvg2-dev \ - libxdo-dev \ - libssl-dev \ - patchelf \ No newline at end of file diff --git a/.github/workflows/install_rust.sh b/.github/workflows/install_rust.sh deleted file mode 100644 index 0074e4ac..00000000 --- a/.github/workflows/install_rust.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env bash - -# env needed: -# - TARGET -# - GUI_TARGET -# - OS - -# dependencies are only needed on ubuntu as that's the only place where -# we make cross-compilation -if [[ $OS =~ ^ubuntu.*$ ]]; then - sudo apt-get update && sudo apt-get install -qq musl-tools libappindicator3-dev llvm clang - # https://github.com/cross-tools/musl-cross/releases - # if "musl" is a substring of TARGET, we assume that we are using musl - MUSL_TARGET=$TARGET - # if target is mips or mipsel, we should use soft-float version of musl - if [[ $TARGET =~ ^mips.*$ || $TARGET =~ ^mipsel.*$ ]]; then - MUSL_TARGET=${TARGET}sf - elif [[ $TARGET =~ ^riscv64gc-.*$ ]]; then - MUSL_TARGET=${TARGET/#riscv64gc-/riscv64-} - fi - if [[ $MUSL_TARGET =~ musl ]]; then - mkdir -p ./musl_gcc - wget --inet4-only -c https://github.com/cross-tools/musl-cross/releases/download/20250520/${MUSL_TARGET}.tar.xz -P ./musl_gcc/ - tar xf ./musl_gcc/${MUSL_TARGET}.tar.xz -C ./musl_gcc/ - sudo ln -sf $(pwd)/musl_gcc/${MUSL_TARGET}/bin/*gcc /usr/bin/ - sudo ln -sf $(pwd)/musl_gcc/${MUSL_TARGET}/include/ /usr/include/musl-cross - sudo ln -sf $(pwd)/musl_gcc/${MUSL_TARGET}/${MUSL_TARGET}/sysroot/ ./musl_gcc/sysroot - sudo chmod -R a+rwx ./musl_gcc - fi -fi - -# see https://github.com/rust-lang/rustup/issues/3709 -rustup set auto-self-update disable -rustup install 1.93 -rustup default 1.93 - -# mips/mipsel cannot add target from rustup, need compile by ourselves -if [[ $OS =~ ^ubuntu.*$ && $TARGET =~ ^mips.*$ ]]; then - cd "$PWD/musl_gcc/${MUSL_TARGET}/lib/gcc/${MUSL_TARGET}/15.1.0" || exit 255 - # for panic-abort - cp libgcc_eh.a libunwind.a - - # for mimalloc - ar x libgcc.a _ctzsi2.o _clz.o _bswapsi2.o - ar rcs libctz.a _ctzsi2.o _clz.o _bswapsi2.o - - rustup toolchain install nightly-2026-02-02-x86_64-unknown-linux-gnu - rustup component add rust-src --toolchain nightly-2026-02-02-x86_64-unknown-linux-gnu - - # https://github.com/rust-lang/rust/issues/128808 - # remove it after Cargo or rustc fix this. - RUST_LIB_SRC=$HOME/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/ - if [[ -f $RUST_LIB_SRC/library/Cargo.lock && ! -f $RUST_LIB_SRC/Cargo.lock ]]; then - cp -f $RUST_LIB_SRC/library/Cargo.lock $RUST_LIB_SRC/Cargo.lock - fi -else - rustup target add $TARGET - if [[ $GUI_TARGET != '' ]]; then - rustup target add $GUI_TARGET - fi -fi diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index 4276f404..e8caa484 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -35,20 +35,25 @@ jobs: concurrent_skipping: 'same_content_newer' skip_after_successful_duplicate: 'true' cancel_others: 'true' - paths: '["Cargo.toml", "Cargo.lock", "easytier/**", "easytier-gui/**", "tauri-plugin-vpnservice/**", ".github/workflows/mobile.yml", ".github/workflows/install_rust.sh"]' + paths: '["Cargo.toml", "Cargo.lock", "easytier/**", "easytier-gui/**", "tauri-plugin-vpnservice/**", ".github/workflows/mobile.yml", ".github/actions/**"]' build-mobile: strategy: fail-fast: true matrix: include: - - TARGET: android - OS: ubuntu-22.04 - ARTIFACT_NAME: android - runs-on: ${{ matrix.OS }} + - TARGET: aarch64-linux-android + ARCH: aarch64 + - TARGET: armv7-linux-androideabi + ARCH: armv7 + - TARGET: i686-linux-android + ARCH: i686 + - TARGET: x86_64-linux-android + ARCH: x86_64 + runs-on: ubuntu-latest env: NAME: easytier TARGET: ${{ matrix.TARGET }} - OS: ${{ matrix.OS }} + ARCH: ${{ matrix.ARCH }} OSS_BUCKET: ${{ secrets.ALIYUN_OSS_BUCKET }} needs: pre_job if: needs.pre_job.outputs.should_skip != 'true' @@ -67,47 +72,41 @@ jobs: - name: Setup Android SDK uses: android-actions/setup-android@v3 with: - cmdline-tools-version: 11076708 - packages: 'build-tools;34.0.0 ndk;26.0.10792818 tools platform-tools platforms;android-34 ' + cmdline-tools-version: 12.0 + packages: 'build-tools;34.0.0 ndk;26.0.10792818 platform-tools platforms;android-34 ' - name: Setup Android Environment run: | echo "$ANDROID_HOME/platform-tools" >> $GITHUB_PATH echo "$ANDROID_HOME/ndk/26.0.10792818/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH - echo "NDK_HOME=$ANDROID_HOME/ndk/26.0.10792818/" > $GITHUB_ENV + echo "NDK_HOME=$ANDROID_HOME/ndk/26.0.10792818/" >> $GITHUB_ENV - - name: Setup Frontend Environment - uses: ./.github/actions/prepare-pnpm + - name: Prepare build environment + uses: ./.github/actions/prepare-build + with: + target: ${{ matrix.TARGET }} + gui: false + pnpm: true + pnpm-build-filter: '' + token: ${{ secrets.GITHUB_TOKEN }} - uses: Swatinem/rust-cache@v2 with: # The prefix cache key, this can be changed to start a new cache manually. # default: "v0-rust" prefix-key: "" + shared-key: "gui-registry" + cache-targets: "false" - - name: Install rust target - run: | - bash ./.github/workflows/install_rust.sh - rustup target add aarch64-linux-android - rustup target add armv7-linux-androideabi - rustup target add i686-linux-android - rustup target add x86_64-linux-android - - - name: Setup protoc - uses: arduino/setup-protoc@v3 - with: - # GitHub repo token to use to avoid rate limiter - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Build Android + - name: Build run: | cd easytier-gui - pnpm tauri android build + pnpm tauri android build --apk --target "$ARCH" --split-per-abi - - name: Compress + - name: Collect artifact run: | mkdir -p ./artifacts/objects/ - mv easytier-gui/src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk ./artifacts/objects/ + mv easytier-gui/src-tauri/gen/android/app/build/outputs/apk/*/release/*.apk ./artifacts/objects/ if [[ $GITHUB_REF_TYPE =~ ^tag$ ]]; then TAG=$GITHUB_REF_NAME @@ -115,13 +114,13 @@ jobs: TAG=$GITHUB_SHA fi - mv ./artifacts/objects/* ./artifacts + mv ./artifacts/objects/* ./artifacts/ rm -rf ./artifacts/objects/ - name: Archive artifact uses: actions/upload-artifact@v5 with: - name: easytier-gui-${{ matrix.ARTIFACT_NAME }} + name: easytier-mobile-android-${{ matrix.ARCH }} path: | ./artifacts/* diff --git a/.github/workflows/ohos.yml b/.github/workflows/ohos.yml index 39371112..6c4d2951 100644 --- a/.github/workflows/ohos.yml +++ b/.github/workflows/ohos.yml @@ -29,12 +29,21 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - - name: fmt check + + - name: Prepare build environment + uses: ./.github/actions/prepare-build + with: + gui: false + pnpm: false + + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt + + - name: Check formatting working-directory: ./easytier-contrib/easytier-ohrs - run: | - bash ../../.github/workflows/install_rust.sh - rustup component add rustfmt - cargo fmt --all -- --check + run: cargo fmt --all -- --check + pre_job: # continue-on-error: true # Uncomment once integration is finished runs-on: ubuntu-latest @@ -51,7 +60,8 @@ jobs: concurrent_skipping: "same_content_newer" skip_after_successful_duplicate: "true" cancel_others: "true" - paths: '["Cargo.toml", "Cargo.lock", "easytier/**", "easytier-contrib/easytier-ohrs/**", ".github/workflows/ohos.yml", ".github/workflows/install_rust.sh"]' + paths: '["Cargo.toml", "Cargo.lock", "easytier/**", "easytier-contrib/easytier-ohrs/**", ".github/workflows/ohos.yml", ".github/actions/**"]' + build-ohos: runs-on: ubuntu-latest needs: pre_job @@ -63,13 +73,12 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y \ + sudo apt-get install -qq \ build-essential \ wget \ unzip \ git \ pkg-config curl libgl1-mesa-dev expect - sudo apt-get clean - name: Resolve easytier version run: | @@ -141,6 +150,15 @@ jobs: run: | echo "TARGET_ARCH=aarch64-linux-ohos" >> $GITHUB_ENV + rustup install stable + rustup default stable + + rustup target add aarch64-unknown-linux-ohos + + - uses: taiki-e/install-action@v2 + with: + tool: ohrs + - name: Create clang wrapper script run: | sudo mkdir -p $OHOS_NDK_HOME/native/llvm @@ -159,11 +177,7 @@ jobs: run: | sudo apt-get install -y llvm clang lldb lld sudo apt-get install -y protobuf-compiler - bash ../../.github/workflows/install_rust.sh source env.sh - cargo install ohrs - rustup target add aarch64-unknown-linux-ohos - cargo update easytier ohrs doctor ohrs build --release --arch aarch ohrs artifact diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5f624d4f..df1c490a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,7 +34,7 @@ jobs: # All of these options are optional, so you can remove them if you are happy with the defaults concurrent_skipping: 'never' skip_after_successful_duplicate: 'true' - paths: '["Cargo.toml", "Cargo.lock", "easytier/**", ".github/workflows/test.yml", ".github/workflows/install_gui_dep.sh", ".github/workflows/install_rust.sh"]' + paths: '["Cargo.toml", "Cargo.lock", "easytier/**", ".github/workflows/test.yml", ".github/actions/**"]' check: name: Run linters & check @@ -48,15 +48,12 @@ jobs: uses: ./.github/actions/prepare-build with: gui: true - web: true + pnpm: true token: ${{ secrets.GITHUB_TOKEN }} - - uses: Swatinem/rust-cache@v2 - - - name: Install rustfmt and clippy - run: | - rustup component add rustfmt - rustup component add clippy + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt,clippy - uses: taiki-e/install-action@cargo-hack @@ -89,7 +86,7 @@ jobs: uses: ./.github/actions/prepare-build with: gui: true - web: true + pnpm: true token: ${{ secrets.GITHUB_TOKEN }} - uses: Swatinem/rust-cache@v2 diff --git a/Cargo.lock b/Cargo.lock index a72d6dd0..37e59923 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5118,13 +5118,13 @@ dependencies = [ [[package]] name = "network-interface" -version = "2.0.0" +version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433419f898328beca4f2c6c73a1b52540658d92b0a99f0269330457e0fd998d5" +checksum = "4ddcb8865ad3d9950f22f42ffa0ef0aecbfbf191867b3122413602b0a360b2a6" dependencies = [ "cc", "libc", - "thiserror 1.0.63", + "thiserror 2.0.11", "winapi", ] diff --git a/easytier-gui/src-tauri/Cargo.toml b/easytier-gui/src-tauri/Cargo.toml index f49aa3a2..3dfb9498 100644 --- a/easytier-gui/src-tauri/Cargo.toml +++ b/easytier-gui/src-tauri/Cargo.toml @@ -11,15 +11,6 @@ edition.workspace = true name = "app_lib" crate-type = ["staticlib", "cdylib", "rlib"] -[build-dependencies] -tauri-build = { version = "2.0.0-rc", features = [] } - -# enable thunk-rs when compiling for x86_64 or i686 windows -[target.x86_64-pc-windows-msvc.build-dependencies] -thunk-rs = { git = "https://github.com/easytier/thunk.git", default-features = false, features = ["win7"] } - -[target.i686-pc-windows-msvc.build-dependencies] -thunk-rs = { git = "https://github.com/easytier/thunk.git", default-features = false, features = ["win7"] } [dependencies] # wry 0.47 may crash on android, see https://github.com/EasyTier/EasyTier/issues/527 @@ -66,6 +57,14 @@ libc = "0.2" [target.'cfg(target_os = "macos")'.dependencies] security-framework-sys = "2.9.0" + +[build-dependencies] +tauri-build = { version = "2.0.0-rc", features = [] } +thunk-rs = { git = "https://github.com/easytier/thunk.git", default-features = false, features = [ + "win7", +] } + + [features] # This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!! custom-protocol = ["tauri/custom-protocol"] diff --git a/easytier-gui/src-tauri/build.rs b/easytier-gui/src-tauri/build.rs index 2fda40fe..ab290968 100644 --- a/easytier-gui/src-tauri/build.rs +++ b/easytier-gui/src-tauri/build.rs @@ -1,12 +1,12 @@ -fn main() { - // enable thunk-rs when target os is windows and arch is x86_64 or i686 - #[cfg(target_os = "windows")] - if !std::env::var("TARGET") - .unwrap_or_default() - .contains("aarch64") - { - thunk::thunk(); - } - - tauri_build::build(); -} +use std::env; + +fn main() { + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); + let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default(); + // enable thunk-rs when target os is windows and arch is x86_64 or i686 + if target_os == "windows" && (target_arch == "x86" || target_arch == "x86_64") { + thunk::thunk(); + } + + tauri_build::build(); +} diff --git a/easytier-web/Cargo.toml b/easytier-web/Cargo.toml index 96883b54..b681dc5b 100644 --- a/easytier-web/Cargo.toml +++ b/easytier-web/Cargo.toml @@ -69,13 +69,11 @@ subtle = "2.6" mimalloc = { version = "*" } +[build-dependencies] +thunk-rs = { git = "https://github.com/easytier/thunk.git", default-features = false, features = [ + "win7", +] } + [features] default = [] embed = ["dep:axum-embed"] - -# enable thunk-rs when compiling for x86_64 or i686 windows -[target.x86_64-pc-windows-msvc.build-dependencies] -thunk-rs = { git = "https://github.com/easytier/thunk.git", default-features = false, features = ["win7"] } - -[target.i686-pc-windows-msvc.build-dependencies] -thunk-rs = { git = "https://github.com/easytier/thunk.git", default-features = false, features = ["win7"] } diff --git a/easytier-web/build.rs b/easytier-web/build.rs index 3de4b90a..9772f9cd 100644 --- a/easytier-web/build.rs +++ b/easytier-web/build.rs @@ -1,10 +1,10 @@ +use std::env; + fn main() { + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); + let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default(); // enable thunk-rs when target os is windows and arch is x86_64 or i686 - #[cfg(target_os = "windows")] - if !std::env::var("TARGET") - .unwrap_or_default() - .contains("aarch64") - { + if target_os == "windows" && (target_arch == "x86" || target_arch == "x86_64") { thunk::thunk(); } } diff --git a/easytier/Cargo.toml b/easytier/Cargo.toml index 4d254fbd..972da260 100644 --- a/easytier/Cargo.toml +++ b/easytier/Cargo.toml @@ -324,22 +324,14 @@ easytier-rpc-build = { path = "../easytier-rpc-build", features = [ "internal-namespace", ] } prost-reflect-build = { version = "0.14.0" } +thunk-rs = { git = "https://github.com/easytier/thunk.git", default-features = false, features = [ + "win7", +] } [target.'cfg(windows)'.build-dependencies] reqwest = { version = "0.12.12", features = ["blocking"] } zip = "4.0.0" -# enable thunk-rs when compiling for x86_64 or i686 windows -[target.x86_64-pc-windows-msvc.build-dependencies] -thunk-rs = { git = "https://github.com/easytier/thunk.git", default-features = false, features = [ - "win7", -] } - -[target.i686-pc-windows-msvc.build-dependencies] -thunk-rs = { git = "https://github.com/easytier/thunk.git", default-features = false, features = [ - "win7", -] } - [dev-dependencies] serial_test = "3.0.0" diff --git a/easytier/build.rs b/easytier/build.rs index 5f6a74d8..0cc372df 100644 --- a/easytier/build.rs +++ b/easytier/build.rs @@ -143,12 +143,10 @@ fn main() -> Result<(), Box> { } } + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); + let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default(); // enable thunk-rs when target os is windows and arch is x86_64 or i686 - #[cfg(target_os = "windows")] - if !std::env::var("TARGET") - .unwrap_or_default() - .contains("aarch64") - { + if target_os == "windows" && (target_arch == "x86" || target_arch == "x86_64") { thunk::thunk(); }