build: add opt-in sccache arguments to dev.ps1 #1242

Merged
tedin7 merged 4 commits from upstream-pr/1249 into main 2026-11-24 06:04:20 +00:00
tedin7 commented 2026-11-24 05:27:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:27:54Z.


Change

AI-assisted. Adds an opt-in compiler cache to the Windows developer shell script.

tools/dev.ps1 does not call cmake itself, so it cannot add arguments to a configure command. Instead, with X2W_USE_SCCACHE=1 and sccache on PATH, it sets the global $X2wSccacheCmakeArgs to four definitions: CMAKE_C_COMPILER_LAUNCHER=sccache, CMAKE_CXX_COMPILER_LAUNCHER=sccache, CMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded (so /Zi does not block the cache) and CMAKE_POLICY_DEFAULT_CMP0141=NEW. The fourth is needed because the project declares cmake_minimum_required(3.21), where CMP0141 is OLD and CMake ignores the format variable. If the variable is 1 but sccache is missing, the script calls Write-Warning and continues without it. Otherwise the global is removed and nothing else changes. The presets set neither the launchers nor the debug format, so there is nothing to override.

Try it: $env:X2W_USE_SCCACHE = '1'; .\tools\dev.ps1; cmake --preset dev @X2wSccacheCmakeArgs

Files: tools/dev.ps1, tests/dev_ps1_sccache_check.py, docs/experiments.md, plus one step in .github/workflows/windows.yml (the pixel-binary job) so the check runs. This is outside the CPU targets.

Verification

  • python3 -B tests/dev_ps1_sccache_check.py <pwsh 7.7.0> on Linux: dev.ps1 sccache opt-in: ok (executed with pwsh). It parses the whole script with the PowerShell parser and runs the block for seven environments: unset (with and without sccache), 0, true, empty (no arguments, no warning), 1 with a stub sccache on PATH (exactly the four definitions), and 1 without it (no arguments, warning).
  • Negative control: the same test against origin/main's dev.ps1 exits 1 (dev.ps1 has no x2w-sccache block). Four mutated copies of the block (Z7 instead of Embedded, always on, no warning, missing policy) are each rejected.
  • Without pwsh the test falls back to checking the block text.
  • Not run: no Windows, MSVC or real sccache here. Only the argument list is checked; whether it speeds up a build is not.

Evidence and follow-up

