diff --git a/.github/scripts/msvc-env.bat b/.github/scripts/msvc-env.bat new file mode 100644 index 000000000..c9c7775e9 --- /dev/null +++ b/.github/scripts/msvc-env.bat @@ -0,0 +1,4 @@ +@rem From https://github.com/microsoft/vswhere/wiki/Start-Developer-Command-Prompt#using-batch +for /f "delims=" %%p in ('vswhere.exe -prerelease -latest -property installationPath') do set vspath=%%p +@rem From https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#developer_command_file_locations +call "%vspath%\VC\Auxiliary\Build\vcvars%1.bat" diff --git a/.github/workflows/create-release-artifacts.yml b/.github/workflows/create-release-artifacts.yml index bc58456fa..a070c2d4d 100644 --- a/.github/workflows/create-release-artifacts.yml +++ b/.github/workflows/create-release-artifacts.yml @@ -36,13 +36,15 @@ jobs: run: | bash .github/scripts/install_deps.sh windows - name: Build Windows binaries + shell: cmd run: | - cmake -S . -B build --preset msvc${{ matrix.bits }} -DFETCHCONTENT_BASE_DIR="${{ env.DEPS_ROOT_DIR }}" - cmake --build build --config Release + call .github\scripts\msvc-env.bat ${{ matrix.bits }} + cmake -B build -G Ninja -DFETCHCONTENT_BASE_DIR="${{ env.DEPS_ROOT_DIR }}" -DCMAKE_C_FLAGS="/nologo" + cmake --build build -- -k 0 - name: Package binaries working-directory: build run: | - cpack -DCPACK_PACKAGE_FILE_NAME=rgbds-win${{ matrix.bits }} -G ZIP -C Release --verbose + cpack -DCPACK_PACKAGE_FILE_NAME=rgbds-win${{ matrix.bits }} -G ZIP --verbose - name: Upload Windows binaries uses: actions/upload-artifact@v7 with: @@ -60,8 +62,8 @@ jobs: ./.github/scripts/install_deps.sh macos lld - name: Build binaries run: | - cmake -S . -B build --preset macos-static -DFETCHCONTENT_BASE_DIR="${{ env.DEPS_ROOT_DIR }}" - cmake --build build + cmake -B build -G Ninja --preset macos-static -DFETCHCONTENT_BASE_DIR="${{ env.DEPS_ROOT_DIR }}" + cmake --build build -- -k 0 strip rgb{asm,link,fix,gfx} env: LDFLAGS: -fuse-ld=lld # cmake/macos-static.cmake comments explain why we use lld. diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 01c31e855..5935ebadf 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -13,8 +13,6 @@ env: 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 - CMAKE_BUILD_PARALLEL_LEVEL: 4 # `cmake --build` now implies `--parallel 4`. - CMAKE_INSTALL_PARALLEL_LEVEL: 4 # `cmake --install` now implies `--parallel 4`. 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_OUTPUT_ON_FAILURE: ON # CTest reports test program output on failure. @@ -63,8 +61,8 @@ jobs: # 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_FIND_FRAMEWORK=LAST -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DTESTS_OS_NAME=${{ matrix.os }} - cmake --build build --verbose + CXX=${{ matrix.cxx }} cmake -B build -G Ninja --preset develop -DCMAKE_FIND_FRAMEWORK=LAST -DTESTS_OS_NAME=${{ matrix.os }} + cmake --build build -- -k 0 sudo cmake --install build --verbose - name: Package binaries run: | @@ -122,8 +120,8 @@ jobs: enableCrossOsArchive: true - name: Build & install run: | - cmake -S . -B build --preset macos-static -DFETCHCONTENT_BASE_DIR="${{ env.DEPS_ROOT_DIR }}" -DTESTS_OS_NAME=macos - cmake --build build + cmake -B build -G Ninja --preset macos-static -DFETCHCONTENT_BASE_DIR="${{ env.DEPS_ROOT_DIR }}" -DTESTS_OS_NAME=macos + cmake --build build -- -k 0 env: LDFLAGS: -fuse-ld=lld # cmake/macos-static.cmake comments explain why we use lld. - name: Package binaries @@ -181,14 +179,16 @@ jobs: key: dep-srcs-${{ hashFiles('cmake/deps.cmake') }} enableCrossOsArchive: true - name: Build Windows binaries + shell: cmd run: | # ASan seems to be broken on Windows, so we disable it. - cmake -S . -B build --preset develop-msvc${{ matrix.bits }} -DSANITIZERS=OFF \ - -DTESTS_OS_NAME=${{ matrix.os }} -DFETCHCONTENT_BASE_DIR="${{ env.DEPS_ROOT_DIR }}" - cmake --build build + call .github\scripts\msvc-env.bat ${{ matrix.bits }} + cmake -B build -G Ninja --preset develop -DSANITIZERS=OFF -DTESTS_OS_NAME=${{ matrix.os }} ^ + -DFETCHCONTENT_BASE_DIR="${{ env.DEPS_ROOT_DIR }}" -DCMAKE_C_FLAGS="/nologo" + cmake --build build -- -k 0 - name: Package binaries working-directory: build run: | - cpack -DCPACK_PACKAGE_FILE_NAME=rgbds-win${{ matrix.bits }} -G ZIP -C Debug --verbose + cpack -DCPACK_PACKAGE_FILE_NAME=rgbds-win${{ matrix.bits }} -G ZIP --verbose - name: Upload Windows binaries uses: actions/upload-artifact@v7 with: @@ -218,7 +218,7 @@ jobs: test/fetch-test-deps.sh --get-deps ${{ matrix.os }} - name: Run tests using CTest run: | - ctest --test-dir build --schedule-random -C Debug + ctest --test-dir build --schedule-random windows-mingw-build: strategy: @@ -241,9 +241,9 @@ jobs: - name: Cross-build Windows binaries run: | # MinGW does not support `--preset develop` sanitizers ASan or UBSan. dll_search_dir=$(printf '%s\n' /usr/lib/gcc/*-w64-mingw32/*-win32 | tee -a /dev/stderr) - cmake -B build --preset develop -DSANITIZERS=OFF --toolchain cmake/toolchain-mingw${{ matrix.bits }}.cmake \ + cmake -B build -G Ninja --preset develop -DSANITIZERS=OFF --toolchain cmake/toolchain-mingw${{ matrix.bits }}.cmake \ -DFETCHCONTENT_BASE_DIR="${{ env.DEPS_ROOT_DIR }}" -DDLL_SEARCH_DIRS="$dll_search_dir" - cmake --build build + cmake --build build -- -k 0 - name: Package binaries run: | cmake --install build --prefix . --verbose --component binaries @@ -362,7 +362,7 @@ jobs: envs: >- TERM CLICOLOR CLICOLOR_FORCE CMAKE_COLOR_DIAGNOSTICS CMAKE_CONFIG_TYPE - CMAKE_BUILD_PARALLEL_LEVEL CTEST_PARALLEL_LEVEL + CTEST_PARALLEL_LEVEL CTEST_NO_TESTS_ACTION CTEST_OUTPUT_ON_FAILURE GIT_CONFIG_COUNT GIT_CONFIG_KEY_0 GIT_CONFIG_VALUE_0 release: "14.3" @@ -370,7 +370,7 @@ jobs: prepare: | .github/scripts/install_deps.sh freebsd run: | # Leak detection is not supported on FreeBSD, so disable it. - cmake -S . -B build --preset develop -DTESTS_OS_NAME=freebsd - cmake --build build --verbose + cmake -B build --preset develop -DTESTS_OS_NAME=freebsd + cmake --build build --verbose -- -k -j 4 ASAN_OPTIONS=detect_leaks=0 ctest --test-dir build --schedule-random --label-exclude external cmake --install build --verbose diff --git a/CMakePresets.json b/CMakePresets.json index 74b4d18fb..405264fb5 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -16,22 +16,22 @@ "errors": { "dev": true } }, { - "name": "develop-msvc32", - "inherits": ["develop", "msvc32"] + "name": "develop-msbuild32", + "inherits": ["develop", "msbuild32"] }, { - "name": "develop-msvc64", - "inherits": ["develop", "msvc64"] + "name": "develop-msbuild64", + "inherits": ["develop", "msbuild64"] }, { - "name": "msvc32", - "description": "Flags for building 32-bit executables with MSVC", + "name": "msbuild32", + "description": "Flags for building 32-bit executables with MSBuild", "architecture": "Win32" }, { - "name": "msvc64", - "description": "Flags for building 64-bit executables with MSVC", + "name": "msbuild64", + "description": "Flags for building 64-bit executables with MSBuild", "architecture": "x64" },