diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2021-01-05 15:55:02 -0800 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2021-01-19 10:14:10 -0800 |
| commit | bff0b415250b4f4f7cd750b60e6c01daaa61af15 (patch) | |
| tree | ddd28d1a95975bb95d9a4fe9161dac62f7fab155 /test cases/rust | |
| parent | 3ae115b57ad7f8eca09c03f5bd6bf65604dcaf59 (diff) | |
| download | meson-bff0b415250b4f4f7cd750b60e6c01daaa61af15.tar.gz | |
rust: Accept generated sources for main.rs
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 #8157
Diffstat (limited to 'test cases/rust')
| -rw-r--r-- | test cases/rust/11 generated main/gen.py | 16 | ||||
| -rw-r--r-- | test cases/rust/11 generated main/meson.build | 16 |
2 files changed, 32 insertions, 0 deletions
diff --git a/test cases/rust/11 generated main/gen.py b/test cases/rust/11 generated main/gen.py new file mode 100644 index 000000000..ebbc2a7a6 --- /dev/null +++ b/test cases/rust/11 generated main/gen.py @@ -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() diff --git a/test cases/rust/11 generated main/meson.build b/test cases/rust/11 generated main/meson.build new file mode 100644 index 000000000..474981658 --- /dev/null +++ b/test cases/rust/11 generated main/meson.build @@ -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'])) |
