mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.3k stars 1.52k forks source link

`find_program` produces an object with an inconsistent interface when `meson.override_find_program` overrides the specified program #13151

Open apache-hb opened 3 weeks ago

apache-hb commented 3 weeks ago

Describe the bug the object produced by find_program('xxx') is of type ExecutableHolder rather than ExternalProgramHolder. Which produces incompatibilities when using the returned object. i.e. ExecutableHolder has no .version() method, and cannot be formatted by summary.

To Reproduce

# subprojects/example/meson.build
project('thing-provider', 'cpp')

# pretend theres a .wrap file that specifies program_names=thing 
exe = executable('thing', 'main.cpp')
meson.override_find_program('thing', thing)
# meson.build
project('example', 'cpp')

thing = find_program('thing')

# this line is fine if `thing` is found externally
# otherwise produces ERROR: Summary value in section 'Test Summary', key 'Program', must be string, integer, boolean, dependency, disabler, or external program
summary({ 'Program': thing }, section : 'Test Summary')

Expected behavior find_program always provides an object with a uniform interface

system parameters

dcbaker commented 3 weeks ago

I have some half finished patches for this somewhere… let me find them

apache-hb commented 2 weeks ago

Somewhat related, quite a few functions that accept dep also cause errors when dependency uses a subproject as opposed to a system dependency. I've run into this with compiler.has_function and compiler.has_header

dcbaker commented 2 weeks ago

Those can probably error more gracefully, but if those are from a subproject they can’t be used for tests because they don’t yet exist