summaryrefslogtreecommitdiffstats
path: root/test cases/rust/11 generated main
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
commit7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch)
tree4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/rust/11 generated main
parentInitial commit. (diff)
downloadmeson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.tar.xz
meson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.zip
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test cases/rust/11 generated main')
-rw-r--r--test cases/rust/11 generated main/gen.py20
-rw-r--r--test cases/rust/11 generated main/generated_lib_main.rs5
-rw-r--r--test cases/rust/11 generated main/meson.build21
-rw-r--r--test cases/rust/11 generated main/sub/meson.build13
4 files changed, 59 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 0000000..c8cfe76
--- /dev/null
+++ b/test cases/rust/11 generated main/gen.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+
+import argparse
+
+
+def main() -> None:
+ parser = argparse.ArgumentParser()
+ parser.add_argument('out')
+ parser.add_argument('--mode', choices=['main', 'lib'], default='main')
+ args = parser.parse_args()
+
+ with open(args.out, 'w') as f:
+ if args.mode == 'main':
+ f.write('fn main() { println!("I prefer tarnish, actually.") }')
+ elif args.mode == 'lib':
+ f.write('pub fn libfun() { println!("I prefer tarnish, actually.") }')
+
+
+if __name__ == "__main__":
+ main()
diff --git a/test cases/rust/11 generated main/generated_lib_main.rs b/test cases/rust/11 generated main/generated_lib_main.rs
new file mode 100644
index 0000000..d9b373e
--- /dev/null
+++ b/test cases/rust/11 generated main/generated_lib_main.rs
@@ -0,0 +1,5 @@
+extern crate static_lib_generated as lib;
+
+fn main() {
+ lib::libfun();
+}
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 0000000..695124c
--- /dev/null
+++ b/test cases/rust/11 generated main/meson.build
@@ -0,0 +1,21 @@
+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])
+
+gener = generator(gen, arguments : ['@OUTPUT@'], output : '@BASENAME@.rs')
+# Doesn't actually use gen.py as input, just a limitation of generators
+executable('generator_main', gener.process(['gen.py']))
+
+subdir('sub')
+executable('custom_target_subdir_main', s)
+
+executable('link_with_generated_lib', 'generated_lib_main.rs', link_with : lib)
diff --git a/test cases/rust/11 generated main/sub/meson.build b/test cases/rust/11 generated main/sub/meson.build
new file mode 100644
index 0000000..3ce96e5
--- /dev/null
+++ b/test cases/rust/11 generated main/sub/meson.build
@@ -0,0 +1,13 @@
+s = custom_target(
+ 'subdir_target',
+ command : [gen, '@OUTPUT@'],
+ output : ['main.rs'],
+)
+
+l = custom_target(
+ 'lib_target',
+ command : [gen, '@OUTPUT@', '--mode', 'lib'],
+ output : ['lib.rs'],
+)
+
+lib = static_library('static_lib_generated', l)