aboutsummaryrefslogtreecommitdiffstats
path: root/meson/test cases/native/7 selfbuilt custom
diff options
context:
space:
mode:
Diffstat (limited to 'meson/test cases/native/7 selfbuilt custom')
-rw-r--r--meson/test cases/native/7 selfbuilt custom/checkarg.cpp6
-rw-r--r--meson/test cases/native/7 selfbuilt custom/data.dat1
-rw-r--r--meson/test cases/native/7 selfbuilt custom/mainprog.cpp5
-rw-r--r--meson/test cases/native/7 selfbuilt custom/meson.build39
-rw-r--r--meson/test cases/native/7 selfbuilt custom/tool.cpp34
5 files changed, 85 insertions, 0 deletions
diff --git a/meson/test cases/native/7 selfbuilt custom/checkarg.cpp b/meson/test cases/native/7 selfbuilt custom/checkarg.cpp
new file mode 100644
index 000000000..99092eea0
--- /dev/null
+++ b/meson/test cases/native/7 selfbuilt custom/checkarg.cpp
@@ -0,0 +1,6 @@
+#include <cassert>
+
+int main(int argc, char *[]) {
+ assert(argc == 2);
+ return 0;
+}
diff --git a/meson/test cases/native/7 selfbuilt custom/data.dat b/meson/test cases/native/7 selfbuilt custom/data.dat
new file mode 100644
index 000000000..83fd1d90d
--- /dev/null
+++ b/meson/test cases/native/7 selfbuilt custom/data.dat
@@ -0,0 +1 @@
+generated_function
diff --git a/meson/test cases/native/7 selfbuilt custom/mainprog.cpp b/meson/test cases/native/7 selfbuilt custom/mainprog.cpp
new file mode 100644
index 000000000..bb45dcae8
--- /dev/null
+++ b/meson/test cases/native/7 selfbuilt custom/mainprog.cpp
@@ -0,0 +1,5 @@
+#include"data.h"
+
+int main(void) {
+ return generated_function() != 52;
+}
diff --git a/meson/test cases/native/7 selfbuilt custom/meson.build b/meson/test cases/native/7 selfbuilt custom/meson.build
new file mode 100644
index 000000000..b53635218
--- /dev/null
+++ b/meson/test cases/native/7 selfbuilt custom/meson.build
@@ -0,0 +1,39 @@
+project('selfbuilt custom', 'cpp')
+
+# Build an exe and use it in a custom target
+# whose output is used to build a different exe.
+
+tool = executable('tool', 'tool.cpp', native : true)
+
+hfile = custom_target('datah',
+ output : 'data.h',
+ input : 'data.dat',
+ command : [tool, '@INPUT@', '@OUTPUT@'],
+)
+
+main = executable('mainprog', 'mainprog.cpp', hfile)
+
+test('maintest', main)
+
+lib = library('libtool', 'tool.cpp')
+
+checkarg = executable('checkarg', 'checkarg.cpp', native : true)
+
+ctlib = custom_target('ctlib',
+ output : 'ctlib.out',
+ capture : true,
+ command : [checkarg, lib],
+ build_by_default : true,
+)
+
+if meson.is_cross_build() and meson.can_run_host_binaries()
+ checkarg_host = executable('checkarg_host', 'checkarg.cpp')
+
+ ctlib_host = custom_target(
+ 'ctlib_host',
+ output : 'ctlib.host.out',
+ capture : true,
+ command : [checkarg_host, lib],
+ build_by_default : true,
+ )
+endif
diff --git a/meson/test cases/native/7 selfbuilt custom/tool.cpp b/meson/test cases/native/7 selfbuilt custom/tool.cpp
new file mode 100644
index 000000000..6a28dd800
--- /dev/null
+++ b/meson/test cases/native/7 selfbuilt custom/tool.cpp
@@ -0,0 +1,34 @@
+#include<iostream>
+#include<fstream>
+#include<string>
+
+using namespace std;
+
+const char prefix[] = "int ";
+const char suffix[] = " () {\n return 52;}\n";
+
+int main(int argc, char **argv) {
+ if(argc != 3) {
+ cout << "You is fail.\n";
+ return 1;
+ }
+ ifstream is(argv[1], ifstream::binary);
+ if(!is) {
+ cout << "Opening input file failed.\n";
+ return 1;
+ }
+ string funcname;
+ is >> funcname;
+ ofstream os(argv[2], ofstream::binary);
+ if(!os) {
+ cout << "Opening output file failed.\n";
+ return 1;
+ }
+ os << prefix << funcname << suffix;
+ os.close();
+ if(!os.good()) {
+ cout << "Writing data out failed.\n";
+ return 1;
+ }
+ return 0;
+}