diff --git a/.gitea/scripts/install-ninja.sh b/.gitea/scripts/install-ninja.sh new file mode 100644 index 0000000..1aff578 --- /dev/null +++ b/.gitea/scripts/install-ninja.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +# Ensure Ninja >= 1.11 (CMake needs it for C++20 module scanning). +# +# Tries, in order: the distribution package, the pip wheel, and the official +# static release binary (installed into /usr/local/bin so it shadows an older +# distro ninja). +set -euo pipefail + +minimum=1.11 +version_ok() { + local have="${1:-0}" + [ "$(printf '%s\n%s\n' "${minimum}" "${have}" | sort -V | head -n1)" = "${minimum}" ] +} + +have="$(ninja --version 2>/dev/null || echo 0)" +if version_ok "${have}"; then + echo "ninja ${have} already satisfies >= ${minimum}" + exit 0 +fi + +sudo="" +if [ "$(id -u)" -ne 0 ]; then sudo="sudo"; fi + +# 1. Distribution package. +if command -v apt-get >/dev/null 2>&1; then + ${sudo} apt-get update || true + ${sudo} apt-get install -y ninja-build || true + hash -r +fi +have="$(ninja --version 2>/dev/null || echo 0)" +if version_ok "${have}"; then + echo "installed ninja ${have} from the distribution" + exit 0 +fi + +# 2. pip wheel (installs into /usr/local/bin, which shadows the distro binary). +if command -v python3 >/dev/null 2>&1; then + python3 -m pip install --quiet --break-system-packages ninja || + python3 -m pip install --quiet ninja || true + hash -r +fi +have="$(ninja --version 2>/dev/null || echo 0)" +if version_ok "${have}"; then + echo "installed ninja ${have} from pip" + exit 0 +fi + +# 3. Official static binary. +release=1.12.1 +tmp="$(mktemp -d)" +url="https://github.com/ninja-build/ninja/releases/download/v${release}/ninja-linux.zip" +if command -v curl >/dev/null 2>&1; then + curl -fsSL "${url}" -o "${tmp}/ninja.zip" +elif command -v wget >/dev/null 2>&1; then + wget -qO "${tmp}/ninja.zip" "${url}" +else + echo "curl or wget is required to download ninja" >&2 + exit 1 +fi +python3 -c 'import sys, zipfile; zipfile.ZipFile(sys.argv[1]).extractall(sys.argv[2])' \ + "${tmp}/ninja.zip" "${tmp}" +${sudo} install -m 0755 "${tmp}/ninja" /usr/local/bin/ninja +hash -r +have="$(ninja --version 2>/dev/null || echo 0)" +if ! version_ok "${have}"; then + echo "Ninja ${minimum}+ is required for C++20 module scanning (found ${have})" >&2 + exit 1 +fi +echo "installed ninja ${have} from the official release" diff --git a/.gitea/scripts/windows-native.sh b/.gitea/scripts/windows-native.sh index a68f1f8..7f9bce2 100644 --- a/.gitea/scripts/windows-native.sh +++ b/.gitea/scripts/windows-native.sh @@ -18,6 +18,16 @@ cd "${root}" build="build/windows-${variant}" out="dist-windows-${variant}" +# Make sure the UCRT64 environment provides the build tools. +if ! command -v cmake >/dev/null 2>&1 || ! command -v ninja >/dev/null 2>&1; then + if command -v pacman >/dev/null 2>&1; then + pacman -S --noconfirm --needed \ + mingw-w64-ucrt-x86_64-cmake \ + mingw-w64-ucrt-x86_64-ninja \ + mingw-w64-ucrt-x86_64-gcc + fi +fi + cmake -S . -B "${build}" -G Ninja \ -DCMAKE_BUILD_TYPE="${build_type}" \ -DCMAKE_CXX_COMPILER=g++ \ diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 3ac1919..b8b8032 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -65,22 +65,7 @@ jobs: echo "CMake 4 or newer is required (found ${cmake_major:-unknown})" >&2 exit 1 fi - ninja --version - ninja_version="$(ninja --version)" - if [ "$(printf '%s\n%s\n' 1.11 "${ninja_version}" | sort -V | head -n1)" != "1.11" ]; then - # CMake needs Ninja 1.11+ for C++20 module scanning: try upgrading once. - if command -v apt-get >/dev/null 2>&1; then - sudo="" - if [ "$(id -u)" -ne 0 ]; then sudo="sudo"; fi - ${sudo} apt-get update || true - ${sudo} apt-get install -y ninja-build || true - fi - ninja_version="$(ninja --version)" - fi - if [ "$(printf '%s\n%s\n' 1.11 "${ninja_version}" | sort -V | head -n1)" != "1.11" ]; then - echo "Ninja 1.11 or newer is required for C++20 module scanning (found ${ninja_version})" >&2 - exit 1 - fi + bash .gitea/scripts/install-ninja.sh git --version - name: Install the development requirements run: | diff --git a/tests/FullV1Tests.cpp b/tests/FullV1Tests.cpp index d8fa1bb..7821d17 100644 --- a/tests/FullV1Tests.cpp +++ b/tests/FullV1Tests.cpp @@ -1452,8 +1452,10 @@ VOID_TEST(FullV1Tests, track_c_windows_target_cross_build_and_wine_test) { const auto proj = tmp / "win_proj"; write_file(proj / "build.cpp", R"cpp(#include void build(Void::Build::Project &p) { - p.executable("winapp").cxx_standard(Void::Build::CxxStandard::Cxx26).sources({"main.cpp"}); - p.test("win_test").cxx_standard(Void::Build::CxxStandard::Cxx26).sources({"test.cpp"}); + // C++20 keeps the Windows target buildable with older MinGW-w64 toolchains + // (the CI runner ships GCC 10); the test exercises PE/Wine path handling. + p.executable("winapp").cxx_standard(Void::Build::CxxStandard::Cxx20).sources({"main.cpp"}); + p.test("win_test").cxx_standard(Void::Build::CxxStandard::Cxx20).sources({"test.cpp"}); } )cpp"); write_file(proj / "main.cpp", "#include \nint main() { return 0; }\n");