summaryrefslogtreecommitdiff
path: root/mesonbuild/programs.py
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2024-06-22 10:59:05 -0500
committerJussi Pakkanen <jpakkane@gmail.com>2024-06-23 15:10:42 +0300
commit9be6e653d49957c974af2c171257cbaf942abbb9 (patch)
tree788b00fc4997ec587ccc64e21cba1b7d7f030dc1 /mesonbuild/programs.py
parenta111c28ecef721af960721c26b40f4e5108760c7 (diff)
downloadmeson-9be6e653d49957c974af2c171257cbaf942abbb9.tar.gz
find_program: add a kwarg to specify custom version argument
When trying to get the version of a program, meson was previously hardcoded to run the binary with `--version`. This does work with the vast majority of programs, but there are a few outliers (e.g. ffmpeg) which have an unusual argument for printing out the version. Support these programs by introducing a version_argument kwarg in find_program which allows users to override `--version` with whatever the custom argument for printing the version may be for the program.
Diffstat (limited to 'mesonbuild/programs.py')
-rw-r--r--mesonbuild/programs.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/mesonbuild/programs.py b/mesonbuild/programs.py
index b73f9e402..fbe241d99 100644
--- a/mesonbuild/programs.py
+++ b/mesonbuild/programs.py
@@ -36,6 +36,7 @@ class ExternalProgram(mesonlib.HoldableObject):
self.name = name
self.path: T.Optional[str] = None
self.cached_version: T.Optional[str] = None
+ self.version_arg = '--version'
if command is not None:
self.command = mesonlib.listify(command)
if mesonlib.is_windows():
@@ -93,9 +94,9 @@ class ExternalProgram(mesonlib.HoldableObject):
def get_version(self, interpreter: T.Optional['Interpreter'] = None) -> str:
if not self.cached_version:
- raw_cmd = self.get_command() + ['--version']
+ raw_cmd = self.get_command() + [self.version_arg]
if interpreter:
- res = interpreter.run_command_impl((self, ['--version']),
+ res = interpreter.run_command_impl((self, [self.version_arg]),
{'capture': True,
'check': True,
'env': mesonlib.EnvironmentVariables()},