summaryrefslogtreecommitdiffstats
path: root/test cases/native/5 install script
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test cases/native/5 install script/file.txt0
-rw-r--r--test cases/native/5 install script/meson.build12
-rw-r--r--test cases/native/5 install script/src/exe.c27
-rw-r--r--test cases/native/5 install script/src/meson.build1
-rw-r--r--test cases/native/5 install script/test.json8
-rwxr-xr-xtest cases/native/5 install script/wrap.py6
6 files changed, 54 insertions, 0 deletions
diff --git a/test cases/native/5 install script/file.txt b/test cases/native/5 install script/file.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test cases/native/5 install script/file.txt
diff --git a/test cases/native/5 install script/meson.build b/test cases/native/5 install script/meson.build
new file mode 100644
index 0000000..8a69a0d
--- /dev/null
+++ b/test cases/native/5 install script/meson.build
@@ -0,0 +1,12 @@
+project('custom install script', 'c')
+
+# this is just to ensure that the install directory exists before exe is run
+install_data('file.txt', install_dir: '.')
+
+subdir('src')
+
+meson.add_install_script(exe, 'generated.txt')
+wrap = find_program('wrap.py')
+# Yes, these are getting silly
+meson.add_install_script(wrap, exe, 'wrapped.txt')
+meson.add_install_script(wrap, wrap, exe, 'wrapped2.txt')
diff --git a/test cases/native/5 install script/src/exe.c b/test cases/native/5 install script/src/exe.c
new file mode 100644
index 0000000..2df3ee8
--- /dev/null
+++ b/test cases/native/5 install script/src/exe.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main(int argc, char * argv[]) {
+ if (argc != 2) {
+ fprintf(stderr, "Takes exactly 2 arguments\n");
+ return 1;
+ }
+
+ char * dirname = getenv("MESON_INSTALL_DESTDIR_PREFIX");
+ char * fullname = malloc(strlen(dirname) + 1 + strlen(argv[1]) + 1);
+ strcpy(fullname, dirname);
+ strcat(fullname, "/");
+ strcat(fullname, argv[1]);
+
+ FILE * fp = fopen(fullname, "w");
+ if (!fp)
+ return 1;
+
+ fputs("Some text\n", fp);
+ fclose(fp);
+
+ free(fullname);
+
+ return 0;
+}
diff --git a/test cases/native/5 install script/src/meson.build b/test cases/native/5 install script/src/meson.build
new file mode 100644
index 0000000..f60c995
--- /dev/null
+++ b/test cases/native/5 install script/src/meson.build
@@ -0,0 +1 @@
+exe = executable('exe', 'exe.c', install : false, native : true)
diff --git a/test cases/native/5 install script/test.json b/test cases/native/5 install script/test.json
new file mode 100644
index 0000000..c41c27c
--- /dev/null
+++ b/test cases/native/5 install script/test.json
@@ -0,0 +1,8 @@
+{
+ "installed": [
+ {"type": "file", "file": "usr/file.txt"},
+ {"type": "file", "file": "usr/generated.txt"},
+ {"type": "file", "file": "usr/wrapped.txt"},
+ {"type": "file", "file": "usr/wrapped2.txt"}
+ ]
+}
diff --git a/test cases/native/5 install script/wrap.py b/test cases/native/5 install script/wrap.py
new file mode 100755
index 0000000..87508e0
--- /dev/null
+++ b/test cases/native/5 install script/wrap.py
@@ -0,0 +1,6 @@
+#!/usr/bin/env python3
+
+import subprocess
+import sys
+
+subprocess.run(sys.argv[1:])