aboutsummaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2015-11-19 16:16:36 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2015-11-19 16:16:36 +0200
commit16fa65730469dacbdb9374858c090fe59c1aa70c (patch)
tree42baf8c8e7276af5d75fc4a79cef68b68e69b939 /test cases
parent5f44748dddc22775864fe7c55e94a87547ab252e (diff)
downloadmeson-16fa65730469dacbdb9374858c090fe59c1aa70c.zip
meson-16fa65730469dacbdb9374858c090fe59c1aa70c.tar.gz
meson-16fa65730469dacbdb9374858c090fe59c1aa70c.tar.bz2
Can use built exes in custom targets.
Diffstat (limited to 'test cases')
-rw-r--r--test cases/common/97 selfbuilt custom/data.dat1
-rw-r--r--test cases/common/97 selfbuilt custom/mainprog.cpp5
-rw-r--r--test cases/common/97 selfbuilt custom/meson.build16
-rw-r--r--test cases/common/97 selfbuilt custom/tool.cpp34
4 files changed, 56 insertions, 0 deletions
diff --git a/test cases/common/97 selfbuilt custom/data.dat b/test cases/common/97 selfbuilt custom/data.dat
new file mode 100644
index 0000000..83fd1d9
--- /dev/null
+++ b/test cases/common/97 selfbuilt custom/data.dat
@@ -0,0 +1 @@
+generated_function
diff --git a/test cases/common/97 selfbuilt custom/mainprog.cpp b/test cases/common/97 selfbuilt custom/mainprog.cpp
new file mode 100644
index 0000000..dcf9d20
--- /dev/null
+++ b/test cases/common/97 selfbuilt custom/mainprog.cpp
@@ -0,0 +1,5 @@
+#include"data.h"
+
+int main(int, char **) {
+ return generated_function() != 52;
+}
diff --git a/test cases/common/97 selfbuilt custom/meson.build b/test cases/common/97 selfbuilt custom/meson.build
new file mode 100644
index 0000000..4b677a7
--- /dev/null
+++ b/test cases/common/97 selfbuilt custom/meson.build
@@ -0,0 +1,16 @@
+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')
+
+hfile = custom_target('datah',
+ output : 'data.h',
+ input : 'data.dat',
+ command : [tool, '@INPUT@', '@OUTPUT@'],
+)
+
+main = executable('mainprog', 'mainprog.cpp', hfile)
+
+test('maintest', main)
diff --git a/test cases/common/97 selfbuilt custom/tool.cpp b/test cases/common/97 selfbuilt custom/tool.cpp
new file mode 100644
index 0000000..6a28dd8
--- /dev/null
+++ b/test cases/common/97 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;
+}