Add @BASENAMES@ and @PLAINNAMES@ to custom_target
There are currently projects in the wild (I don't want to shame them), who are recommending this:
custom_target(
...
input : ['a.in', 'b.in', 'c.in'],
output : '.'
command : [find_program('cmd'), '@OUTPUT@', '@INPUT@'],
)
of course, this isn't what they actually want, they just don't want to have to list ['a.out', 'b.out', 'c.out'] in their output lines. So lets make it easy to do the right thing:
custom_target(
...
input : ['a.in', 'b.in', 'c.in'],
output : '@[email protected]',
command : [find_program('cmd'), 'batch', '@OUTDIR@', '@INPUT@'],
)
With the plural form passed (it is allowed only to be passed as an exclusve output argument), meson will replace that with the @PLAINNAME@ applied to each output, making it simple to handle a custom_target with multiple outputs that follow the @BASENAME@ or @PLAINNAME@ scheme.
still needs tests, but I figure we're going to bikeshed about the naming for a while, so...
Codecov Report
Attention: Patch coverage is 39.13043% with 14 lines in your changes missing coverage. Please review.
Project coverage is 43.92%. Comparing base (
ee7a7fe) to head (258a2fb). Report is 2195 commits behind head on master.
| Files | Patch % | Lines |
|---|---|---|
| mesonbuild/mesonlib/universal.py | 42.85% | 6 Missing and 2 partials :warning: |
| mesonbuild/interpreter/interpreter.py | 33.33% | 4 Missing and 2 partials :warning: |
:exclamation: There is a different number of reports uploaded between BASE (ee7a7fe) and HEAD (258a2fb). Click for more details.
HEAD has 16 uploads less than BASE
Flag BASE (ee7a7fe) HEAD (258a2fb) 19 3
Additional details and impacted files
@@ Coverage Diff @@
## master #10498 +/- ##
===========================================
- Coverage 68.74% 43.92% -24.83%
===========================================
Files 406 406
Lines 87868 87485 -383
Branches 19530 18554 -976
===========================================
- Hits 60409 38425 -21984
- Misses 22886 45402 +22516
+ Partials 4573 3658 -915
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
of course, this isn't what they actually want, they just don't want to have to list
['a.out', 'b.out', 'c.out']in their output lines. So lets make it easy to do the right thing:
Actually, these projects just want to place output files in subdirectories. It's not technically required, but the transpiler cmd in question simultaneously documents the meson snippet using output: '.' and makes the tool emit the files in directory structure. The example project using the cmd, then makes use of file aliases in the compiler to expose all those files without a directory structure at all.
In theory, the real solution here is generator(...).process(..., preserve_path_from: meson.current_source_dir()), in practice generators are totally useless unless you're outputting *.c *.cpp *.h.
I thought more about this, I think instead of adding a new @BASENAMES@ template, allowing @BASENAME@ to contain the array of outputs like @INPUT@ and @OUTPUT@ do would be more consistant and natural, which would also allow for @BASENAME1@, which is probably useful. This shouldn't cause any regressions because currently passing @BASENAME@ or @PLAINNAME@ with multiple outputs is an error.