feat(tooling): Debug::Use says whether it added the library
A consumer adds its debug-only sources, the ones that import Crafter.Debug, under the same condition Use adds the library. Testing its own flag is not that condition: a build with the flag for a target other than native Linux gets neither the library nor the define, and its debug-only sources would then fail to import Crafter.Debug. Use now returns whether it added them, and the README shows the pattern. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5d34df7afb
commit
6da3b274a6
2 changed files with 19 additions and 12 deletions
12
README.md
12
README.md
|
|
@ -56,15 +56,17 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
|
|||
if (arg != "--debug-api") depArgs.emplace_back(arg);
|
||||
}
|
||||
// ...give depArgs to every other dependency too...
|
||||
Debug::Use(cfg, { .enabled = opts.Has("--debug-api"), .flag = "--debug-api",
|
||||
.define = "MYAPP_DEBUG_API", .args = depArgs });
|
||||
// ...
|
||||
const bool debugApi = Debug::Use(cfg, { .enabled = opts.Has("--debug-api"), .flag = "--debug-api",
|
||||
.define = "MYAPP_DEBUG_API", .args = depArgs });
|
||||
// ...your sources, plus the debug-only ones when debugApi...
|
||||
}
|
||||
```
|
||||
|
||||
**What `Use` does with the flag:**
|
||||
- **Flag on, native Linux target:** it adds the define and the library, from the checkout the pragma names, and writes `build/crafter-debug`.
|
||||
- **Otherwise:** it adds nothing, and release builds never link Crafter.Debug. Until a debug build has run, `build/crafter-debug` is a stub that says to build one.
|
||||
- **Flag on, native Linux target:** it adds the define and the library, from the checkout the pragma names, writes `build/crafter-debug`, and returns true.
|
||||
- **Otherwise:** it adds nothing and returns false, and release builds never link Crafter.Debug. Until a debug build has run, `build/crafter-debug` is a stub that says to build one.
|
||||
|
||||
Add your debug-only sources when `Use` returns true, not when the flag is on: a non-Linux target with the flag gets neither the library nor the define.
|
||||
|
||||
A dependency that two paths in the build graph share must get the **same arg list on both**. Otherwise crafter-build refuses the graph with "module … built twice". Build one `depArgs` and give it to every dependency, as above.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue