Skip to content

Commit 3163fbb

Browse files
committed
Configure pygame-ce SDL build
- Modify VS projects to pick up SDL in location we install - Modify VS projects to use libpng and libjpeg(turbo) - Adds libpng and libjpeg(turbo) to VisualC/external (libpng+zlib is from SDL_image 2.0.5 build, libjpeg turbo is from libjpeg-turbo 3.0.1 release gcc installers, lib/headers extracted from install) - Adds automation to construct SDL_image bundle using msbuild (VS projects)
1 parent df9552d commit 3163fbb

22 files changed

+9056
-295
lines changed

.github/workflows/main.yml

Lines changed: 51 additions & 275 deletions
Original file line numberDiff line numberDiff line change
@@ -1,283 +1,59 @@
1-
name: Build
1+
name: PGCE Build
22

33
on: [push, pull_request]
44

55
jobs:
6-
Build:
7-
name: ${{ matrix.platform.name }}
8-
runs-on: ${{ matrix.platform.os }}
9-
10-
defaults:
11-
run:
12-
shell: ${{ matrix.platform.shell }}
6+
build:
7+
name: Windows ${{ matrix.archplatform }}
8+
runs-on: windows-latest
139

1410
strategy:
15-
fail-fast: false
11+
fail-fast: false # if a particular matrix build fails, don't skip the rest
1612
matrix:
17-
platform:
18-
- { name: Windows (MSVC+CMake), os: windows-latest, shell: sh, cmake: '-GNinja', msvc: 1, shared: 1, static: 0, vendored: 1 }
19-
- { name: Windows (mingw32+autotools), os: windows-latest, shell: 'msys2 {0}', msystem: mingw32, msys-env: mingw-w64-i686, shared: 1, static: 1 }
20-
- { name: Windows (mingw64+CMake), os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64, shared: 1, static: 0,
21-
cmake: '-DSDL2IMAGE_BACKEND_STB=OFF -DSDL2IMAGE_BACKEND_WIC=OFF -G "Ninja Multi-Config"' }
22-
- { name: Linux (autotools), os: ubuntu-latest, shell: sh, shared: 1, static: 1}
23-
- { name: Linux (CMake), os: ubuntu-latest, shell: sh, cmake: '-GNinja', shared: 1, static: 0, vendored: 1 }
24-
- { name: 'Linux (CMake, static)', os: ubuntu-latest, shell: sh, cmake: '-DBUILD_SHARED_LIBS=OFF -GNinja', shared: 0, static: 1, vendored: 1 }
25-
- { name: Macos (autotools), os: macos-latest, shell: sh, shared: 1, static: 1 }
26-
- { name: Macos (CMake), os: macos-latest, shell: sh, cmake: '-GNinja', shared: 1, static: 0, vendored: 1 }
27-
13+
include:
14+
- {
15+
arch: x86_amd64,
16+
archplatform: x64,
17+
archlocation: x64,
18+
}
19+
- {
20+
arch: x86,
21+
archplatform: x86,
22+
archlocation: Win32,
23+
}
24+
2825
steps:
29-
- uses: ilammy/msvc-dev-cmd@v1
30-
if: ${{ matrix.platform.msvc }}
31-
with:
32-
arch: x64
33-
- name: Set up MSYS2
34-
if: ${{ contains(matrix.platform.shell, 'msys2') }}
35-
uses: msys2/setup-msys2@v2
36-
with:
37-
msystem: ${{ matrix.platform.msystem }}
38-
path-type: inherit
39-
install: >-
40-
${{ matrix.platform.msys-env }}-autotools
41-
${{ matrix.platform.msys-env }}-cmake
42-
${{ matrix.platform.msys-env }}-gcc
43-
${{ matrix.platform.msys-env }}-ninja
44-
${{ matrix.platform.msys-env }}-pkg-config
45-
${{ matrix.platform.msys-env }}-nasm
46-
${{ matrix.platform.msys-env }}-libavif
47-
${{ matrix.platform.msys-env }}-libjpeg-turbo
48-
${{ matrix.platform.msys-env }}-libjxl
49-
${{ matrix.platform.msys-env }}-libpng
50-
${{ matrix.platform.msys-env }}-libtiff
51-
${{ matrix.platform.msys-env }}-libwebp
52-
${{ matrix.platform.msys-env }}-zlib
53-
- name: Install Ninja
54-
uses: aseprite/get-ninja@main
55-
if: ${{ !contains(matrix.platform.shell, 'msys2') }}
56-
- name: Set up SDL
57-
id: sdl
58-
uses: libsdl-org/setup-sdl@main
59-
with:
60-
cmake-generator: Ninja
61-
version: 2-head
62-
sdl-test: true
63-
shell: ${{ matrix.platform.shell }}
64-
add-to-environment: true
65-
- name: Setup Macos dependencies
66-
if: ${{ runner.os == 'macOS' }}
67-
run: |
68-
brew install \
69-
autoconf \
70-
automake \
71-
jpeg \
72-
jpeg-xl \
73-
libavif \
74-
libpng \
75-
libtiff \
76-
libtool \
77-
nasm \
78-
ninja \
79-
webp \
80-
zlib \
81-
${NULL+}
82-
- name: Setup Linux dependencies
83-
if: ${{ runner.os == 'Linux' }}
84-
run: |
85-
sudo apt-get update
86-
sudo apt-get -y install \
87-
autoconf \
88-
automake \
89-
cmake \
90-
libavif-dev \
91-
libjpeg-dev \
92-
libpng-dev \
93-
libtiff-dev \
94-
libtool \
95-
libwebp-dev \
96-
nasm \
97-
ninja-build \
98-
pkg-config \
99-
zlib1g-dev \
100-
${NULL+}
101-
- name: Set up NASM
102-
uses: ilammy/setup-nasm@v1
103-
if: ${{ matrix.platform.vendored && !contains(matrix.platform.shell, 'msys2') }}
104-
105-
- uses: actions/checkout@v4
106-
with:
107-
submodules: recursive
108-
109-
- name: Check that versioning is consistent
110-
# We only need to run this once: arbitrarily use the Linux/CMake build
111-
if: ${{ runner.os == 'Linux' && matrix.platform.cmake }}
112-
run: ./build-scripts/test-versioning.sh
113-
114-
- name: Configure (CMake)
115-
if: ${{ matrix.platform.cmake }}
116-
run: |
117-
export CMAKE_CONFIGURATION_TYPES=Debug
118-
cmake -B build \
119-
-DSDL2IMAGE_VENDORED=${{ matrix.platform.vendored }} \
120-
-DSDL2IMAGE_STRICT=ON \
121-
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=$PWD/build \
122-
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$PWD/build \
123-
-DBUILD_SHARED_LIBS=ON \
124-
-DCMAKE_BUILD_TYPE=Debug \
125-
-DSDL2IMAGE_SAMPLES=ON \
126-
-DSDL2IMAGE_TESTS=ON \
127-
-DSDL2IMAGE_TESTS_INSTALL=ON \
128-
-DSDL2IMAGE_AVIF=ON \
129-
-DSDL2IMAGE_JXL=ON \
130-
-DSDL2IMAGE_TIF=ON \
131-
-DSDL2IMAGE_WEBP=ON \
132-
-DCMAKE_INSTALL_PREFIX=prefix_cmake \
133-
${{ matrix.platform.cmake }}
134-
- name: Build (CMake)
135-
if: ${{ matrix.platform.cmake }}
136-
run: cmake --build build/ --config Debug --parallel --verbose
137-
- name: Run build-time tests (CMake)
138-
if: ${{ matrix.platform.cmake }}
139-
run: |
140-
set -eu
141-
if [ "x${{ runner.os }}" = xLinux ]; then
142-
export LD_LIBRARY_PATH="${{ github.workspace }}/build:$LD_LIBRARY_PATH"
143-
fi
144-
if [ "x${{ runner.os }}" = xmacos ]; then
145-
export DYLD_LIBRARY_PATH="${{ github.workspace }}/build:$DYLD_LIBRARY_PATH"
146-
fi
147-
if [ "x${{ runner.os }}" = "xWindows" ]; then
148-
sdl_binpath="$( cygpath -u "${{ steps.sdl.outputs.prefix }}" )"
149-
sdlimage_binpath="$( cygpath -u "${{ github.workspace }}/build" )"
150-
export PATH="$sdl_binpath:$sdlimage_binpath:$PATH"
151-
fi
152-
153-
export SDL_IMAGE_TEST_REQUIRE_LOAD_AVIF=1
154-
export SDL_IMAGE_TEST_REQUIRE_LOAD_BMP=1
155-
export SDL_IMAGE_TEST_REQUIRE_LOAD_CUR=1
156-
export SDL_IMAGE_TEST_REQUIRE_LOAD_GIF=1
157-
export SDL_IMAGE_TEST_REQUIRE_LOAD_ICO=1
158-
export SDL_IMAGE_TEST_REQUIRE_LOAD_JPG=1
159-
export SDL_IMAGE_TEST_REQUIRE_LOAD_JXL=1
160-
export SDL_IMAGE_TEST_REQUIRE_LOAD_LBM=1
161-
export SDL_IMAGE_TEST_REQUIRE_LOAD_PCX=1
162-
export SDL_IMAGE_TEST_REQUIRE_LOAD_PNG=1
163-
export SDL_IMAGE_TEST_REQUIRE_LOAD_PNM=1
164-
export SDL_IMAGE_TEST_REQUIRE_LOAD_QOI=1
165-
export SDL_IMAGE_TEST_REQUIRE_LOAD_SVG=1
166-
export SDL_IMAGE_TEST_REQUIRE_LOAD_TGA=1
167-
export SDL_IMAGE_TEST_REQUIRE_LOAD_TIF=1
168-
export SDL_IMAGE_TEST_REQUIRE_LOAD_WEBP=1
169-
export SDL_IMAGE_TEST_REQUIRE_LOAD_XPM=1
170-
export SDL_IMAGE_TEST_REQUIRE_LOAD_XV=1
171-
172-
export SDL_IMAGE_TEST_REQUIRE_SAVE_JPG=1
173-
export SDL_IMAGE_TEST_REQUIRE_SAVE_PNG=1
174-
175-
cd build/test
176-
ctest -VV -C Debug
177-
- name: Install (CMake)
178-
if: ${{ (matrix.platform.shell == 'sh' || contains(matrix.platform.shell, 'msys2')) && matrix.platform.cmake }}
179-
run: |
180-
set -eu
181-
rm -fr DESTDIR-cmake
182-
cmake --install build/ --config Debug
183-
echo "SDL2_image_DIR=$(pwd)/prefix_cmake" >> $GITHUB_ENV
184-
( cd prefix_cmake; find . ) | LC_ALL=C sort -u
185-
- name: Upload artifacts (CMake)
186-
if: ${{ failure() && runner.os == 'Linux' && matrix.platform.cmake }}
187-
uses: actions/upload-artifact@v4
188-
with:
189-
name: "${{ matrix.platform.name }} artifacts"
190-
path: |
191-
build/test/*.bmp
192-
build/test/*.jpg
193-
build/test/*.png
194-
if-no-files-found: ignore
195-
196-
- name: Configure (Autotools)
197-
if: ${{ !matrix.platform.cmake }}
198-
run: |
199-
set -eu
200-
rm -fr build
201-
mkdir build
202-
./autogen.sh
203-
if [ "x${{ runner.os }}" = "xmacOS" ]; then
204-
export LDFLAGS=-Wl,-rpath,${{ steps.sdl.outputs.prefix }}/lib
205-
fi
206-
# We do the CMake build with stb_image and the Autotools build without
207-
set -- --disable-stb-image --prefix=$(pwd)/prefix_autotools --enable-tests --enable-installed-tests
208-
( cd build && ../configure "$@" )
209-
- name: Build (Autotools)
210-
if: ${{ !matrix.platform.cmake }}
211-
run: |
212-
set -eu
213-
parallel="$(getconf _NPROCESSORS_ONLN)"
214-
make -j"${parallel}" -C build V=1
215-
- name: Run build-time tests (Autotools)
216-
if: ${{ !matrix.platform.cmake }}
217-
run: |
218-
set -eu
219-
if [ "x${{ runner.os }}" = "xWindows" ]; then
220-
sdl_binpath="$( cygpath -u "${{ steps.sdl.outputs.prefix }}" )"
221-
export PATH="$sdl_binpath:$PATH"
222-
fi
223-
parallel="$(getconf _NPROCESSORS_ONLN)"
224-
225-
# Expect to support all formats except JXL in these builds.
226-
# See test/README.md for how this works.
227-
export SDL_IMAGE_TEST_REQUIRE_LOAD_AVIF=1
228-
export SDL_IMAGE_TEST_REQUIRE_LOAD_BMP=1
229-
export SDL_IMAGE_TEST_REQUIRE_LOAD_CUR=1
230-
export SDL_IMAGE_TEST_REQUIRE_LOAD_GIF=1
231-
export SDL_IMAGE_TEST_REQUIRE_LOAD_ICO=1
232-
export SDL_IMAGE_TEST_REQUIRE_LOAD_JPG=1
233-
export SDL_IMAGE_TEST_REQUIRE_LOAD_JXL=0
234-
export SDL_IMAGE_TEST_REQUIRE_LOAD_LBM=1
235-
export SDL_IMAGE_TEST_REQUIRE_LOAD_PCX=1
236-
export SDL_IMAGE_TEST_REQUIRE_LOAD_PNG=1
237-
export SDL_IMAGE_TEST_REQUIRE_LOAD_PNM=1
238-
export SDL_IMAGE_TEST_REQUIRE_LOAD_QOI=1
239-
export SDL_IMAGE_TEST_REQUIRE_LOAD_SVG=1
240-
export SDL_IMAGE_TEST_REQUIRE_LOAD_TGA=1
241-
export SDL_IMAGE_TEST_REQUIRE_LOAD_TIF=1
242-
export SDL_IMAGE_TEST_REQUIRE_LOAD_WEBP=1
243-
export SDL_IMAGE_TEST_REQUIRE_LOAD_XPM=1
244-
export SDL_IMAGE_TEST_REQUIRE_LOAD_XV=1
245-
246-
export SDL_IMAGE_TEST_REQUIRE_SAVE_JPG=1
247-
export SDL_IMAGE_TEST_REQUIRE_SAVE_PNG=1
248-
249-
make -j"${parallel}" -C build check V=1 VERBOSE=1
250-
- name: Install (Autotools)
251-
if: ${{ !matrix.platform.cmake }}
252-
run: |
253-
set -eu
254-
curdir="$(pwd)"
255-
parallel="$(getconf _NPROCESSORS_ONLN)"
256-
make -j"${parallel}" -C build install V=1
257-
echo "SDL2_image_DIR=$(pwd)/prefix_autotools" >> $GITHUB_ENV
258-
( cd prefix_autotools; find . ) | LC_ALL=C sort -u
259-
- name: Distcheck (Autotools)
260-
if: ${{ runner.os == 'Linux' && !matrix.platform.cmake }}
261-
run: |
262-
set -eu
263-
parallel="$(getconf _NPROCESSORS_ONLN)"
264-
make -j"${parallel}" -C build distcheck V=1
265-
- name: Upload artifacts (Autotools)
266-
if: ${{ failure() && !matrix.platform.cmake }}
267-
uses: actions/upload-artifact@v4
268-
with:
269-
name: ${{ matrix.platform.name }} artifacts
270-
path: |
271-
build/test/*.bmp
272-
build/test/*.jpg
273-
build/test/*.log
274-
build/test/*.png
275-
if-no-files-found: ignore
276-
- name: Verify CMake configuration files
277-
run: |
278-
cmake -S cmake/test -B cmake_config_build \
279-
-DCMAKE_BUILD_TYPE=Debug \
280-
-DCMAKE_PREFIX_PATH="${{ env.SDL2_image_DIR }}" \
281-
-DTEST_SHARED=${{ matrix.platform.shared }} \
282-
-DTEST_STATIC=${{ matrix.platform.static }}
283-
cmake --build cmake_config_build --verbose
26+
- uses: actions/checkout@v4.1.1
27+
28+
- uses: TheMrMilchmann/setup-msvc-dev@v3 # this lets us use the developer command prompt on windows
29+
with:
30+
arch: ${{ matrix.arch }}
31+
32+
- name: Get SDL
33+
run: |
34+
.github/fetch_sdl_vc.ps1
35+
36+
- name: Build SDL_image
37+
run: |
38+
msbuild VisualC/SDL_image.vcxproj /p:PlatformToolset=v143 /p:Configuration=Release /p:Platform=${{ matrix.archplatform }}
39+
40+
- name: Prepare upload
41+
run: |
42+
mkdir upload_prep/lib/${{ matrix.archplatform }}
43+
cp VisualC/${{ matrix.archlocation }}/Release/SDL2_image.dll upload_prep/lib/${{ matrix.archplatform }}/SDL2_image.dll
44+
cp VisualC/${{ matrix.archlocation }}/Release/SDL2_image.lib upload_prep/lib/${{ matrix.archplatform }}/SDL2_image.lib
45+
cp -r VisualC/external/optional/${{ matrix.archplatform }} upload_prep/lib/${{ matrix.archplatform }}/optional
46+
47+
- name: Add constant files to bundle
48+
if: matrix.archplatform == 'x64' # only run once, adds to same bundle as win32
49+
run: |
50+
mkdir upload_prep/include
51+
cp include/SDL_image.h upload_prep/include/SDL_image.h
52+
cp CHANGES.txt upload_prep/CHANGES.txt
53+
cp README.txt upload_prep/README.txt
54+
cp LICENSE.txt upload_prep/LICENSE.txt
55+
56+
- uses: actions/upload-artifact@v3
57+
with:
58+
name: SDL-image-build
59+
path: upload_prep

0 commit comments

Comments
 (0)