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/common/242 custom target feed | |
parent | e02cda008591317b1625707ff8e115a4841aa889 (diff) |
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'meson/test cases/common/242 custom target feed')
4 files changed, 44 insertions, 0 deletions
diff --git a/meson/test cases/common/242 custom target feed/data_source.txt b/meson/test cases/common/242 custom target feed/data_source.txt new file mode 100644 index 000000000..0c23cc0c3 --- /dev/null +++ b/meson/test cases/common/242 custom target feed/data_source.txt @@ -0,0 +1 @@ +This is a text only input file. diff --git a/meson/test cases/common/242 custom target feed/meson.build b/meson/test cases/common/242 custom target feed/meson.build new file mode 100644 index 000000000..1cda37d75 --- /dev/null +++ b/meson/test cases/common/242 custom target feed/meson.build @@ -0,0 +1,24 @@ +project('custom target feed', 'c') + +python3 = import('python3').find_python() + +# Note that this will not add a dependency to the compiler executable. +# Code will not be rebuilt if it changes. +comp = '@0@/@1@'.format(meson.current_source_dir(), 'my_compiler.py') + +mytarget = custom_target('bindat', + output : 'data.dat', + input : 'data_source.txt', + feed : true, + command : [python3, comp, '@OUTPUT@'], + install : true, + install_dir : 'subdir' +) + +ct_output_exists = '''import os, sys +if not os.path.exists(sys.argv[1]): + print("could not find {!r} in {!r}".format(sys.argv[1], os.getcwd())) + sys.exit(1) +''' + +test('capture-wrote', python3, args : ['-c', ct_output_exists, mytarget]) diff --git a/meson/test cases/common/242 custom target feed/my_compiler.py b/meson/test cases/common/242 custom target feed/my_compiler.py new file mode 100755 index 000000000..97d42087b --- /dev/null +++ b/meson/test cases/common/242 custom target feed/my_compiler.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 + +import sys + +if __name__ == '__main__': + if len(sys.argv) != 2: + print(sys.argv[0], 'output_file') + sys.exit(1) + ifile = sys.stdin.read() + if ifile != 'This is a text only input file.\n': + print('Malformed input') + sys.exit(1) + with open(sys.argv[1], 'w+') as f: + f.write('This is a binary output file.') diff --git a/meson/test cases/common/242 custom target feed/test.json b/meson/test cases/common/242 custom target feed/test.json new file mode 100644 index 000000000..ba66b024a --- /dev/null +++ b/meson/test cases/common/242 custom target feed/test.json @@ -0,0 +1,5 @@ +{ + "installed": [ + {"type": "file", "file": "usr/subdir/data.dat"} + ] +} |