forked from libsdl-org/sdl2-compat
-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (152 loc) · 7.24 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Build
on:
pull_request:
push:
schedule:
- cron: '5 1 * * *' # Build every day at 1:05am
jobs:
Build:
name: '${{ matrix.platform.name }}'
runs-on: '${{ matrix.platform.os }}'
# The scheduled event should only run on libsdl-org/sdl2-compat
if: ${{ (github.event_name == 'schedule' && github.repository == 'libsdl-org/sdl2-compat') || (github.event_name != 'schedule') }}
strategy:
fail-fast: false
matrix:
platform:
- { name: 'Linux', os: ubuntu-latest, artifact: 'SDL2_compat-ubuntu', shell: sh, linux: true, static: true }
- { name: 'MacOS', os: macos-latest, artifact: 'SDL2_compat-macos', shell: sh }
- { name: 'Windows msys2 (mingw32)', os: windows-latest, artifact: 'SDL2_compat-mingw32', shell: 'msys2 {0}', msystem: mingw32, msys-env: mingw-w64-i686 }
- { name: 'Windows msys2 (mingw64)', os: windows-latest, artifact: 'SDL2_compat-mingw64', shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64 }
- { name: 'Windows msys2 (clang32)', os: windows-latest, artifact: 'SDL2_compat-clang32', shell: 'msys2 {0}', msystem: clang32, msys-env: mingw-w64-clang-i686 }
- { name: 'Windows msys2 (clang64)', os: windows-latest, artifact: 'SDL2_compat-clang64', shell: 'msys2 {0}', msystem: clang64, msys-env: mingw-w64-clang-x86_64 }
- { name: 'Windows MSVC (x86)', os: windows-latest, artifact: 'SDL2_compat-VC-x86', shell: sh, no-test-pc: true, msvc: true, msvc-arch: x86 }
- { name: 'Windows MSVC (x64)', os: windows-latest, artifact: 'SDL2_compat-VC-x64', shell: sh, no-test-pc: true, msvc: true, msvc-arch: x64 }
- { name: 'Windows MSVC (arm32)', os: windows-latest, artifact: 'SDL2_compat-VC-arm32', shell: sh, no-test-pc: true, msvc: true, msvc-arch: amd64_arm, cross: true, windows-sdk-version: '10.0.22621.0' }
- { name: 'Windows MSVC (arm64)', os: windows-latest, artifact: 'SDL2_compat-VC-arm64', shell: sh, no-test-pc: true, msvc: true, msvc-arch: amd64_arm64, cross: true }
# - { name: 'Android', os: ubuntu-latest, artifact: 'SDL2_compat-android-aarch64', shell: sh, no-test-pc: true, android: true, android-abi: "arm64-v8a", android-platform: 23, ndk-version: r21e, cross: true, cmake-extra: }
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- uses: nttld/setup-ndk@v1
if: ${{ matrix.platform.android }}
id: setup-ndk
with:
local-cache: true
ndk-version: ${{ matrix.platform.ndk-version }}
- uses: ilammy/msvc-dev-cmd@v1
if: ${{ matrix.platform.msvc }}
with:
arch: ${{ matrix.platform.msvc-arch }}
sdk: '${{ matrix.platform.windows-sdk-version }}'
- name: Set up MSYS2
if: ${{ contains(matrix.platform.shell, 'msys2') }}
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.platform.msystem }}
install: >-
${{ matrix.platform.msys-env }}-cc
${{ matrix.platform.msys-env }}-cmake
${{ matrix.platform.msys-env }}-crt
${{ matrix.platform.msys-env }}-ninja
- name: Get sdl2-compat sources
uses: actions/checkout@v4
- name: Install Ninja
if: ${{ !contains(matrix.platform.shell, 'msys2') }}
uses: aseprite/get-ninja@main
- name: Calculate extra arguments
id: calculate-arguments
run: |
CMAKE_ARGUMENTS=
if test "x${{ matrix.platform.android }}" != x; then
CMAKE_ARGUMENTS="-DCMAKE_TOOLCHAIN_FILE=${{ steps.setup-ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake"
CMAKE_ARGUMENTS="$CMAKE_ARGUMENTS -DANDROID_PLATFORM=${{ matrix.platform.android-platform }}"
CMAKE_ARGUMENTS="$CMAKE_ARGUMENTS -DANDROID_ABI=${{ matrix.platform.android-abi }}"
CMAKE_ARGUMENTS="$CMAKE_ARGUMENTS -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH"
fi
echo "CMAKE_ARGUMENTS=${CMAKE_ARGUMENTS}"
echo "cmake-arguments=${CMAKE_ARGUMENTS}" >>$GITHUB_OUTPUT
- name: Set up SDL3
uses: libsdl-org/setup-sdl@main
id: sdl
with:
cmake-arguments: ${{ steps.calculate-arguments.outputs.cmake-arguments }}
cmake-generator: Ninja
version: 3-head
sdl-test: true
shell: ${{ matrix.platform.shell }}
add-to-environment: true
- name: Set up Linux dependencies
if: ${{ matrix.platform.linux }}
run: |
sudo apt-get update -y
sudo apt-get install -y libgl1-mesa-dev libglu1-mesa-dev
- name: Configure (CMake)
run: |
cmake -S . -B build \
-DSDL2COMPAT_STATIC=${{ matrix.platform.static }} \
-DSDL2COMPAT_INSTALL=TRUE \
-DCMAKE_INSTALL_LIBDIR=lib \
-DSDL2COMPAT_INSTALL_CPACK=TRUE \
-DCMAKE_INSTALL_PREFIX=prefix \
-DSDL2COMPAT_WERROR=ON \
-DCMAKE_POLICY_DEFAULT_CMP0141="NEW" \
-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT="ProgramDatabase" \
-DCMAKE_EXE_LINKER_FLAGS="${{ matrix.platform.msvc && '-DEBUG' }}" \
-DCMAKE_SHARED_LINKER_FLAGS="${{ matrix.platform.msvc && '-DEBUG' }}" \
${{ steps.calculate-arguments.outputs.cmake-arguments }}\
-DCMAKE_POLICY_DEFAULT_CMP0074=NEW \
-GNinja
- name: Build (CMake)
id: build
run: |
cmake --build build/ --verbose
- name: Install (CMake)
run: |
cmake --install build/
echo "SDL2_ROOT=$(pwd)/prefix" >>$GITHUB_ENV
- name: Package (CPack)
if: ${{ always() && steps.build.outcome == 'success' }}
run: |
cmake --build build/ --target package
- name: Run build-time tests (CMake)
if: ${{ !matrix.platform.cross }}
run: |
set -eu
export SDL_TESTS_QUICK=1
ctest -VV --test-dir build/
- name: Run compile tests (CMake)
if: ${{ always() }}
run: |
cmake --build build/ --verbose --target sdl2compat-build-tests
- name: Check that versioning is consistent
# We only need to run this once: arbitrarily use the Linux build
if: ${{ runner.os == 'Linux' }}
run: |
./build-scripts/test-versioning.sh
- name: Verify CMake configuration files
run: |
cmake -S cmake/test -B cmake_config_build \
-DTEST_SHARED=TRUE \
-DTEST_STATIC=${{ matrix.platform.static || 'false' }} \
-DCMAKE_BUILD_TYPE=Release \
${{ steps.calculate-arguments.outputs.cmake-arguments }}\
-GNinja
cmake --build cmake_config_build --verbose
- name: Verify sdl2-config
if: ${{ !matrix.platform.no-test-pc }}
run: |
export PATH=${{ env.SDL2_ROOT }}/bin:$PATH
cmake/test/test_sdlconfig.sh ${{ !matrix.platform.static && '--no-static' }}
- name: Verify sdl2.pc
if: ${{ !matrix.platform.no-test-pc }}
run: |
export PKG_CONFIG_PATH=${{ env.SDL2_ROOT }}/lib/pkgconfig
cmake/test/test_pkgconfig.sh ${{ !matrix.platform.static && '--no-static' }}
- uses: actions/upload-artifact@v4
if: ${{ always() && steps.build.outcome == 'success' }}
with:
if-no-files-found: error
name: ${{ matrix.platform.artifact }}
path: build/dist/SDL2_compat*