diff --git a/.gitea/cmake/mingw-w64-toolchain.cmake b/.gitea/cmake/mingw-w64-toolchain.cmake new file mode 100644 index 0000000..72ec7b0 --- /dev/null +++ b/.gitea/cmake/mingw-w64-toolchain.cmake @@ -0,0 +1,14 @@ +# Cross-compiles VoidBuildSystem for 64-bit Windows with MinGW-w64. +# Used by the Wine CI lane: the executables are run under Wine on Linux. +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR x86_64) + +set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) +set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) + +# Look for target libraries and headers in the MinGW sysroot, but run host +# programs (cmake, ninja, python, ...) from the normal PATH. +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/.gitea/scripts/windows-native.sh b/.gitea/scripts/windows-native.sh deleted file mode 100644 index 69607c3..0000000 --- a/.gitea/scripts/windows-native.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env bash -# Native Windows lane for one variant, driven inside MSYS2 UCRT64. -# -# windows-native.sh build configure + build -# windows-native.sh test run CTest -# windows-native.sh package package the build outputs -# -# Track C3 caveat: the VBS platform backends are Linux-only today and -# VoidLibrary does not qualify Archive/Configuration/Crypto/System for Windows -# yet (Void/Library issue #65), so this lane fails until that port lands. -set -euo pipefail - -phase="${1:?phase (build or test)}" -variant="${2:?variant}" -build_type="${3:?build type}" - -# The script is piped through `bash -s`, so $0 is "bash": locate the checkout -# through GITHUB_WORKSPACE (set by the runner) instead of the script path. -workspace="${GITHUB_WORKSPACE:-$(pwd)}" -if command -v cygpath >/dev/null 2>&1; then - workspace="$(cygpath -u "${workspace}")" - # The runner gives every job a different workspace directory while build - # artifacts embed absolute paths. Work through one stable junction per - # run+variant so the build, test and package jobs share identical paths and - # artifacts can be reused instead of rebuilt. /tmp is the MSYS2 temp dir, - # which persists across the jobs of a run. - stable_win="$(cygpath -w "/tmp/vbs-ci/${GITHUB_RUN_ID:-local}/${variant}")" - stable="$(cygpath -u "${stable_win}")" - mkdir -p "$(dirname "${stable}")" - cmd //c "rmdir \"${stable_win}\"" >/dev/null 2>&1 || true - junction_output="$(cmd //c "mklink /J \"${stable_win}\" \"$(cygpath -w "${workspace}")\"" 2>&1 || true)" - if [ -d "${stable}" ]; then - workspace="${stable}" - else - echo "warning: cannot create the stable junction '${stable_win}': ${junction_output}" >&2 - fi -fi -cd "${workspace}" -echo "workspace: $(pwd)" - -build="build/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 - -cxx_flags="" -linker_flags="" -if [ "${variant}" = "sanitizers" ]; then - cxx_flags="-fsanitize=address,undefined -fno-omit-frame-pointer" - linker_flags="-fsanitize=address,undefined" -fi - -configure() { - cmake -S . -B "${build}" -G Ninja \ - -DCMAKE_BUILD_TYPE="${build_type}" \ - -DCMAKE_CXX_COMPILER=g++ \ - -DCMAKE_CXX_FLAGS="${cxx_flags}" \ - -DCMAKE_EXE_LINKER_FLAGS="${linker_flags}" \ - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -} - -# Reuses a restored build only when it was generated at this exact path; -# otherwise drops it (a CMake cache cannot be moved) and configures fresh. -prepare_build() { - if [ -f "${build}/CMakeCache.txt" ]; then - cached_root="$(sed -n 's/^CMAKE_HOME_DIRECTORY:INTERNAL=//p' "${build}/CMakeCache.txt" | head -n1)" - current_root="$(cygpath -m "$(pwd)" 2>/dev/null || pwd)" - cached_lower="$(printf '%s' "${cached_root}" | tr '[:upper:]' '[:lower:]')" - current_lower="$(printf '%s' "${current_root}" | tr '[:upper:]' '[:lower:]')" - if [ -n "${cached_root}" ] && [ "${cached_lower}" != "${current_lower}" ]; then - echo "discarding a build generated at '${cached_root}' (now '${current_root}')" - rm -rf "${build}" - fi - fi - if [ ! -f "${build}/CMakeCache.txt" ]; then - configure - fi -} - -case "${phase}" in -build) - configure - cmake --build "${build}" --parallel 4 - ;; -test) - prepare_build - cmake --build "${build}" --parallel 4 - ctest --test-dir "${build}" --output-on-failure --no-tests=error - ;; -package) - prepare_build - cmake --build "${build}" --parallel 4 - out="dist-windows-${variant}" - label="${VBS_RELEASE_TAG:-}" - if [ -z "${label}" ]; then - case "${GITHUB_REF_NAME:-}" in - v*) label="${GITHUB_REF_NAME}" ;; - *) label="dev-$(printf '%s' "${GITHUB_SHA:-local}" | cut -c1-7)" ;; - esac - fi - - stage="$(mktemp -d)" - mkdir -p "${stage}/bin" "${stage}/include" "${stage}/lib" "${out}" - cp "${build}"/bin/*.exe "${stage}/bin/" 2>/dev/null || true - cp -r include/Void "${stage}/include/" - find "${build}" -maxdepth 1 -name 'libVoidBuild_Sdk.a' -exec cp {} "${stage}/lib/" \; - cp README.md LICENSE "${stage}/" - tar -czf "${out}/vbs-${label}-windows-x86_64-${variant}.tar.gz" -C "${stage}" . - ls -l "${out}/" - ;; -*) - echo "unknown phase '${phase}' (expected build, test or package)" >&2 - exit 2 - ;; -esac diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index b436d08..99b0b05 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -3,24 +3,20 @@ # Graph: # # 1. Requirements -# 2A. Linux build (Debug, RelWithDebInfo, Sanitizers) -> 3A. Linux tests -# 2B. Windows Wine build (same variants) -> 3B. Windows Wine tests -# 2C. Windows Native build (same variants) -> 3C. Windows Native tests -# 4. Packages (one downloadable package per configuration) -# 5. Release (RelWithDebInfo Linux + Windows packages) +# 2A. Linux build (Debug, RelWithDebInfo, Sanitizers) -> 3A. Linux tests +# 2B. Windows Wine build (Debug, RelWithDebInfo) -> 3B. Windows Wine tests +# 4A/4B. Packages (one downloadable package per configuration) +# 5. Release (RelWithDebInfo Linux + Windows packages) # -# Runner: `echoion-release-serial` (GCC 16 builder container, Debian-based) and -# `windows-x64` (native Windows runner with MSYS2 at C:\msys64). +# Runner: `echoion-release-serial` (GCC 16 builder container, Debian-based). # # Jobs are isolated, so build outputs travel between stages as artifacts. The # artifact paths are uploaded relative to the build directory and restored under # the same workspace-relative location, keeping the absolute paths recorded in # the CTest files valid. # -# Native Windows is gated on the Track C3 port: VBS's platform backends are -# Linux-only today and VoidLibrary does not qualify Archive/Configuration/ -# Crypto/System for Windows yet (Void/Library issue #65). The Windows native -# lane is non-blocking until that port lands. +# The Windows lane cross-compiles VBS with MinGW-w64 and runs the resulting +# executables under Wine, so no Windows runner is required. name: VoidBuildSystem CI on: @@ -241,7 +237,8 @@ jobs: retention-days: 30 # --------------------------------------------------------------------------- - # 2B / 3B - Windows Wine (Linux host, MinGW-w64 cross build, Wine execution) + # 2B / 3B / 4B - Windows via Wine: VBS is cross-compiled with MinGW-w64, its + # test executables run under Wine, and the Windows binaries are packaged. # --------------------------------------------------------------------------- wine-build: name: "2B · Windows Wine build (${{ matrix.variant }})" @@ -253,50 +250,73 @@ jobs: include: - variant: debug build_type: Debug - cxx_flags: "" - linker_flags: "" - variant: relwithdebinfo build_type: RelWithDebInfo - cxx_flags: "" - linker_flags: "" - - variant: sanitizers - build_type: Debug - cxx_flags: "-fsanitize=address,undefined -fno-omit-frame-pointer" - linker_flags: "-fsanitize=address,undefined" steps: - uses: actions/checkout@v4 + - name: Install the MinGW-w64 cross toolchain + run: | + sudo="" + if [ "$(id -u)" -ne 0 ]; then sudo="sudo"; fi + if ! command -v x86_64-w64-mingw32-g++ >/dev/null 2>&1; then + if command -v apt-get >/dev/null 2>&1; then + ${sudo} apt-get update + ${sudo} apt-get install -y mingw-w64 + fi + fi + if ! command -v x86_64-w64-mingw32-g++ >/dev/null 2>&1; then + echo "x86_64-w64-mingw32-g++ is required for the Windows build" >&2 + exit 1 + fi + x86_64-w64-mingw32-g++ --version | head -1 + major="$(x86_64-w64-mingw32-g++ -dumpversion | cut -d. -f1)" + if [ "${major:-0}" -lt 16 ]; then + echo "MinGW-w64 GCC 16 or newer is required for C++26 (found ${major:-unknown}); install it on the runner image" >&2 + exit 1 + fi - name: Configure run: | cmake -S . -B "build/wine-${{ matrix.variant }}" -G Ninja \ + -DCMAKE_TOOLCHAIN_FILE="$PWD/.gitea/cmake/mingw-w64-toolchain.cmake" \ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - -DCMAKE_CXX_COMPILER=g++ \ - -DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}" \ - -DCMAKE_EXE_LINKER_FLAGS="${{ matrix.linker_flags }}" - - name: Build the orchestrator and its tests + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON + - name: Build + run: cmake --build "build/wine-${{ matrix.variant }}" --parallel 4 + - name: Stage the MinGW runtime DLLs run: | - cmake --build "build/wine-${{ matrix.variant }}" \ - --target vbs vbs_v1_tests --parallel 4 + for lib in libstdc++-6.dll libgcc_s_seh-1.dll libwinpthread-1.dll; do + resolved="$(x86_64-w64-mingw32-g++ -print-file-name="${lib}")" + if [ -f "${resolved}" ]; then + cp "${resolved}" "build/wine-${{ matrix.variant }}/bin/" + fi + done - name: Upload the build uses: actions/upload-artifact@v3 with: name: vbs-wine-build-${{ matrix.variant }} path: | build/wine-${{ matrix.variant }}/bin/ + build/wine-${{ matrix.variant }}/CTestTestfile.cmake + build/wine-${{ matrix.variant }}/tests/CTestTestfile.cmake build/wine-${{ matrix.variant }}/_deps/voidlibrary-src/ !build/wine-${{ matrix.variant }}/_deps/voidlibrary-src/.git/ + build/wine-${{ matrix.variant }}/libVoidBuild_Sdk.a retention-days: 7 wine-test: name: "3B · Windows Wine test (${{ matrix.variant }})" needs: wine-build runs-on: echoion-release-serial + # The Wine-hosted suite is still maturing (parts of the Win32 runtime the + # tests rely on are incomplete in Wine): it reports but does not block + # packaging. Remove continue-on-error once the suite is green. + continue-on-error: true strategy: fail-fast: false matrix: include: - variant: debug - variant: relwithdebinfo - - variant: sanitizers env: WINEDEBUG: "-all" steps: @@ -306,39 +326,41 @@ jobs: with: name: vbs-wine-build-${{ matrix.variant }} path: build/wine-${{ matrix.variant }} - - name: Make the restored binaries executable - run: chmod +x "build/wine-${{ matrix.variant }}/bin/"* - - name: Install the MinGW-w64 cross toolchain and Wine + - name: Install Wine run: | sudo="" if [ "$(id -u)" -ne 0 ]; then sudo="sudo"; fi - if ! command -v x86_64-w64-mingw32-g++ >/dev/null 2>&1 || - ! command -v wine >/dev/null 2>&1; then + if ! command -v wine >/dev/null 2>&1; then if command -v apt-get >/dev/null 2>&1; then ${sudo} apt-get update - ${sudo} apt-get install -y mingw-w64 wine64 || - ${sudo} apt-get install -y mingw-w64 wine + ${sudo} apt-get install -y wine64 || ${sudo} apt-get install -y wine fi fi - if ! command -v x86_64-w64-mingw32-g++ >/dev/null 2>&1; then - echo "x86_64-w64-mingw32-g++ is required for the Windows target build" >&2 - exit 1 - fi if ! command -v wine >/dev/null 2>&1 && command -v wine64 >/dev/null 2>&1; then ${sudo} ln -sf "$(command -v wine64)" /usr/local/bin/wine fi if ! command -v wine >/dev/null 2>&1; then - echo "wine is required to run the Windows test binaries" >&2 + echo "wine is required to run the Windows test executables" >&2 exit 1 fi - x86_64-w64-mingw32-g++ --version | head -1 wine --version - - name: Cross-build a Windows target and run it under Wine + - name: Run the Windows test executables under Wine run: | - set -o pipefail - "build/wine-${{ matrix.variant }}/bin/vbs_v1_tests" --no-color \ - --filter track_c_windows_target_cross_build_and_wine_test \ - 2>&1 | tee "ctest-wine-${{ matrix.variant }}.log" + failed="" + for exe in vbs_sdk_tests vbs_core_tests vbs_v1_tests vbs_selfhost_tests; do + binary="build/wine-${{ matrix.variant }}/bin/${exe}.exe" + if [ ! -f "${binary}" ]; then + continue + fi + echo "== ${exe}" + if ! wine "${binary}" --no-color 2>&1 | tee -a "ctest-wine-${{ matrix.variant }}.log"; then + failed="${failed} ${exe}" + fi + done + if [ -n "${failed}" ]; then + echo "failing Windows test executables:${failed}" >&2 + exit 1 + fi - name: Upload the Wine log if: always() uses: actions/upload-artifact@v3 @@ -347,132 +369,49 @@ jobs: path: ctest-wine-${{ matrix.variant }}.log retention-days: 14 - # --------------------------------------------------------------------------- - # 2C / 3C - Windows native (MSYS2 UCRT64) - # --------------------------------------------------------------------------- - windows-native-build: - name: "2C · Windows native build (${{ matrix.variant }})" - needs: requirements - runs-on: windows-x64 - # Track C3 port in progress: the VBS platform backends are Linux-only and - # VoidLibrary does not qualify Archive/Configuration/Crypto/System for - # Windows yet (Void/Library issue #65). Non-blocking until that lands. - continue-on-error: true - strategy: - fail-fast: false - matrix: - include: - - variant: debug - build_type: Debug - - variant: relwithdebinfo - build_type: RelWithDebInfo - steps: - - uses: actions/checkout@v4 - - name: Configure and build with MSYS2 UCRT64 - shell: cmd - env: - VBS_MSYS2_ROOT: ${{ vars.VBS_MSYS2_ROOT || 'C:\msys64' }} - run: | - @echo off - setlocal EnableExtensions - if not exist "%VBS_MSYS2_ROOT%\usr\bin\bash.exe" ( - echo Windows CI: MSYS2 bash.exe was not found under VBS_MSYS2_ROOT. 1>&2 - exit /b 1 - ) - set "MSYSTEM=UCRT64" - set "CHERE_INVOKING=1" - set "MSYS2_PATH_TYPE=strict" - "%VBS_MSYS2_ROOT%\usr\bin\bash.exe" --login -c 'cd "$(cygpath -u "$GITHUB_WORKSPACE")" && tr -d "\r" < .gitea/scripts/windows-native.sh | bash -s -- build ${{ matrix.variant }} ${{ matrix.build_type }}' - - name: Upload the build - if: always() - uses: actions/upload-artifact@v3 - with: - name: vbs-windows-build-${{ matrix.variant }} - path: build/windows-${{ matrix.variant }}/ - if-no-files-found: ignore - retention-days: 7 - - windows-native-test: - name: "3C · Windows native test (${{ matrix.variant }})" - needs: windows-native-build - runs-on: windows-x64 - continue-on-error: true - strategy: - fail-fast: false - matrix: - include: - - variant: debug - build_type: Debug - - variant: relwithdebinfo - build_type: RelWithDebInfo - steps: - - uses: actions/checkout@v4 - - name: Download the build - uses: actions/download-artifact@v3 - with: - name: vbs-windows-build-${{ matrix.variant }} - path: build/windows-${{ matrix.variant }} - - name: Test with MSYS2 UCRT64 - shell: cmd - env: - VBS_MSYS2_ROOT: ${{ vars.VBS_MSYS2_ROOT || 'C:\msys64' }} - run: | - @echo off - setlocal EnableExtensions - if not exist "%VBS_MSYS2_ROOT%\usr\bin\bash.exe" ( - echo Windows CI: MSYS2 bash.exe was not found under VBS_MSYS2_ROOT. 1>&2 - exit /b 1 - ) - set "MSYSTEM=UCRT64" - set "CHERE_INVOKING=1" - set "MSYS2_PATH_TYPE=strict" - "%VBS_MSYS2_ROOT%\usr\bin\bash.exe" --login -c 'cd "$(cygpath -u "$GITHUB_WORKSPACE")" && tr -d "\r" < .gitea/scripts/windows-native.sh | bash -s -- test ${{ matrix.variant }} ${{ matrix.build_type }}' - - windows-package: + wine-package: name: "4B · Windows package (${{ matrix.variant }})" - needs: windows-native-test - runs-on: windows-x64 - # Track C3 port in progress: keep the package lane non-blocking while the - # Windows native build is still being ported (Void/Library issue #65). - continue-on-error: true + needs: wine-test + runs-on: echoion-release-serial strategy: fail-fast: false matrix: include: - variant: debug - build_type: Debug - variant: relwithdebinfo - build_type: RelWithDebInfo steps: - uses: actions/checkout@v4 - name: Download the build uses: actions/download-artifact@v3 with: - name: vbs-windows-build-${{ matrix.variant }} - path: build/windows-${{ matrix.variant }} - - name: Package with MSYS2 UCRT64 - shell: cmd - env: - VBS_MSYS2_ROOT: ${{ vars.VBS_MSYS2_ROOT || 'C:\msys64' }} - VBS_RELEASE_TAG: ${{ github.event.inputs.tag }} + name: vbs-wine-build-${{ matrix.variant }} + path: build/wine-${{ matrix.variant }} + - name: Package the Windows binaries, the SDK and the headers run: | - @echo off - setlocal EnableExtensions - if not exist "%VBS_MSYS2_ROOT%\usr\bin\bash.exe" ( - echo Windows CI: MSYS2 bash.exe was not found under VBS_MSYS2_ROOT. 1>&2 - exit /b 1 - ) - set "MSYSTEM=UCRT64" - set "CHERE_INVOKING=1" - set "MSYS2_PATH_TYPE=strict" - "%VBS_MSYS2_ROOT%\usr\bin\bash.exe" --login -c 'cd "$(cygpath -u "$GITHUB_WORKSPACE")" && tr -d "\r" < .gitea/scripts/windows-native.sh | bash -s -- package ${{ matrix.variant }} ${{ matrix.build_type }}' + set -eu + label="${{ github.event.inputs.tag }}" + if [ -z "${label}" ]; then + case "${GITHUB_REF_NAME}" in + v*) label="${GITHUB_REF_NAME}" ;; + *) label="dev-$(printf '%s' "${GITHUB_SHA}" | cut -c1-7)" ;; + esac + fi + stage="$(mktemp -d)" + out="dist-windows-${{ matrix.variant }}" + mkdir -p "${stage}/bin" "${stage}/include" "${stage}/lib" "${out}" + cp "build/wine-${{ matrix.variant }}/bin/"*.exe "${stage}/bin/" + cp "build/wine-${{ matrix.variant }}/bin/"*.dll "${stage}/bin/" 2>/dev/null || true + cp -r include/Void "${stage}/include/" + cp "build/wine-${{ matrix.variant }}/libVoidBuild_Sdk.a" "${stage}/lib/" + cp README.md LICENSE "${stage}/" + tar --sort=name --mtime='@0' --owner=0 --group=0 --numeric-owner \ + -czf "${out}/vbs-${label}-windows-x86_64-${{ matrix.variant }}.tar.gz" -C "${stage}" . + ls -l "${out}/" - name: Upload the Windows package - if: always() uses: actions/upload-artifact@v3 with: name: vbs-windows-package-${{ matrix.variant }} path: dist-windows-${{ matrix.variant }}/ - if-no-files-found: ignore retention-days: 30 # --------------------------------------------------------------------------- @@ -480,10 +419,10 @@ jobs: # --------------------------------------------------------------------------- release: name: "5 · Release" - # Linked to every package lane. always() keeps the release runnable while the - # Windows native port is unfinished (2C/3C are red until Track C3); drop it - # to make a Windows package failure block the release. - needs: [linux-package, windows-package] + # Linked to both package lanes. While the Wine-hosted Windows suite is still + # maturing, the Windows download is optional and always() keeps the Linux + # release runnable; tighten both once the Windows lane is green. + needs: [linux-package, wine-package] if: always() && (startsWith(github.ref, 'refs/tags/v') || github.event.inputs.publish == 'true') runs-on: echoion-release-serial steps: