There are still caveats here. Rust/cargo handles generated sources by writing out all targets of a single repo into a single output directory, setting a path to that via a build-time environment variable, and then include those files via a set of functions and macros. Meson's build layout is naturally different, and ninja makes working with environment variables at compile time difficult. Fixes #8157pull/8158/head
parent
3ae115b57a
commit
bff0b41525
4 changed files with 60 additions and 8 deletions
@ -0,0 +1,16 @@ |
||||
#!/usr/bin/env python3 |
||||
|
||||
import argparse |
||||
|
||||
|
||||
def main() -> None: |
||||
parser = argparse.ArgumentParser() |
||||
parser.add_argument('out') |
||||
args = parser.parse_args() |
||||
|
||||
with open(args.out, 'w') as f: |
||||
f.write('fn main() { println!("I prefer tarnish, actually.") }') |
||||
|
||||
|
||||
if __name__ == "__main__": |
||||
main() |
@ -0,0 +1,16 @@ |
||||
project('generated rust main', 'rust') |
||||
|
||||
gen = find_program('gen.py') |
||||
|
||||
c = custom_target( |
||||
'custom_target', |
||||
command : [gen, '@OUTPUT@'], |
||||
output : ['main.rs'], |
||||
) |
||||
|
||||
executable('custom_target_main', c) |
||||
executable('custom_target_index_main', c[0]) |
||||
|
||||
gen = generator(gen, arguments : ['@OUTPUT@'], output : '@BASENAME@.rs') |
||||
# Doesn't actually use gen.py as input, just a limitation of generators |
||||
executable('generator_main', gen.process(['gen.py'])) |
Loading…
Reference in new issue