mirror of
https://github.com/gbdev/rgbds.git
synced 2026-08-29 18:15:16 +00:00
Parallelize build jobs according to CPU count
This commit is contained in:
@@ -20,7 +20,7 @@ jobs:
|
|||||||
.github/scripts/install_deps.sh ubuntu-latest lcov
|
.github/scripts/install_deps.sh ubuntu-latest lcov
|
||||||
- name: Generate coverage report
|
- name: Generate coverage report
|
||||||
run: |
|
run: |
|
||||||
contrib/coverage.bash ubuntu-ci
|
contrib/coverage.bash --os ubuntu-latest --jobs "$(getconf _NPROCESSORS_ONLN)"
|
||||||
- name: Upload coverage report
|
- name: Upload coverage report
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -11,9 +11,6 @@ env:
|
|||||||
CLICOLOR_FORCE: 1
|
CLICOLOR_FORCE: 1
|
||||||
|
|
||||||
CMAKE_COLOR_DIAGNOSTICS: ON # Tells CMake-generated build systems to have colored output.
|
CMAKE_COLOR_DIAGNOSTICS: ON # Tells CMake-generated build systems to have colored output.
|
||||||
# Approximate number of CPU cores in GitHub's runners as of 2026-03-18:
|
|
||||||
# https://docs.github.com/en/actions/reference/runners/github-hosted-runners#standard-github-hosted-runners-for-public-repositories
|
|
||||||
CMAKE_BUILD_PARALLEL_LEVEL: 4 # `cmake --build` now implies `--parallel 4`.
|
|
||||||
CMAKE_BUILD_TYPE: Release # `cmake -S` now implies `-DCMAKE_BUILD_TYPE=Release`.
|
CMAKE_BUILD_TYPE: Release # `cmake -S` now implies `-DCMAKE_BUILD_TYPE=Release`.
|
||||||
CMAKE_CONFIG_TYPE: Release # `cmake --build` now implies `--config Release`.
|
CMAKE_CONFIG_TYPE: Release # `cmake --build` now implies `--config Release`.
|
||||||
|
|
||||||
@@ -92,7 +89,7 @@ jobs:
|
|||||||
./.github/scripts/install_deps.sh ubuntu-22.04
|
./.github/scripts/install_deps.sh ubuntu-22.04
|
||||||
- name: Build binaries
|
- name: Build binaries
|
||||||
run: |
|
run: |
|
||||||
make -kj WARNFLAGS="-Wall -Wextra -pedantic -static" PKG_CONFIG="pkg-config --static" Q=
|
make -k -j "$(getconf _NPROCESSORS_ONLN)" WARNFLAGS="-Wall -Wextra -pedantic -static" PKG_CONFIG="pkg-config --static" Q=
|
||||||
strip rgb{asm,link,fix,gfx}
|
strip rgb{asm,link,fix,gfx}
|
||||||
- name: Create install script
|
- name: Create install script
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -11,9 +11,8 @@ env:
|
|||||||
|
|
||||||
CMAKE_COLOR_DIAGNOSTICS: ON # Tells CMake-generated build systems to have colored output.
|
CMAKE_COLOR_DIAGNOSTICS: ON # Tells CMake-generated build systems to have colored output.
|
||||||
CMAKE_CONFIG_TYPE: Debug # `cmake --build` now implies `--config Debug`.
|
CMAKE_CONFIG_TYPE: Debug # `cmake --build` now implies `--config Debug`.
|
||||||
# Approximate number of CPU cores in GitHub's runners as of 2026-03-18:
|
|
||||||
# https://docs.github.com/en/actions/reference/runners/github-hosted-runners#standard-github-hosted-runners-for-public-repositories
|
CTEST_PARALLEL_LEVEL: "" # `ctest` now implies `--parallel` (default number of logical CPUs).
|
||||||
CTEST_PARALLEL_LEVEL: 0 # `ctest` now implies `--parallel 0` (number of logical CPUs).
|
|
||||||
CTEST_NO_TESTS_ACTION: error # Make CTest fail if it cannot find any tests. (That should never happen.)
|
CTEST_NO_TESTS_ACTION: error # Make CTest fail if it cannot find any tests. (That should never happen.)
|
||||||
CTEST_OUTPUT_ON_FAILURE: ON # CTest reports test program output on failure.
|
CTEST_OUTPUT_ON_FAILURE: ON # CTest reports test program output on failure.
|
||||||
|
|
||||||
@@ -57,11 +56,11 @@ jobs:
|
|||||||
- name: Build using Make
|
- name: Build using Make
|
||||||
if: matrix.buildsys == 'make'
|
if: matrix.buildsys == 'make'
|
||||||
run: |
|
run: |
|
||||||
make develop -kj Q= CXX=${{ matrix.cxx }}
|
make develop -k -j "$(getconf _NPROCESSORS_ONLN)" Q= CXX=${{ matrix.cxx }}
|
||||||
- name: Install using Make
|
- name: Install using Make
|
||||||
if: matrix.buildsys == 'make'
|
if: matrix.buildsys == 'make'
|
||||||
run: |
|
run: |
|
||||||
sudo make install -j Q=
|
sudo make install Q=
|
||||||
type rgbasm rgblink rgbfix rgbgfx
|
type rgbasm rgblink rgbfix rgbgfx
|
||||||
man -w 1 rgbasm rgblink rgbfix rgbgfx
|
man -w 1 rgbasm rgblink rgbfix rgbgfx
|
||||||
- name: Build using CMake
|
- name: Build using CMake
|
||||||
@@ -111,7 +110,7 @@ jobs:
|
|||||||
- name: Run tests using our script
|
- name: Run tests using our script
|
||||||
if: matrix.buildsys == 'make'
|
if: matrix.buildsys == 'make'
|
||||||
run: |
|
run: |
|
||||||
CXX=${{ matrix.cxx }} test/run-tests.sh --os ${{ matrix.os }}
|
CXX=${{ matrix.cxx }} test/run-tests.sh --os ${{ matrix.os }} --jobs "$(getconf _NPROCESSORS_ONLN)"
|
||||||
- name: Run tests using CTest
|
- name: Run tests using CTest
|
||||||
if: matrix.buildsys == 'cmake'
|
if: matrix.buildsys == 'cmake'
|
||||||
run: |
|
run: |
|
||||||
@@ -328,7 +327,7 @@ jobs:
|
|||||||
test/external/fetch-repos.sh
|
test/external/fetch-repos.sh
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
test/run-tests.sh --os ${{ matrix.os }}
|
test/run-tests.sh --os ${{ matrix.os }} --jobs "$(getconf _NPROCESSORS_ONLN)"
|
||||||
|
|
||||||
cygwin:
|
cygwin:
|
||||||
strategy:
|
strategy:
|
||||||
@@ -365,15 +364,15 @@ jobs:
|
|||||||
pkg-config
|
pkg-config
|
||||||
- name: Build
|
- name: Build
|
||||||
run: | # Cygwin does not support `make develop` sanitizers ASan or UBSan
|
run: | # Cygwin does not support `make develop` sanitizers ASan or UBSan
|
||||||
make -kj Q=
|
make -k -j "$(getconf _NPROCESSORS_ONLN)" Q=
|
||||||
- name: Install
|
- name: Install
|
||||||
run: |
|
run: |
|
||||||
make install -j Q=
|
make install Q=
|
||||||
type rgbasm rgblink rgbfix rgbgfx
|
type rgbasm rgblink rgbfix rgbgfx
|
||||||
man -w 1 rgbasm rgblink rgbfix rgbgfx
|
man -w 1 rgbasm rgblink rgbfix rgbgfx
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
test/run-tests.sh --only-internal
|
test/run-tests.sh --only-internal --jobs "$(getconf _NPROCESSORS_ONLN)"
|
||||||
- name: Use Windows git location in the PATH
|
- name: Use Windows git location in the PATH
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: | # Prevents the `actions/checkout` post-job cleanup from using Cygwin's git binary
|
run: | # Prevents the `actions/checkout` post-job cleanup from using Cygwin's git binary
|
||||||
@@ -400,7 +399,7 @@ jobs:
|
|||||||
.github/scripts/install_deps.sh freebsd
|
.github/scripts/install_deps.sh freebsd
|
||||||
run: | # Leak detection is not supported on FreeBSD, so disable it.
|
run: | # Leak detection is not supported on FreeBSD, so disable it.
|
||||||
cmake -B build --preset develop
|
cmake -B build --preset develop
|
||||||
cmake --build build --verbose -- -k -j 4
|
cmake --build build --verbose -- -k -j "$(getconf _NPROCESSORS_ONLN)"
|
||||||
ASAN_OPTIONS=detect_leaks=0 ctest --test-dir build --schedule-random --label-exclude external
|
ASAN_OPTIONS=detect_leaks=0 ctest --test-dir build --schedule-random --label-exclude external
|
||||||
cmake --install build --verbose
|
cmake --install build --verbose
|
||||||
type rgbasm rgblink rgbfix rgbgfx
|
type rgbasm rgblink rgbfix rgbgfx
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ RUN apt-get update && \
|
|||||||
|
|
||||||
# Install dependencies and compile RGBDS
|
# Install dependencies and compile RGBDS
|
||||||
RUN ./.github/scripts/install_deps.sh debian
|
RUN ./.github/scripts/install_deps.sh debian
|
||||||
RUN make -j CXXFLAGS="-O3 -flto -DNDEBUG -static" PKG_CONFIG="pkg-config --static" Q=
|
RUN make -j "$(getconf _NPROCESSORS_ONLN)" CXXFLAGS="-O3 -flto -DNDEBUG -static" PKG_CONFIG="pkg-config --static" Q=
|
||||||
|
|
||||||
# Create the install script
|
# Create the install script
|
||||||
RUN make install.sh Q=
|
RUN make install.sh Q=
|
||||||
|
|||||||
+54
-14
@@ -1,17 +1,55 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<"EOF"
|
||||||
|
Generates LCOV code coverage report for RGBDS.
|
||||||
|
Options:
|
||||||
|
-h, --help show this help message
|
||||||
|
-o, --open open the HTML report in the preferred application
|
||||||
|
--jobs <n> build RGBDS and external codebases with `make -j<n>`
|
||||||
|
--os <os> skip tests known to fail on <os> (e.g. `macos-14`)
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
# Parse options in pure Bash because macOS `getopt` is stuck
|
||||||
|
# in what util-linux `getopt` calls `GETOPT_COMPATIBLE` mode
|
||||||
|
make_args=()
|
||||||
|
runtests_args=()
|
||||||
|
open_report=false
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
-h|--help)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-o|--open)
|
||||||
|
open_report=true
|
||||||
|
;;
|
||||||
|
--jobs)
|
||||||
|
shift
|
||||||
|
make_args+=("-j" "$1")
|
||||||
|
runtests_args+=("--jobs" "$1")
|
||||||
|
;;
|
||||||
|
--os)
|
||||||
|
shift
|
||||||
|
runtests_args+=("--os" "$1")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "$(basename "$0"): unknown option '$1'"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
# Build RGBDS with gcov support
|
# Build RGBDS with gcov support
|
||||||
make coverage -j
|
make coverage "${make_args[@]}"
|
||||||
|
|
||||||
# Run the tests
|
# Run the tests
|
||||||
pushd test
|
pushd test
|
||||||
external/fetch-repos.sh
|
external/fetch-repos.sh
|
||||||
if [[ $# -eq 0 ]]; then
|
./run-tests.sh "${runtests_args[@]}"
|
||||||
./run-tests.sh
|
|
||||||
else
|
|
||||||
./run-tests.sh --os "$1"
|
|
||||||
fi
|
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Generate coverage logs
|
# Generate coverage logs
|
||||||
@@ -24,12 +62,14 @@ lcov -c --no-external -d . -o "$COVERAGE_INFO"
|
|||||||
lcov -r "$COVERAGE_INFO" src/asm/parser.{hpp,cpp} src/link/script.{hpp,cpp} -o "$COVERAGE_INFO"
|
lcov -r "$COVERAGE_INFO" src/asm/parser.{hpp,cpp} src/link/script.{hpp,cpp} -o "$COVERAGE_INFO"
|
||||||
genhtml --dark-mode --num-spaces 4 -f -s -o coverage/ "$COVERAGE_INFO"
|
genhtml --dark-mode --num-spaces 4 -f -s -o coverage/ "$COVERAGE_INFO"
|
||||||
|
|
||||||
# Check whether running from coverage.yml workflow
|
if "$open_report"; then
|
||||||
if [ "$1" != "ubuntu-ci" ]; then
|
# Open the report in the preferred web browser
|
||||||
# Open report in web browser
|
if [ "$(uname)" == "Darwin" ]; then
|
||||||
if [ "$(uname)" == "Darwin" ]; then
|
open coverage/index.html
|
||||||
open coverage/index.html
|
else
|
||||||
else
|
xdg-open coverage/index.html
|
||||||
xdg-open coverage/index.html
|
fi
|
||||||
fi
|
else
|
||||||
|
# Output the path to the report
|
||||||
|
echo "Generated LCOV report at $PWD/coverage/index.html"
|
||||||
fi
|
fi
|
||||||
|
|||||||
+12
-3
@@ -9,6 +9,15 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
set(TESTS_OS_NAME "${TESTS_OS_NAME}" CACHE STRING "Skip running tests known to fail on this OS.")
|
set(TESTS_OS_NAME "${TESTS_OS_NAME}" CACHE STRING "Skip running tests known to fail on this OS.")
|
||||||
|
|
||||||
|
include(ProcessorCount)
|
||||||
|
ProcessorCount(PROCESSOR_COUNT)
|
||||||
|
if(PROCESSOR_COUNT EQUAL 0)
|
||||||
|
set(PROCESSOR_COUNT 4)
|
||||||
|
message(STATUS "Could not determine CPU count; defaulting to ${PROCESSOR_COUNT}.")
|
||||||
|
else()
|
||||||
|
message(STATUS "Counted ${PROCESSOR_COUNT} logical CPU cores.")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(randtilegen gfx/randtilegen.cpp)
|
add_executable(randtilegen gfx/randtilegen.cpp)
|
||||||
add_executable(rgbgfx_test gfx/rgbgfx_test.cpp)
|
add_executable(rgbgfx_test gfx/rgbgfx_test.cpp)
|
||||||
set_target_properties(randtilegen rgbgfx_test PROPERTIES
|
set_target_properties(randtilegen rgbgfx_test PROPERTIES
|
||||||
@@ -29,7 +38,7 @@ foreach(component "asm" "link" "fix" "gfx")
|
|||||||
COMMAND bash -- test.sh
|
COMMAND bash -- test.sh
|
||||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${component}")
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${component}")
|
||||||
set_tests_properties("rgb${component}" PROPERTIES REQUIRED_FILES "$<TARGET_FILE:rgb${component}>"
|
set_tests_properties("rgb${component}" PROPERTIES REQUIRED_FILES "$<TARGET_FILE:rgb${component}>"
|
||||||
PROCESSORS 1
|
PROCESSORS 1 # These cannot be parallelized.
|
||||||
LABELS "internal;free")
|
LABELS "internal;free")
|
||||||
endforeach()
|
endforeach()
|
||||||
set_tests_properties(rgbgfx PROPERTIES REQUIRED_FILES "$<TARGET_FILE:rgbgfx>;$<TARGET_FILE:randtilegen>;$<TARGET_FILE:rgbgfx_test>")
|
set_tests_properties(rgbgfx PROPERTIES REQUIRED_FILES "$<TARGET_FILE:rgbgfx>;$<TARGET_FILE:randtilegen>;$<TARGET_FILE:rgbgfx_test>")
|
||||||
@@ -69,10 +78,10 @@ foreach(cfg_file IN LISTS ext_projects)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_test(NAME "${project}"
|
add_test(NAME "${project}"
|
||||||
COMMAND bash -- external/test.sh ${project}
|
COMMAND bash -- external/test.sh ${project} -j "${PROCESSOR_COUNT}"
|
||||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
set_tests_properties(${project} PROPERTIES DEPENDS "rgbasm;rgblink;rgbfix;rgbgfx" # Only attempt external tests after all individual tool tests.
|
set_tests_properties(${project} PROPERTIES DEPENDS "rgbasm;rgblink;rgbfix;rgbgfx" # Only attempt external tests after all individual tool tests.
|
||||||
PROCESSORS 4
|
PROCESSORS "${PROCESSOR_COUNT}"
|
||||||
LABELS "external;${freedom}"
|
LABELS "external;${freedom}"
|
||||||
FIXTURES_REQUIRED "${freedom}-repos")
|
FIXTURES_REQUIRED "${freedom}-repos")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|||||||
Vendored
+5
-4
@@ -7,10 +7,11 @@ usage() {
|
|||||||
cat <<"EOF"
|
cat <<"EOF"
|
||||||
Downloads source code of Game Boy project repos used as RGBDS test cases.
|
Downloads source code of Game Boy project repos used as RGBDS test cases.
|
||||||
Options:
|
Options:
|
||||||
-h, --help show this help message
|
-h, --help show this help message
|
||||||
--only-free download only freely licensed codebases
|
--only-free download only freely licensed codebases
|
||||||
--get-hash print repos' commit hashes instead of downloading them
|
--only-nonfree download only non-freely licensed codebases
|
||||||
--get-paths print repos' clone paths instead of downloading them
|
--get-hash print repos' commit hashes instead of downloading them
|
||||||
|
--get-paths print repos' clone paths instead of downloading them
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+8
-5
@@ -8,13 +8,16 @@ export SOURCE_DATE_EPOCH=609165296
|
|||||||
|
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
if [ ! -f "$1.cfg" ]; then
|
NAME="$1"
|
||||||
echo >&2 'External test file '"$1"'.cfg does not exist'
|
shift # Any remaining arguments get forwarded to `make`.
|
||||||
|
|
||||||
|
if [ ! -f "$NAME.cfg" ]; then
|
||||||
|
echo >&2 'External test file '"$NAME"'.cfg does not exist'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Sourcing "$1.cfg" defines `EXT_TEST_*` variables used below.
|
# Sourcing "$NAME.cfg" defines `EXT_TEST_*` variables used below.
|
||||||
. "$1.cfg"
|
. "$NAME.cfg"
|
||||||
|
|
||||||
if ! cd "$EXT_TEST_REPO"; then
|
if ! cd "$EXT_TEST_REPO"; then
|
||||||
echo >&2 'Please fetch test deps before running any external test'
|
echo >&2 'Please fetch test deps before running any external test'
|
||||||
@@ -23,7 +26,7 @@ fi
|
|||||||
|
|
||||||
RGBDS_PATH="RGBDS=../../../"
|
RGBDS_PATH="RGBDS=../../../"
|
||||||
git clean -fdx # Clean any previous build products so `make` rebuilds everything from scratch.
|
git clean -fdx # Clean any previous build products so `make` rebuilds everything from scratch.
|
||||||
make -j4 "$EXT_TEST_TARGET" $RGBDS_PATH
|
make "$@" "$EXT_TEST_TARGET" $RGBDS_PATH
|
||||||
|
|
||||||
hash="$(sha1sum -b "$EXT_TEST_FILE" | head -c 40)"
|
hash="$(sha1sum -b "$EXT_TEST_FILE" | head -c 40)"
|
||||||
if [ "$hash" != "$EXT_TEST_HASH" ]; then
|
if [ "$hash" != "$EXT_TEST_HASH" ]; then
|
||||||
|
|||||||
+7
-1
@@ -16,6 +16,7 @@ Options:
|
|||||||
--only-internal only run tests that build local examples
|
--only-internal only run tests that build local examples
|
||||||
--only-external only run tests that build external codebases
|
--only-external only run tests that build external codebases
|
||||||
--only-free skip tests that build nonfree codebases
|
--only-free skip tests that build nonfree codebases
|
||||||
|
--jobs <n> build external codebases with `make -j<n>`
|
||||||
--os <os> skip tests known to fail on <os> (e.g. `macos-14`)
|
--os <os> skip tests known to fail on <os> (e.g. `macos-14`)
|
||||||
--installed-rgbds use the system installed RGBDS
|
--installed-rgbds use the system installed RGBDS
|
||||||
(only compatible with external codebases)
|
(only compatible with external codebases)
|
||||||
@@ -28,6 +29,7 @@ nonfree=true
|
|||||||
internal=true
|
internal=true
|
||||||
external=true
|
external=true
|
||||||
installedrgbds=false
|
installedrgbds=false
|
||||||
|
make_jobs=
|
||||||
osname=
|
osname=
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@@ -47,6 +49,10 @@ while [[ $# -gt 0 ]]; do
|
|||||||
--installed-rgbds)
|
--installed-rgbds)
|
||||||
installedrgbds=true
|
installedrgbds=true
|
||||||
;;
|
;;
|
||||||
|
--jobs)
|
||||||
|
shift
|
||||||
|
make_jobs="-j$1"
|
||||||
|
;;
|
||||||
--os)
|
--os)
|
||||||
shift
|
shift
|
||||||
osname="$1"
|
osname="$1"
|
||||||
@@ -122,6 +128,6 @@ for cfg in *.cfg; do (
|
|||||||
|
|
||||||
# Run nonfree tests only if they are opted into.
|
# Run nonfree tests only if they are opted into.
|
||||||
if ! "$EXT_TEST_IS_NONFREE" || "$nonfree"; then
|
if ! "$EXT_TEST_IS_NONFREE" || "$nonfree"; then
|
||||||
./test.sh "$test_name"
|
./test.sh "$test_name" "$make_jobs"
|
||||||
fi
|
fi
|
||||||
); done
|
); done
|
||||||
|
|||||||
Reference in New Issue
Block a user