8 Commits
Author SHA1 Message Date
Brad King 4daf96a1eb Tests/RunCMake/Codegen: Fix rebuild cases on make tools with 1s resolution
Revise a test from commit 36fcfb3e01 (Tests/RunCMake/Codegen: Extend
coverage, 2026-10-25, v4.5.0-rc2~4^2) to pass more reliably on such
`make` tools.
2026-11-02 11:17:46 -05:00
Tyler Yankee 36fcfb3e01 Tests/RunCMake/Codegen: Extend coverage
Cover additional cases pertaining to add_dependencies:

* dependencies followed through an intermediate target,
* a dependency's non-CODEGEN commands must not run,
* dependencies of EXCLUDE_FROM_ALL targets are not followed,
* a dependency in an EXCLUDE_FROM_ALL subdirectory is reached.

Also verify that codegen re-runs a command only when its inputs change.
2026-10-25 19:52:43 -04:00
Tyler Yankee fe95f96096 Ninja Multi-Config: Fix cross-config codegen target suffix
The target that runs codegen for all cross-configs was named
`codegen:codegen`. Name it `codegen:all` to follow the documented
`<target>:all` convention, as the `all` target already does.

Amends commit 197cb419d1 (add_custom_command: Add CODEGEN support,
2024-05-27, v3.31.0-rc1~394^2).
2026-10-25 19:52:43 -04:00
Tyler Yankee f54117c6b1 Ninja: Evaluate generator expressions in CODEGEN outputs
Codegen is supported for Ninja Multi-Config, so CODEGEN should support
generator expressions.
2026-10-25 19:52:43 -04:00
Tyler Yankee 902ec85438 Makefile, Ninja: Fix no-op codegen builds with no CODEGEN
Ninja: Since commit 2d85779126 (Ninja: Account for explicit target
dependencies via CODEGEN, 2026-09-15, v4.5.0-rc1~162^2), a directory's
codegen phony depends on the full build of every add_dependencies
target (which caused their non-CODEGEN commands to run). Instead,
depend only on those targets' CODEGEN outputs, and follow their own
codegen dependencies in turn.

Makefiles: Since commit 197cb419d1 (add_custom_command: Add CODEGEN
support, 2024-05-27, v3.31.0-rc1~394^2), a target's `<target>/codegen`
rule used to depend on `<dep>/all` for every add_dependencies target,
which fully built them. Instead, depend on `<dep>/codegen`, except when
the target has CODEGEN commands of its own, in which case it should
still depend on `<dep>/all` as the commands may need the dependency's
outputs.

Shape up the prior `no-codegen` test case, which wasn't verifying much
of anything.

Fixes: #28205
2026-10-25 19:52:43 -04:00
Tyler Yankee 2d85779126 Ninja: Account for explicit target dependencies via CODEGEN
When a "normal" target (e.g., an executable) depends on a custom target
that is not part of `all`, and that custom target owns the output of a
custom command marked `CODEGEN`, an explicit `add_dependencies` from
the normal to custom target must be incorporated in `codegen`.

Amends commit 197cb419d1 (add_custom_command: Add CODEGEN support,
2024-05-27, v3.31.0-rc1~394^2), which already incorporated such logic
in the Unix Makefile generator, but was not tested nor implemented for
Ninja.

Fixes: #28092
2026-09-15 10:34:09 -04:00
Brad King 5ce1ca607f Ninja: Add missing top-level codegen dependencies on per-directory codegen
In commit 197cb419d1 (add_custom_command: Add CODEGEN support,
2024-05-27, v3.31.0-rc1~394^2) we accidentally left out the global
`codegen` target's dependencies on the per-directory `codegen` targets.
Add them for parity with the `all` target.

Fixes: #26517
2024-12-10 11:46:31 -05:00
Juan Ramos 197cb419d1 add_custom_command: Add CODEGEN support
By specifying CODEGEN as an argument to add_custom_command the
custom command will be added to a codegen build target.

The intent is to provide a convenient way for users to get
their generated files without having to build the whole project.

This can be helpful for code analysis tools which can be useful
for IDEs and CI.
2024-07-01 12:02:49 -04:00