fix(build): build.cmd builds its own tree from any directory #17

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

@⁠landovg on GitHub · 2026-11-27 18:41 UTC · original
landovg:fix/build-cmd-script-dir → main · +3 −1 · 1 files · 1 commits · open

build.cmd parses its options with shift, and each shift also moves %0. After any option (--test, Debug…), pushd "%~dp0" resolves against the current directory rather than the script's folder. So D:\src\xvalkyrie\build.cmd --test, run from another directory, configures and builds that directory instead of the repository.

This change captures the script's folder in ROOT before the options are parsed, and pushdes there.

Tested (Windows 11, VS 2022 Build Tools 17.14, CMake 4.4.4):

  • build.cmd --test from an empty directory outside the tree builds build\win of the repository, and CTest passes 2/2. The empty directory stays empty.
  • Before the change, the same command started configuring the current directory.

🤖 Generated with Claude Code

**@⁠landovg** on GitHub · 2026-11-27 18:41 UTC · [original](https://github.com/sammwyy/xvalkyrie/pull/17) `landovg:fix/build-cmd-script-dir` → `main` · +3 −1 · 1 files · 1 commits · open `build.cmd` parses its options with `shift`, and each `shift` also moves `%0`. After any option (`--test`, `Debug`…), `pushd "%~dp0"` resolves against the current directory rather than the script's folder. So `D:\src\xvalkyrie\build.cmd --test`, run from another directory, configures and builds that directory instead of the repository. This change captures the script's folder in `ROOT` before the options are parsed, and `pushd`es there. **Tested** (Windows 11, VS 2022 Build Tools 17.14, CMake 4.4.4): - `build.cmd --test` from an empty directory outside the tree builds `build\win` of the repository, and CTest passes 2/2. The empty directory stays empty. - Before the change, the same command started configuring the current directory. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Each `shift` that consumes an option also shifts %0, so after `--test` (or any
other option) `pushd "%~dp0"` resolved against the current directory instead of
the script's folder. Run from anywhere but the repository root, the script
configured and built whatever directory it was started in.

Capture the script's folder before the options are parsed and pushd there.

Tested: `build.cmd --test` from an empty directory outside the tree builds
build\win of the repository and passes CTest; the empty directory stays empty.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 18:45:27 +00:00
This pull request can be merged automatically.
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/17/head:github-bot/gh-17'
git switch 'github-bot/gh-17'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-17'
git switch 'github-bot/gh-17'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-17'
git switch 'github-bot/gh-17'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-17'
git switch 'main'
git merge --squash 'github-bot/gh-17'
git switch 'main'
git merge --ff-only 'github-bot/gh-17'
git switch 'main'
git merge 'github-bot/gh-17'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/sammwyy--xvalkyrie!17
No description provided.