Skip to content

Commit 624ac67

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 abcf63a commit 624ac67

22 files changed

+9048
-291
lines changed

.github/workflows/main.yml

Lines changed: 51 additions & 279 deletions
Original file line numberDiff line numberDiff line change
@@ -1,287 +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: turtlesec-no/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-
libavif \
73-
libpng \
74-
libtiff \
75-
libtool \
76-
nasm \
77-
ninja \
78-
pkg-config \
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@v3
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: Setup (CMake)
115-
if: ${{ matrix.platform.cmake && !matrix.platform.msystem && !matrix.platform.msvc }}
116-
uses: jwlawson/actions-setup-cmake@master
117-
with:
118-
cmake-version: '3.16'
119-
- name: Configure (CMake)
120-
if: ${{ matrix.platform.cmake }}
121-
run: |
122-
export CMAKE_CONFIGURATION_TYPES=Debug
123-
cmake -B build \
124-
-DSDL2IMAGE_VENDORED=${{ matrix.platform.vendored }} \
125-
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=$PWD/build \
126-
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$PWD/build \
127-
-DBUILD_SHARED_LIBS=ON \
128-
-DCMAKE_BUILD_TYPE=Debug \
129-
-DSDL2IMAGE_SAMPLES=ON \
130-
-DSDL2IMAGE_TESTS=ON \
131-
-DSDL2IMAGE_TESTS_INSTALL=ON \
132-
-DSDL2IMAGE_AVIF=ON \
133-
-DSDL2IMAGE_JXL=ON \
134-
-DSDL2IMAGE_TIF=ON \
135-
-DSDL2IMAGE_WEBP=ON \
136-
-DCMAKE_INSTALL_PREFIX=prefix_cmake \
137-
${{ matrix.platform.cmake }}
138-
- name: Build (CMake)
139-
if: ${{ matrix.platform.cmake }}
140-
run: cmake --build build/ --config Debug --parallel --verbose
141-
- name: Run build-time tests (CMake)
142-
if: ${{ matrix.platform.cmake }}
143-
run: |
144-
set -eu
145-
if [ "x${{ runner.os }}" = xLinux ]; then
146-
export LD_LIBRARY_PATH="${{ github.workspace }}/build:$LD_LIBRARY_PATH"
147-
fi
148-
if [ "x${{ runner.os }}" = xmacos ]; then
149-
export DYLD_LIBRARY_PATH="${{ github.workspace }}/build:$DYLD_LIBRARY_PATH"
150-
fi
151-
if [ "x${{ runner.os }}" = "xWindows" ]; then
152-
sdl_binpath="$( cygpath -u "${{ steps.sdl.outputs.prefix }}" )"
153-
sdlimage_binpath="$( cygpath -u "${{ github.workspace }}/build" )"
154-
export PATH="$sdl_binpath:$sdlimage_binpath:$PATH"
155-
fi
156-
157-
export SDL_IMAGE_TEST_REQUIRE_LOAD_AVIF=1
158-
export SDL_IMAGE_TEST_REQUIRE_LOAD_BMP=1
159-
export SDL_IMAGE_TEST_REQUIRE_LOAD_CUR=1
160-
export SDL_IMAGE_TEST_REQUIRE_LOAD_GIF=1
161-
export SDL_IMAGE_TEST_REQUIRE_LOAD_ICO=1
162-
export SDL_IMAGE_TEST_REQUIRE_LOAD_JPG=1
163-
export SDL_IMAGE_TEST_REQUIRE_LOAD_JXL=1
164-
export SDL_IMAGE_TEST_REQUIRE_LOAD_LBM=1
165-
export SDL_IMAGE_TEST_REQUIRE_LOAD_PCX=1
166-
export SDL_IMAGE_TEST_REQUIRE_LOAD_PNG=1
167-
export SDL_IMAGE_TEST_REQUIRE_LOAD_PNM=1
168-
export SDL_IMAGE_TEST_REQUIRE_LOAD_QOI=1
169-
export SDL_IMAGE_TEST_REQUIRE_LOAD_SVG=1
170-
export SDL_IMAGE_TEST_REQUIRE_LOAD_TGA=1
171-
export SDL_IMAGE_TEST_REQUIRE_LOAD_TIF=1
172-
export SDL_IMAGE_TEST_REQUIRE_LOAD_WEBP=1
173-
export SDL_IMAGE_TEST_REQUIRE_LOAD_XPM=1
174-
export SDL_IMAGE_TEST_REQUIRE_LOAD_XV=1
175-
176-
export SDL_IMAGE_TEST_REQUIRE_SAVE_JPG=1
177-
export SDL_IMAGE_TEST_REQUIRE_SAVE_PNG=1
178-
179-
cd build/test
180-
ctest -VV -C Debug
181-
- name: Install (CMake)
182-
if: ${{ (matrix.platform.shell == 'sh' || contains(matrix.platform.shell, 'msys2')) && matrix.platform.cmake }}
183-
run: |
184-
set -eu
185-
rm -fr DESTDIR-cmake
186-
cmake --install build/ --config Debug
187-
echo "SDL2_image_DIR=$(pwd)/prefix_cmake" >> $GITHUB_ENV
188-
( cd prefix_cmake; find . ) | LC_ALL=C sort -u
189-
- name: Upload artifacts (CMake)
190-
if: ${{ failure() && runner.os == 'Linux' && matrix.platform.cmake }}
191-
uses: actions/upload-artifact@v3
192-
with:
193-
name: "${{ matrix.platform.name }} artifacts"
194-
path: |
195-
build/test/*.bmp
196-
build/test/*.jpg
197-
build/test/*.png
198-
if-no-files-found: ignore
199-
200-
- name: Configure (Autotools)
201-
if: ${{ !matrix.platform.cmake }}
202-
run: |
203-
set -eu
204-
rm -fr build
205-
mkdir build
206-
./autogen.sh
207-
if [ "x${{ runner.os }}" = "xmacOS" ]; then
208-
export LDFLAGS=-Wl,-rpath,${{ steps.sdl.outputs.prefix }}/lib
209-
fi
210-
# We do the CMake build with stb_image and the Autotools build without
211-
set -- --disable-stb-image --prefix=$(pwd)/prefix_autotools --enable-tests --enable-installed-tests
212-
( cd build && ../configure "$@" )
213-
- name: Build (Autotools)
214-
if: ${{ !matrix.platform.cmake }}
215-
run: |
216-
set -eu
217-
parallel="$(getconf _NPROCESSORS_ONLN)"
218-
make -j"${parallel}" -C build V=1
219-
- name: Run build-time tests (Autotools)
220-
if: ${{ !matrix.platform.cmake }}
221-
run: |
222-
set -eu
223-
if [ "x${{ runner.os }}" = "xWindows" ]; then
224-
sdl_binpath="$( cygpath -u "${{ steps.sdl.outputs.prefix }}" )"
225-
export PATH="$sdl_binpath:$PATH"
226-
fi
227-
parallel="$(getconf _NPROCESSORS_ONLN)"
228-
229-
# Expect to support all formats except JXL in these builds.
230-
# See test/README.md for how this works.
231-
export SDL_IMAGE_TEST_REQUIRE_LOAD_AVIF=1
232-
export SDL_IMAGE_TEST_REQUIRE_LOAD_BMP=1
233-
export SDL_IMAGE_TEST_REQUIRE_LOAD_CUR=1
234-
export SDL_IMAGE_TEST_REQUIRE_LOAD_GIF=1
235-
export SDL_IMAGE_TEST_REQUIRE_LOAD_ICO=1
236-
export SDL_IMAGE_TEST_REQUIRE_LOAD_JPG=1
237-
export SDL_IMAGE_TEST_REQUIRE_LOAD_JXL=0
238-
export SDL_IMAGE_TEST_REQUIRE_LOAD_LBM=1
239-
export SDL_IMAGE_TEST_REQUIRE_LOAD_PCX=1
240-
export SDL_IMAGE_TEST_REQUIRE_LOAD_PNG=1
241-
export SDL_IMAGE_TEST_REQUIRE_LOAD_PNM=1
242-
export SDL_IMAGE_TEST_REQUIRE_LOAD_QOI=1
243-
export SDL_IMAGE_TEST_REQUIRE_LOAD_SVG=1
244-
export SDL_IMAGE_TEST_REQUIRE_LOAD_TGA=1
245-
export SDL_IMAGE_TEST_REQUIRE_LOAD_TIF=1
246-
export SDL_IMAGE_TEST_REQUIRE_LOAD_WEBP=1
247-
export SDL_IMAGE_TEST_REQUIRE_LOAD_XPM=1
248-
export SDL_IMAGE_TEST_REQUIRE_LOAD_XV=1
249-
250-
export SDL_IMAGE_TEST_REQUIRE_SAVE_JPG=1
251-
export SDL_IMAGE_TEST_REQUIRE_SAVE_PNG=1
252-
253-
make -j"${parallel}" -C build check V=1 VERBOSE=1
254-
- name: Install (Autotools)
255-
if: ${{ !matrix.platform.cmake }}
256-
run: |
257-
set -eu
258-
curdir="$(pwd)"
259-
parallel="$(getconf _NPROCESSORS_ONLN)"
260-
make -j"${parallel}" -C build install V=1
261-
echo "SDL2_image_DIR=$(pwd)/prefix_autotools" >> $GITHUB_ENV
262-
( cd prefix_autotools; find . ) | LC_ALL=C sort -u
263-
- name: Distcheck (Autotools)
264-
if: ${{ runner.os == 'Linux' && !matrix.platform.cmake }}
265-
run: |
266-
set -eu
267-
parallel="$(getconf _NPROCESSORS_ONLN)"
268-
make -j"${parallel}" -C build distcheck V=1
269-
- name: Upload artifacts (Autotools)
270-
if: ${{ failure() && !matrix.platform.cmake }}
271-
uses: actions/upload-artifact@v3
272-
with:
273-
name: ${{ matrix.platform.name }} artifacts
274-
path: |
275-
build/test/*.bmp
276-
build/test/*.jpg
277-
build/test/*.log
278-
build/test/*.png
279-
if-no-files-found: ignore
280-
- name: Verify CMake configuration files
281-
run: |
282-
cmake -S cmake/test -B cmake_config_build \
283-
-DCMAKE_BUILD_TYPE=Debug \
284-
-DCMAKE_PREFIX_PATH="${{ env.SDL2_image_DIR }}" \
285-
-DTEST_SHARED=${{ matrix.platform.shared }} \
286-
-DTEST_STATIC=${{ matrix.platform.static }}
287-
cmake --build cmake_config_build --verbose
26+
- uses: actions/[email protected]
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)