Debian Codegraph @

test cases/common/26 find program/meson.build

raw
1 project('find program', meson_version: '>= 1.10.0',)
2
3 if build_machine.system() == 'windows'
4 # Things Windows does not provide:
5 # - an executable to copy files without prompting
6 # - working command line quoting
7 # - anything that you might actually need
8 # Because of these reasons we only check that
9 # the program can be found.
10 cp = find_program('xcopy')
11 else
12 cp = find_program('donotfindme', 'cp')
13 gen = generator(cp, \
14 output : '@[email protected]', \
15 arguments : ['@INPUT@', '@OUTPUT@'])
16
17 generated = gen.process('source.in')
18 add_languages('c', required: true)
19 e = executable('prog', generated)
20 test('external exe', e)
21 endif
22
23 prog = find_program('print-version.py', version : '>=2.0', required : false)
24 assert(not prog.found(), 'Version should be too old')
25
26 prog = find_program('print-version.py', version : '>=1.0')
27 assert(prog.found(), 'Program version should match')
28
29 prog = find_program('print-version.py')
30 assert(prog.version() == '1.0', 'Program version should be detectable')
31
32 prog = find_program('print-version-with-prefix.py', version : '>=1.0')
33 assert(prog.found(), 'Program version should match')
34
35 prog = find_program('print-version-custom-argument.py', version : '>=1.0', version_argument : '-version')
36 assert(prog.found(), 'Program version should match')
37
38 prog = find_program('test_subdir.py', required : false)
39 assert(not prog.found(), 'Program should not be found')
40
41 prog = find_program('test_subdir.py', dirs : ['/nonexistent', meson.current_source_dir() / 'scripts'])
42 assert(prog.found(), 'Program should be found')
43
44 prog = find_program('print-version.py')
45 if build_machine.system() != 'cygwin'
46 assert(prog.cmd_array() != [prog.full_path()])
47 assert(prog.cmd_array().length() == 2)
48 endif
49
50 ret = run_command(prog.cmd_array(),'--version', check: true)
51 assert(ret.returncode() == 0)
52 assert(ret.stdout().strip() == '1.0')
53
54 if build_machine.system() == 'windows'
55 prog = find_program('cmd.exe')
56 assert(prog.cmd_array() == [prog.full_path()])
57 else
58 prog = find_program('ld')
59 assert(prog.cmd_array() == [prog.full_path()])
60 endif