Add ability to mutate a target's `extra_files` list through the rewriter. The logic is copied from sources add/rm, but changes the `extra_files` kwarg instead of the sources positional argument. Has additional logic to handle creating the `extra_files` list if it doesn't exist.pull/9738/head
parent
a2934ca9d1
commit
c5148d8c73
8 changed files with 518 additions and 57 deletions
@ -0,0 +1,26 @@ |
|||||||
|
## `meson rewrite` can modify `extra_files` |
||||||
|
|
||||||
|
The build script rewriter can now modify targets' `extra_files` lists, |
||||||
|
or create them if absent. It it used in the same way as with rewriting |
||||||
|
source lists: |
||||||
|
|
||||||
|
```bash |
||||||
|
meson rewrite target <target name/id> {add_extra_files/rm_extra_files} [list of extra files] |
||||||
|
``` |
||||||
|
|
||||||
|
The rewriter's script mode also supports these actions: |
||||||
|
|
||||||
|
```json |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "<target name>", |
||||||
|
"operation": "extra_files_add / extra_files_rm", |
||||||
|
"sources": ["list", "of", "extra", "files", "to", "add, remove"], |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
## `meson rewrite target <target> info` outputs *target*'s `extra_files` |
||||||
|
|
||||||
|
Targets' `extra_files` lists are now included in the rewriter's target info dump |
||||||
|
as a list of file paths, in the same way `sources` are. This applies to both |
||||||
|
`meson rewrite` CLI and script mode. |
@ -0,0 +1,111 @@ |
|||||||
|
[ |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog1", |
||||||
|
"operation": "extra_files_add", |
||||||
|
"sources": ["a2.hpp", "a1.hpp", "a2.hpp"] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog2", |
||||||
|
"operation": "extra_files_add", |
||||||
|
"sources": ["a7.hpp"] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog3", |
||||||
|
"operation": "extra_files_add", |
||||||
|
"sources": ["a5.hpp"] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog4", |
||||||
|
"operation": "extra_files_add", |
||||||
|
"sources": ["a5.hpp"] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog5", |
||||||
|
"operation": "extra_files_add", |
||||||
|
"sources": ["a3.hpp"] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog7", |
||||||
|
"operation": "extra_files_add", |
||||||
|
"sources": ["a6.hpp", "a1.hpp"] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog8", |
||||||
|
"operation": "extra_files_add", |
||||||
|
"sources": ["a2.hpp", "a7.hpp"] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog9", |
||||||
|
"operation": "extra_files_add", |
||||||
|
"sources": ["a9.hpp", "a8.hpp"] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog10", |
||||||
|
"operation": "extra_files_add", |
||||||
|
"sources": ["a4.hpp", "a1.hpp"] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog0", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog1", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog2", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog3", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog4", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog5", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog6", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog7", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog8", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog9", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog10", |
||||||
|
"operation": "info" |
||||||
|
} |
||||||
|
] |
@ -0,0 +1,57 @@ |
|||||||
|
[ |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog0", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog1", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "exe2", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog3", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "exe4", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog5", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "exe6", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog7", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "exe8", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog9", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog10", |
||||||
|
"operation": "info" |
||||||
|
} |
||||||
|
] |
@ -0,0 +1,21 @@ |
|||||||
|
project('rewritetest', 'cpp') |
||||||
|
|
||||||
|
ef1 = ['main.hpp', 'fileA.hpp'] |
||||||
|
ef2 = files(['fileB.hpp', 'fileC.hpp']) |
||||||
|
ef3 = ef1 |
||||||
|
ef4 = [ef3] |
||||||
|
ef5 = [] |
||||||
|
|
||||||
|
# Magic comment |
||||||
|
|
||||||
|
exe0 = executable('trivialprog0', 'main.cpp', extra_files : ef1 + ef2) |
||||||
|
exe1 = executable('trivialprog1', 'main.cpp', extra_files : ef1) |
||||||
|
exe2 = executable('trivialprog2', 'main.cpp', extra_files : [ef2]) |
||||||
|
exe3 = executable('trivialprog3', 'main.cpp', extra_files : ['main.hpp', 'fileA.hpp']) |
||||||
|
exe4 = executable('trivialprog4', 'main.cpp', extra_files : ['main.hpp', ['fileA.hpp']]) |
||||||
|
exe5 = executable('trivialprog5', 'main.cpp', extra_files : [ef2, 'main.hpp']) |
||||||
|
exe6 = executable('trivialprog6', 'main.cpp', extra_files : ef3) |
||||||
|
executable('trivialprog7', 'main.cpp', extra_files : ef4) |
||||||
|
exe8 = executable('trivialprog8', 'main.cpp', extra_files : []) |
||||||
|
exe9 = executable('trivialprog9', 'main.cpp') |
||||||
|
exe10 = executable('trivialprog10', 'main.cpp', extra_files : ef5) |
@ -0,0 +1,93 @@ |
|||||||
|
[ |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog1", |
||||||
|
"operation": "extra_files_rm", |
||||||
|
"sources": ["fileA.hpp"] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog3", |
||||||
|
"operation": "extra_files_rm", |
||||||
|
"sources": ["fileA.hpp"] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog4", |
||||||
|
"operation": "extra_files_rm", |
||||||
|
"sources": ["fileA.hpp"] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog5", |
||||||
|
"operation": "extra_files_rm", |
||||||
|
"sources": ["fileB.hpp"] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog6", |
||||||
|
"operation": "extra_files_rm", |
||||||
|
"sources": ["fileA.hpp"] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog7", |
||||||
|
"operation": "extra_files_rm", |
||||||
|
"sources": ["fileA.hpp"] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog0", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog1", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog2", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog3", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog4", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog5", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog6", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog7", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog8", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog9", |
||||||
|
"operation": "info" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"type": "target", |
||||||
|
"target": "trivialprog10", |
||||||
|
"operation": "info" |
||||||
|
} |
||||||
|
] |
Loading…
Reference in new issue