From 9be6e653d49957c974af2c171257cbaf942abbb9 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Sat, 22 Jun 2024 10:59:05 -0500 Subject: 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. --- test cases/common/26 find program/meson.build | 3 +++ .../common/26 find program/print-version-custom-argument.py | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 test cases/common/26 find program/print-version-custom-argument.py (limited to 'test cases') diff --git a/test cases/common/26 find program/meson.build b/test cases/common/26 find program/meson.build index 3c4d15cda..a20f6b45a 100644 --- a/test cases/common/26 find program/meson.build +++ b/test cases/common/26 find program/meson.build @@ -32,6 +32,9 @@ assert(prog.version() == '1.0', 'Program version should be detectable') prog = find_program('print-version-with-prefix.py', version : '>=1.0') assert(prog.found(), 'Program version should match') +prog = find_program('print-version-custom-argument.py', version : '>=1.0', version_argument : '-version') +assert(prog.found(), 'Program version should match') + prog = find_program('test_subdir.py', required : false) assert(not prog.found(), 'Program should not be found') diff --git a/test cases/common/26 find program/print-version-custom-argument.py b/test cases/common/26 find program/print-version-custom-argument.py new file mode 100644 index 000000000..7d9ad58fe --- /dev/null +++ b/test cases/common/26 find program/print-version-custom-argument.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 + +import sys + +if len(sys.argv) != 2 or sys.argv[1] != '-version': + exit(1) + +print('1.0') -- cgit v1.2.3