-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
find_program: add a kwarg to skip searching the source dir
Unless search directories or overrides are provided, `find_program()` will by first search for an executable name in the source directory before trying to look it up via the `PATH` environment variable. This can create issues in some projects where the executable exists in the source directory, but when the actual program should be looked up via PATH. While the obvious answer is to move out the given executable from the source directory it's not always feasible. Git for example supports being built with both Makefiles and Meson. In the former case, the resulting `git` executable will be put into the root level source directory. So if one then sets up Meson, we would find that binary instead of the system-provided binary. Add a new "skip_source_dir" kwarg to `find_program()` that allows the user to skip looking up programs via the source directory. Signed-off-by: Patrick Steinhardt <ps@pks.im>
- Loading branch information
Showing
7 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## `find_program()` can optionally skip searching the source directory | ||
|
||
When given an executable name without any overrides, the `find_program()` | ||
function searches the source directory for the executable before scanning | ||
through `PATH`. This can now be skipped by passing `skip_source_dir: true` to | ||
`find_program()` so that only `PATH` will be searched. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env python3 | ||
|
||
print('from source directory') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
project('skip_source_dir', | ||
meson_version: '>=1.7.0', | ||
) | ||
|
||
summary({ | ||
'no args': run_command(find_program('executable.py'), capture: true, check: true).stdout(), | ||
'skip_source_dir: true': run_command(find_program('executable.py', skip_source_dir: false), capture: true, check: true).stdout(), | ||
'skip_source_dir: false': run_command(find_program('executable.py', skip_source_dir: true), capture: true, check: true).stdout(), | ||
}, section: 'output') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env python3 | ||
|
||
print('from path') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters