Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/scripts/install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ case "${1%-*}" in
pkg install -y bash bison cmake git png
;;
windows)
choco install -y winflexbison3
# GitHub Actions' hosted runners ship CMake 3.x, but versions prior to 4.0.0 ignore `CPACK_PACKAGE_FILE_NAME`.
choco install -y winflexbison3 cmake
# The below expects the base name, not the Windows-specific name.
bison() { win_bison "$@"; } # An alias doesn't work, so we use a function instead.
;;
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/create-release-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ jobs:
strategy:
matrix:
bits: [32, 64]
include:
- bits: 32
arch: x86
- bits: 64
arch: x86_x64
fail-fast: false
steps:
- name: Checkout repo
Expand All @@ -42,14 +37,14 @@ jobs:
cmake -S . -B build --preset msvc${{ matrix.bits }} -DFETCHCONTENT_BASE_DIR="${{ env.DEPS_ROOT_DIR }}"
cmake --build build --config Release
- name: Package binaries
working-directory: build
run: |
Comment thread
ISSOtm marked this conversation as resolved.
cmake --install build --config Release --prefix install_dir --verbose
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"
cpack -DCPACK_PACKAGE_FILE_NAME=rgbds-win${{ matrix.bits }} -G ZIP -C Release --verbose
- name: Upload Windows binaries
uses: actions/upload-artifact@v7
with:
name: win${{ matrix.bits }}
path: rgbds-win${{ matrix.bits }}.zip
path: build/rgbds-win${{ matrix.bits }}.zip
if-no-files-found: error

