mesonbuild / mesonbuild/meson

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

Open
#13,151 3 comments 0 reactions 1 assignee Claimed by @dcbaker View on GitHub
Dominant language
Python
Stars
6.6k
Forks
1.9k
Avg merge
2d 6h
Merged PRs (30d)
33

Description

**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**
```py
# 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)
```
```py
# 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**
* 1.4.0
* windows 11 build 22621
* ninja 1.11.1
* python 3.11.9

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.