From 9386b67e8309369866a0ef5875153e7cc4451f0e Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Mon, 2 May 2022 18:15:08 -0400 Subject: [PATCH] meson: fix warning about unexpected return code checking for run_command Recent versions of Meson warn you that the default is to not check the return code, which is a bad default and may eventually change. To suppress this warning, an explicit `check: ` value must be set. Considering the code in play here: - check if git exists - if so, always assume this is running from a git checkout - embed either '()' or '(git describe version)' it seems likely the intention is indeed to have it be `check: false`, but there's some missing error checking here to ensure it. Check the returncode. If git fails, it is surely because there is no git repository and the build is being run from a tarball. In that case, behave as though git wasn't found in the first place, and use the fallback value. Suppressing the warning can be done without bumping the minimum version of meson by only passing it on sufficiently new versions of Meson. This can be simplified by bumping the minimum version of Meson, which may or may not be desirable. --- src/meson.build | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/meson.build b/src/meson.build index 32dab83d5..87f722e1c 100644 --- a/src/meson.build +++ b/src/meson.build @@ -20,13 +20,20 @@ config_file = configure_file( output : 'config.h', configuration : config_cfg) +intel_driver_git_version = intel_vaapi_driver_version if git.found() - git_version = run_command( - git, '--git-dir', join_paths(meson.source_root(), '.git'), - 'describe', '--tags') - intel_driver_git_version = git_version.stdout().strip() -else - intel_driver_git_version = intel_vaapi_driver_version + if meson.version().version_compare('>=0.47.0') + git_version = run_command( + git, '--git-dir', join_paths(meson.source_root(), '.git'), + 'describe', '--tags', check: false) + else + git_version = run_command( + git, '--git-dir', join_paths(meson.source_root(), '.git'), + 'describe', '--tags') + endif + if git_version.returncode() == 0 + intel_driver_git_version = git_version.stdout().strip() + endif endif version_cfg = configuration_data()