diff options
author | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
---|---|---|
committer | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
commit | af1a266670d040d2f4083ff309d732d648afba2a (patch) | |
tree | 2fc46203448ddcc6f81546d379abfaeb323575e9 /meson/test cases/native/5 install script | |
parent | e02cda008591317b1625707ff8e115a4841aa889 (diff) |
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'meson/test cases/native/5 install script')
6 files changed, 54 insertions, 0 deletions
diff --git a/meson/test cases/native/5 install script/file.txt b/meson/test cases/native/5 install script/file.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/meson/test cases/native/5 install script/file.txt diff --git a/meson/test cases/native/5 install script/meson.build b/meson/test cases/native/5 install script/meson.build new file mode 100644 index 000000000..8a69a0d15 --- /dev/null +++ b/meson/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/meson/test cases/native/5 install script/src/exe.c b/meson/test cases/native/5 install script/src/exe.c new file mode 100644 index 000000000..2df3ee885 --- /dev/null +++ b/meson/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/meson/test cases/native/5 install script/src/meson.build b/meson/test cases/native/5 install script/src/meson.build new file mode 100644 index 000000000..f60c995e3 --- /dev/null +++ b/meson/test cases/native/5 install script/src/meson.build @@ -0,0 +1 @@ +exe = executable('exe', 'exe.c', install : false, native : true) diff --git a/meson/test cases/native/5 install script/test.json b/meson/test cases/native/5 install script/test.json new file mode 100644 index 000000000..c41c27c6a --- /dev/null +++ b/meson/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/meson/test cases/native/5 install script/wrap.py b/meson/test cases/native/5 install script/wrap.py new file mode 100755 index 000000000..87508e008 --- /dev/null +++ b/meson/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:]) |