summaryrefslogtreecommitdiffstats
path: root/test cases/rust/19 structured sources
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xtest cases/rust/19 structured sources/gen.py20
-rw-r--r--test cases/rust/19 structured sources/main-gen-copy.rs5
-rw-r--r--test cases/rust/19 structured sources/meson.build58
-rwxr-xr-xtest cases/rust/19 structured sources/no_copy_test.py18
-rw-r--r--test cases/rust/19 structured sources/priv.rs3
-rw-r--r--test cases/rust/19 structured sources/src/foo.rs.in4
-rw-r--r--test cases/rust/19 structured sources/src/main.rs5
-rw-r--r--test cases/rust/19 structured sources/src2/foo/mod.rs4
-rw-r--r--test cases/rust/19 structured sources/src2/main-unique.rs5
-rw-r--r--test cases/rust/19 structured sources/src2/meson.build4
10 files changed, 126 insertions, 0 deletions
diff --git a/test cases/rust/19 structured sources/gen.py b/test cases/rust/19 structured sources/gen.py
new file mode 100755
index 0000000..16e5c04
--- /dev/null
+++ b/test cases/rust/19 structured sources/gen.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+
+import argparse
+import textwrap
+
+
+def main() -> None:
+ parser = argparse.ArgumentParser()
+ parser.add_argument('output')
+ args = parser.parse_args()
+
+ with open(args.output, 'w') as f:
+ f.write(textwrap.dedent('''\
+ pub fn bar() -> () {
+ println!("Hello, World!");
+ }'''))
+
+
+if __name__ == "__main__":
+ main()
diff --git a/test cases/rust/19 structured sources/main-gen-copy.rs b/test cases/rust/19 structured sources/main-gen-copy.rs
new file mode 100644
index 0000000..db66a51
--- /dev/null
+++ b/test cases/rust/19 structured sources/main-gen-copy.rs
@@ -0,0 +1,5 @@
+include!(r#"@dir@/include.rs"#);
+
+pub fn main() {
+ priv_func();
+}
diff --git a/test cases/rust/19 structured sources/meson.build b/test cases/rust/19 structured sources/meson.build
new file mode 100644
index 0000000..d84e83f
--- /dev/null
+++ b/test cases/rust/19 structured sources/meson.build
@@ -0,0 +1,58 @@
+project('structured input', 'rust')
+
+foo_mod_rs = configure_file(
+ input : 'src/foo.rs.in',
+ output : 'mod.rs',
+ configuration : {'message' : 'Hello, World!'},
+)
+
+conf_file = executable(
+ 'main_conf_file',
+ structured_sources(
+ 'src/main.rs',
+ {'foo' : [foo_mod_rs]},
+ ),
+)
+
+ct = custom_target(
+ 'foo.rs',
+ output : 'foo.rs',
+ command : ['gen.py', '@OUTPUT@'],
+)
+
+target = executable(
+ 'main_custom_target',
+ structured_sources(
+ ['src/main.rs', ct],
+ ),
+)
+
+# Should not be coppied
+executable(
+ 'no_copy_target',
+ structured_sources(
+ ['src2/main-unique.rs'],
+ {'foo': 'src2/foo/mod.rs'},
+ ),
+)
+
+test('no-copy', find_program('no_copy_test.py'), args : meson.current_build_dir())
+
+subdir('src2')
+
+executable('copy-no-gen', srcs2)
+
+m_src = configure_file(
+ input : 'main-gen-copy.rs',
+ output : 'main-gen-copy.rs',
+ configuration : {'dir' : meson.current_build_dir().replace('\\', '/')},
+)
+
+m_src2 = configure_file(
+ input : 'priv.rs',
+ output : 'include.rs',
+ copy : true
+)
+
+executable('gen-no-copy', structured_sources([m_src, m_src2]))
+
diff --git a/test cases/rust/19 structured sources/no_copy_test.py b/test cases/rust/19 structured sources/no_copy_test.py
new file mode 100755
index 0000000..91506b2
--- /dev/null
+++ b/test cases/rust/19 structured sources/no_copy_test.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+
+import argparse
+import os
+
+
+def main() -> None:
+ parser = argparse.ArgumentParser()
+ parser.add_argument('builddir')
+ args = parser.parse_args()
+
+ for _, _, files in os.walk(args.builddir):
+ if 'main-unique.rs' in files:
+ exit(1)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/test cases/rust/19 structured sources/priv.rs b/test cases/rust/19 structured sources/priv.rs
new file mode 100644
index 0000000..aad196b
--- /dev/null
+++ b/test cases/rust/19 structured sources/priv.rs
@@ -0,0 +1,3 @@
+fn priv_func() {
+ std::process::exit(0);
+}
diff --git a/test cases/rust/19 structured sources/src/foo.rs.in b/test cases/rust/19 structured sources/src/foo.rs.in
new file mode 100644
index 0000000..4f3fc42
--- /dev/null
+++ b/test cases/rust/19 structured sources/src/foo.rs.in
@@ -0,0 +1,4 @@
+
+pub fn bar() -> () {
+ println!("@message@");
+}
diff --git a/test cases/rust/19 structured sources/src/main.rs b/test cases/rust/19 structured sources/src/main.rs
new file mode 100644
index 0000000..3ffeee2
--- /dev/null
+++ b/test cases/rust/19 structured sources/src/main.rs
@@ -0,0 +1,5 @@
+mod foo;
+
+fn main() {
+ foo::bar();
+}
diff --git a/test cases/rust/19 structured sources/src2/foo/mod.rs b/test cases/rust/19 structured sources/src2/foo/mod.rs
new file mode 100644
index 0000000..9463d95
--- /dev/null
+++ b/test cases/rust/19 structured sources/src2/foo/mod.rs
@@ -0,0 +1,4 @@
+
+pub fn bar() -> () {
+ println!("Hello, World!");
+}
diff --git a/test cases/rust/19 structured sources/src2/main-unique.rs b/test cases/rust/19 structured sources/src2/main-unique.rs
new file mode 100644
index 0000000..3ffeee2
--- /dev/null
+++ b/test cases/rust/19 structured sources/src2/main-unique.rs
@@ -0,0 +1,5 @@
+mod foo;
+
+fn main() {
+ foo::bar();
+}
diff --git a/test cases/rust/19 structured sources/src2/meson.build b/test cases/rust/19 structured sources/src2/meson.build
new file mode 100644
index 0000000..b4844d2
--- /dev/null
+++ b/test cases/rust/19 structured sources/src2/meson.build
@@ -0,0 +1,4 @@
+srcs2 = structured_sources(
+ ['main-unique.rs'],
+ {'foo': 'foo/mod.rs'},
+)