Skip to content

Commit

Permalink
Allow command lists for find_program cross file overrides
Browse files Browse the repository at this point in the history
This is accepted by all other binaries in the cross file. With this
change, we also don't check whether the specified command exists at
configure time, but that's probably a feature anyway.

Fixes #3737
  • Loading branch information
nirbheek committed Jun 29, 2018
1 parent f3a8f9c commit 221e4eb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions mesonbuild/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2627,8 +2627,12 @@ def program_from_cross_file(self, prognames, silent=False):
if not isinstance(p, str):
raise InterpreterException('Executable name must be a string.')
if p in bins:
exename = bins[p]
extprog = dependencies.ExternalProgram(exename, silent=silent)
command = bins[p]
if isinstance(command, (list, str)):
extprog = dependencies.ExternalProgram(p, command=command, silent=silent)
else:
raise InterpreterException('Invalid type {!r} for binary {!r} in cross file'
''.format(command, p))
progobj = ExternalProgramHolder(extprog)
return progobj

Expand Down
3 changes: 2 additions & 1 deletion run_unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3207,7 +3207,8 @@ def test_cross_find_program(self):
c = '/usr/bin/cc'
ar = '/usr/bin/ar'
strip = '/usr/bin/ar'
sometool.py = '%s'
sometool.py = ['%s']
someothertool.py = '%s'
[properties]
Expand Down
4 changes: 4 additions & 0 deletions test cases/unit/12 cross prog/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ project('cross find program', 'c')

native_exe = find_program('sometool.py', native : true)
cross_exe = find_program('sometool.py')
cross_exe = find_program('someothertool.py')

native_out = run_command(native_exe).stdout().strip()
cross_out = run_command(cross_exe).stdout().strip()
cross_other_out = run_command(cross_exe).stdout().strip()

assert(native_out == 'native',
'Native output incorrect:' + native_out)
assert(cross_out == 'cross',
'Cross output incorrect:' + cross_out)
assert(cross_out == cross_other_out,
'Cross output incorrect:' + cross_other_out)

0 comments on commit 221e4eb

Please sign in to comment.