macos:
Expand Down
15 changes: 3 additions & 12 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@ jobs:
matrix:
bits: [32, 64]
os: [windows-2022, windows-2025]
include:
- bits: 32
arch: x86
- bits: 64
arch: x86_x64
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -175,21 +170,19 @@ jobs:
key: dep-srcs-${{ hashFiles('cmake/deps.cmake') }}
enableCrossOsArchive: true # Currently only used on Windows, but the contents are OS-agnostic.
- name: Build Windows binaries
shell: bash
run: | # ASan seems to be broken on Windows, so we disable it.
cmake -S . -B build --preset develop-msvc${{ matrix.bits }} -DFETCHCONTENT_BASE_DIR="${{ env.DEPS_ROOT_DIR }}" -DSANITIZERS=OFF
cmake --build build
- name: Package binaries
working-directory: build
shell: bash
run: |
cmake --install build --config Debug --prefix install_dir --verbose
mkdir bins
cp -v install_dir/bin/{rgb*.exe,*.dll} bins
cpack -DCPACK_PACKAGE_FILE_NAME=rgbds-win${{ matrix.bits }} -G ZIP -C Debug --verbose
- name: Upload Windows binaries
uses: actions/upload-artifact@v7
with:
name: rgbds-canary-w${{ matrix.bits }}-${{ matrix.os }}
path: bins
path: build/rgbds-win${{ matrix.bits }}.zip
if-no-files-found: error
- name: Compute test dependency cache params
id: test-deps-cache-params
Expand Down Expand Up @@ -218,8 +211,6 @@ jobs:
- name: Run tests
shell: bash
run: |
cp bins/* .
cp bins/*.dll test/gfx
test/run-tests.sh --os ${{ matrix.os }}

windows-mingw-build:
Expand Down
22 changes: 21 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,25 @@ set(man7 "man/gbz80.7"
"man/rgbds.7")

foreach(SECTION "man1" "man5" "man7")
install(FILES ${${SECTION}} DESTINATION "${CMAKE_INSTALL_MANDIR}/${SECTION}")
install(FILES ${${SECTION}} DESTINATION "${CMAKE_INSTALL_MANDIR}/${SECTION}" COMPONENT man)
endforeach()

## Packaging.

# We only specify here the package-agnostic options;
# the rest is rather convention from our side, and thus more appropriate for presets or CLI flags.
## CPACK_PACKAGE_NAME: copied from `project()`
set(CPACK_PACKAGE_VENDOR "GBDev")
set(CPACK_PACKAGE_VERSION "${CMAKE_PROJECT_VERSION}") # The individual components are defined implicitly.
set(CPACK_PACKAGE_DESCRIPTION "An assembly toolchain for the Nintendo Game Boy and Game Boy Color") # Same as our repo's description.
## CPACK_PACKAGE_DESCRIPTION_SUMMARY: copied from `project()`
set(CPACK_PACKAGE_HOMEPAGE_URL "https://rgbds.gbdev.io")
## CPACK_PACKAGE_FILE_NAME: should be provided at runtime (`cpack -P`)
set(CPACK_PACKAGE_CHECKSUM SHA256)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_STRIP_FILES ON) # Only applies to binary packages, not sources.
set(CPACK_VERBATIM_VARIABLES ON)
set(CPACK_THREADS 0) # Use all available CPU cores.
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
include(CPack)
2 changes: 2 additions & 0 deletions cmake/deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
FetchContent_Declare(PNG
URL https://download.sourceforge.net/libpng/libpng-1.6.56.tar.xz
URL_HASH SHA256=f7d8bf1601b7804f583a254ab343a6549ca6cf27d255c302c47af2d9d36a6f18
EXCLUDE_FROM_ALL # We only install the runtime dependencies, and do so separately.
FIND_PACKAGE_ARGS 1.5.4)

set(PNG_TESTS OFF CACHE INTERNAL "") # We do not care for these two (and they can even cause compile errors!)
Expand All @@ -15,6 +16,7 @@ set(PNG_STATIC OFF CACHE INTERNAL "")
FetchContent_Declare(ZLIB
URL https://www.zlib.net/zlib-1.3.2.tar.xz
URL_HASH SHA256=d7a0654783a4da529d1bb793b7ad9c3318020af77667bcae35f95d0e42a792f3
EXCLUDE_FROM_ALL # We only install the runtime dependencies, and do so separately.
# libpng documents requiring "zlib 1.0.4 or later (1.2.13 or later recommended for performance and security reasons)".
# We thus enforce 1.0.4, but note that the libpng source code mentions that "it may work with versions as old as zlib 0.95".
FIND_PACKAGE_ARGS 1.0.4)
Expand Down
38 changes: 37 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,45 @@ add_executable(rgbgfx $<TARGET_OBJECTS:common>
"verbosity.cpp"
)

install(TARGETS rgbasm rgblink rgbfix rgbgfx RUNTIME)
install(TARGETS rgbasm rgblink rgbfix rgbgfx RUNTIME COMPONENT binaries)
# Tests expect the binaries to end up in-source; this is more acceptable than the entire artifact dir.
set_target_properties(rgbasm rgblink rgbfix rgbgfx PROPERTIES
# The generator expression (even if a no-op) stops muti-config generators using a of "per-configuration subdirectory".
RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_SOURCE_DIR}>)
target_link_libraries(rgbgfx PRIVATE PNG::PNG)
# Copy the DLLs in the output directory so the program can be run for testing without having to `install`.
# From https://cmake.org/cmake/help/v4.3/manual/cmake-generator-expressions.7.html#genex:TARGET_RUNTIME_DLLS.
add_custom_command(TARGET rgbgfx POST_BUILD COMMENT "Copying rgbgfx's DLLs"
# It would be nice to symlink instead, but that only supports one file at a time.
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:rgbgfx> $<TARGET_RUNTIME_DLLS:rgbgfx>
COMMAND_EXPAND_LISTS VERBATIM)

# On Windows, you don't link against DLLs directly, but against an import library for that DLL.
# This leads to, sometimes, the DLL being stored in a directory far away from the import library itself!
set(DLL_SEARCH_DIRS CACHE PATH "List of directories in which DLLs will be searched")
cmake_path(CONVERT "${DLL_SEARCH_DIRS}" TO_CMAKE_PATH_LIST search_dirs NORMALIZE)
# TODO: we've only tested this with MinGW, but it may not work with other uses of the variable.
# Anyone who knows how to handle this better, feel free to submit a patch!
Comment thread
ISSOtm marked this conversation as resolved.
if(DEFINED CMAKE_FIND_ROOT_PATH)
list(APPEND search_dirs "${CMAKE_FIND_ROOT_PATH}/bin")
endif()
# Escape the search paths in a form that makes them suitable for splatting into the CMake install script.
list(TRANSFORM search_dirs REPLACE "([\\$\"])" "\\\\1") # Neutralize escapes and variable refs...
list(TRANSFORM search_dirs REPLACE "^(.+)\$" "\"\\1\"") # ...and quote each argument.
list(JOIN search_dirs " " search_dirs_splat)
# This is a modified version of the install code generated by
# `install(TARGETS rgbgfx RUNTIME_DEPENDENCIES)`.
# Unfortunately, that `install(TARGETS)` is outright not supported when cross-compiling,
# and working around that has CMake fail to resolve the DLL locations with MinGW,
# due to not specifying any `DIRECTORIES` and the system search path being ineffective.
install(CODE "\
file(GET_RUNTIME_DEPENDENCIES
RESOLVED_DEPENDENCIES_VAR rgbgfx_deps
EXECUTABLES \"$<TARGET_FILE:rgbgfx>\"
DIRECTORIES ${search_dirs_splat} \"$<TARGET_FILE_DIR:ZLIB::ZLIB>\" \"$<TARGET_FILE_DIR:PNG::PNG>\"
PRE_EXCLUDE_REGEXES \"^kernel32\\\\.dll$\" \"^msvcrt.?.?\\\\.dll\" \"^api-ms-win-.*\\\\.dll$\")
Comment thread
Rangi42 marked this conversation as resolved.
foreach(rgbgfx_dep IN LISTS rgbgfx_deps)
file(INSTALL DESTINATION \"$<INSTALL_PREFIX>/${CMAKE_INSTALL_BINDIR}\" TYPE SHARED_LIBRARY FILES \${rgbgfx_dep}
FOLLOW_SYMLINK_CHAIN)
endforeach()"
COMPONENT shared-libs EXCLUDE_FROM_ALL) # Most platforms install those separately.
14 changes: 10 additions & 4 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ add_executable(rgbgfx_test gfx/rgbgfx_test.cpp)
set_target_properties(randtilegen rgbgfx_test PROPERTIES
# hack for MSVC: no-op generator expression to stop generation of "per-configuration subdirectory"
RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_SOURCE_DIR}/gfx>)
target_link_libraries(randtilegen PRIVATE PNG::PNG)
target_link_libraries(rgbgfx_test PRIVATE PNG::PNG)
foreach(prog "randtilegen" "rgbgfx_test")
target_link_libraries(${prog} PRIVATE PNG::PNG)
# Copy the DLLs in the output directory so the program can be run for testing without having to `install`.
# From https://cmake.org/cmake/help/v4.3/manual/cmake-generator-expressions.7.html#genex:TARGET_RUNTIME_DLLS.
add_custom_command(TARGET ${prog} POST_BUILD COMMENT "Copying ${prog}'s DLLs"
# It would be nice to symlink instead, but that only supports one file at a time.
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:${prog}> $<TARGET_RUNTIME_DLLS:${prog}>
COMMAND_EXPAND_LISTS VERBATIM)
endforeach()

set(ONLY_FREE)
if(NOT TESTS_RUN_NONFREE)
Expand All @@ -31,5 +38,4 @@ configure_file(CTestCustom.cmake.in ${CMAKE_BINARY_DIR}/CTestCustom.cmake @ONLY)

add_test(NAME all
COMMAND ./run-tests.sh ${ONLY_FREE} ${ONLY_INTERNAL} ${OS_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
Loading