stale_build: strip comments/raw strings, handle UTF-8 BOM and backslashes, compare mtime_ns (STALE-BUILD-COMMENTS-BOM-AND-NS-MTIME) #1588

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

@⁠IlyassRS3 on GitHub · 2026-11-25 05:16 UTC · original
IlyassRS3:fix/stale-build-comments-bom-and-ns-mtime → main · +86 −9 · 2 files · 1 commits · open

Item: STALE-BUILD-COMMENTS-BOM-AND-NS-MTIME (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch tools/stale_build.py).

Summary

  • Strip C/C++ block comments (/* ... */), line comments (// ...), and raw string literals (R"(...)") before scanning for #include "..." so block-commented or raw-string includes are not followed, while /* note */ #include "real.h" and includes after strings containing "/*" are followed accurately.
  • Read source files with encoding="utf-8-sig" so a UTF-8 BOM (\ufeff) at the start of an MSVC-saved .cpp/.h does not cause the first-line #include to be missed.
  • Normalize backslash separators (#include "sub\nested.h") in _resolve_include() so Windows-style relative includes resolve on POSIX, and ignore absolute #include paths instead of discarding the search directory via os.path.join.
  • Compare os.stat(...).st_mtime_ns integers in newer_sources() instead of float64 os.path.getmtime() (which has ~238 ns ULP at modern Unix timestamps and misses 100 ns edits on NTFS/APFS/ext4), deduplicate via realpath/normcase, and sort returned relative paths deterministically.

Verification

  • python3 -W error -I tests/test_stale_build.py -v: 19/19 passed.
  • python3 -W error -I tests/test_stale_build_include_dirs.py -v: 11/11 passed.
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed.
  • python3 -I scripts/check_no_game_data.py tools/stale_build.py tests/test_stale_build.py: passed.
  • python3 -m compileall -q tools/stale_build.py tests/test_stale_build.py: passed.
  • Mutation check (running tests/test_stale_build.py against unpatched main:tools/stale_build.py): failures=4, errors=0 across all 4 new regression tests.

AI-assisted: yes
GPUs tested: none (CPU-only Python build helper; synthetic source trees only, no game data)

**@⁠IlyassRS3** on GitHub · 2026-11-25 05:16 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1588) `IlyassRS3:fix/stale-build-comments-bom-and-ns-mtime` → `main` · +86 −9 · 2 files · 1 commits · open Item: `STALE-BUILD-COMMENTS-BOM-AND-NS-MTIME` (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch `tools/stale_build.py`). ### Summary - Strip C/C++ block comments (`/* ... */`), line comments (`// ...`), and raw string literals (`R"(...)"`) before scanning for `#include "..."` so block-commented or raw-string includes are not followed, while `/* note */ #include "real.h"` and includes after strings containing `"/*"` are followed accurately. - Read source files with `encoding="utf-8-sig"` so a UTF-8 BOM (`\ufeff`) at the start of an MSVC-saved `.cpp`/`.h` does not cause the first-line `#include` to be missed. - Normalize backslash separators (`#include "sub\nested.h"`) in `_resolve_include()` so Windows-style relative includes resolve on POSIX, and ignore absolute `#include` paths instead of discarding the search directory via `os.path.join`. - Compare `os.stat(...).st_mtime_ns` integers in `newer_sources()` instead of float64 `os.path.getmtime()` (which has ~238 ns ULP at modern Unix timestamps and misses 100 ns edits on NTFS/APFS/ext4), deduplicate via realpath/normcase, and sort returned relative paths deterministically. ### Verification - `python3 -W error -I tests/test_stale_build.py -v`: 19/19 passed. - `python3 -W error -I tests/test_stale_build_include_dirs.py -v`: 11/11 passed. - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed. - `python3 -I scripts/check_no_game_data.py tools/stale_build.py tests/test_stale_build.py`: passed. - `python3 -m compileall -q tools/stale_build.py tests/test_stale_build.py`: passed. - Mutation check (running `tests/test_stale_build.py` against unpatched `main:tools/stale_build.py`): `failures=4, errors=0` across all 4 new regression tests. AI-assisted: yes GPUs tested: none (CPU-only Python build helper; synthetic source trees only, no game data)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:57:22 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 05:16 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 05:16 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1588#pullrequestreview-6052209066) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
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/1588/head:github-bot/gh-1588'
git switch 'github-bot/gh-1588'

Merge

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