Skip to content

Commit

Permalink
build: update ci scripts (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
xensik authored Feb 7, 2025
1 parent fc84d6c commit d13b704
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 50 deletions.
81 changes: 58 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ jobs:
build-macos:
name: Build macOS
runs-on: macos-13
runs-on: macos-14
strategy:
fail-fast: false
matrix:
config:
- release
arch:
- x64
- amd64
- arm64
steps:
- name: Check out files
Expand All @@ -93,7 +93,7 @@ jobs:
uses: Homebrew/actions/setup-homebrew@master

- name: Install LLVM
run: brew install llvm
run: brew install llvm lld

- name: Add LLVM to PATH
run: |
Expand Down Expand Up @@ -122,17 +122,50 @@ jobs:
path: |
build/bin/${{matrix.arch}}/${{matrix.config}}/gsc-tool
prebuild-linux:
name: Prebuild Linux
runs-on: ubuntu-24.04
steps:
- name: Check out files
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
lfs: false

- name: Add premake5 to PATH
uses: abel0b/[email protected]
with:
version: ${{ env.PREMAKE_VERSION }}

- name: Generate project files
run: premake5 gmake2

- name: Upload project files
uses: actions/[email protected]
with:
name: linux-project-files
path: |
build/
include/xsk/version.hpp
build-linux:
name: Build Linux
runs-on: ubuntu-24.04
runs-on: ${{ matrix.os }}
needs: prebuild-linux
strategy:
fail-fast: false
matrix:
config:
- release
arch:
- x64
# - arm64
- amd64
- arm64
include:
- arch: amd64
os: ubuntu-24.04
- arch: arm64
os: ubuntu-24.04-arm
steps:
- name: Check out files
uses: actions/checkout@v4
Expand All @@ -141,26 +174,28 @@ jobs:
fetch-depth: 0
lfs: false

- name: Download project files
uses: actions/[email protected]
with:
name: linux-project-files
path: ./

- name: Install LLVM
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 18
# - name: Install dependencies (arm64)
# if: matrix.arch == 'arm64'
# run: sudo apt-get install crossbuild-essential-arm64 -y

- name: Add premake5 to PATH
uses: abel0b/[email protected]
with:
version: ${{ env.PREMAKE_VERSION }}
# - name: Add premake5 to PATH
# uses: abel0b/[email protected]
# with:
# version: ${{ env.PREMAKE_VERSION }}

- name: Generate project files
run: premake5 gmake2
# - name: Generate project files
# run: premake5 gmake2

- name: Set up problem matching
uses: ammaraskar/gcc-problem-matcher@master
# - name: Set up problem matching
# uses: ammaraskar/gcc-problem-matcher@master

- name: Build ${{matrix.arch}} ${{matrix.config}} binaries
run: |
Expand Down Expand Up @@ -196,6 +231,8 @@ jobs:

- name: Compress Binaries
run: |
rm -rf linux-project-files/
for dir in */; do
if [[ $dir == *"windows"* ]]; then
cd "$dir" && zip -r "../${dir%/}.zip" . && cd ..
Expand All @@ -221,10 +258,8 @@ jobs:
# with:
# cosign-release: 'v2.1.1'

# - name: Setup QEMU
# uses: docker/[email protected]
# with:
# platforms: linux/amd64,linux/arm64
- name: Setup QEMU
uses: docker/[email protected]

- name: Setup Docker Buildx
uses: docker/[email protected]
Expand Down Expand Up @@ -257,7 +292,7 @@ jobs:
uses: docker/[email protected]
with:
context: .
platforms: linux/amd64
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ubuntu:24.04
ARG TARGETARCH

COPY --chmod=755 ./linux-x64-release/gsc-tool /usr/local/bin/
COPY --chmod=755 ./linux-${TARGETARCH}-release/gsc-tool /usr/local/bin/

RUN groupadd gsc-tool && useradd -r -g gsc-tool gsc-tool
USER gsc-tool
Expand Down
55 changes: 29 additions & 26 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,29 @@ workspace "gsc-tool"
objdir "%{wks.location}/obj/%{cfg.buildcfg}/%{prj.name}"
targetdir "%{wks.location}/bin/%{cfg.platform}/%{cfg.buildcfg}"
targetname "%{prj.name}"
cppdialect "C++20"
staticruntime "On"
warnings "Extra"

-- configurations
configurations { "debug", "release" }

filter "configurations:debug"
optimize "Debug"
symbols "On"
defines { "DEBUG", "_DEBUG" }
filter {}

filter "configurations:release"
optimize "Full"
symbols "Off"
defines "NDEBUG"
flags "FatalCompileWarnings"
filter {}

-- platforms
if os.istarget("linux") or os.istarget("macosx") then
platforms { "x64", "arm64" }
platforms { "arm64", "amd64" }
else
platforms { "x86", "x64", "arm64" }
end
Expand All @@ -98,15 +116,15 @@ workspace "gsc-tool"
architecture "x86_64"
filter {}

filter "platforms:arm64"
architecture "ARM64"
filter "platforms:amd64"
architecture "x86_64"
filter {}

filter { "language:C++", "toolset:not msc*" }
buildoptions "-std=c++20"
filter "platforms:arm64"
architecture "ARM64"
filter {}

filter "toolset:msc*"
filter { "toolset:msc*" }
buildoptions "/bigobj"
buildoptions "/Zc:__cplusplus"
buildoptions "/std:c++20"
Expand All @@ -116,36 +134,21 @@ workspace "gsc-tool"
systemversion "latest"
filter {}

staticruntime "On"
warnings "Extra"

filter "system:linux"
filter { "system:linux" }
toolset "clang"
linkoptions "-fuse-ld=lld"
filter {}

filter { "system:linux", "platforms:arm64" }
buildoptions "--target=arm64-linux-gnu"
linkoptions "--target=arm64-linux-gnu"
filter { "system:macosx", "platforms:amd64" }
buildoptions "-arch x86_64"
linkoptions "-arch x86_64"
filter {}

filter { "system:macosx", "platforms:arm64" }
buildoptions "-arch arm64"
linkoptions "-arch arm64"
filter {}

filter "configurations:release"
optimize "Full"
symbols "Off"
defines "NDEBUG"
flags "FatalCompileWarnings"
filter {}

filter "configurations:debug"
optimize "Debug"
symbols "On"
defines { "DEBUG", "_DEBUG" }
filter {}

project "xsk-tool"
kind "ConsoleApp"
language "C++"
Expand Down

0 comments on commit d13b704

Please sign in to comment.