diff --git a/.github/workflows/build-on-Windows-ARM64.yml b/.github/workflows/build-on-Windows-ARM64.yml new file mode 100644 index 00000000..bddc20f3 --- /dev/null +++ b/.github/workflows/build-on-Windows-ARM64.yml @@ -0,0 +1,55 @@ +# --------------------------------------------------------------- +# Workflow File : build-on-Windows-ARM64.yml +# File Authors : NewbieXvwu +# Contributors : Nul None +# | +# Created On : <2026-07-21> +# Last Modified : <2026-07-21> +# +# Build chsrc on Windows (ARM64/WoA) and upload it to GitHub: the 'pre' release +# --------------------------------------------------------------- + +name: 构建于 Windows ARM64 + +on: + push: + branches: [ "gh-build" ] + +jobs: + build-and-upload: + # windows-11-arm 为原生 WoA (Windows on ARM) runner,已 GA + runs-on: windows-11-arm + defaults: + run: + shell: msys2 {0} + + steps: + + - name: 检出代码 + uses: actions/checkout@v6 + + - name: 安装 Clang (CLANGARM64) + uses: msys2/setup-msys2@v2 + with: + # CLANGARM64 提供原生 AArch64 的 clang 工具链 + msystem: CLANGARM64 + update: true + install: | + mingw-w64-clang-aarch64-clang + mingw-w64-clang-aarch64-make + + - name: 为 arm64 (AArch64) 构建 + run: | + mingw32-make.exe build-in-ci-release-mode + mv chsrc-ci-release.exe chsrc-aarch64-windows.exe + + - name: List files + run: ls *.exe + + - name: 上传至 'pre' release + uses: softprops/action-gh-release@v2 + # if: startsWith(github.ref, 'refs/tags/') + with: + tag_name: pre + files: | + chsrc-aarch64-windows.exe diff --git a/.github/workflows/build-on-Windows.yml b/.github/workflows/build-on-Windows-x64x86.yml similarity index 92% rename from .github/workflows/build-on-Windows.yml rename to .github/workflows/build-on-Windows-x64x86.yml index 182f4e62..fdf3042a 100644 --- a/.github/workflows/build-on-Windows.yml +++ b/.github/workflows/build-on-Windows-x64x86.yml @@ -1,15 +1,15 @@ # --------------------------------------------------------------- -# Workflow File : build-on-Windows.yml +# Workflow File : build-on-Windows-x64x86.yml # File Authors : 曾奥然 -# Contributors : Nul None +# Contributors : NewbieXvwu # | # Created On : <2023-09-14> -# Last Modified : <2025-09-12> +# Last Modified : <2026-07-21> # # Build chsrc on Windows and upload it to GitHub: the 'pre' release # --------------------------------------------------------------- -name: 构建于 Windows +name: 构建于 Windows x64x86 on: push: branches: [ "gh-build" ] diff --git a/Makefile b/Makefile index 9797adab..9dfeabf4 100755 --- a/Makefile +++ b/Makefile @@ -60,7 +60,11 @@ endif CFLAGS += -Iinclude -Ilib ifeq ($(On-Windows), 1) - CLANG_FLAGS = -target x86_64-pc-windows-gnu + # 依据 MSYS2 环境的目标架构选择 clang 的 target triple + # MSYSTEM_CARCH 由 MSYS2 提供: x86_64 (MINGW64/UCRT64/CLANG64) / i686 (MINGW32) / aarch64 (CLANGARM64) + # 非 MSYS2 环境 (独立 LLVM) 下回退到 x86_64 + Windows-Clang-Arch = $(if $(MSYSTEM_CARCH),$(MSYSTEM_CARCH),x86_64) + CLANG_FLAGS = -target $(Windows-Clang-Arch)-pc-windows-gnu endif ifeq ($(CC), clang) diff --git a/README.md b/README.md index 601d0249..6f2be9e9 100644 --- a/README.md +++ b/README.md @@ -192,6 +192,9 @@ curl -L https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-x64-windo # x86 curl -L https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-x86-windows.exe -o chsrc.exe + +# arm64/aarch64 (WoA, Windows on ARM) +curl -L https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-aarch64-windows.exe -o chsrc.exe ``` diff --git a/justfile b/justfile index 19875242..0d1ad521 100644 --- a/justfile +++ b/justfile @@ -48,7 +48,8 @@ DEBUGGER := if os() == 'windows' { CFLAGS_chk_Clang := if os() == 'windows' { if CC == 'clang' { - '-target x86_64-pc-windows-gnu' + # arch() 返回当前架构 (x86_64 / aarch64),以适配原生 WoA 环境 + '-target ' + arch() + '-pc-windows-gnu' } else {''} } else {''} diff --git a/tool/installer.ps1 b/tool/installer.ps1 index ebdcfd26..d92c8059 100644 --- a/tool/installer.ps1 +++ b/tool/installer.ps1 @@ -6,9 +6,10 @@ # | ChatGPT # | 曾奥然 # Contributors : GitHub Copilot +# | NewbieXvwu # | # Created On : <2024-10-26> -# Last Modified : <2026-01-06> +# Last Modified : <2026-07-21> # # chsrc installer for Windows # --------------------------------------------------------------- @@ -155,8 +156,9 @@ function Set_URL { $script:arch = "x86" } } + 12 { $script:arch = "aarch64" } default { - Output_Error "Unsupported architecture '$cpuArchitecture'. Only x86 or x64 architectures are supported." + Output_Error "Unsupported architecture '$cpuArchitecture'. Only x86, x64 or ARM64 architectures are supported." } } Output_Info "Get my CPU architecture: $script:arch"