-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add native compilation on windows, linux and macos. Add cross-compilation from linux/macos to windows, and from windows/macos to linux.
- Loading branch information
Showing
1 changed file
with
169 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
name: ci | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
# Cancels pending runs when a PR gets updated. | ||
group: ${{ github.head_ref || github.run_id }}-${{ github.actor }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
lint-and-build-and-test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
runs-on: ${{matrix.os}} | ||
build-linux: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
@@ -29,10 +28,174 @@ jobs: | |
uses: mlugg/setup-zig@v1 | ||
with: | ||
version: ${{ steps.zigversion.outputs.content }} | ||
- name: Install sdl2 | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install libsdl2-dev | ||
- name: SDL version | ||
run: sdl2-config --version | ||
- name: Check format | ||
continue-on-error: true | ||
run: zig fmt --check . | ||
- name: Build and run tests | ||
run: zig build test | ||
- name: Build examples | ||
run: zig build examples | ||
|
||
build-macos: | ||
runs-on: macos-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Read .zig-version | ||
id: zigversion | ||
uses: juliangruber/read-file-action@v1 | ||
with: | ||
path: ./.zigversion | ||
- name: Install Zig | ||
uses: mlugg/setup-zig@v1 | ||
with: | ||
version: ${{ steps.zigversion.outputs.content }} | ||
- name: Install sdl2 | ||
run: brew install sdl2 | ||
- name: Build and run tests | ||
run: zig build test | ||
- name: Build examples | ||
run: zig build examples | ||
|
||
build-windows: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
target: [x86_64-windows-gnu, x86_64-windows-msvc] | ||
runs-on: windows-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Read .zig-version | ||
id: zigversion | ||
uses: juliangruber/read-file-action@v1 | ||
with: | ||
path: ./.zigversion | ||
- name: Install Zig | ||
uses: mlugg/setup-zig@v1 | ||
with: | ||
version: ${{ steps.zigversion.outputs.content }} | ||
- name: Install VisualStudio (x64) | ||
if: ${{ matrix.target == 'x86_64-windows-msvc' }} | ||
uses: ilammy/msvc-dev-cmd@v1 | ||
with: | ||
uwp: false | ||
arch: x64 | ||
- name: Download SDL2 (MinGW) | ||
uses: carlosperate/[email protected] | ||
if: ${{ matrix.target == 'x86_64-windows-gnu' }} | ||
with: | ||
file-url: https://www.libsdl.org/release/SDL2-devel-2.0.18-mingw.tar.gz | ||
file-name: SDL2.tar.gz | ||
location: . | ||
- name: Download SDL2 (Visual Studio) | ||
uses: carlosperate/[email protected] | ||
if: ${{ matrix.target == 'x86_64-windows-msvc' }} | ||
with: | ||
file-url: https://www.libsdl.org/release/SDL2-devel-2.0.18-VC.zip | ||
file-name: SDL2.tar.gz | ||
location: . | ||
- name: Extract SDL2 | ||
uses: brunoborges/justextract@v1 | ||
with: | ||
file: SDL2.tar.gz | ||
- name: Create SDK file | ||
uses: DamianReeves/[email protected] | ||
with: | ||
path: .build_config/sdl.json | ||
contents: | | ||
{ | ||
"x86_64-windows-gnu": { | ||
"include": "SDL2-2.0.18/x86_64-w64-mingw32/include", | ||
"libs": "SDL2-2.0.18/x86_64-w64-mingw32/lib", | ||
"bin": "SDL2-2.0.18/x86_64-w64-mingw32/bin" | ||
}, | ||
"x86_64-windows-msvc": { | ||
"include": "SDL2-2.0.18/include", | ||
"libs": "SDL2-2.0.18/lib/x64", | ||
"bin": "SDL2-2.0.18/lib/x64" | ||
} | ||
} | ||
write-mode: overwrite | ||
- name: Build and run tests | ||
run: zig build test | ||
- name: Build examples | ||
run: zig build -Dtarget=${{matrix.target}} examples | ||
|
||
build-cross-windows: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
host: [ubuntu-latest, macos-latest] | ||
target: [x86-windows-gnu, x86_64-windows-gnu] | ||
runs-on: ${{matrix.host}} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Read .zig-version | ||
id: zigversion | ||
uses: juliangruber/read-file-action@v1 | ||
with: | ||
path: ./.zigversion | ||
- name: Install Zig | ||
uses: mlugg/setup-zig@v1 | ||
with: | ||
version: ${{ steps.zigversion.outputs.content }} | ||
- name: Download SDL2 (MinGW) | ||
uses: carlosperate/[email protected] | ||
with: | ||
file-url: https://www.libsdl.org/release/SDL2-devel-2.0.18-mingw.tar.gz | ||
file-name: SDL2.tar.gz | ||
location: . | ||
- name: Extract SDL2 | ||
uses: brunoborges/justextract@v1 | ||
with: | ||
file: SDL2.tar.gz | ||
- name: Create SDK file | ||
uses: DamianReeves/[email protected] | ||
with: | ||
path: .build_config/sdl.json | ||
contents: | | ||
{ | ||
"x86-windows-gnu": { | ||
"include": "SDL2-2.0.18/i686-w64-mingw32/include", | ||
"libs": "SDL2-2.0.18/i686-w64-mingw32/lib", | ||
"bin": "SDL2-2.0.18/i686-w64-mingw32/bin" | ||
}, | ||
"x86_64-windows-gnu": { | ||
"include": "SDL2-2.0.18/x86_64-w64-mingw32/include", | ||
"libs": "SDL2-2.0.18/x86_64-w64-mingw32/lib", | ||
"bin": "SDL2-2.0.18/x86_64-w64-mingw32/bin" | ||
} | ||
} | ||
write-mode: overwrite | ||
- name: Build examples | ||
run: zig build -Dtarget=${{matrix.target}} examples | ||
|
||
build-cross-linux: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
host: [macos-latest, windows-latest] | ||
target: [x86_64-linux-gnu, aarch64-linux-gnu] | ||
runs-on: ${{matrix.host}} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Read .zig-version | ||
id: zigversion | ||
uses: juliangruber/read-file-action@v1 | ||
with: | ||
path: ./.zigversion | ||
- name: Install Zig | ||
uses: mlugg/setup-zig@v1 | ||
with: | ||
version: ${{ steps.zigversion.outputs.content }} | ||
- name: Build examples | ||
run: zig build -Dtarget=${{matrix.target}} examples |