engine: wire --define=NAME=VALUE into {def.NAME} - #60
Merged
Conversation
ResolveDefines collects --define globals into a name->value map (last
wins; VALUE may contain '='). run.cc builds it once and passes it on the
EvalContext and the --template RenderContext; the gated -exec carries it
through too. So {def.NAME} resolves in --format/--template and -exec.
Completes #53 (the fields side landed in PR #58). run_test drives
--define end-to-end through --template, including last-wins.
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.
Summary
Completes #53 (the fields side landed in #58). Wires the
--define=NAME=VALUEglobal to the{def.NAME}namespace:ResolveDefinescollects--defineglobals into a name→value map — last wins, and VALUE may itself contain=(split at the first one).run.ccbuilds it once and passes it on theEvalContextand the--templateRenderContext; the gated-execcarries it through (render_ctx.defines = ctx.defines).{def.NAME}resolves in--format/--templateand (gated)-exec.Example:
xff --define=tag=v2 . --template='{def.tag} {name}'.Test plan
run_test.DefinePopulatesDefNamespace:--define=label=old --define=label=new --template={def.label}:{name}→new:a.txt(proves wiring + last-wins).fields_test.DefNamespaceReadsDefines(from fields: add {def.NAME} namespace reading a defines map #58) covers the field lookup.bazel test //...(default) and--config=clang --config=asan.