From a610d2d899727acd44505e75cc43e6dcd6c4a265 Mon Sep 17 00:00:00 2001 From: Kris Austin Date: Wed, 16 Sep 2026 07:50:27 -0500 Subject: [PATCH] ci: build Windows with build_win.bat and drop the old scripts (#15721) * ci: build Windows with build_win.bat and drop the old scripts The deps and slicer jobs called build_release_vs.bat; they now call build_win.bat. --deps-dir and --build-dir name the build/build-arm64 directories the cache keys and later steps already use, and the script's own VsDevCmd call replaces the Enter-VsDevShell blocks. With both stages configured each way into the same directory, the deps superbuild is byte-identical and the slicer build files are byte-identical apart from CMakeCache.txt recording how DEP_BUILD_DIR was set. Two changes beyond the script swap: - The compiler is the clang-cl bundled with Visual Studio, the script's default. The old script's bare "clang-cl" resolved to the LLVM on the runner image's PATH, 20.1.8 on x64 and 22.1.8 on arm64; both arches now build with the 22.1.3 VS 18.9 ships. Cached dependencies are only rebuilt when deps/ changes, so they stay on the LLVM they were built with; the arm64 leg already links deps built with Clang 19 into a Clang 22 slicer. - The deps job no longer zips the dependencies afterwards. The zip was never uploaded and was not in the cached path. A failed cmake --build now fails the job. The old script returned 0, so the arm64 failure fixed in #15719 was reported as success and the half-built dependencies were saved to the cache. build_release.bat, build_release_vs.bat and build_release_vs2022.bat are removed; nothing referenced them any more. * ci: run Build all when the Windows build script changes; tests doc builds the deps The push filter of build_all.yml never listed a build script, and CI now depends on build_win.bat, so it and its test suite join the list the pull_request filter already has. tests/AGENTS.md told Windows to run build_win.bat --run-tests, which only implies -s and stops at the dependency check on a clean checkout. The old build_release_vs.bat tests built the dependencies first, so the line now says -ds --run-tests. --- .github/workflows/build_all.yml | 4 +- .github/workflows/build_check_cache.yml | 3 +- .github/workflows/build_deps.yml | 24 +-- .github/workflows/build_orca.yml | 20 +-- build_release.bat | 52 ------- build_release_vs.bat | 190 ------------------------ build_release_vs2022.bat | 80 ---------- tests/AGENTS.md | 2 +- 8 files changed, 16 insertions(+), 359 deletions(-) delete mode 100644 build_release.bat delete mode 100644 build_release_vs.bat delete mode 100644 build_release_vs2022.bat diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index f8d6bb8235..2357b1a5a4 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -15,6 +15,8 @@ on: - 'resources/**' - ".github/workflows/build_*.yml" - ".github/workflows/unit_tests*.yml" + - 'build_win.bat' + - 'scripts/test_build_win.ps1' - 'scripts/build_preset_cache.*' - 'scripts/flatpak/**' - 'scripts/msix/**' @@ -33,8 +35,6 @@ on: - ".github/workflows/build_*.yml" - ".github/workflows/unit_tests*.yml" - 'build_linux.sh' - - 'build_release_vs.bat' - - 'build_release_vs2022.bat' - 'build_win.bat' - 'scripts/test_build_win.ps1' - 'build_release_macos.sh' diff --git a/.github/workflows/build_check_cache.yml b/.github/workflows/build_check_cache.yml index 91ea51ac60..2da05e1d69 100644 --- a/.github/workflows/build_check_cache.yml +++ b/.github/workflows/build_check_cache.yml @@ -41,7 +41,8 @@ jobs: # restores one it cannot use. Linux amd64 passes no arch deliberately, so # 'linux-clang' keeps the cache it already has. cache-os: ${{ runner.os == 'macOS' && format('macos-{0}', inputs.arch) || (runner.os == 'Windows' && format('windows-{0}-{1}', inputs.arch, inputs.compiler) || format('linux-clang{0}', inputs.arch && format('-{0}', inputs.arch) || '')) }} - # ARM64 builds use the build-arm64 tree (see build_release_vs.bat); x64/other use build. + # The Windows ARM64 deps build in build-arm64, all others under build; + # build_deps.yml and build_orca.yml pass the Windows directory to build_win.bat. dep-folder-name: ${{ runner.os == 'macOS' && format('/{0}', inputs.arch) || (runner.os == 'Windows' && inputs.arch == 'arm64') && '-arm64/OrcaSlicer_dep' || '/OrcaSlicer_dep' }} output-cmd: ${{ runner.os == 'Windows' && '$env:GITHUB_OUTPUT' || '"$GITHUB_OUTPUT"'}} run: | diff --git a/.github/workflows/build_deps.yml b/.github/workflows/build_deps.yml index f7082a8a06..a6d7a17dff 100644 --- a/.github/workflows/build_deps.yml +++ b/.github/workflows/build_deps.yml @@ -138,25 +138,11 @@ jobs: if (-not "${{ vars.SELF_HOSTED }}") { choco install strawberryperl } - $arch = "${{ inputs.arch }}" - # -l selects clang-cl and -x Ninja; together they build the deps with clang. - $clang = "${{ inputs.compiler }}" -eq "clang" - $flags = if ($clang) { "-l", "-x" } else { @() } - if ($clang) { - # OpenSSL builds with nmake, which needs a VC environment. - $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" - $vs = & $vswhere -latest -property installationPath - $devArch = if ($arch -eq "arm64") { "arm64" } else { "amd64" } - Import-Module "$vs\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" - Enter-VsDevShell -VsInstallPath $vs -SkipAutomaticLocation -DevCmdArguments "-arch=$devArch" - } - if ($arch -eq "arm64") { - .\build_release_vs.bat deps arm64 @flags - .\build_release_vs.bat pack arm64 - } else { - .\build_release_vs.bat deps @flags - .\build_release_vs.bat pack - } + # cache-path is the install directory inside the deps build directory. + $deps = (Split-Path "${{ inputs.cache-path }}").Replace('\', '/') + # -l compiles with Visual Studio's clang-cl and -x builds with Ninja; --msvc --msbuild is cl under the Visual Studio generator. + $flags = if ("${{ inputs.compiler }}" -eq "clang") { "-l", "-x" } else { "--msvc", "--msbuild" } + .\build_win.bat -d --arch ${{ inputs.arch }} --deps-dir $deps @flags shell: pwsh - name: Build on Mac ${{ inputs.arch }} diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index 95ec52a65d..cba8d059f1 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -450,21 +450,13 @@ jobs: # env: # WindowsSdkDir: 'C:\Program Files (x86)\Windows Kits\10\' # WindowsSDKVersion: '10.0.26100.0\' - # "tests" builds the unit tests too; the unit_tests_windows_* jobs run them. + # --tests builds the unit tests too; the unit_tests_windows_* jobs run them. run: | - $arch = "${{ inputs.arch }}" - # -l selects clang-cl and -x Ninja; together they build the slicer with clang. - $clang = "${{ inputs.compiler }}" -eq "clang" - $flags = if ($clang) { "-l", "-x" } else { @() } - if ($clang) { - # Build against the same VC toolchain and SDK as the dependencies. - $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" - $vs = & $vswhere -latest -property installationPath - $devArch = if ($arch -eq "arm64") { "arm64" } else { "amd64" } - Import-Module "$vs\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" - Enter-VsDevShell -VsInstallPath $vs -SkipAutomaticLocation -DevCmdArguments "-arch=$devArch" - } - if ($arch -eq "arm64") { .\build_release_vs.bat slicer arm64 @flags tests } else { .\build_release_vs.bat slicer @flags tests } + # cache-path is the install directory inside the deps build directory. + $deps = (Split-Path "${{ inputs.cache-path }}").Replace('\', '/') + # -l compiles with Visual Studio's clang-cl and -x builds with Ninja; --msvc --msbuild is cl under the Visual Studio generator. + $flags = if ("${{ inputs.compiler }}" -eq "clang") { "-l", "-x" } else { "--msvc", "--msbuild" } + .\build_win.bat -s --tests -i --arch ${{ inputs.arch }} --build-dir $env:BUILD_DIR --deps-dir $deps @flags shell: pwsh - name: Build system preset cache (Windows) diff --git a/build_release.bat b/build_release.bat deleted file mode 100644 index f751c17e5a..0000000000 --- a/build_release.bat +++ /dev/null @@ -1,52 +0,0 @@ -set WP=%CD% - -set debug=OFF -set debuginfo=OFF -if "%1"=="debug" set debug=ON -if "%2"=="debug" set debug=ON -if "%1"=="debuginfo" set debuginfo=ON -if "%2"=="debuginfo" set debuginfo=ON -if "%debug%"=="ON" ( - set build_type=Debug - set build_dir=build-dbg -) else ( - if "%debuginfo%"=="ON" ( - set build_type=RelWithDebInfo - set build_dir=build-dbginfo - ) else ( - set build_type=Release - set build_dir=build - ) -) -echo build type set to %build_type% - -cd deps -mkdir %build_dir% -cd %build_dir% -set DEPS=%CD%/OrcaSlicer_dep -set "SIG_FLAG=" -if defined ORCA_UPDATER_SIG_KEY set "SIG_FLAG=-DORCA_UPDATER_SIG_KEY=%ORCA_UPDATER_SIG_KEY%" -if "%1"=="slicer" ( - GOTO :slicer -) -echo "building deps.." - -echo cmake ../ -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=%build_type% -cmake ../ -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=%build_type% -cmake --build . --config %build_type% --target deps -- -m - -if "%1"=="deps" exit /b 0 - -:slicer -echo "building Orca Slicer..." -cd %WP% -mkdir %build_dir% -cd %build_dir% - -echo cmake .. -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=%build_type% -cmake .. -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=%build_type% %SIG_FLAG% -cmake --build . --config %build_type% --target ALL_BUILD -- -m -cd .. -call scripts/run_gettext.bat -cd %build_dir% -cmake --build . --target install --config %build_type% diff --git a/build_release_vs.bat b/build_release_vs.bat deleted file mode 100644 index 3842f1d198..0000000000 --- a/build_release_vs.bat +++ /dev/null @@ -1,190 +0,0 @@ -@REM OrcaSlicer build script for Windows with VS auto-detect -@echo off -set WP=%CD% -set _START_TIME=%TIME% - -@REM Default target architecture to the host CPU arch; override by passing -@REM "x64" or "arm64" as an argument. PROCESSOR_ARCHITEW6432 covers a 32-bit -@REM shell running on a 64-bit OS, where PROCESSOR_ARCHITECTURE reads "x86". -set arch=x64 -if /I "%PROCESSOR_ARCHITECTURE%"=="ARM64" set arch=ARM64 -if /I "%PROCESSOR_ARCHITEW6432%"=="ARM64" set arch=ARM64 -if /I "%1"=="arm64" set arch=ARM64 -if /I "%2"=="arm64" set arch=ARM64 -if /I "%1"=="x64" set arch=x64 -if /I "%2"=="x64" set arch=x64 - -@REM Check for Ninja Multi-Config option (-x) -set USE_NINJA=0 -for %%a in (%*) do ( - if "%%a"=="-x" set USE_NINJA=1 -) - -@REM Check for clang-cl option (-l). Combined with -x it also builds the deps with -@REM clang-cl; on the Visual Studio generator it applies to the slicer only, because -@REM the dependency sub-builds have no toolset to inherit and stay on MSVC. -set CLANG_ARG= -set TOOLSET_ARG= -for %%a in (%*) do ( - if "%%a"=="-l" ( - set CLANG_ARG=-DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl - set TOOLSET_ARG=-T ClangCL - ) -) - -@REM Check for unit-tests option ("tests") -set BUILD_TESTS=OFF -for %%a in (%*) do ( - if /I "%%a"=="tests" set BUILD_TESTS=ON -) - -if "%USE_NINJA%"=="1" ( - echo Using Ninja Multi-Config generator - set CMAKE_GENERATOR="Ninja Multi-Config" - set VS_VERSION=Ninja - goto :generator_ready -) - -@REM Detect Visual Studio version using msbuild -echo Detecting Visual Studio version using msbuild... - -@REM Try to get MSBuild version - the output format varies by VS version -set VS_MAJOR= -for /f "tokens=*" %%i in ('msbuild -version 2^>^&1 ^| findstr /r "^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"') do ( - for /f "tokens=1 delims=." %%a in ("%%i") do set VS_MAJOR=%%a - set MSBUILD_OUTPUT=%%i - goto :version_found -) - -@REM Alternative method for newer MSBuild versions -if "%VS_MAJOR%"=="" ( - for /f "tokens=*" %%i in ('msbuild -version 2^>^&1 ^| findstr /r "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"') do ( - for /f "tokens=1 delims=." %%a in ("%%i") do set VS_MAJOR=%%a - set MSBUILD_OUTPUT=%%i - goto :version_found - ) -) - -:version_found -echo MSBuild version detected: %MSBUILD_OUTPUT% -echo Major version: %VS_MAJOR% - -if "%VS_MAJOR%"=="" ( - echo Error: Could not determine Visual Studio version from msbuild - echo Please ensure Visual Studio and MSBuild are properly installed - exit /b 1 -) - -if "%VS_MAJOR%"=="16" ( - set VS_VERSION=2019 - set CMAKE_GENERATOR="Visual Studio 16 2019" -) else if "%VS_MAJOR%"=="17" ( - set VS_VERSION=2022 - set CMAKE_GENERATOR="Visual Studio 17 2022" -) else if "%VS_MAJOR%"=="18" ( - set VS_VERSION=2026 - set CMAKE_GENERATOR="Visual Studio 18 2026" -) else ( - echo Error: Unsupported Visual Studio version: %VS_MAJOR% - echo Supported versions: VS2019 (16.8+^), VS2022 (17.x^), VS2026 (18.x^) - exit /b 1 -) - -echo Detected Visual Studio %VS_VERSION% (version %VS_MAJOR%) -echo Using CMake generator: %CMAKE_GENERATOR% - -:generator_ready - -@REM Pack deps -if "%1"=="pack" ( - setlocal ENABLEDELAYEDEXPANSION - cd %WP%/deps/build - if "%arch%"=="ARM64" cd %WP%/deps/build-arm64 - for /f "tokens=2-4 delims=/ " %%a in ('date /t') do set build_date=%%c%%b%%a - echo packing deps: OrcaSlicer_dep_win-!arch!_!build_date!_vs!VS_VERSION!.zip - - %WP%/tools/7z.exe a OrcaSlicer_dep_win-!arch!_!build_date!_vs!VS_VERSION!.zip OrcaSlicer_dep - goto :done -) - -set debug=OFF -set debuginfo=OFF -if "%1"=="debug" set debug=ON -if "%2"=="debug" set debug=ON -if "%1"=="debuginfo" set debuginfo=ON -if "%2"=="debuginfo" set debuginfo=ON -if "%debug%"=="ON" ( - set build_type=Debug - set build_dir=build-dbg -) else ( - if "%debuginfo%"=="ON" ( - set build_type=RelWithDebInfo - set build_dir=build-dbginfo - ) else ( - set build_type=Release - set build_dir=build - ) -) -if "%arch%"=="ARM64" set build_dir=%build_dir%-arm64 -echo build type set to %build_type%, arch=%arch% - -setlocal DISABLEDELAYEDEXPANSION -cd deps -mkdir %build_dir% -cd %build_dir% -set "SIG_FLAG=" -if defined ORCA_UPDATER_SIG_KEY set "SIG_FLAG=-DORCA_UPDATER_SIG_KEY=%ORCA_UPDATER_SIG_KEY%" - -if "%1"=="slicer" ( - GOTO :slicer -) -echo "building deps.." -if defined CLANG_ARG if "%USE_NINJA%"=="0" echo Note: -l needs -x for the dependencies; building them with MSVC. - -echo on -REM Set minimum CMake policy to avoid <3.5 errors -set CMAKE_POLICY_VERSION_MINIMUM=3.5 -if "%USE_NINJA%"=="1" ( - cmake ../ -G %CMAKE_GENERATOR% %CLANG_ARG% -DCMAKE_BUILD_TYPE=%build_type% - cmake --build . --config %build_type% --target deps -) else ( - cmake ../ -G %CMAKE_GENERATOR% -A %arch% -DCMAKE_BUILD_TYPE=%build_type% - cmake --build . --config %build_type% --target deps -- -m -) -@echo off - -if "%1"=="deps" goto :done - -:slicer -echo "building Orca Slicer..." -cd %WP% -mkdir %build_dir% -cd %build_dir% - -echo on -set CMAKE_POLICY_VERSION_MINIMUM=3.5 -if "%USE_NINJA%"=="1" ( - cmake .. -G %CMAKE_GENERATOR% %CLANG_ARG% -DORCA_TOOLS=ON %SIG_FLAG% -DBUILD_TESTS=%BUILD_TESTS% -DCMAKE_BUILD_TYPE=%build_type% - cmake --build . --config %build_type% --target all -) else ( - cmake .. -G %CMAKE_GENERATOR% -A %arch% %TOOLSET_ARG% -DORCA_TOOLS=ON %SIG_FLAG% -DBUILD_TESTS=%BUILD_TESTS% -DCMAKE_BUILD_TYPE=%build_type% - cmake --build . --config %build_type% --target ALL_BUILD -- -m -) -@echo off -cd .. -call scripts/run_gettext.bat -cd %build_dir% -cmake --build . --target install --config %build_type% - -:done -@echo off -for /f "tokens=1-3 delims=:.," %%a in ("%_START_TIME: =0%") do set /a "_start_s=%%a*3600+%%b*60+%%c" -for /f "tokens=1-3 delims=:.," %%a in ("%TIME: =0%") do set /a "_end_s=%%a*3600+%%b*60+%%c" -set /a "_elapsed=_end_s - _start_s" -if %_elapsed% lss 0 set /a "_elapsed+=86400" -set /a "_hours=_elapsed / 3600" -set /a "_remainder=_elapsed - _hours * 3600" -set /a "_mins=_remainder / 60" -set /a "_secs=_remainder - _mins * 60" -echo. -echo Build completed in %_hours%h %_mins%m %_secs%s diff --git a/build_release_vs2022.bat b/build_release_vs2022.bat deleted file mode 100644 index 32f39745e3..0000000000 --- a/build_release_vs2022.bat +++ /dev/null @@ -1,80 +0,0 @@ -@REM OrcaSlicer build script for Windows -@echo off -set WP=%CD% - -@REM Pack deps -if "%1"=="pack" ( - setlocal ENABLEDELAYEDEXPANSION - cd %WP%/deps/build - for /f "tokens=2-4 delims=/ " %%a in ('date /t') do set build_date=%%c%%b%%a - echo packing deps: OrcaSlicer_dep_win64_!build_date!_vs2022.zip - - %WP%/tools/7z.exe a OrcaSlicer_dep_win64_!build_date!_vs2022.zip OrcaSlicer_dep - exit /b 0 -) - -set debug=OFF -set debuginfo=OFF -@REM Default target architecture to the host CPU arch; override with x64/arm64 arg. -set arch=x64 -if /I "%PROCESSOR_ARCHITECTURE%"=="ARM64" set arch=ARM64 -if /I "%PROCESSOR_ARCHITEW6432%"=="ARM64" set arch=ARM64 -if "%1"=="debug" set debug=ON -if "%2"=="debug" set debug=ON -if "%1"=="debuginfo" set debuginfo=ON -if "%2"=="debuginfo" set debuginfo=ON -if /I "%1"=="arm64" set arch=ARM64 -if /I "%2"=="arm64" set arch=ARM64 -if /I "%1"=="x64" set arch=x64 -if /I "%2"=="x64" set arch=x64 -if "%debug%"=="ON" ( - set build_type=Debug - set build_dir=build-dbg -) else ( - if "%debuginfo%"=="ON" ( - set build_type=RelWithDebInfo - set build_dir=build-dbginfo - ) else ( - set build_type=Release - set build_dir=build - ) -) -if "%arch%"=="ARM64" set build_dir=%build_dir%-arm64 -echo build type set to %build_type%, arch=%arch% - -setlocal DISABLEDELAYEDEXPANSION -cd deps -mkdir %build_dir% -cd %build_dir% -set "SIG_FLAG=" -if defined ORCA_UPDATER_SIG_KEY set "SIG_FLAG=-DORCA_UPDATER_SIG_KEY=%ORCA_UPDATER_SIG_KEY%" - -if "%1"=="slicer" ( - GOTO :slicer -) -echo "building deps.." - -echo on -REM Set minimum CMake policy to avoid <3.5 errors -set CMAKE_POLICY_VERSION_MINIMUM=3.5 -cmake ../ -G "Visual Studio 17 2022" -A %arch% -DCMAKE_BUILD_TYPE=%build_type% -cmake --build . --config %build_type% --target deps -- -m -@echo off - -if "%1"=="deps" exit /b 0 - -:slicer -echo "building Orca Slicer..." -cd %WP% -mkdir %build_dir% -cd %build_dir% - -echo on -set CMAKE_POLICY_VERSION_MINIMUM=3.5 -cmake .. -G "Visual Studio 17 2022" -A %arch% -DORCA_TOOLS=ON %SIG_FLAG% -DCMAKE_BUILD_TYPE=%build_type% -cmake --build . --config %build_type% --target ALL_BUILD -- -m -@echo off -cd .. -call scripts/run_gettext.bat -cd %build_dir% -cmake --build . --target install --config %build_type% diff --git a/tests/AGENTS.md b/tests/AGENTS.md index 50ea40cafc..e6f3bf864c 100644 --- a/tests/AGENTS.md +++ b/tests/AGENTS.md @@ -16,7 +16,7 @@ Rules for writing tests under `tests/`. [CATCH2.md](CATCH2.md) is the Catch2 ref Tests are off by default, so the build has to be told to include them. -- Windows: `build_release_vs.bat tests`, then `ctest --test-dir build/tests -C Release` +- Windows: `build_win.bat -ds --run-tests`, which builds the dependencies and the tests and runs them (`-l -x` for the clang-cl and Ninja build CI uses) - macOS: `./build_release_macos.sh -s -a arm64 -T`, which builds and runs them - Linux: `./build_linux.sh -t`, then `ctest --test-dir build/tests -C Release`