mirror of
https://github.com/gbdev/rgbds.git
synced 2026-03-25 06:13:03 +00:00
Seek lib deps via CMake FetchContent
`FetchContent` respects existing installs, and downloads and compiles the libs if they aren't found. This is admittedly a little finicky, since this ignores the usual `Find*` modules provided by CMake, requiring a bit of glue on our side. But, one upside is that this moves that logic from our CI into the build system, which can thus benefit other downstream users. This also opens the door to some improvements in upcoming commits. Doing this with Bison turned out to be much more painful, however, due to `FindBISON` providing the specific `bison_target` command; thus, it remains installed externally, so that it can be picked up by `FindBISON`. This also bumps our CMake version requirement slightly, though it's possible that older versions keep working, or could be supported with small patches; however, our CI doesn't provide anything below 3.31, so we can't check.
This commit is contained in:
7
.github/scripts/get_win_deps.ps1
vendored
7
.github/scripts/get_win_deps.ps1
vendored
@@ -15,9 +15,4 @@ function getlibrary ([string] $URI, [string] $filename, [string] $hash, [string]
|
||||
Expand-Archive -DestinationPath $destdir $filename
|
||||
}
|
||||
|
||||
getlibrary 'https://www.zlib.net/zlib132.zip' 'zlib.zip' 'e8bf55f3017aa181690990cb58a994e77885da140609fc8f94abe9b65d2cae28' .
|
||||
getlibrary 'https://github.com/pnggroup/libpng/archive/refs/tags/v1.6.53.zip' 'libpng.zip' '9fb99118ec4523d9a9dab652ce7c2472ec76f6ccd69d1aba3ab873bb8cf84b98' .
|
||||
getlibrary 'https://github.com/lexxmark/winflexbison/releases/download/v2.5.25/win_flex_bison-2.5.25.zip' 'winflexbison.zip' '8d324b62be33604b2c45ad1dd34ab93d722534448f55a16ca7292de32b6ac135' install_dir
|
||||
|
||||
Move-Item zlib-1.3.2 zlib
|
||||
Move-Item libpng-1.6.53 libpng
|
||||
getlibrary 'https://github.com/lexxmark/winflexbison/releases/download/v2.5.25/win_flex_bison-2.5.25.zip' 'winflexbison.zip' '8d324b62be33604b2c45ad1dd34ab93d722534448f55a16ca7292de32b6ac135' bison
|
||||
|
||||
23
.github/workflows/create-release-artifacts.yml
vendored
23
.github/workflows/create-release-artifacts.yml
vendored
@@ -28,27 +28,14 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
- name: Install deps
|
||||
run: .github/scripts/get_win_deps.ps1
|
||||
- name: Build zlib
|
||||
run: | # BUILD_SHARED_LIBS causes the output DLL to be called `z.dll` as of zlib 1.3.2 (formerly `zlib1.dll`)
|
||||
cmake -S zlib -B zbuild -A ${{ matrix.platform }} -Wno-dev -DCMAKE_INSTALL_PREFIX=install_dir -DBUILD_SHARED_LIBS=ON
|
||||
cmake --build zbuild --config Release -j
|
||||
- name: Install zlib
|
||||
run: |
|
||||
cmake --install zbuild --config Release
|
||||
- name: Build libpng
|
||||
shell: bash
|
||||
run: |
|
||||
cmake -S libpng -B pngbuild -A ${{ matrix.platform }} -Wno-dev -DCMAKE_INSTALL_PREFIX=install_dir -DPNG_SHARED=ON -DPNG_STATIC=OFF -DPNG_TESTS=OFF
|
||||
cmake --build pngbuild --config Release -j
|
||||
- name: Install libpng
|
||||
run: |
|
||||
cmake --install pngbuild --config Release
|
||||
- name: Build Windows binaries
|
||||
shell: bash
|
||||
# We instruct CMake to download and build third-party projects outside of our source tree,
|
||||
# otherwise they can trigger `-Werror=dev` (from the `develop` preset).
|
||||
run: |
|
||||
cmake -S . -B build -A ${{ matrix.platform }} -DCMAKE_INSTALL_PREFIX=install_dir -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build build --config Release -j --verbose
|
||||
cmake --install build --config Release --strip
|
||||
cmake -S . -B build -A ${{ matrix.platform }} -DCMAKE_BUILD_TYPE=Release -DFETCHCONTENT_BASE_DIR="$TEMP/cmake-deps" -DBISON_EXECUTABLE=bison/win_bison.exe
|
||||
cmake --build build --config Release -j
|
||||
cmake --install build --config Release --prefix install_dir --verbose
|
||||
- name: Package binaries
|
||||
run: |
|
||||
Compress-Archive -LiteralPath @("install_dir/bin/rgbasm.exe", "install_dir/bin/rgblink.exe", "install_dir/bin/rgbfix.exe", "install_dir/bin/rgbgfx.exe", "install_dir/bin/z.dll", "install_dir/bin/libpng16.dll") "rgbds-win${{ matrix.bits }}.zip"
|
||||
|
||||
43
.github/workflows/testing.yml
vendored
43
.github/workflows/testing.yml
vendored
@@ -30,8 +30,13 @@ jobs:
|
||||
sudo make install -j Q=
|
||||
- name: Build & install using CMake
|
||||
if: matrix.buildsys == 'cmake'
|
||||
# Since GitHub's runners are basically kitchen sinks,
|
||||
# the Mono framework exposes a libpng 1.4.x header, breaking everything.
|
||||
# Searching frameworks last makes Homebrew's libpng be discovered first, which works.
|
||||
# Note that since this is specific to our CI environment, the workaround is
|
||||
# better applied here than in our CMakeLists, where it could affect and break someone else.
|
||||
run: |
|
||||
cmake -S . -B build --preset develop -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DTESTS_OS_NAME=${{ matrix.os }}
|
||||
cmake -S . -B build --preset develop -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DTESTS_OS_NAME=${{ matrix.os }}
|
||||
cmake --build build -j --verbose
|
||||
sudo cmake --install build --verbose
|
||||
- name: Package binaries
|
||||
@@ -147,38 +152,14 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
- name: Install deps
|
||||
run: .github/scripts/get_win_deps.ps1
|
||||
- name: Check libraries cache
|
||||
id: cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
zbuild
|
||||
pngbuild
|
||||
key: ${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles('zlib/**', 'libpng/**') }}
|
||||
- name: Build zlib
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: | # BUILD_SHARED_LIBS causes the output DLL to be called `z.dll` as of zlib 1.3.2 (formerly `zlib1.dll`)
|
||||
cmake -S zlib -B zbuild -A ${{ matrix.platform }} -Wno-dev -DCMAKE_INSTALL_PREFIX=install_dir -DBUILD_SHARED_LIBS=ON
|
||||
cmake --build zbuild --config Debug -j
|
||||
- name: Install zlib
|
||||
run: |
|
||||
cmake --install zbuild --config Debug
|
||||
- name: Build libpng
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
cmake -S libpng -B pngbuild -A ${{ matrix.platform }} -Wno-dev -DCMAKE_INSTALL_PREFIX=install_dir -DCMAKE_BUILD_TYPE=Debug -DPNG_SHARED=ON -DPNG_STATIC=OFF -DPNG_TESTS=OFF
|
||||
cmake --build pngbuild --config Debug -j
|
||||
- name: Install libpng
|
||||
run: |
|
||||
cmake --install pngbuild --config Debug
|
||||
- name: Build Windows binaries
|
||||
shell: bash
|
||||
run: | # ASan seems to be broken on Windows.
|
||||
cmake -S . -B build -A ${{ matrix.platform }} --preset develop -DCMAKE_INSTALL_PREFIX=install_dir -DSANITIZERS=OFF
|
||||
cmake --build build --config Debug -j --verbose
|
||||
cmake --install build --verbose
|
||||
# We instruct CMake to download and build third-party projects outside of our source tree,
|
||||
# otherwise they can trigger `-Werror=dev` (from the `develop` preset).
|
||||
run: | # ASan seems to be broken on Windows, so we disable it.
|
||||
cmake -S . -B build -A ${{ matrix.platform }} --preset develop -DFETCHCONTENT_BASE_DIR="$TEMP/cmake-deps" -DBISON_EXECUTABLE=bison/win_bison.exe -DSANITIZERS=OFF
|
||||
cmake --build build --config Debug -j
|
||||
cmake --install build --config Debug --prefix install_dir --verbose
|
||||
- name: Package binaries
|
||||
shell: bash
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user