Skip to content

Commit a8de8cc

Browse files
madebricculus
authored andcommitted
ci: use Ninja generator
1 parent 15028f2 commit a8de8cc

File tree

2 files changed

+73
-3
lines changed

2 files changed

+73
-3
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: 'Setup ninja'
2+
description: 'Download ninja and add it to the PATH environment variable'
3+
inputs:
4+
version:
5+
description: 'Ninja version'
6+
default: '1.12.1'
7+
runs:
8+
using: 'composite'
9+
steps:
10+
- name: 'Calculate variables'
11+
id: calc
12+
shell: sh
13+
run: |
14+
case "${{ runner.os }}-${{ runner.arch }}" in
15+
"Linux-X86" | "Linux-X64")
16+
archive="ninja-linux.zip"
17+
;;
18+
"Linux-ARM64")
19+
archive="ninja-linux-aarch64.zip"
20+
;;
21+
"macOS-X86" | "macOS-X64" | "macOS-ARM64")
22+
archive="ninja-mac.zip"
23+
;;
24+
"Windows-X86" | "Windows-X64")
25+
archive="ninja-win.zip"
26+
;;
27+
"Windows-ARM64")
28+
archive="ninja-winarm64.zip"
29+
;;
30+
*)
31+
echo "Unsupported ${{ runner.os }}-${{ runner.arch }}"
32+
exit 1;
33+
;;
34+
esac
35+
echo "archive=${archive}" >> ${GITHUB_OUTPUT}
36+
echo "cache-key=${archive}-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}" >> ${GITHUB_OUTPUT}
37+
- name: 'Restore cached ${{ steps.calc.outputs.archive }}'
38+
id: cache-restore
39+
uses: actions/cache/restore@v4
40+
with:
41+
path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}'
42+
key: ${{ steps.calc.outputs.cache-key }}
43+
- name: 'Download ninja ${{ inputs.version }} for ${{ runner.os }} (${{ runner.arch }})'
44+
if: ${{ !steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false' }}
45+
shell: pwsh
46+
run: |
47+
Invoke-WebRequest "https://github.com/ninja-build/ninja/releases/download/v${{ inputs.version }}/${{ steps.calc.outputs.archive }}" -OutFile "${{ runner.temp }}/${{ steps.calc.outputs.archive }}"
48+
- name: 'Cache ${{ steps.calc.outputs.archive }}'
49+
if: ${{ !steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false' }}
50+
uses: actions/cache/save@v4
51+
with:
52+
path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}'
53+
key: ${{ steps.calc.outputs.cache-key }}
54+
- name: 'Extract ninja'
55+
shell: pwsh
56+
run: |
57+
7z "-o${{ runner.temp }}/ninja-${{ inputs.version }}-${{ runner.arch }}" x "${{ runner.temp }}/${{ steps.calc.outputs.archive }}"
58+
- name: 'Set output variables'
59+
id: final
60+
shell: pwsh
61+
run: |
62+
echo "${{ runner.temp }}/ninja-${{ inputs.version }}-${{ runner.arch }}" >> $env:GITHUB_PATH

.github/workflows/main.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,22 @@ jobs:
1313
- { name: Windows, os: windows-latest }
1414
- { name: MacOS, os: macos-latest }
1515
steps:
16+
- name: Get DirkSimple sources
17+
uses: actions/checkout@v4
18+
- name: Set up MSVC toolchain
19+
uses: ilammy/msvc-dev-cmd@v1
20+
if: ${{ matrix.platform.name == 'Windows' }}
21+
with:
22+
arch: x64
23+
- name: Set up ninja
24+
uses: ./.github/actions/setup-ninja
1625
- name: Set up SDL
1726
id: sdl
1827
uses: libsdl-org/setup-sdl@v1
1928
with:
2029
version: sdl3-latest
21-
- name: Get DirkSimple sources
22-
uses: actions/checkout@v3
30+
cmake-generator: Ninja
2331
- name: Configure CMake
24-
run: cmake -B build ${{ matrix.platform.flags }}
32+
run: cmake -B build -GNinja ${{ matrix.platform.flags }}
2533
- name: Build
2634
run: cmake --build build/

0 commit comments

Comments
 (0)