meson-plus-plus
meson-plus-plus copied to clipboard
Constant combine the output of identical function calls
It happens often that we get identical calls to the same function, especially find_program. If we note that there are two calls to the same thing, we should make them references, consider this:
a = custom_target(
command : ['myscript.py', '@INPUT@', '@OUTPUT@'],
input : ['a.h.in'],
output : '@BASENAME@,
)
b = custom_target(
command : ['myscript.py', '--code', '@INPUT@', '@OUTPUT@'],
input : ['a.c.in'],
output : ['@BASENAME@'],
)
This could be rewritten as:
myscript = find_program('myscript.ph')
a = custom_target(
command : [myscript, '@INPUT@', '@OUTPUT@'],
input : ['a.h.in'],
output : '@BASENAME@,
)
b = custom_target(
command : [myscript, '--code', '@INPUT@', '@OUTPUT@'],
input : ['a.c.in'],
output : ['@BASENAME@'],
)
Which would simplify the threaded lookup process.
This is related to #42, but that has more to do with putting the IR into a shape easy to consume in the backends. This needs to run earlier, and probably only targets find_program, dependency, and compiler.find_library(), while that is really targeted at calls to build_targets