Skip to content

Conversation

@lhearachel
Copy link

Overview

This adds support to specify additional dependencies during invocation of generator.process, which will be merged with the list of dependencies for the generator itself to produce a full dependency mapping for each output target. This can be useful for creating a single generator for processing a given type of input file where some cases may require additional targets to be built before some subset of them can be used.

Motivation

Consider the following illustration:

generated_constants = custom_target(...)
gen = generator(
    script_sh,
    arguments: [ '@INPUT@', '@OUTPUT@' ],
    depends: generated_constants,
    output: '@BASENAME@',
    depfile: '@BASENAME@.d',
)

custom_target(
    'some_binary_file.bin',
    output: 'some_binary_file.bin',
    input: gen.process(files(...))
    command: [ ... ],
)

more_constants = custom_target(...)
custom_target(
    'another_binary_file.bin',
    output: 'another_binary_file.bin',
    input: gen.process(files(...), depends: more_constants),
    command: [ ... ],
)

In this example, the another_binary_file.bin target accepts some input files which cannot be built correctly without more_constants. However, the generator itself does not need to have this dependency, as some_binary_file.bin's input files do not require these to be built, and thus they should not be flagged as dirty if more_constants is dirty.

Testing

The test case in common is functional for the Ninja backend. I will need some help understanding the mental model for the VSCode and XCode backends to make similar changes, as I have never worked with them before.

@lhearachel lhearachel requested a review from jpakkane as a code owner December 18, 2025 01:50
@lhearachel lhearachel force-pushed the feature/generator-process-depends branch from f28d1bb to a38409d Compare December 18, 2025 01:52
@dcbaker
Copy link
Member

dcbaker commented Dec 18, 2025

You have my ack for this idea. This MR also looks really nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants