Debian Codegraph @

test cases/common/51 run target/meson.build

raw
1 project('run target', 'c')
2
3 # Make it possible to run built programs.
4 # In cross builds exe_wrapper should be added if it exists.
5
6 exe = executable('helloprinter', 'helloprinter.c')
7
8 if not meson.is_cross_build() or meson.can_run_host_binaries()
9 run_target('runhello',
10 command : [exe, 'argument'])
11 endif
12
13 converter = find_program('converter.py')
14
15 hex = custom_target('exe.hex',
16 input : exe,
17 output : 'exe.hex',
18 command : [converter, '@INPUT@', '@OUTPUT@',
19 ],
20 )
21
22 fakeburner = find_program('fakeburner.py')
23
24 # These emulates the Arduino flasher application. It sandwiches the filename inside
25 # a packed argument. Thus we need to declare it manually.
26 run_target('upload',
27 command : [fakeburner, 'x:@0@:y'.format(exe.full_path())],
28 depends : exe,
29 )
30
31 run_target('upload2',
32 command : [fakeburner, 'x:@0@:y'.format(hex.full_path())],
33 depends : hex,
34 )
35
36 run_target('upload3',
37 command : [fakeburner, 'x:@0@:y'.format(hex.full_path())],
38 depends : hex[0],
39 )
40
41 python3 = find_program('python3', required : false)
42 if not python3.found()
43 python3 = find_program('python')
44 endif
45
46 run_target('py3hi',
47 command : [python3, '-c', 'print("I am Python3.")'])
48
49 run_target('check_exists',
50 command : [find_program('check_exists.py'), files('helloprinter.c')])
51
52 run_target('check_exists',
53 command : [find_program('check_exists.py'), files('helloprinter.c')],
54 depends : disabler(),
55 )
56
57 run_target('check_exists',
58 command : [disabler(), files('helloprinter.c')])
59
60 # What if the output of a custom_target is the command to
61 # execute. Obviously this will not work as hex is not an
62 # executable but test that the output is generated correctly.
63 run_target('donotrunme',
64 command : hex)
65
66 # Ensure configure files can be passed
67 conf = configure_file(
68 input: 'configure.in',
69 output: 'configure',
70 configuration: configuration_data()
71 )
72
73 run_target('configure_script',
74 command : conf
75 )
76
77 custom_target('configure_script_ct',
78 command: conf,
79 output: 'dummy.txt',
80 capture: true)
81
82 # Target names that clash with potential builtin functionality.
83 run_target('ctags',
84 command : converter)
85
86 clangf = run_target('clang-format',
87 command : [converter, files('.clang-format'), meson.current_build_dir() / 'clang-format'])
88 custom_target('clang-tidy',
89 input: '.clang-tidy',
90 output: 'clang-tidy',
91 command : [converter, '@INPUT@', '@OUTPUT@'])
92 alias_target('clang-format-check', clangf)
93
94 # Check we can pass env to the program. Also check some string substitutions
95 # that were added in 0.57.0 but not documented. This is documented behaviour
96 # since 0.57.1.
97 run_target('check-env',
98 command: [find_program('check-env.py'), '@SOURCE_ROOT@', '@BUILD_ROOT@',
99 '@CURRENT_SOURCE_DIR@'],
100 env: {'MY_ENV': '1'},
101 )
102
103 # Check some string substitutions that has always been done but never documented.
104 # Some projects have been relying on this implementation detail. This is
105 # documented behaviour since 0.57.1.
106 custom_target('check-env-ct',
107 command: [find_program('check-env.py'), '@SOURCE_ROOT@', '@BUILD_ROOT@',
108 '@CURRENT_SOURCE_DIR@'],
109 env: {'MESON_SOURCE_ROOT': meson.source_root(),
110 'MESON_BUILD_ROOT': meson.build_root(),
111 'MESON_SUBDIR': meson.current_source_dir(),
112 'MESONINTROSPECT': 'fake value',
113 'MY_ENV': '1'},
114 output: 'check-env-ct',
115 )
116
117 run_target('textprinter', command: ['subdir/textprinter.py'])