Skip to content

Commit

Permalink
meson: fix warning about unexpected return code checking for run_command
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Eli Schwartz <[email protected]>
  • Loading branch information
eli-schwartz committed May 2, 2022
1 parent 67f619a commit dad1f2f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit dad1f2f

Please sign in to comment.