From e553279e918bf8e693f2d59ef685809ae62264d1 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 13 Jan 2025 23:04:10 +0800 Subject: [PATCH 1/4] improve cross for zig --- xmake/toolchains/zig/xmake.lua | 37 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/xmake/toolchains/zig/xmake.lua b/xmake/toolchains/zig/xmake.lua index 701bf2e787..b88449fb84 100644 --- a/xmake/toolchains/zig/xmake.lua +++ b/xmake/toolchains/zig/xmake.lua @@ -124,25 +124,26 @@ toolchain("zig") end -- init target - local target - if toolchain:is_plat("cross") then - -- xmake f -p cross --toolchain=zig --cross=mips64el-linux-gnuabi64 - target = toolchain:cross() - elseif toolchain:is_plat("macosx") then - --@see https://github.com/ziglang/zig/issues/14226 - target = arch .. "-macos-none" - elseif toolchain:is_plat("linux") then - if arch == "arm" then - target = "arm-linux-gnueabi" - elseif arch == "mips64" or arch == "mips64el" then - target = arch .. "-linux-gnuabi64" - else - target = arch .. "-linux-gnu" + local target = toolchain:cross() + if target == nil then + if toolchain:is_plat("cross") then + -- xmake f -p cross --toolchain=zig --cross=mips64el-linux-gnuabi64 + elseif toolchain:is_plat("macosx") then + --@see https://github.com/ziglang/zig/issues/14226 + target = arch .. "-macos-none" + elseif toolchain:is_plat("linux") then + if arch == "arm" then + target = "arm-linux-gnueabi" + elseif arch == "mips64" or arch == "mips64el" then + target = arch .. "-linux-gnuabi64" + else + target = arch .. "-linux-gnu" + end + elseif toolchain:is_plat("windows") then + target = arch .. "-windows-msvc" + elseif toolchain:is_plat("mingw") then + target = arch .. "-windows-gnu" end - elseif toolchain:is_plat("windows") then - target = arch .. "-windows-msvc" - elseif toolchain:is_plat("mingw") then - target = arch .. "-windows-gnu" end if target then toolchain:add("asflags", "-target", target) From 5920033babf244d606b3ce4e96e1fbc9d34ab546 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 13 Jan 2025 23:06:38 +0800 Subject: [PATCH 2/4] use zig to build xmake bundle --- .github/workflows/linux.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index d4f1eeb120..5f0f607333 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -33,12 +33,25 @@ jobs: sudo apt install -y ruby ruby-dev rubygems build-essential llvm libc++-dev sudo apt install -y libgl1-mesa-dev libglu1-mesa-dev clang --version + xrepo install zig - name: Tests run: | xmake lua -v -D tests/run.lua xrepo --version + - name: Artifact + run: | + cd core + xrepo env -b zig xmake f --embed=y --toolchain=zig --cross=x86_64-linux-gnu.2.29 -c + xmake + cp build/xmake ../artifacts/xmake-bundle + cd .. + - uses: actions/upload-artifact@v4 + with: + name: xmake-bundle.linux.x86_64 + path: artifacts/xmake-bundle + - name: Publish if: github.event.action == 'published' env: @@ -57,3 +70,14 @@ jobs: scripts/makeppa bionic # 18.04 scripts/makeppa xenial # 16.04 scripts/makeppa trusty # 14.04 + + - name: Publish bundle binary + if: github.event.action == 'published' + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: artifacts/xmake-bundle + asset_name: xmake-bundle-${{ steps.tagName.outputs.tag }}.linux.x86_64 + asset_content_type: application/zip From f8189afc9f41ddb6d22957cb6e4056144b1b8da9 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 13 Jan 2025 14:24:01 +0800 Subject: [PATCH 3/4] Update linux.yml --- .github/workflows/linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 5f0f607333..83d7a620ce 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -33,7 +33,7 @@ jobs: sudo apt install -y ruby ruby-dev rubygems build-essential llvm libc++-dev sudo apt install -y libgl1-mesa-dev libglu1-mesa-dev clang --version - xrepo install zig + xrepo install -y zig - name: Tests run: | From fdefc50f0c67505d7649dffc2730e3aa874560b2 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 13 Jan 2025 14:47:30 +0800 Subject: [PATCH 4/4] Update linux.yml --- .github/workflows/linux.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 83d7a620ce..5368a7061b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -45,6 +45,7 @@ jobs: cd core xrepo env -b zig xmake f --embed=y --toolchain=zig --cross=x86_64-linux-gnu.2.29 -c xmake + mkdir ../artifacts cp build/xmake ../artifacts/xmake-bundle cd .. - uses: actions/upload-artifact@v4