Let the environment say where the library lives - #36
Merged
Conversation
ARCHETYPE_INCLUDE is a colon-separated search path in the shape PATH taught everyone to expect. It is consulted after --include, so an explicit flag still wins, and after the source file's own directory, which primarySource has always pushed to the front -- so nothing changes for a game sitting beside the library it includes. The motivating case is a packaged interpreter. The snap knows perfectly well where standard.arch ended up inside its own squashfs; without this the player has to know too, and type it. A package can now set the variable once and have `archetype --source=mygame.arch` simply work. Set but empty counts as unset, the way it usually does. An empty entry *within* a list still means the current directory, the way it does in PATH, so --include=a: is unchanged. Splitting the view in place rather than through an istringstream means the only strings allocated are the ones actually kept, which addSearchPath takes by value and moves. The SHOW(path) trace went with the block it lived in. It was guarded by `#if NDEBUG` and so was only ever meant for a debug build, but the build this project documents sets no CMAKE_BUILD_TYPE, CMake therefore passes no -DNDEBUG, and the trace printed on every compile anyone has ever run. With that call gone the macro had no users left, so it is gone as well. Verified that a game compiled by way of the variable is byte-for-byte the game compiled by way of the flag. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019g4fqvhoV5MtLJJXM7uFLZ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ARCHETYPE_INCLUDEis a colon-separated search path, in the shapePATHtaughteveryone to expect. It is consulted after
--include, so an explicit flagstill wins, and after the source file's own directory, which
primarySourcehasalways pushed to the front — so nothing changes for a game sitting beside the
library it includes.
The motivating case is a packaged interpreter. The snap in #35 knows perfectly
well where
standard.archended up inside its own squashfs; without this theplayer has to know too, and type
--include=/snap/archetype/current/usr/share/archetype/games. A package can setthe variable once and let
archetype --source=mygame.archsimply work.Two edge cases, both deliberate:
usually does.
does in
PATH. So--include=a:is unchanged.The split is done on the
string_viewin place rather than through anistringstream, so the only strings allocated are the ones actually kept — whichaddSearchPathtakes by value and moves.The debug trace
SHOW(path)is gone, and the answer to "wasn't that debug-only?" is yes, andthat was not enough. It was guarded by
#if NDEBUG, butcmake -S src -B build— the build this project documents — sets no
CMAKE_BUILD_TYPE, so CMake passesno
-DNDEBUGand the guard never fired. It has printedpath == gameson everycompile anyone has run. With that call removed the macro had no users left in
main.cc, so it went too. (TestExpression.ccdefines its own, untouched.)Test plan
./build/archetype --test— 17 suites, 0 failures.mygame.archin a temp dir, library ingames/), which isthe case the snap cares about:
Cannot open source file "standard"ARCHETYPE_INCLUDEonly → compilesARCHETYPE_INCLUDE=""→ fails, i.e. treated as unsetARCHETYPE_INCLUDE=/nonexistent:games→ compiles, second entry found--includepresent with a bogus env value → compiles, flag wins.acxproduced via the variable is byte-identical to the one producedvia the flag, and to the in-tree compile: 69,784 bytes.
Once this lands, #35 should gain an
environment:stanza setting the variable,and lose the long path from its description.
🤖 Generated with Claude Code
https://claude.ai/code/session_019g4fqvhoV5MtLJJXM7uFLZ