feat(cross): add --define CLI override for build-system -D defines#107
Merged
Conversation
Add a repeatable --define/-D KEY=VALUE flag to `emb cross` that overrides a build-system define for the embedder configure. The override is parsed up front (usage error before any download) and baked into the CrossTarget itself via withDefineOverrides, so it wins over every manifest source — cross.defines, any backends entry, and anything an extends chain merged in. Because the target is amended, everything downstream sees the final values: buildKey (so the build-dir key differs and caches never go stale), the backend matrix, the no-backend build, and --dry-run. The override rides on the shared `defines` map, which both the CMake (`cmake -S`) and Meson (`meson setup`) paths emit as -Dkey=value, so it is generator-agnostic; cmakeArgs is deliberately left untouched. Values reach the build tool only as discrete argv elements (Process.start with runInShell: false), so there is no shell interpolation. parseDefineOverrides splits on the first = only (a value may contain =), allows an empty value (CMake unset-style), and rejects a missing = or empty key with a FormatException. Tests: unit coverage for withDefineOverrides/parseDefineOverrides, builder-level tests proving the override reaches the CMake and Meson configure argv (and every backend), and CLI --dry-run cases for the glued -DKEY=VALUE form, empty values, embedded =, and last-wins. Signed-off-by: Joel Winarske <joel.winarske@linux.com>
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.
What
Adds a repeatable
--define/-D KEY=VALUEflag toemb crossthat overrides a build-system-Ddefine for the embedder configure. The override wins over every manifest source —cross.defines, anybackendsentry, and anything anextendschain merged in.How
-Dis a usage error before any download.CrossTargetviawithDefineOverrides, so everything downstream sees the final values:buildKey(the build-dir key differs, so caches never go stale), the backend matrix, the no-backend build, and--dry-run.definesmap, which both the CMake (cmake -S) and Meson (meson setup) paths emit as-Dkey=value— so it is generator-agnostic.cmakeArgs(CMake-only) is deliberately left untouched.Safety
Process.startwithrunInShell: false) — no shell interpolation.parseDefineOverridessplits on the first=only (a value may contain=), allows an empty value (CMake unset-style), and rejects a missing=or empty key with aFormatException.Tests
withDefineOverrides/parseDefineOverrides(multiple overrides, verbatim spaces, empty value, generator preserved, no mutation).--dry-runcases: Meson embedder, glued-DKEY=VALUEform, empty value, embedded=, and repeated-key last-wins.Full suite green (549 tests); every new line is covered including both error branches.