From ab7dee49b0f6b4cd4c322c4afeced50ed16a3cb5 Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Thu, 9 Feb 2023 19:43:29 +0800 Subject: [PATCH] feat: add `windows/arm64` target (close #3308) --- .github/workflows/build.yml | 1 + .github/workflows/release.yml | 1 + build.sh | 13 ++++++++++++- wrapper/zcc-arm64 | 2 ++ wrapper/zcxx-arm64 | 2 ++ 5 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 wrapper/zcc-arm64 create mode 100644 wrapper/zcxx-arm64 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5a6ce275..9e4d1021 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,6 +25,7 @@ jobs: - name: Install dependencies run: | + sudo snap install zig --classic --beta docker pull crazymax/xgo:latest go install github.com/crazy-max/xgo@latest sudo apt install upx diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f411b3a0..c1f218ff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,6 +38,7 @@ jobs: - name: Install dependencies run: | + sudo snap install zig --classic --beta docker pull crazymax/xgo:latest go install github.com/crazy-max/xgo@latest sudo apt install upx diff --git a/build.sh b/build.sh index b2bb172b..7c780bd1 100644 --- a/build.sh +++ b/build.sh @@ -41,14 +41,24 @@ FetchWebRelease() { rm -rf dist.tar.gz } +BuildWinArm64() { + echo building for windows-arm64 + export GOOS=windows + export GOARCH=arm64 + export CC=$(pwd)/wrapper/zcc-arm64 + export CXX=$(pwd)/wrapper/zcxx-arm64 + go build -o "$1" -ldflags="$ldflags" -tags=jsoniter . +} + BuildDev() { rm -rf .git/ + BuildWinArm64 ./alist-windows-arm64.exe xgo -targets=linux/amd64,windows/amd64,darwin/amd64 -out "$appName" -ldflags="$ldflags" -tags=jsoniter . mkdir -p "dist" mv alist-* dist cd dist upx -9 ./alist-linux* - upx -9 ./alist-windows* + upx -9 ./alist-windows-amd64.exe find . -type f -print0 | xargs -0 md5sum >md5.txt cat md5.txt } @@ -80,6 +90,7 @@ BuildRelease() { export CGO_ENABLED=1 go build -o ./build/$appName-$os_arch -ldflags="$muslflags" -tags=jsoniter . done + BuildWinArm64 ./build/alist-windows-arm64.exe xgo -out "$appName" -ldflags="$ldflags" -tags=jsoniter . # why? Because some target platforms seem to have issues with upx compression upx -9 ./alist-linux-amd64 diff --git a/wrapper/zcc-arm64 b/wrapper/zcc-arm64 new file mode 100644 index 00000000..afcd6d43 --- /dev/null +++ b/wrapper/zcc-arm64 @@ -0,0 +1,2 @@ +#!/bin/sh +zig cc -target aarch64-windows-gnu $@ diff --git a/wrapper/zcxx-arm64 b/wrapper/zcxx-arm64 new file mode 100644 index 00000000..25c7482f --- /dev/null +++ b/wrapper/zcxx-arm64 @@ -0,0 +1,2 @@ +#!/bin/sh +zig c++ -target aarch64-windows-gnu $@