scripts/build_llvm_mc.ps1: validate Version, normalize -Temp, harden VS/tool fallback and literal install #1871

Open
github-bot wants to merge 1 commit from github-bot/gh-1871 into main AGit
Owner

@⁠kirigayakazima on GitHub · 2026-11-25 13:46 UTC · original
kirigayakazima:fix/build-llvm-mc-safety → main · +191 −7 · 2 files · 1 commits · open

Claimed in the coordination issue as: BUILD-LLVM-MC-REL-TEMP-VS-AND-TOOL-FALLBACK-SAFETY (#1608)

What and why

  • Validate -Version up front in scripts/build_llvm_mc.ps1 so empty strings, whitespace, control characters, or % fail before cloning or running prerequisites.
  • Normalize $Temp = $fullTemp after resolving via PowerShell provider paths so _build.cmd, $src, $out, and [System.IO.File]::WriteAllText never drift to [Environment]::CurrentDirectory when a relative -Temp is passed.
  • Guard missing vswhere.exe and missing vcvars64.bat with explicit actionable errors (Test-Path -LiteralPath ... -PathType Leaf) instead of CommandNotFoundException or opaque call failures.
  • Resolve VS-bundled and PATH cmake/ninja independently so one tool from Visual Studio can pair cleanly with the other on PATH.
  • Pass [System.Text.UTF8Encoding]::new($false) explicitly when writing probe.txt, and switch Copy-Item to -LiteralPath ... -Destination $final so bracketed paths work reliably. Preserve CRLF line endings (PS1_CRLF=177, PS1_LF_ONLY=0).
  • Add regression tests in tests/test_build_llvm_mc_prereqs.py without disturbing any anchors sliced by the existing 5 build_llvm_mc tests.

Tested

  • Patched:
    • python -I tests/test_build_llvm_mc_prereqs.py -v -> Ran 5 tests in 3.172s (OK)
    • python -I tests/test_build_llvm_mc_batch.py -v -> Ran 1 test in 0.933s (OK)
    • python -I tests/test_build_llvm_mc_cleanup.py -v -> Ran 1 test in 0.310s (OK)
    • python -I tests/test_llvm_install_destination.py -v -> Ran 1 test in 1.470s (OK)
    • python -I tests/test_llvm_install_path.py -v -> Ran 3 tests in 1.578s (OK)
    • python -I tests/test_llvm_source_version.py -v -> Ran 6 tests in 5.677s (OK)
  • Baseline check (upstream/main 5e95fa2f with tests/test_build_llvm_mc_prereqs.py copied into detached worktree): Ran 5 tests in 3.120s (FAILED (failures=8, errors=1)).
  • Repo gates: PS1_CRLF=177 PS1_LF_ONLY=0, python -I tests/test_ci_registration.py (Ran 16 tests in 5.989s, OK), python -I tests/test_text_write_line_endings.py (Ran 3 tests in 14.043s, OK), python -I scripts/check_no_game_data.py (exit 0), python -I -m compileall -q (exit 0), git diff --check (exit 0).

GPUs tested: n/a (PowerShell prerequisite validation, relative-path normalization, tool fallback, and literal install tests)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.
**@⁠kirigayakazima** on GitHub · 2026-11-25 13:46 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1871) `kirigayakazima:fix/build-llvm-mc-safety` → `main` · +191 −7 · 2 files · 1 commits · open Claimed in the coordination issue as: BUILD-LLVM-MC-REL-TEMP-VS-AND-TOOL-FALLBACK-SAFETY (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why - Validate `-Version` up front in `scripts/build_llvm_mc.ps1` so empty strings, whitespace, control characters, or `%` fail before cloning or running prerequisites. - Normalize `$Temp = $fullTemp` after resolving via PowerShell provider paths so `_build.cmd`, `$src`, `$out`, and `[System.IO.File]::WriteAllText` never drift to `[Environment]::CurrentDirectory` when a relative `-Temp` is passed. - Guard missing `vswhere.exe` and missing `vcvars64.bat` with explicit actionable errors (`Test-Path -LiteralPath ... -PathType Leaf`) instead of `CommandNotFoundException` or opaque `call` failures. - Resolve VS-bundled and `PATH` `cmake`/`ninja` independently so one tool from Visual Studio can pair cleanly with the other on `PATH`. - Pass `[System.Text.UTF8Encoding]::new($false)` explicitly when writing `probe.txt`, and switch `Copy-Item` to `-LiteralPath ... -Destination $final` so bracketed paths work reliably. Preserve CRLF line endings (`PS1_CRLF=177, PS1_LF_ONLY=0`). - Add regression tests in `tests/test_build_llvm_mc_prereqs.py` without disturbing any anchors sliced by the existing 5 `build_llvm_mc` tests. ### Tested - Patched: - `python -I tests/test_build_llvm_mc_prereqs.py -v` -> `Ran 5 tests in 3.172s` (`OK`) - `python -I tests/test_build_llvm_mc_batch.py -v` -> `Ran 1 test in 0.933s` (`OK`) - `python -I tests/test_build_llvm_mc_cleanup.py -v` -> `Ran 1 test in 0.310s` (`OK`) - `python -I tests/test_llvm_install_destination.py -v` -> `Ran 1 test in 1.470s` (`OK`) - `python -I tests/test_llvm_install_path.py -v` -> `Ran 3 tests in 1.578s` (`OK`) - `python -I tests/test_llvm_source_version.py -v` -> `Ran 6 tests in 5.677s` (`OK`) - Baseline check (`upstream/main` `5e95fa2f` with `tests/test_build_llvm_mc_prereqs.py` copied into detached worktree): `Ran 5 tests in 3.120s` (`FAILED (failures=8, errors=1)`). - Repo gates: `PS1_CRLF=177 PS1_LF_ONLY=0`, `python -I tests/test_ci_registration.py` (`Ran 16 tests in 5.989s`, `OK`), `python -I tests/test_text_write_line_endings.py` (`Ran 3 tests in 14.043s`, `OK`), `python -I scripts/check_no_game_data.py` (exit 0), `python -I -m compileall -q` (exit 0), `git diff --check` (exit 0). GPUs tested: n/a (PowerShell prerequisite validation, relative-path normalization, tool fallback, and literal install tests) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:09:26 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1871/head:github-bot/gh-1871'
git switch 'github-bot/gh-1871'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1871'
git switch 'github-bot/gh-1871'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1871'
git switch 'github-bot/gh-1871'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1871'
git switch 'main'
git merge --squash 'github-bot/gh-1871'
git switch 'main'
git merge --ff-only 'github-bot/gh-1871'
git switch 'main'
git merge 'github-bot/gh-1871'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.