aboutsummaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2023-01-09 11:12:15 -0800
committerDylan Baker <dylan@pnwbakers.com>2023-01-10 13:02:07 -0800
commit6aeec808367f05463394e30a8d40834e97c7afc0 (patch)
tree3c257977bfc010242b2393e7febd1ce70df818c0 /test cases
parent8655287c562cd54823add07b6d7a2c76c205d7fc (diff)
downloadmeson-6aeec808367f05463394e30a8d40834e97c7afc0.zip
meson-6aeec808367f05463394e30a8d40834e97c7afc0.tar.gz
meson-6aeec808367f05463394e30a8d40834e97c7afc0.tar.bz2
backends: Stop passing generator exes to ExecutableSerialisation as strings
The code below this already handles being passed an Executable or ExternalProgram, and it does it correctly, since it handles host binaries that need an exe_wrapper correctly, while the code in the generator paths doesn't. The xcode backend is, like always, problematic, it doesn't handle things the same way as the ninja and vscode backends, and generates a shell script instead of using meson as a wrapper when needed (it seems likely that just forcing the meson path for xcode would be better). I don't have a working mac to develop a fix for, so I've left a todo comment there. Fixes: #11264
Diffstat (limited to 'test cases')
-rw-r--r--test cases/common/105 generatorcustom/gen.c35
-rw-r--r--test cases/common/105 generatorcustom/host.c9
-rw-r--r--test cases/common/105 generatorcustom/meson.build16
-rw-r--r--test cases/failing/129 generator host binary/exe.c1
-rw-r--r--test cases/failing/129 generator host binary/lib.in1
-rw-r--r--test cases/failing/129 generator host binary/meson.build14
-rw-r--r--test cases/failing/129 generator host binary/test.json5
7 files changed, 81 insertions, 0 deletions
diff --git a/test cases/common/105 generatorcustom/gen.c b/test cases/common/105 generatorcustom/gen.c
new file mode 100644
index 0000000..59518c0
--- /dev/null
+++ b/test cases/common/105 generatorcustom/gen.c
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: Apache-2.0 */
+/* Copyright © 2023 Intel Corporation */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, const char ** argv) {
+ if (argc != 3) {
+ fprintf(stderr, "%s %i %s\n", "Got incorrect number of arguments, got ", argc - 1, ", but expected 2");
+ exit(1);
+ }
+
+ FILE * input, * output;
+
+ if ((input = fopen(argv[1], "rb")) == NULL) {
+ exit(1);
+ }
+ if ((output = fopen(argv[2], "wb")) == NULL) {
+ exit(1);
+ }
+
+ fprintf(output, "#pragma once\n");
+ fprintf(output, "#define ");
+
+ char c;
+ while((c = fgetc(input)) != EOF) {
+ fputc(c, output);
+ }
+ fputc('\n', output);
+
+ fclose(input);
+ fclose(output);
+
+ return 0;
+}
diff --git a/test cases/common/105 generatorcustom/host.c b/test cases/common/105 generatorcustom/host.c
new file mode 100644
index 0000000..1ddfa88
--- /dev/null
+++ b/test cases/common/105 generatorcustom/host.c
@@ -0,0 +1,9 @@
+#include "res1-cpp.h"
+
+int main(void) {
+ #ifdef res1
+ return 0;
+ #else
+ return 1;
+ #endif
+}
diff --git a/test cases/common/105 generatorcustom/meson.build b/test cases/common/105 generatorcustom/meson.build
index 2128d21..dab55de 100644
--- a/test cases/common/105 generatorcustom/meson.build
+++ b/test cases/common/105 generatorcustom/meson.build
@@ -26,3 +26,19 @@ allinone = custom_target('alltogether',
proggie = executable('proggie', 'main.c', allinone)
test('proggie', proggie)
+
+# specifically testing that cross binaries are run with an exe_wrapper
+if meson.can_run_host_binaries()
+ gen_tool = executable('generator', 'gen.c', native : false)
+
+ c_gen = generator(
+ gen_tool,
+ output : '@BASENAME@-cpp.h',
+ arguments : ['@INPUT@', '@OUTPUT@']
+ )
+
+ hs2 = c_gen.process('res1.txt')
+
+ host_exe = executable('host_test', 'host.c', hs2, native : false)
+ test('compiled generator', host_exe)
+endif
diff --git a/test cases/failing/129 generator host binary/exe.c b/test cases/failing/129 generator host binary/exe.c
new file mode 100644
index 0000000..78f2de1
--- /dev/null
+++ b/test cases/failing/129 generator host binary/exe.c
@@ -0,0 +1 @@
+int main(void) { return 0; }
diff --git a/test cases/failing/129 generator host binary/lib.in b/test cases/failing/129 generator host binary/lib.in
new file mode 100644
index 0000000..d0b6ab7
--- /dev/null
+++ b/test cases/failing/129 generator host binary/lib.in
@@ -0,0 +1 @@
+int foo(void) { return 7; }
diff --git a/test cases/failing/129 generator host binary/meson.build b/test cases/failing/129 generator host binary/meson.build
new file mode 100644
index 0000000..fc1f9be
--- /dev/null
+++ b/test cases/failing/129 generator host binary/meson.build
@@ -0,0 +1,14 @@
+project('generator host binary no exe_wrapper')
+
+if meson.can_run_host_binaries()
+ error('MESON_SKIP_TEST: test requires that build machine cannot run host binaries')
+endif
+
+add_languages('c', native : false)
+
+exe = executable('exe', 'exe.c', native : false)
+
+gen = generator(exe, output : '@BASENAME@.c', arguments : ['@INPUT@', '@OUTPU@'])
+foo = gen.process('lib.in')
+
+library('foo', foo)
diff --git a/test cases/failing/129 generator host binary/test.json b/test cases/failing/129 generator host binary/test.json
new file mode 100644
index 0000000..7e354d6
--- /dev/null
+++ b/test cases/failing/129 generator host binary/test.json
@@ -0,0 +1,5 @@
+{
+ "stdout": [
+ { "line": "ERROR: An exe_wrapper is needed but was not found. Please define one in cross file and check the command and/or add it to PATH." }
+ ]
+}