diff options
Diffstat (limited to 'test cases/common/53 install script')
-rwxr-xr-x | test cases/common/53 install script/customtarget.py | 19 | ||||
-rw-r--r-- | test cases/common/53 install script/meson.build | 45 | ||||
-rwxr-xr-x | test cases/common/53 install script/myinstall.py | 31 | ||||
-rw-r--r-- | test cases/common/53 install script/prog.c | 14 | ||||
-rw-r--r-- | test cases/common/53 install script/src/a file.txt | 0 | ||||
-rw-r--r-- | test cases/common/53 install script/src/foo.c | 10 | ||||
-rw-r--r-- | test cases/common/53 install script/src/meson.build | 5 | ||||
-rw-r--r-- | test cases/common/53 install script/src/myinstall.py | 14 | ||||
-rw-r--r-- | test cases/common/53 install script/test.json | 15 |
9 files changed, 153 insertions, 0 deletions
diff --git a/test cases/common/53 install script/customtarget.py b/test cases/common/53 install script/customtarget.py new file mode 100755 index 0000000..e28373a --- /dev/null +++ b/test cases/common/53 install script/customtarget.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 + +import argparse +import os + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument('dirname') + args = parser.parse_args() + + with open(os.path.join(args.dirname, '1.txt'), 'w') as f: + f.write('') + with open(os.path.join(args.dirname, '2.txt'), 'w') as f: + f.write('') + + +if __name__ == "__main__": + main() diff --git a/test cases/common/53 install script/meson.build b/test cases/common/53 install script/meson.build new file mode 100644 index 0000000..24d5dc8 --- /dev/null +++ b/test cases/common/53 install script/meson.build @@ -0,0 +1,45 @@ +project('custom install script', 'c') + +meson.add_install_script('myinstall.py', 'diiba/daaba', 'file.dat') +meson.add_install_script('myinstall.py', 'this/should', 'also-work.dat') + +subdir('src') + +meson.add_install_script('myinstall.py', 'dir', afile, '--mode=copy') + +data = configuration_data() +data.set10('foo', true) +conf = configure_file( + configuration : data, + output : 'conf.txt' +) + +meson.add_install_script('myinstall.py', 'dir', conf, '--mode=copy') + +t = custom_target( + 'ct', + command : [find_program('customtarget.py'), '@OUTDIR@'], + output : ['1.txt', '2.txt'], +) + +meson.add_install_script('myinstall.py', 'customtarget', t, '--mode=copy') +meson.add_install_script('myinstall.py', 'customtargetindex', t[0], '--mode=copy') + +installer = configure_file( + input : 'myinstall.py', + output : 'myinstall_copy.py', + copy : true, +) + +meson.add_install_script(installer, 'otherdir', afile, '--mode=copy') + +# This executable links on a library built in src/ directory. On Windows this +# means meson must add src/ into $PATH to find the DLL when running it as +# install script. +myexe = executable('prog', 'prog.c', + link_with: mylib, + install : true, +) +if meson.can_run_host_binaries() + meson.add_install_script(myexe) +endif diff --git a/test cases/common/53 install script/myinstall.py b/test cases/common/53 install script/myinstall.py new file mode 100755 index 0000000..a573342 --- /dev/null +++ b/test cases/common/53 install script/myinstall.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import argparse +import os +import shutil + +prefix = os.environ['MESON_INSTALL_DESTDIR_PREFIX'] + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument('dirname') + parser.add_argument('files', nargs='+') + parser.add_argument('--mode', action='store', default='create', choices=['create', 'copy']) + args = parser.parse_args() + + dirname = os.path.join(prefix, args.dirname) + if not os.path.exists(dirname): + os.makedirs(dirname) + + if args.mode == 'create': + for name in args.files: + with open(os.path.join(dirname, name), 'w') as f: + f.write('') + else: + for name in args.files: + shutil.copy(name, dirname) + + +if __name__ == "__main__": + main() diff --git a/test cases/common/53 install script/prog.c b/test cases/common/53 install script/prog.c new file mode 100644 index 0000000..85f8df9 --- /dev/null +++ b/test cases/common/53 install script/prog.c @@ -0,0 +1,14 @@ +#include<stdio.h> + +#ifdef _WIN32 + #define DO_IMPORT __declspec(dllimport) +#else + #define DO_IMPORT +#endif + +DO_IMPORT int foo(void); + +int main(void) { + printf("This is text.\n"); + return foo(); +} diff --git a/test cases/common/53 install script/src/a file.txt b/test cases/common/53 install script/src/a file.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/common/53 install script/src/a file.txt diff --git a/test cases/common/53 install script/src/foo.c b/test cases/common/53 install script/src/foo.c new file mode 100644 index 0000000..46cb845 --- /dev/null +++ b/test cases/common/53 install script/src/foo.c @@ -0,0 +1,10 @@ +#ifdef _WIN32 + #define DO_EXPORT __declspec(dllexport) +#else + #define DO_EXPORT +#endif + +DO_EXPORT int foo(void) +{ + return 0; +} diff --git a/test cases/common/53 install script/src/meson.build b/test cases/common/53 install script/src/meson.build new file mode 100644 index 0000000..72de346 --- /dev/null +++ b/test cases/common/53 install script/src/meson.build @@ -0,0 +1,5 @@ +meson.add_install_script('myinstall.py', 'this/does', 'something-different.dat') + +afile = files('a file.txt') + +mylib = shared_library('mylib', 'foo.c') diff --git a/test cases/common/53 install script/src/myinstall.py b/test cases/common/53 install script/src/myinstall.py new file mode 100644 index 0000000..3a9d89b --- /dev/null +++ b/test cases/common/53 install script/src/myinstall.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 + +import os +import sys + +prefix = os.environ['MESON_INSTALL_DESTDIR_PREFIX'] + +dirname = os.path.join(prefix, sys.argv[1]) + +if not os.path.exists(dirname): + os.makedirs(dirname) + +with open(os.path.join(dirname, sys.argv[2] + '.in'), 'w') as f: + f.write('') diff --git a/test cases/common/53 install script/test.json b/test cases/common/53 install script/test.json new file mode 100644 index 0000000..7ac2607 --- /dev/null +++ b/test cases/common/53 install script/test.json @@ -0,0 +1,15 @@ +{ + "installed": [ + {"type": "exe", "file": "usr/bin/prog"}, + {"type": "pdb", "file": "usr/bin/prog"}, + {"type": "file", "file": "usr/diiba/daaba/file.dat"}, + {"type": "file", "file": "usr/this/should/also-work.dat"}, + {"type": "file", "file": "usr/this/does/something-different.dat.in"}, + {"type": "file", "file": "usr/dir/a file.txt"}, + {"type": "file", "file": "usr/dir/conf.txt"}, + {"type": "file", "file": "usr/otherdir/a file.txt"}, + {"type": "file", "file": "usr/customtarget/1.txt"}, + {"type": "file", "file": "usr/customtarget/2.txt"}, + {"type": "file", "file": "usr/customtargetindex/1.txt"} + ] +} |