The 3.51 s to 0.29 s (about 12x) figure is an outside maintainer's measurement on Windows Server 2025, MSVC 14.44, sccache 0.20.0. It is not mine and I did not repeat it. The Windows node should run X2W_USE_SCCACHE=1 and unset configures and compare.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6575309982 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:27:54Z. --- ## Change AI-assisted. Adds an opt-in compiler cache to the Windows developer shell script. `tools/dev.ps1` does not call `cmake` itself, so it cannot add arguments to a configure command. Instead, with `X2W_USE_SCCACHE=1` and `sccache` on `PATH`, it sets the global `$X2wSccacheCmakeArgs` to four definitions: `CMAKE_C_COMPILER_LAUNCHER=sccache`, `CMAKE_CXX_COMPILER_LAUNCHER=sccache`, `CMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded` (so `/Zi` does not block the cache) and `CMAKE_POLICY_DEFAULT_CMP0141=NEW`. The fourth is needed because the project declares `cmake_minimum_required(3.21)`, where CMP0141 is OLD and CMake ignores the format variable. If the variable is 1 but `sccache` is missing, the script calls `Write-Warning` and continues without it. Otherwise the global is removed and nothing else changes. The presets set neither the launchers nor the debug format, so there is nothing to override. Try it: `$env:X2W_USE_SCCACHE = '1'; .\tools\dev.ps1; cmake --preset dev @X2wSccacheCmakeArgs` Files: `tools/dev.ps1`, `tests/dev_ps1_sccache_check.py`, `docs/experiments.md`, plus one step in `.github/workflows/windows.yml` (the `pixel-binary` job) so the check runs. This is outside the CPU targets. ## Verification - `python3 -B tests/dev_ps1_sccache_check.py <pwsh 7.7.0>` on Linux: `dev.ps1 sccache opt-in: ok (executed with pwsh)`. It parses the whole script with the PowerShell parser and runs the block for seven environments: unset (with and without sccache), `0`, `true`, empty (no arguments, no warning), `1` with a stub `sccache` on PATH (exactly the four definitions), and `1` without it (no arguments, warning). - Negative control: the same test against `origin/main`'s `dev.ps1` exits 1 (`dev.ps1 has no x2w-sccache block`). Four mutated copies of the block (Z7 instead of Embedded, always on, no warning, missing policy) are each rejected. - Without `pwsh` the test falls back to checking the block text. - Not run: no Windows, MSVC or real sccache here. Only the argument list is checked; whether it speeds up a build is not. ## Evidence and follow-up The 3.51 s to 0.29 s (about 12x) figure is an outside maintainer's measurement on Windows Server 2025, MSVC 14.44, sccache 0.20.0. It is not mine and I did not repeat it. The Windows node should run `X2W_USE_SCCACHE=1` and unset configures and compare. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets.
upstream-sync closed this pull request 2026-11-24 06:47:17 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:47:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T05:39:21Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c51633e8da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6034245368 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#pullrequestreview-6034245368). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T05:39:21Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `c51633e8da` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
tedin7 commented 2026-11-24 06:47:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:40:52Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6034256386 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#pullrequestreview-6034256386). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:40:52Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-24 06:47:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:40:54Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6034256645 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#pullrequestreview-6034256645). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:40:54Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-24 06:47:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:41:28Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6034260838 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#pullrequestreview-6034260838). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:41:28Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-24 06:47:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:41:30Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6034261078 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#pullrequestreview-6034261078). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:41:30Z. **Review:** COMMENTED --- _No description provided._
chatgpt-codex-connector[bot commented 2026-11-24 06:47:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T05:46:34Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c39e2be7a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6034299094 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#pullrequestreview-6034299094). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T05:46:34Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `9c39e2be7a` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
tedin7 commented 2026-11-24 06:47:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:47:33Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6034307247 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#pullrequestreview-6034307247). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:47:33Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-24 06:47:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:47:53Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6034309678 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#pullrequestreview-6034309678). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:47:53Z. **Review:** COMMENTED --- _No description provided._
chatgpt-codex-connector[bot commented 2026-11-24 06:47:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T05:55:03Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 64b4a53bce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6034374207 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#pullrequestreview-6034374207). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T05:55:03Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `64b4a53bce` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
tedin7 commented 2026-11-24 06:47:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:56:54Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6034391095 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#pullrequestreview-6034391095). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:56:54Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-24 06:50:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:31:37Z.


Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 / 19.44.35230.0, AMD Ryzen 5 PRO 5650U) at HEAD c51633e8da582e050a264d5e94744d0798488f50:

  • Default mode (no X2W_USE_SCCACHE):
    • . .\tools\dev.ps1: $X2wSccacheCmakeArgs is unset (Test-Path variable:global:X2wSccacheCmakeArgs -> False).
    • cmake --preset dev (fresh CMakeCache.txt): configured cleanly; neither CMAKE_C_COMPILER_LAUNCHER nor CMAKE_CXX_COMPILER_LAUNCHER is set in CMakeCache.txt.
  • Opt-in mode (X2W_USE_SCCACHE=1 with sccache on PATH):
    • . .\tools\dev.ps1: $X2wSccacheCmakeArgs is set to -DCMAKE_C_COMPILER_LAUNCHER=sccache, -DCMAKE_CXX_COMPILER_LAUNCHER=sccache, -DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded, -DCMAKE_POLICY_DEFAULT_CMP0141=NEW.
    • cmake --preset dev @X2wSccacheCmakeArgs (fresh CMakeCache.txt): configured cleanly with all four entries recorded in CMakeCache.txt.
    • cmake --build --preset dev --target startup_stub_xg_xs -- -j 6: built xg_xs.dll (Compile requests: 1, Cache misses: 1, Cache errors: 0).
    • cmake --build --preset dev --target startup_stub_xg_xs --clean-first -- -j 6: clean rebuild hit the cache (Compile requests: 2, Cache hits: 1, Cache misses: 1, Cache errors: 0, Compilation failures: 0).
  • python -B tests/dev_ps1_sccache_check.py: dev.ps1 sccache opt-in: ok (text only) (exit code 0).
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123030541 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#issuecomment-7123030541). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:31:37Z. --- Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 / 19.44.35230.0, AMD Ryzen 5 PRO 5650U) at HEAD `c51633e8da582e050a264d5e94744d0798488f50`: - **Default mode (no `X2W_USE_SCCACHE`)**: - `. .\tools\dev.ps1`: `$X2wSccacheCmakeArgs` is unset (`Test-Path variable:global:X2wSccacheCmakeArgs` -> `False`). - `cmake --preset dev` (fresh `CMakeCache.txt`): configured cleanly; neither `CMAKE_C_COMPILER_LAUNCHER` nor `CMAKE_CXX_COMPILER_LAUNCHER` is set in `CMakeCache.txt`. - **Opt-in mode (`X2W_USE_SCCACHE=1` with `sccache` on `PATH`)**: - `. .\tools\dev.ps1`: `$X2wSccacheCmakeArgs` is set to `-DCMAKE_C_COMPILER_LAUNCHER=sccache`, `-DCMAKE_CXX_COMPILER_LAUNCHER=sccache`, `-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded`, `-DCMAKE_POLICY_DEFAULT_CMP0141=NEW`. - `cmake --preset dev @X2wSccacheCmakeArgs` (fresh `CMakeCache.txt`): configured cleanly with all four entries recorded in `CMakeCache.txt`. - `cmake --build --preset dev --target startup_stub_xg_xs -- -j 6`: built `xg_xs.dll` (`Compile requests: 1`, `Cache misses: 1`, `Cache errors: 0`). - `cmake --build --preset dev --target startup_stub_xg_xs --clean-first -- -j 6`: clean rebuild hit the cache (`Compile requests: 2`, `Cache hits: 1`, `Cache misses: 1`, `Cache errors: 0`, `Compilation failures: 0`). - `python -B tests/dev_ps1_sccache_check.py`: `dev.ps1 sccache opt-in: ok (text only)` (exit code 0).
tedin7 commented 2026-11-24 06:50:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:40:58Z.


AI-assisted update: with X2W_USE_SCCACHE=1 and sccache missing, dev.ps1 now passes empty compiler-launcher definitions so an earlier cached launcher is cleared; the test stub is a .cmd file on Windows. Behavior without the variable is unchanged. python3 -B tests/dev_ps1_sccache_check.py passes (text-only here, pwsh absent) and fails against the previous dev.ps1.

@codex review

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123175591 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#issuecomment-7123175591). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:40:58Z. --- AI-assisted update: with X2W_USE_SCCACHE=1 and sccache missing, dev.ps1 now passes empty compiler-launcher definitions so an earlier cached launcher is cleared; the test stub is a .cmd file on Windows. Behavior without the variable is unchanged. python3 -B tests/dev_ps1_sccache_check.py passes (text-only here, pwsh absent) and fails against the previous dev.ps1. @codex review
tedin7 commented 2026-11-24 06:50:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:41:32Z.


Fixed both P2 findings in 9c39e2be: the missing-sccache fallback now clears both launcher cache entries, and the test stub is a .cmd on Windows. @codex review

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123184441 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#issuecomment-7123184441). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:41:32Z. --- Fixed both P2 findings in 9c39e2be: the missing-sccache fallback now clears both launcher cache entries, and the test stub is a .cmd on Windows. @codex review
tedin7 commented 2026-11-24 06:50:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:47:35Z.


Fixed the SystemRoot lookup in 64b4a53b. @codex review

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123278894 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#issuecomment-7123278894). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:47:35Z. --- Fixed the SystemRoot lookup in 64b4a53b. @codex review
tedin7 commented 2026-11-24 06:50:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:47:55Z.


AI-assisted: the Windows KeyError in the sccache check is fixed in 64b4a53b (SystemRoot is read from os.environ). @codex review

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123284495 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#issuecomment-7123284495). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:47:55Z. --- AI-assisted: the Windows KeyError in the sccache check is fixed in 64b4a53b (SystemRoot is read from os.environ). @codex review
tedin7 commented 2026-11-24 06:50:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:51:21Z.


Verified on Windows Server 2025 (Build 26100, MSVC 14.44) at commit 64b4a53bce2e33d6b107f5ea9de78d2d5d170964:

  • python -B tests/dev_ps1_sccache_check.py powershell: dev.ps1 sccache opt-in: ok (executed with pwsh) (exit code 0)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123338428 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#issuecomment-7123338428). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:51:21Z. --- Verified on Windows Server 2025 (Build 26100, MSVC 14.44) at commit `64b4a53bce2e33d6b107f5ea9de78d2d5d170964`: - `python -B tests/dev_ps1_sccache_check.py powershell`: `dev.ps1 sccache opt-in: ok (executed with pwsh)` (exit code 0)
tedin7 commented 2026-11-24 06:50:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:56:56Z.


Addressed the isolated-PATH finding in 33234dd9. The test now keeps pwsh's own directory out of PATH. AI-assisted. @codex review

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123427053 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#issuecomment-7123427053). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:56:56Z. --- Addressed the isolated-PATH finding in 33234dd9. The test now keeps pwsh's own directory out of PATH. AI-assisted. @codex review
chatgpt-codex-connector[bot commented 2026-11-24 06:50:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T06:01:39Z.


Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 33234dd961

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123501138 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#issuecomment-7123501138). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T06:01:39Z. --- <!-- codex-review-receipt:v1 --> Codex Review: Didn't find any major issues. Chef's kiss. **Reviewed commit:** `33234dd961` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
chatgpt-codex-connector[bot commented 2026-11-24 06:50:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T05:30:49Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T06:01:40.132009Z 33234dd Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123017662 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#issuecomment-7123017662). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T05:30:49Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"33234dd9615aa72c9fcd13aac839151231af61ec","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T06:01:40.132009Z">2026-11-24T06:01:40.132009Z</relative-time> | `33234dd` | Manual request | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
chatgpt-codex-connector[bot commented 2026-11-24 06:50:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T05:39:21Z.

Code review location: tools/dev.ps1; line 53

@@ -33,3 +33,24 @@ if (Test-Path -LiteralPath (Join-Path $bin 'xbdepends.exe')) {
     $bin = (Resolve-Path -LiteralPath $bin).Path
     if ($bin -notin ($env:Path -split ';')) { $env:Path = "$bin;$env:Path" }
 }
+
+# Opt-in compiler cache. With X2W_USE_SCCACHE=1 and sccache on PATH, the global
+# $X2wSccacheCmakeArgs holds the extra configure arguments; pass them as
+# "cmake --preset dev @X2wSccacheCmakeArgs". Embedded debug information (/Z7)
+# lets sccache cache Debug objects; CMP0141 must be NEW for CMake to honor it.
+# Otherwise the variable is removed and every command line stays as it was.
+# x2w-sccache-begin
+Remove-Variable -Name X2wSccacheCmakeArgs -Scope Global -ErrorAction SilentlyContinue
+if ($env:X2W_USE_SCCACHE -eq '1') {
+    if (Get-Command sccache -CommandType Application -ErrorAction SilentlyContinue) {
+        $global:X2wSccacheCmakeArgs = @(
+            '-DCMAKE_C_COMPILER_LAUNCHER=sccache',
+            '-DCMAKE_CXX_COMPILER_LAUNCHER=sccache',
+            '-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded',
+            '-DCMAKE_POLICY_DEFAULT_CMP0141=NEW'
+        )
+    } else {
+        Write-Warning 'X2W_USE_SCCACHE=1 but sccache is not on PATH; configuring without a compiler launcher.'

P2 Badge Clear cached launchers in the missing-sccache fallback

If the preset was configured once with sccache and a later shell no longer has it on PATH, this fallback does not actually remove the launcher. CMakePresets.json:7 reuses out/build/dev, and cmake --help defines -D as “Create or update a cmake cache entry,” so CMAKE_CXX_COMPILER_LAUNCHER=sccache survives reconfiguration with the empty argument list. The next build therefore invokes the missing executable despite this warning promising otherwise. I reproduced that failure with CMake 3.28/Ninja in a minimal C++ project; clearing the launcher cache entries fixes it. Supply cache-clearing arguments or require an explicit cache reset in this fallback.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4675962601 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#discussion_r4675962601). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T05:39:21Z. **Code review location:** `tools/dev.ps1`; line 53 ~~~~diff @@ -33,3 +33,24 @@ if (Test-Path -LiteralPath (Join-Path $bin 'xbdepends.exe')) { $bin = (Resolve-Path -LiteralPath $bin).Path if ($bin -notin ($env:Path -split ';')) { $env:Path = "$bin;$env:Path" } } + +# Opt-in compiler cache. With X2W_USE_SCCACHE=1 and sccache on PATH, the global +# $X2wSccacheCmakeArgs holds the extra configure arguments; pass them as +# "cmake --preset dev @X2wSccacheCmakeArgs". Embedded debug information (/Z7) +# lets sccache cache Debug objects; CMP0141 must be NEW for CMake to honor it. +# Otherwise the variable is removed and every command line stays as it was. +# x2w-sccache-begin +Remove-Variable -Name X2wSccacheCmakeArgs -Scope Global -ErrorAction SilentlyContinue +if ($env:X2W_USE_SCCACHE -eq '1') { + if (Get-Command sccache -CommandType Application -ErrorAction SilentlyContinue) { + $global:X2wSccacheCmakeArgs = @( + '-DCMAKE_C_COMPILER_LAUNCHER=sccache', + '-DCMAKE_CXX_COMPILER_LAUNCHER=sccache', + '-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded', + '-DCMAKE_POLICY_DEFAULT_CMP0141=NEW' + ) + } else { + Write-Warning 'X2W_USE_SCCACHE=1 but sccache is not on PATH; configuring without a compiler launcher.' ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Clear cached launchers in the missing-sccache fallback** If the preset was configured once with sccache and a later shell no longer has it on PATH, this fallback does not actually remove the launcher. `CMakePresets.json:7` reuses `out/build/dev`, and `cmake --help` defines `-D` as “Create or update a cmake cache entry,” so `CMAKE_CXX_COMPILER_LAUNCHER=sccache` survives reconfiguration with the empty argument list. The next build therefore invokes the missing executable despite this warning promising otherwise. I reproduced that failure with CMake 3.28/Ninja in a minimal C++ project; clearing the launcher cache entries fixes it. Supply cache-clearing arguments or require an explicit cache reset in this fallback. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-24 06:50:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T05:39:21Z.

Code review location: tests/dev_ps1_sccache_check.py; line 41

@@ -0,0 +1,115 @@
+#!/usr/bin/env python3
+"""Check the opt-in sccache block of tools/dev.ps1.
+
+With pwsh on PATH the block is executed (and the whole script is parsed) for
+each environment; without it only the shape of the block is checked. Mutated
+copies of the block must fail the same checks.
+"""
+import os
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+from pathlib import Path
+
+DEV = Path(__file__).resolve().parent.parent / "tools" / "dev.ps1"
+EXPECTED = [
+    "-DCMAKE_C_COMPILER_LAUNCHER=sccache",
+    "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache",
+    "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded",
+    "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW",
+]
+RUNNER = "\nforeach ($a in $global:X2wSccacheCmakeArgs) { Write-Output ('ARG=' + $a) }\n"
+
+
+def block_of(text):
+    m = re.search(r"# x2w-sccache-begin\n(.*?)# x2w-sccache-end", text, re.S)
+    if not m:
+        sys.exit("dev.ps1 has no x2w-sccache block")
+    return m.group(1)
+
+
+def run_block(pwsh, block, env_value, with_sccache, work):
+    script = work / "block.ps1"
+    script.write_text(block + RUNNER, encoding="utf-8")
+    bindir = work / ("with" if with_sccache else "without")
+    bindir.mkdir(exist_ok=True)
+    if with_sccache:
+        fake = bindir / "sccache"
+        fake.write_text("#!/bin/sh\nexit 0\n")
+        fake.chmod(0o755)

P2 Badge Create a Windows-compatible sccache test stub

On the x64 Windows build environment documented in AGENTS.md, running the advertised Python check with pwsh installed creates an extensionless POSIX shell script for the “sccache present” cases. With normal Windows executable-extension settings, that file is not discoverable as an application, so the block's Get-Command sccache -CommandType Application takes the missing-cache branch and the ("1", True, ...) case fails even though dev.ps1 is correct. Create a Windows .cmd or .exe fixture on Windows rather than using the Unix shell stub unconditionally.

AGENTS.md reference: AGENTS.md:L38-L40

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4675962607 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#discussion_r4675962607). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T05:39:21Z. **Code review location:** `tests/dev_ps1_sccache_check.py`; line 41 ~~~~diff @@ -0,0 +1,115 @@ +#!/usr/bin/env python3 +"""Check the opt-in sccache block of tools/dev.ps1. + +With pwsh on PATH the block is executed (and the whole script is parsed) for +each environment; without it only the shape of the block is checked. Mutated +copies of the block must fail the same checks. +""" +import os +import re +import shutil +import subprocess +import sys +import tempfile +from pathlib import Path + +DEV = Path(__file__).resolve().parent.parent / "tools" / "dev.ps1" +EXPECTED = [ + "-DCMAKE_C_COMPILER_LAUNCHER=sccache", + "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache", + "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded", + "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW", +] +RUNNER = "\nforeach ($a in $global:X2wSccacheCmakeArgs) { Write-Output ('ARG=' + $a) }\n" + + +def block_of(text): + m = re.search(r"# x2w-sccache-begin\n(.*?)# x2w-sccache-end", text, re.S) + if not m: + sys.exit("dev.ps1 has no x2w-sccache block") + return m.group(1) + + +def run_block(pwsh, block, env_value, with_sccache, work): + script = work / "block.ps1" + script.write_text(block + RUNNER, encoding="utf-8") + bindir = work / ("with" if with_sccache else "without") + bindir.mkdir(exist_ok=True) + if with_sccache: + fake = bindir / "sccache" + fake.write_text("#!/bin/sh\nexit 0\n") + fake.chmod(0o755) ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Create a Windows-compatible sccache test stub** On the x64 Windows build environment documented in `AGENTS.md`, running the advertised Python check with `pwsh` installed creates an extensionless POSIX shell script for the “sccache present” cases. With normal Windows executable-extension settings, that file is not discoverable as an application, so the block's `Get-Command sccache -CommandType Application` takes the missing-cache branch and the `("1", True, ...)` case fails even though `dev.ps1` is correct. Create a Windows `.cmd` or `.exe` fixture on Windows rather than using the Unix shell stub unconditionally. AGENTS.md reference: [AGENTS.md:L38-L40](https://github.com/R0Y00/Xbox2Windows/blob/c51633e8da582e050a264d5e94744d0798488f50/AGENTS.md#L38-L40) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-24 06:50:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:40:52Z.

Code review location: tools/dev.ps1; line 53

@@ -33,3 +33,24 @@ if (Test-Path -LiteralPath (Join-Path $bin 'xbdepends.exe')) {
     $bin = (Resolve-Path -LiteralPath $bin).Path
     if ($bin -notin ($env:Path -split ';')) { $env:Path = "$bin;$env:Path" }
 }
+
+# Opt-in compiler cache. With X2W_USE_SCCACHE=1 and sccache on PATH, the global
+# $X2wSccacheCmakeArgs holds the extra configure arguments; pass them as
+# "cmake --preset dev @X2wSccacheCmakeArgs". Embedded debug information (/Z7)
+# lets sccache cache Debug objects; CMP0141 must be NEW for CMake to honor it.
+# Otherwise the variable is removed and every command line stays as it was.
+# x2w-sccache-begin
+Remove-Variable -Name X2wSccacheCmakeArgs -Scope Global -ErrorAction SilentlyContinue
+if ($env:X2W_USE_SCCACHE -eq '1') {
+    if (Get-Command sccache -CommandType Application -ErrorAction SilentlyContinue) {
+        $global:X2wSccacheCmakeArgs = @(
+            '-DCMAKE_C_COMPILER_LAUNCHER=sccache',
+            '-DCMAKE_CXX_COMPILER_LAUNCHER=sccache',
+            '-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded',
+            '-DCMAKE_POLICY_DEFAULT_CMP0141=NEW'
+        )
+    } else {
+        Write-Warning 'X2W_USE_SCCACHE=1 but sccache is not on PATH; configuring without a compiler launcher.'

Fixed in 9c39e2be

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4675971943 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#discussion_r4675971943). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:40:52Z. **Code review location:** `tools/dev.ps1`; line 53 ~~~~diff @@ -33,3 +33,24 @@ if (Test-Path -LiteralPath (Join-Path $bin 'xbdepends.exe')) { $bin = (Resolve-Path -LiteralPath $bin).Path if ($bin -notin ($env:Path -split ';')) { $env:Path = "$bin;$env:Path" } } + +# Opt-in compiler cache. With X2W_USE_SCCACHE=1 and sccache on PATH, the global +# $X2wSccacheCmakeArgs holds the extra configure arguments; pass them as +# "cmake --preset dev @X2wSccacheCmakeArgs". Embedded debug information (/Z7) +# lets sccache cache Debug objects; CMP0141 must be NEW for CMake to honor it. +# Otherwise the variable is removed and every command line stays as it was. +# x2w-sccache-begin +Remove-Variable -Name X2wSccacheCmakeArgs -Scope Global -ErrorAction SilentlyContinue +if ($env:X2W_USE_SCCACHE -eq '1') { + if (Get-Command sccache -CommandType Application -ErrorAction SilentlyContinue) { + $global:X2wSccacheCmakeArgs = @( + '-DCMAKE_C_COMPILER_LAUNCHER=sccache', + '-DCMAKE_CXX_COMPILER_LAUNCHER=sccache', + '-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded', + '-DCMAKE_POLICY_DEFAULT_CMP0141=NEW' + ) + } else { + Write-Warning 'X2W_USE_SCCACHE=1 but sccache is not on PATH; configuring without a compiler launcher.' ~~~~ --- Fixed in 9c39e2be
tedin7 commented 2026-11-24 06:50:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:40:54Z.

Code review location: tests/dev_ps1_sccache_check.py; line 41

@@ -0,0 +1,115 @@
+#!/usr/bin/env python3
+"""Check the opt-in sccache block of tools/dev.ps1.
+
+With pwsh on PATH the block is executed (and the whole script is parsed) for
+each environment; without it only the shape of the block is checked. Mutated
+copies of the block must fail the same checks.
+"""
+import os
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+from pathlib import Path
+
+DEV = Path(__file__).resolve().parent.parent / "tools" / "dev.ps1"
+EXPECTED = [
+    "-DCMAKE_C_COMPILER_LAUNCHER=sccache",
+    "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache",
+    "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded",
+    "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW",
+]
+RUNNER = "\nforeach ($a in $global:X2wSccacheCmakeArgs) { Write-Output ('ARG=' + $a) }\n"
+
+
+def block_of(text):
+    m = re.search(r"# x2w-sccache-begin\n(.*?)# x2w-sccache-end", text, re.S)
+    if not m:
+        sys.exit("dev.ps1 has no x2w-sccache block")
+    return m.group(1)
+
+
+def run_block(pwsh, block, env_value, with_sccache, work):
+    script = work / "block.ps1"
+    script.write_text(block + RUNNER, encoding="utf-8")
+    bindir = work / ("with" if with_sccache else "without")
+    bindir.mkdir(exist_ok=True)
+    if with_sccache:
+        fake = bindir / "sccache"
+        fake.write_text("#!/bin/sh\nexit 0\n")
+        fake.chmod(0o755)

Fixed in 9c39e2be

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4675972162 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#discussion_r4675972162). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:40:54Z. **Code review location:** `tests/dev_ps1_sccache_check.py`; line 41 ~~~~diff @@ -0,0 +1,115 @@ +#!/usr/bin/env python3 +"""Check the opt-in sccache block of tools/dev.ps1. + +With pwsh on PATH the block is executed (and the whole script is parsed) for +each environment; without it only the shape of the block is checked. Mutated +copies of the block must fail the same checks. +""" +import os +import re +import shutil +import subprocess +import sys +import tempfile +from pathlib import Path + +DEV = Path(__file__).resolve().parent.parent / "tools" / "dev.ps1" +EXPECTED = [ + "-DCMAKE_C_COMPILER_LAUNCHER=sccache", + "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache", + "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded", + "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW", +] +RUNNER = "\nforeach ($a in $global:X2wSccacheCmakeArgs) { Write-Output ('ARG=' + $a) }\n" + + +def block_of(text): + m = re.search(r"# x2w-sccache-begin\n(.*?)# x2w-sccache-end", text, re.S) + if not m: + sys.exit("dev.ps1 has no x2w-sccache block") + return m.group(1) + + +def run_block(pwsh, block, env_value, with_sccache, work): + script = work / "block.ps1" + script.write_text(block + RUNNER, encoding="utf-8") + bindir = work / ("with" if with_sccache else "without") + bindir.mkdir(exist_ok=True) + if with_sccache: + fake = bindir / "sccache" + fake.write_text("#!/bin/sh\nexit 0\n") + fake.chmod(0o755) ~~~~ --- Fixed in 9c39e2be
tedin7 commented 2026-11-24 06:50:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:41:28Z.

Code review location: tools/dev.ps1; line 53

@@ -33,3 +33,24 @@ if (Test-Path -LiteralPath (Join-Path $bin 'xbdepends.exe')) {
     $bin = (Resolve-Path -LiteralPath $bin).Path
     if ($bin -notin ($env:Path -split ';')) { $env:Path = "$bin;$env:Path" }
 }
+
+# Opt-in compiler cache. With X2W_USE_SCCACHE=1 and sccache on PATH, the global
+# $X2wSccacheCmakeArgs holds the extra configure arguments; pass them as
+# "cmake --preset dev @X2wSccacheCmakeArgs". Embedded debug information (/Z7)
+# lets sccache cache Debug objects; CMP0141 must be NEW for CMake to honor it.
+# Otherwise the variable is removed and every command line stays as it was.
+# x2w-sccache-begin
+Remove-Variable -Name X2wSccacheCmakeArgs -Scope Global -ErrorAction SilentlyContinue
+if ($env:X2W_USE_SCCACHE -eq '1') {
+    if (Get-Command sccache -CommandType Application -ErrorAction SilentlyContinue) {
+        $global:X2wSccacheCmakeArgs = @(
+            '-DCMAKE_C_COMPILER_LAUNCHER=sccache',
+            '-DCMAKE_CXX_COMPILER_LAUNCHER=sccache',
+            '-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded',
+            '-DCMAKE_POLICY_DEFAULT_CMP0141=NEW'
+        )
+    } else {
+        Write-Warning 'X2W_USE_SCCACHE=1 but sccache is not on PATH; configuring without a compiler launcher.'

Fixed in 9c39e2be

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4675975800 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#discussion_r4675975800). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:41:28Z. **Code review location:** `tools/dev.ps1`; line 53 ~~~~diff @@ -33,3 +33,24 @@ if (Test-Path -LiteralPath (Join-Path $bin 'xbdepends.exe')) { $bin = (Resolve-Path -LiteralPath $bin).Path if ($bin -notin ($env:Path -split ';')) { $env:Path = "$bin;$env:Path" } } + +# Opt-in compiler cache. With X2W_USE_SCCACHE=1 and sccache on PATH, the global +# $X2wSccacheCmakeArgs holds the extra configure arguments; pass them as +# "cmake --preset dev @X2wSccacheCmakeArgs". Embedded debug information (/Z7) +# lets sccache cache Debug objects; CMP0141 must be NEW for CMake to honor it. +# Otherwise the variable is removed and every command line stays as it was. +# x2w-sccache-begin +Remove-Variable -Name X2wSccacheCmakeArgs -Scope Global -ErrorAction SilentlyContinue +if ($env:X2W_USE_SCCACHE -eq '1') { + if (Get-Command sccache -CommandType Application -ErrorAction SilentlyContinue) { + $global:X2wSccacheCmakeArgs = @( + '-DCMAKE_C_COMPILER_LAUNCHER=sccache', + '-DCMAKE_CXX_COMPILER_LAUNCHER=sccache', + '-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded', + '-DCMAKE_POLICY_DEFAULT_CMP0141=NEW' + ) + } else { + Write-Warning 'X2W_USE_SCCACHE=1 but sccache is not on PATH; configuring without a compiler launcher.' ~~~~ --- Fixed in 9c39e2be
tedin7 commented 2026-11-24 06:50:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:41:30Z.

Code review location: tests/dev_ps1_sccache_check.py; line 41

@@ -0,0 +1,115 @@
+#!/usr/bin/env python3
+"""Check the opt-in sccache block of tools/dev.ps1.
+
+With pwsh on PATH the block is executed (and the whole script is parsed) for
+each environment; without it only the shape of the block is checked. Mutated
+copies of the block must fail the same checks.
+"""
+import os
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+from pathlib import Path
+
+DEV = Path(__file__).resolve().parent.parent / "tools" / "dev.ps1"
+EXPECTED = [
+    "-DCMAKE_C_COMPILER_LAUNCHER=sccache",
+    "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache",
+    "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded",
+    "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW",
+]
+RUNNER = "\nforeach ($a in $global:X2wSccacheCmakeArgs) { Write-Output ('ARG=' + $a) }\n"
+
+
+def block_of(text):
+    m = re.search(r"# x2w-sccache-begin\n(.*?)# x2w-sccache-end", text, re.S)
+    if not m:
+        sys.exit("dev.ps1 has no x2w-sccache block")
+    return m.group(1)
+
+
+def run_block(pwsh, block, env_value, with_sccache, work):
+    script = work / "block.ps1"
+    script.write_text(block + RUNNER, encoding="utf-8")
+    bindir = work / ("with" if with_sccache else "without")
+    bindir.mkdir(exist_ok=True)
+    if with_sccache:
+        fake = bindir / "sccache"
+        fake.write_text("#!/bin/sh\nexit 0\n")
+        fake.chmod(0o755)

Fixed in 9c39e2be

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4675976021 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#discussion_r4675976021). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:41:30Z. **Code review location:** `tests/dev_ps1_sccache_check.py`; line 41 ~~~~diff @@ -0,0 +1,115 @@ +#!/usr/bin/env python3 +"""Check the opt-in sccache block of tools/dev.ps1. + +With pwsh on PATH the block is executed (and the whole script is parsed) for +each environment; without it only the shape of the block is checked. Mutated +copies of the block must fail the same checks. +""" +import os +import re +import shutil +import subprocess +import sys +import tempfile +from pathlib import Path + +DEV = Path(__file__).resolve().parent.parent / "tools" / "dev.ps1" +EXPECTED = [ + "-DCMAKE_C_COMPILER_LAUNCHER=sccache", + "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache", + "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded", + "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW", +] +RUNNER = "\nforeach ($a in $global:X2wSccacheCmakeArgs) { Write-Output ('ARG=' + $a) }\n" + + +def block_of(text): + m = re.search(r"# x2w-sccache-begin\n(.*?)# x2w-sccache-end", text, re.S) + if not m: + sys.exit("dev.ps1 has no x2w-sccache block") + return m.group(1) + + +def run_block(pwsh, block, env_value, with_sccache, work): + script = work / "block.ps1" + script.write_text(block + RUNNER, encoding="utf-8") + bindir = work / ("with" if with_sccache else "without") + bindir.mkdir(exist_ok=True) + if with_sccache: + fake = bindir / "sccache" + fake.write_text("#!/bin/sh\nexit 0\n") + fake.chmod(0o755) ~~~~ --- Fixed in 9c39e2be
chatgpt-codex-connector[bot commented 2026-11-24 06:50:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T05:46:34Z.

Code review location: tests/dev_ps1_sccache_check.py; line 49

@@ -0,0 +1,122 @@
+#!/usr/bin/env python3
+"""Check the opt-in sccache block of tools/dev.ps1.
+
+With pwsh on PATH the block is executed (and the whole script is parsed) for
+each environment; without it only the shape of the block is checked. Mutated
+copies of the block must fail the same checks.
+"""
+import os
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+from pathlib import Path
+
+DEV = Path(__file__).resolve().parent.parent / "tools" / "dev.ps1"
+EXPECTED = [
+    "-DCMAKE_C_COMPILER_LAUNCHER=sccache",
+    "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache",
+    "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded",
+    "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW",
+]
+CLEARED = ["-DCMAKE_C_COMPILER_LAUNCHER=", "-DCMAKE_CXX_COMPILER_LAUNCHER="]
+RUNNER = "\nforeach ($a in $global:X2wSccacheCmakeArgs) { Write-Output ('ARG=' + $a) }\n"
+
+
+def block_of(text):
+    m = re.search(r"# x2w-sccache-begin\n(.*?)# x2w-sccache-end", text, re.S)
+    if not m:
+        sys.exit("dev.ps1 has no x2w-sccache block")
+    return m.group(1)
+
+
+def run_block(pwsh, block, env_value, with_sccache, work):
+    script = work / "block.ps1"
+    script.write_text(block + RUNNER, encoding="utf-8")
+    bindir = work / ("with" if with_sccache else "without")
+    bindir.mkdir(exist_ok=True)
+    if with_sccache:
+        if os.name == "nt":  # found through PATHEXT
+            (bindir / "sccache.cmd").write_text("@exit /b 0\r\n")
+        else:
+            fake = bindir / "sccache"
+            fake.write_text("#!/bin/sh\nexit 0\n")
+            fake.chmod(0o755)
+    env = {k: v for k, v in os.environ.items() if k != "X2W_USE_SCCACHE"}
+    # Only the stub directory and pwsh itself: a real sccache must not leak in.
+    env["PATH"] = os.pathsep.join([str(bindir), os.path.dirname(pwsh)] +
+                                  ([os.path.join(env["SystemRoot"], "System32")] if os.name == "nt" else []))

P2 Badge Use the uppercase key when reading SystemRoot from env

When this check runs on Windows with pwsh installed, os.environ yields uppercase keys, and the comprehension above copies them into a normal, case-sensitive dictionary. Consequently, env contains SYSTEMROOT, not SystemRoot, and this lookup raises KeyError before the first PowerShell block executes. The new .cmd fixture therefore cannot be exercised on the documented Windows platform. Read the value from os.environ["SystemRoot"] or use env["SYSTEMROOT"].

AGENTS.md reference: AGENTS.md:L38-L40

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4676008282 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#discussion_r4676008282). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T05:46:34Z. **Code review location:** `tests/dev_ps1_sccache_check.py`; line 49 ~~~~diff @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 +"""Check the opt-in sccache block of tools/dev.ps1. + +With pwsh on PATH the block is executed (and the whole script is parsed) for +each environment; without it only the shape of the block is checked. Mutated +copies of the block must fail the same checks. +""" +import os +import re +import shutil +import subprocess +import sys +import tempfile +from pathlib import Path + +DEV = Path(__file__).resolve().parent.parent / "tools" / "dev.ps1" +EXPECTED = [ + "-DCMAKE_C_COMPILER_LAUNCHER=sccache", + "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache", + "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded", + "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW", +] +CLEARED = ["-DCMAKE_C_COMPILER_LAUNCHER=", "-DCMAKE_CXX_COMPILER_LAUNCHER="] +RUNNER = "\nforeach ($a in $global:X2wSccacheCmakeArgs) { Write-Output ('ARG=' + $a) }\n" + + +def block_of(text): + m = re.search(r"# x2w-sccache-begin\n(.*?)# x2w-sccache-end", text, re.S) + if not m: + sys.exit("dev.ps1 has no x2w-sccache block") + return m.group(1) + + +def run_block(pwsh, block, env_value, with_sccache, work): + script = work / "block.ps1" + script.write_text(block + RUNNER, encoding="utf-8") + bindir = work / ("with" if with_sccache else "without") + bindir.mkdir(exist_ok=True) + if with_sccache: + if os.name == "nt": # found through PATHEXT + (bindir / "sccache.cmd").write_text("@exit /b 0\r\n") + else: + fake = bindir / "sccache" + fake.write_text("#!/bin/sh\nexit 0\n") + fake.chmod(0o755) + env = {k: v for k, v in os.environ.items() if k != "X2W_USE_SCCACHE"} + # Only the stub directory and pwsh itself: a real sccache must not leak in. + env["PATH"] = os.pathsep.join([str(bindir), os.path.dirname(pwsh)] + + ([os.path.join(env["SystemRoot"], "System32")] if os.name == "nt" else [])) ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Use the uppercase key when reading SystemRoot from env** When this check runs on Windows with `pwsh` installed, `os.environ` yields uppercase keys, and the comprehension above copies them into a normal, case-sensitive dictionary. Consequently, `env` contains `SYSTEMROOT`, not `SystemRoot`, and this lookup raises `KeyError` before the first PowerShell block executes. The new `.cmd` fixture therefore cannot be exercised on the documented Windows platform. Read the value from `os.environ["SystemRoot"]` or use `env["SYSTEMROOT"]`. AGENTS.md reference: [AGENTS.md:L38-L40](https://github.com/R0Y00/Xbox2Windows/blob/9c39e2be7a33d4f0c901ac4b80c6106e68f6d700/AGENTS.md#L38-L40) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-24 06:50:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:47:33Z.

Code review location: tests/dev_ps1_sccache_check.py; line 49

@@ -0,0 +1,122 @@
+#!/usr/bin/env python3
+"""Check the opt-in sccache block of tools/dev.ps1.
+
+With pwsh on PATH the block is executed (and the whole script is parsed) for
+each environment; without it only the shape of the block is checked. Mutated
+copies of the block must fail the same checks.
+"""
+import os
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+from pathlib import Path
+
+DEV = Path(__file__).resolve().parent.parent / "tools" / "dev.ps1"
+EXPECTED = [
+    "-DCMAKE_C_COMPILER_LAUNCHER=sccache",
+    "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache",
+    "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded",
+    "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW",
+]
+CLEARED = ["-DCMAKE_C_COMPILER_LAUNCHER=", "-DCMAKE_CXX_COMPILER_LAUNCHER="]
+RUNNER = "\nforeach ($a in $global:X2wSccacheCmakeArgs) { Write-Output ('ARG=' + $a) }\n"
+
+
+def block_of(text):
+    m = re.search(r"# x2w-sccache-begin\n(.*?)# x2w-sccache-end", text, re.S)
+    if not m:
+        sys.exit("dev.ps1 has no x2w-sccache block")
+    return m.group(1)
+
+
+def run_block(pwsh, block, env_value, with_sccache, work):
+    script = work / "block.ps1"
+    script.write_text(block + RUNNER, encoding="utf-8")
+    bindir = work / ("with" if with_sccache else "without")
+    bindir.mkdir(exist_ok=True)
+    if with_sccache:
+        if os.name == "nt":  # found through PATHEXT
+            (bindir / "sccache.cmd").write_text("@exit /b 0\r\n")
+        else:
+            fake = bindir / "sccache"
+            fake.write_text("#!/bin/sh\nexit 0\n")
+            fake.chmod(0o755)
+    env = {k: v for k, v in os.environ.items() if k != "X2W_USE_SCCACHE"}
+    # Only the stub directory and pwsh itself: a real sccache must not leak in.
+    env["PATH"] = os.pathsep.join([str(bindir), os.path.dirname(pwsh)] +
+                                  ([os.path.join(env["SystemRoot"], "System32")] if os.name == "nt" else []))

Fixed in 64b4a53b

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4676015122 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#discussion_r4676015122). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:47:33Z. **Code review location:** `tests/dev_ps1_sccache_check.py`; line 49 ~~~~diff @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 +"""Check the opt-in sccache block of tools/dev.ps1. + +With pwsh on PATH the block is executed (and the whole script is parsed) for +each environment; without it only the shape of the block is checked. Mutated +copies of the block must fail the same checks. +""" +import os +import re +import shutil +import subprocess +import sys +import tempfile +from pathlib import Path + +DEV = Path(__file__).resolve().parent.parent / "tools" / "dev.ps1" +EXPECTED = [ + "-DCMAKE_C_COMPILER_LAUNCHER=sccache", + "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache", + "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded", + "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW", +] +CLEARED = ["-DCMAKE_C_COMPILER_LAUNCHER=", "-DCMAKE_CXX_COMPILER_LAUNCHER="] +RUNNER = "\nforeach ($a in $global:X2wSccacheCmakeArgs) { Write-Output ('ARG=' + $a) }\n" + + +def block_of(text): + m = re.search(r"# x2w-sccache-begin\n(.*?)# x2w-sccache-end", text, re.S) + if not m: + sys.exit("dev.ps1 has no x2w-sccache block") + return m.group(1) + + +def run_block(pwsh, block, env_value, with_sccache, work): + script = work / "block.ps1" + script.write_text(block + RUNNER, encoding="utf-8") + bindir = work / ("with" if with_sccache else "without") + bindir.mkdir(exist_ok=True) + if with_sccache: + if os.name == "nt": # found through PATHEXT + (bindir / "sccache.cmd").write_text("@exit /b 0\r\n") + else: + fake = bindir / "sccache" + fake.write_text("#!/bin/sh\nexit 0\n") + fake.chmod(0o755) + env = {k: v for k, v in os.environ.items() if k != "X2W_USE_SCCACHE"} + # Only the stub directory and pwsh itself: a real sccache must not leak in. + env["PATH"] = os.pathsep.join([str(bindir), os.path.dirname(pwsh)] + + ([os.path.join(env["SystemRoot"], "System32")] if os.name == "nt" else [])) ~~~~ --- Fixed in 64b4a53b
tedin7 commented 2026-11-24 06:50:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:47:53Z.

Code review location: tests/dev_ps1_sccache_check.py; line 49

@@ -0,0 +1,122 @@
+#!/usr/bin/env python3
+"""Check the opt-in sccache block of tools/dev.ps1.
+
+With pwsh on PATH the block is executed (and the whole script is parsed) for
+each environment; without it only the shape of the block is checked. Mutated
+copies of the block must fail the same checks.
+"""
+import os
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+from pathlib import Path
+
+DEV = Path(__file__).resolve().parent.parent / "tools" / "dev.ps1"
+EXPECTED = [
+    "-DCMAKE_C_COMPILER_LAUNCHER=sccache",
+    "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache",
+    "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded",
+    "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW",
+]
+CLEARED = ["-DCMAKE_C_COMPILER_LAUNCHER=", "-DCMAKE_CXX_COMPILER_LAUNCHER="]
+RUNNER = "\nforeach ($a in $global:X2wSccacheCmakeArgs) { Write-Output ('ARG=' + $a) }\n"
+
+
+def block_of(text):
+    m = re.search(r"# x2w-sccache-begin\n(.*?)# x2w-sccache-end", text, re.S)
+    if not m:
+        sys.exit("dev.ps1 has no x2w-sccache block")
+    return m.group(1)
+
+
+def run_block(pwsh, block, env_value, with_sccache, work):
+    script = work / "block.ps1"
+    script.write_text(block + RUNNER, encoding="utf-8")
+    bindir = work / ("with" if with_sccache else "without")
+    bindir.mkdir(exist_ok=True)
+    if with_sccache:
+        if os.name == "nt":  # found through PATHEXT
+            (bindir / "sccache.cmd").write_text("@exit /b 0\r\n")
+        else:
+            fake = bindir / "sccache"
+            fake.write_text("#!/bin/sh\nexit 0\n")
+            fake.chmod(0o755)
+    env = {k: v for k, v in os.environ.items() if k != "X2W_USE_SCCACHE"}
+    # Only the stub directory and pwsh itself: a real sccache must not leak in.
+    env["PATH"] = os.pathsep.join([str(bindir), os.path.dirname(pwsh)] +
+                                  ([os.path.join(env["SystemRoot"], "System32")] if os.name == "nt" else []))

Fixed in 64b4a53b

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4676017175 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#discussion_r4676017175). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:47:53Z. **Code review location:** `tests/dev_ps1_sccache_check.py`; line 49 ~~~~diff @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 +"""Check the opt-in sccache block of tools/dev.ps1. + +With pwsh on PATH the block is executed (and the whole script is parsed) for +each environment; without it only the shape of the block is checked. Mutated +copies of the block must fail the same checks. +""" +import os +import re +import shutil +import subprocess +import sys +import tempfile +from pathlib import Path + +DEV = Path(__file__).resolve().parent.parent / "tools" / "dev.ps1" +EXPECTED = [ + "-DCMAKE_C_COMPILER_LAUNCHER=sccache", + "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache", + "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded", + "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW", +] +CLEARED = ["-DCMAKE_C_COMPILER_LAUNCHER=", "-DCMAKE_CXX_COMPILER_LAUNCHER="] +RUNNER = "\nforeach ($a in $global:X2wSccacheCmakeArgs) { Write-Output ('ARG=' + $a) }\n" + + +def block_of(text): + m = re.search(r"# x2w-sccache-begin\n(.*?)# x2w-sccache-end", text, re.S) + if not m: + sys.exit("dev.ps1 has no x2w-sccache block") + return m.group(1) + + +def run_block(pwsh, block, env_value, with_sccache, work): + script = work / "block.ps1" + script.write_text(block + RUNNER, encoding="utf-8") + bindir = work / ("with" if with_sccache else "without") + bindir.mkdir(exist_ok=True) + if with_sccache: + if os.name == "nt": # found through PATHEXT + (bindir / "sccache.cmd").write_text("@exit /b 0\r\n") + else: + fake = bindir / "sccache" + fake.write_text("#!/bin/sh\nexit 0\n") + fake.chmod(0o755) + env = {k: v for k, v in os.environ.items() if k != "X2W_USE_SCCACHE"} + # Only the stub directory and pwsh itself: a real sccache must not leak in. + env["PATH"] = os.pathsep.join([str(bindir), os.path.dirname(pwsh)] + + ([os.path.join(env["SystemRoot"], "System32")] if os.name == "nt" else [])) ~~~~ --- Fixed in 64b4a53b
chatgpt-codex-connector[bot commented 2026-11-24 06:50:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T05:55:03Z.

Code review location: tests/dev_ps1_sccache_check.py; line 48

@@ -0,0 +1,122 @@
+#!/usr/bin/env python3
+"""Check the opt-in sccache block of tools/dev.ps1.
+
+With pwsh on PATH the block is executed (and the whole script is parsed) for
+each environment; without it only the shape of the block is checked. Mutated
+copies of the block must fail the same checks.
+"""
+import os
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+from pathlib import Path
+
+DEV = Path(__file__).resolve().parent.parent / "tools" / "dev.ps1"
+EXPECTED = [
+    "-DCMAKE_C_COMPILER_LAUNCHER=sccache",
+    "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache",
+    "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded",
+    "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW",
+]
+CLEARED = ["-DCMAKE_C_COMPILER_LAUNCHER=", "-DCMAKE_CXX_COMPILER_LAUNCHER="]
+RUNNER = "\nforeach ($a in $global:X2wSccacheCmakeArgs) { Write-Output ('ARG=' + $a) }\n"
+
+
+def block_of(text):
+    m = re.search(r"# x2w-sccache-begin\n(.*?)# x2w-sccache-end", text, re.S)
+    if not m:
+        sys.exit("dev.ps1 has no x2w-sccache block")
+    return m.group(1)
+
+
+def run_block(pwsh, block, env_value, with_sccache, work):
+    script = work / "block.ps1"
+    script.write_text(block + RUNNER, encoding="utf-8")
+    bindir = work / ("with" if with_sccache else "without")
+    bindir.mkdir(exist_ok=True)
+    if with_sccache:
+        if os.name == "nt":  # found through PATHEXT
+            (bindir / "sccache.cmd").write_text("@exit /b 0\r\n")
+        else:
+            fake = bindir / "sccache"
+            fake.write_text("#!/bin/sh\nexit 0\n")
+            fake.chmod(0o755)
+    env = {k: v for k, v in os.environ.items() if k != "X2W_USE_SCCACHE"}
+    # Only the stub directory and pwsh itself: a real sccache must not leak in.
+    env["PATH"] = os.pathsep.join([str(bindir), os.path.dirname(pwsh)] +

P2 Badge Keep sibling executables out of the isolated test PATH

If pwsh and sccache live in the same bin directory, such as /usr/bin or a Homebrew prefix, this exposes the real sccache even when with_sccache=False. Consequently, the ("1", False, CLEARED, True) case takes the sccache-present branch, returns the four definitions without a warning, and fails despite the developer script being correct. Since the subprocess already invokes PowerShell by its resolved path, omit its directory from the isolated PATH or otherwise prevent sibling executables from leaking into the missing-tool case.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4676072124 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#discussion_r4676072124). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T05:55:03Z. **Code review location:** `tests/dev_ps1_sccache_check.py`; line 48 ~~~~diff @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 +"""Check the opt-in sccache block of tools/dev.ps1. + +With pwsh on PATH the block is executed (and the whole script is parsed) for +each environment; without it only the shape of the block is checked. Mutated +copies of the block must fail the same checks. +""" +import os +import re +import shutil +import subprocess +import sys +import tempfile +from pathlib import Path + +DEV = Path(__file__).resolve().parent.parent / "tools" / "dev.ps1" +EXPECTED = [ + "-DCMAKE_C_COMPILER_LAUNCHER=sccache", + "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache", + "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded", + "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW", +] +CLEARED = ["-DCMAKE_C_COMPILER_LAUNCHER=", "-DCMAKE_CXX_COMPILER_LAUNCHER="] +RUNNER = "\nforeach ($a in $global:X2wSccacheCmakeArgs) { Write-Output ('ARG=' + $a) }\n" + + +def block_of(text): + m = re.search(r"# x2w-sccache-begin\n(.*?)# x2w-sccache-end", text, re.S) + if not m: + sys.exit("dev.ps1 has no x2w-sccache block") + return m.group(1) + + +def run_block(pwsh, block, env_value, with_sccache, work): + script = work / "block.ps1" + script.write_text(block + RUNNER, encoding="utf-8") + bindir = work / ("with" if with_sccache else "without") + bindir.mkdir(exist_ok=True) + if with_sccache: + if os.name == "nt": # found through PATHEXT + (bindir / "sccache.cmd").write_text("@exit /b 0\r\n") + else: + fake = bindir / "sccache" + fake.write_text("#!/bin/sh\nexit 0\n") + fake.chmod(0o755) + env = {k: v for k, v in os.environ.items() if k != "X2W_USE_SCCACHE"} + # Only the stub directory and pwsh itself: a real sccache must not leak in. + env["PATH"] = os.pathsep.join([str(bindir), os.path.dirname(pwsh)] + ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Keep sibling executables out of the isolated test PATH** If `pwsh` and `sccache` live in the same bin directory, such as `/usr/bin` or a Homebrew prefix, this exposes the real `sccache` even when `with_sccache=False`. Consequently, the `("1", False, CLEARED, True)` case takes the sccache-present branch, returns the four definitions without a warning, and fails despite the developer script being correct. Since the subprocess already invokes PowerShell by its resolved path, omit its directory from the isolated `PATH` or otherwise prevent sibling executables from leaking into the missing-tool case. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-24 06:50:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:56:54Z.

Code review location: tests/dev_ps1_sccache_check.py; line 48

@@ -0,0 +1,122 @@
+#!/usr/bin/env python3
+"""Check the opt-in sccache block of tools/dev.ps1.
+
+With pwsh on PATH the block is executed (and the whole script is parsed) for
+each environment; without it only the shape of the block is checked. Mutated
+copies of the block must fail the same checks.
+"""
+import os
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+from pathlib import Path
+
+DEV = Path(__file__).resolve().parent.parent / "tools" / "dev.ps1"
+EXPECTED = [
+    "-DCMAKE_C_COMPILER_LAUNCHER=sccache",
+    "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache",
+    "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded",
+    "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW",
+]
+CLEARED = ["-DCMAKE_C_COMPILER_LAUNCHER=", "-DCMAKE_CXX_COMPILER_LAUNCHER="]
+RUNNER = "\nforeach ($a in $global:X2wSccacheCmakeArgs) { Write-Output ('ARG=' + $a) }\n"
+
+
+def block_of(text):
+    m = re.search(r"# x2w-sccache-begin\n(.*?)# x2w-sccache-end", text, re.S)
+    if not m:
+        sys.exit("dev.ps1 has no x2w-sccache block")
+    return m.group(1)
+
+
+def run_block(pwsh, block, env_value, with_sccache, work):
+    script = work / "block.ps1"
+    script.write_text(block + RUNNER, encoding="utf-8")
+    bindir = work / ("with" if with_sccache else "without")
+    bindir.mkdir(exist_ok=True)
+    if with_sccache:
+        if os.name == "nt":  # found through PATHEXT
+            (bindir / "sccache.cmd").write_text("@exit /b 0\r\n")
+        else:
+            fake = bindir / "sccache"
+            fake.write_text("#!/bin/sh\nexit 0\n")
+            fake.chmod(0o755)
+    env = {k: v for k, v in os.environ.items() if k != "X2W_USE_SCCACHE"}
+    # Only the stub directory and pwsh itself: a real sccache must not leak in.
+    env["PATH"] = os.pathsep.join([str(bindir), os.path.dirname(pwsh)] +

Fixed in 33234dd9: the isolated PATH now holds only the stub directory (plus System32 on Windows); pwsh is started by absolute path.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4676086875 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1249#discussion_r4676086875). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:56:54Z. **Code review location:** `tests/dev_ps1_sccache_check.py`; line 48 ~~~~diff @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 +"""Check the opt-in sccache block of tools/dev.ps1. + +With pwsh on PATH the block is executed (and the whole script is parsed) for +each environment; without it only the shape of the block is checked. Mutated +copies of the block must fail the same checks. +""" +import os +import re +import shutil +import subprocess +import sys +import tempfile +from pathlib import Path + +DEV = Path(__file__).resolve().parent.parent / "tools" / "dev.ps1" +EXPECTED = [ + "-DCMAKE_C_COMPILER_LAUNCHER=sccache", + "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache", + "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded", + "-DCMAKE_POLICY_DEFAULT_CMP0141=NEW", +] +CLEARED = ["-DCMAKE_C_COMPILER_LAUNCHER=", "-DCMAKE_CXX_COMPILER_LAUNCHER="] +RUNNER = "\nforeach ($a in $global:X2wSccacheCmakeArgs) { Write-Output ('ARG=' + $a) }\n" + + +def block_of(text): + m = re.search(r"# x2w-sccache-begin\n(.*?)# x2w-sccache-end", text, re.S) + if not m: + sys.exit("dev.ps1 has no x2w-sccache block") + return m.group(1) + + +def run_block(pwsh, block, env_value, with_sccache, work): + script = work / "block.ps1" + script.write_text(block + RUNNER, encoding="utf-8") + bindir = work / ("with" if with_sccache else "without") + bindir.mkdir(exist_ok=True) + if with_sccache: + if os.name == "nt": # found through PATHEXT + (bindir / "sccache.cmd").write_text("@exit /b 0\r\n") + else: + fake = bindir / "sccache" + fake.write_text("#!/bin/sh\nexit 0\n") + fake.chmod(0o755) + env = {k: v for k, v in os.environ.items() if k != "X2W_USE_SCCACHE"} + # Only the stub directory and pwsh itself: a real sccache must not leak in. + env["PATH"] = os.pathsep.join([str(bindir), os.path.dirname(pwsh)] + ~~~~ --- Fixed in 33234dd9: the isolated PATH now holds only the stub directory (plus System32 on Windows); pwsh is started by absolute path.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1242
No description provided.