{"author":"Viktor Szakats","author_email":"commit@vsz.me","author_time":1755420382,"commit_time":1755518195,"committer":"Viktor Szakats","committer_email":"commit@vsz.me","hash":"a477789c4344d8231265d739f37787d026086333","message":"GHA/windows: switch from MSBuild to Ninja for MSVC jobs running tests\n\nThis patch fixes flakiness caused by MSBuild scanning the runtests.pl\noutput for regex patterns. When finding a hit, it returns an error code\nto cmake, making the build test CI step fail. This happens rarely after\nan earlier mitigation tweaking outputs, but, as expected, it did not\nresolve it completely.\n\nMSBuild doesn't have an option to disable this behavior. To fix, this\npatch migrates the two affected jobs from MSBuild to Ninja. To align\nwith existing multi-config logic, it uses the `Ninja Multi-Config`\ngenerator, which hasn't been tested before in CI.\n\nSwitching to Ninja was not trivial. Visual Studio to this day relies on\nan MS-DOS batch file stored at an unstable location (containing spaces\nand parenthesis), to initialize its environment. Without this env,\n`cl.exe` is unable to find its own components. GHA does not initialize\nit (even if it did, it could only default to a single specific target).\nCMake helps with this when using a Visual Studio generator, but doesn't\nwhen using Ninja. (On local machines the VS installer adds a couple\nof Start menu items for launching pre-configured command prompts.)\n\nRef: https://learn.microsoft.com/cpp/build/building-on-the-command-line\n\nThe MS-DOS batches don't integrate well with CI envs and even less so\nwith shell scripts. To avoid it, this patch uses manual configuration.\nAlso without using environment variables, to make it easy to use and\neasy to debug and trace in logs. Configuring Visual Studio is relatively\nstable across releases and hasn't changed a whole lot in the last 2\ndecades, but still may need more maintenance compared to llvm, or pretty\nmuch any other toolchain out there. On the upside, it allows to manually\nselect compiler version, SDK version, cross-combinations, and allows\nchoosing clang-cl. The configuration aims to find the latest of these\nautomatically.\n\nSome traps that had to be avoided:\n- need to switch to MS-DOS short names to avoid spaces in the VS\n  component paths.\n- need to switch to forward slashes to avoid confusing downstream tools\n  with backslashes.\n- need to pass either MSYS2 for Windows-style path depending on setting.\n- need to use a trick to retrieve the oddly named `ProgramFiles(x86)`\n  Windows env from shell script.\n- need to match VS version (2022) and edition (Enterprise), found on GHA\n  runners.\n- need to pass the CMake generator via env so that the space in the name\n  doesn't trip the shell when passed via a variable.\n- trash and unexpected dirs when detecting SDK/toolchain versions.\n- need to pass `-external:W0` to the C compiler to avoid MSVC warning:\n  `D9007: '/external:I' requires '/external:W'; option ignored`\n- using cmake options only, to make it run without relying on envs and\n  work out-of-the-box when running subsequent cmake sessions.\n- some others discovered while making work clang-cl locally in\n  cross-builds.\n\nNinja also improves performance in most cases (though wasn't a goal\nhere). After this patch configure is significantly faster (1.5-2x),\nbuilds are a tiny bit faster, except examples which was twice as fast\nwith MSBuild. Disk space use is 10% lower.\n\nMSBuild builds remain tested in AppVeyor CI and the UWP job.\n\nBefore: https://github.com/curl/curl/actions/runs/17025737223/job/48260856051\nAfter: https://github.com/curl/curl/actions/runs/17027981486/job/48266133301\n\nFixes:\n```\n  === Start of file stderr1635\n     % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                    Dload  Upload   Total   Spent    Left  Speed\n\n     0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0\n   100     4  100     4    0     0    449      0 --:--:-- --:--:-- --:--:--   500\ncurl : (22) The requested URL returned error : 429 [D:\\a\\curl\\curl\\bld\\tests\\test-ci.vcxproj]\nCUSTOMBUILD : warning : Problem : HTTP error. Will retry in 1 second. 1 retry left. [D:\\a\\curl\\curl\\bld\\tests\\test-ci.vcxproj]\n[...]\nC:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\MSBuild\\Microsoft\\VC\\v170\\Microsoft.CppCommon.targets(254,5): error MSB8066: Custom build for 'D:\\a\\curl\\curl\\bld\\CMakeFiles\\621f80ddbb0fa48179f056ca77842ff0\\test-ci.rule;D:\\a\\curl\\curl\\tests\\CMakeLists.txt' exited with code -1. [D:\\a\\curl\\curl\\bld\\tests\\test-ci.vcxproj]\nError: Process completed with exit code 1.\n```\nRef: https://github.com/curl/curl/actions/runs/16966304797/job/48091058271?pr=18287#step:13:3471\n\nBug: https://github.com/curl/curl/discussions/14854#discussioncomment-14104166\nRef: a19bd4321030c6ea18e3bbec411dfd49961a1f71 #18307\nFollow-up to 9463769f2e2dba9eeff554a88e5df5195d2c774b #16583\n\nCloses #18301\n","parents":["7dafe10db2f0b104317e6640670b4cd973a4e3da"],"tree_hash":"12837511519c937368be391de46fa795dfc21c41"}