From 75d644077608e6719607878371c848e031201287 Mon Sep 17 00:00:00 2001 From: diamante0018 Date: Sun, 13 Apr 2025 13:46:57 +0200 Subject: [PATCH] feat: arm64 Linux Docker image --- .github/workflows/build.yml | 100 +++++++++++++++++++++++++++++++---- Dockerfile | 8 ++- deps/premake/libtomcrypt.lua | 2 +- premake5.lua | 17 +++--- 4 files changed, 104 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 66ba525..3cc1e46 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ env: PREMAKE_VERSION: "5.0.0-beta6" jobs: - build-win: + build-windows: name: Build Windows runs-on: windows-latest strategy: @@ -48,7 +48,6 @@ jobs: with: submodules: true fetch-depth: 0 - # NOTE - If LFS ever starts getting used during builds, switch this to true! lfs: false - name: Add msbuild to PATH @@ -93,7 +92,7 @@ jobs: - release arch: - x86 - - x64 + - amd64 steps: - name: Install g++ and multilib run: | @@ -109,7 +108,6 @@ jobs: with: submodules: true fetch-depth: 0 - # NOTE - If LFS ever starts getting used during builds, switch this to true! lfs: false - name: Install dependencies (x86) @@ -146,6 +144,86 @@ jobs: path: | build/bin/${{matrix.arch}}/${{matrix.configuration}}/alterware-master + prebuild-linux-arm64: + name: Prebuild Linux + runs-on: ubuntu-latest + steps: + - name: Check out files + uses: actions/checkout@main + with: + submodules: true + fetch-depth: 0 + lfs: false + + - name: Install Premake5 + uses: diamante0018/setup-premake@master + with: + version: ${{ env.PREMAKE_VERSION }} + + - name: Generate project files + run: premake5 --cc=clang gmake + + - name: Upload project files + uses: actions/upload-artifact@main + with: + name: linux-project-files + path: | + build/ + + build-linux-arm64: + name: Build Linux + runs-on: ${{ matrix.os }} + needs: prebuild-linux-arm64 + strategy: + fail-fast: false + matrix: + configuration: + - debug + - release + arch: + - arm64 + include: + - arch: arm64 + os: ubuntu-24.04-arm + steps: + - name: Check out files + uses: actions/checkout@main + with: + submodules: true + fetch-depth: 0 + lfs: false + + - name: Compress the build directory + run: mkdir -p build + + - name: Download project files + uses: actions/download-artifact@main + with: + name: linux-project-files + path: build/ + + - name: Install LLVM + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 18 + + - name: Build ${{matrix.arch}} ${{matrix.configuration}} binaries + working-directory: ${{ github.workspace }} + run: | + pushd build + make config=${{matrix.configuration}}_${{matrix.arch}} -j$(nproc) + env: + CC: clang-18 + CXX: clang++-18 + + - name: Upload ${{matrix.arch}} ${{matrix.configuration}} binaries + uses: actions/upload-artifact@main + with: + name: linux-${{matrix.arch}}-${{matrix.configuration}} + path: | + build/bin/${{matrix.arch}}/${{matrix.configuration}}/alterware-master + build-macos: name: Build macOS runs-on: macos-latest @@ -156,7 +234,7 @@ jobs: - debug - release arch: - - x64 + - amd64 - arm64 steps: - name: Check out files @@ -164,7 +242,6 @@ jobs: with: submodules: true fetch-depth: 0 - # NOTE - If LFS ever starts getting used during builds, switch this to true! lfs: false - name: Install Premake5 @@ -192,7 +269,7 @@ jobs: deploy: name: Deploy artifacts - needs: [build-win, build-linux, build-macos] + needs: [build-windows, build-linux, build-linux-arm64, build-macos] runs-on: ubuntu-latest if: github.ref_type == 'tag' steps: @@ -202,7 +279,7 @@ jobs: - name: Download Release binaries uses: actions/download-artifact@main with: - name: linux-x64-release + name: linux-amd64-release - name: Install SSH key uses: shimataro/ssh-key-action@v2.7.0 @@ -221,7 +298,7 @@ jobs: docker: name: Create Docker Image - needs: [build-win, build-linux, build-macos] + needs: [build-windows, build-linux, build-linux-arm64, build-macos] runs-on: ubuntu-latest if: github.ref_type == 'tag' steps: @@ -247,6 +324,9 @@ jobs: done shell: bash + - name: Setup QEMU + uses: docker/setup-qemu-action@v3.6.0 + - name: Setup Docker Buildx uses: docker/setup-buildx-action@v3.10.0 @@ -270,7 +350,7 @@ jobs: uses: docker/build-push-action@v6.15.0 with: context: . - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index e3e573b..22781e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,5 @@ -FROM ubuntu:latest - -RUN apt-get update -RUN apt-get install -y libc++-dev +FROM ubuntu:noble +ARG TARGETARCH WORKDIR /master-server @@ -11,7 +9,7 @@ RUN mkdir -p /master-server && \ chown alterware-master:alterware-master /master-server && \ chmod 775 /master-server -COPY --chown=alterware-master:alterware-master --chmod=755 ./linux-x64-release/alterware-master /master-server +COPY --chown=alterware-master:alterware-master --chmod=755 ./linux-${TARGETARCH}-release/alterware-master /master-server USER alterware-master diff --git a/deps/premake/libtomcrypt.lua b/deps/premake/libtomcrypt.lua index 14c4428..e4b7683 100644 --- a/deps/premake/libtomcrypt.lua +++ b/deps/premake/libtomcrypt.lua @@ -60,7 +60,7 @@ function libtomcrypt.project() buildoptions "-mcpu=apple-m1" filter {} - filter { "system:macosx", "platforms:x64" } + filter { "system:macosx", "platforms:amd64" } buildoptions "-mcpu=x86-64" filter {} diff --git a/premake5.lua b/premake5.lua index e98ab6c..ad2e115 100644 --- a/premake5.lua +++ b/premake5.lua @@ -41,9 +41,11 @@ configurations {"debug", "release"} language "C++" cppdialect "C++20" -if os.istarget("darwin") then - platforms {"x64", "arm64"} -else +if os.istarget("linux") then + platforms {"x86", "amd64", "arm64"} +elseif os.istarget("macosx") then + platforms {"amd64", "arm64"} +else platforms {"x86", "x64", "arm64"} end @@ -55,6 +57,10 @@ filter "platforms:x64" architecture "x86_64" filter {} +filter "platforms:amd64" +architecture "x86_64" +filter {} + filter "platforms:arm64" architecture "ARM64" filter {} @@ -77,15 +83,12 @@ if os.istarget("linux") then filter {} filter { "toolset:clang*" } - buildoptions "-stdlib=libc++" - linkoptions "-stdlib=libc++" - -- always try to use lld. LD or Gold will not work linkoptions "-fuse-ld=lld" filter {} end -filter { "system:macosx", "platforms:x64" } +filter { "system:macosx", "platforms:amd64" } buildoptions "-arch x86_64" linkoptions "-arch x86_64" filter {}