Skip to content

Commit

Permalink
meson: Add explicit check: kwarg to all run_command() calls
Browse files Browse the repository at this point in the history
This is required since Meson 0.61.0, and causes a warning to be
emitted otherwise:

mesonbuild/meson@2c079d8
mesonbuild/meson#9300

This exposed a bunch of places where we had broken run_command()
calls, unnecessary run_command() calls, and places where check: true
should be used.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1507>
  • Loading branch information
nirbheek committed Jan 9, 2022
1 parent 945fd11 commit 1be6d6c
Show file tree
Hide file tree
Showing 33 changed files with 97 additions and 184 deletions.
10 changes: 5 additions & 5 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ ensure_not_uninstalled = '''
import os
assert('GST_ENV' not in os.environ)
'''
cmdres = run_command(python3, '-c', ensure_not_uninstalled)
cmdres = run_command(python3, '-c', ensure_not_uninstalled, check: false)
if cmdres.returncode() != 0
error('Do not run `ninja` or `meson` for gst-build inside the uninstalled environment, you will run into problems')
endif

# Install gst-indent pre-commit hook
run_command(python3, '-c', 'import shutil; shutil.copy("scripts/git-hooks/multi-pre-commit.hook", ".git/hooks/pre-commit")')
run_command(python3, '-c', 'import shutil; shutil.copy("scripts/git-hooks/multi-pre-commit.hook", ".git/hooks/pre-commit")', check: false)

# Ensure that the user does not have Strawberry Perl in PATH, since it ships
# with a pkg-config.bat and broken pkgconfig files for libffi and zlib. Will
Expand All @@ -41,7 +41,7 @@ import os
assert(r'Strawberry\perl\bin' not in os.environ['PATH'])
'''
if build_system == 'windows' and meson.version().version_compare('<0.60.0')
cmdres = run_command(python3, '-c', ensure_no_strawberry_perl)
cmdres = run_command(python3, '-c', ensure_no_strawberry_perl, check: false)
if cmdres.returncode() != 0
error('You have Strawberry Perl in PATH which is known to cause build issues with Meson < 0.60.0. Please remove it from PATH, uninstall it, or upgrade Meson.')
endif
Expand All @@ -53,9 +53,9 @@ documented_projects = ''
if not meson.is_subproject() and cc.get_id() == 'msvc'
uname = find_program('uname', required: false)
if uname.found()
ret = run_command(uname, '-o')
ret = run_command(uname, '-o', check: false)
if ret.returncode() == 0 and ret.stdout().to_lower() == 'msys'
ret = run_command(uname, '-r')
ret = run_command(uname, '-r', check: false)
# The kernel version returned by uname is actually the msys version
if ret.returncode() == 0 and ret.stdout().startswith('2')
# If a system zlib is found, disable UNIX features in zlib.h and zconf.h
Expand Down
3 changes: 1 addition & 2 deletions subprojects/gst-devtools/debug-viewer/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ icondir = join_paths(get_option('datadir'), 'icons/hicolor')
subdir('data')


if run_command(python3,
'-c', 'import gi; gi.require_version("Gtk", "3.0")').returncode() == 0
if run_command(python3, '-c', 'import gi; gi.require_version("Gtk", "3.0")', check: false).returncode() == 0
test('gst-debug-viewer', python3, args: ['-m', 'unittest'],
workdir: meson.current_source_dir())
endif
2 changes: 0 additions & 2 deletions subprojects/gst-devtools/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,3 @@ if not get_option('debug_viewer').disabled()
subdir('debug-viewer')
endif
subdir('docs')

run_command(python3, '-c', 'import shutil; shutil.copy("hooks/multi-pre-commit.hook", ".git/hooks/pre-commit")')
3 changes: 2 additions & 1 deletion subprojects/gst-docs/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if not hotdoc_p.found()
endif

hotdoc_req = '>= 0.12.2'
hotdoc_version = run_command(hotdoc_p, '--version').stdout()
hotdoc_version = run_command(hotdoc_p, '--version', check: false).stdout()
if not hotdoc_version.version_compare(hotdoc_req)
error('Hotdoc version @0@ not found, got @1@'.format(hotdoc_req, hotdoc_version))
endif
Expand Down Expand Up @@ -49,6 +49,7 @@ with open(fname, 'r') as f:
python3,
'-c', read_file_contents,
fname,
check: false,
)
if cmdres.returncode() == 0
built_subprojects = cmdres.stdout().strip()
Expand Down
10 changes: 3 additions & 7 deletions subprojects/gst-editing-services/docs/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ if not hotdoc_p.found()
endif

hotdoc_req = '>= 0.11.0'
hotdoc_version = run_command(hotdoc_p, '--version').stdout()
hotdoc_version = run_command(hotdoc_p, '--version', check: false).stdout()
if not hotdoc_version.version_compare(hotdoc_req)
if get_option('doc').enabled()
error('Hotdoc version @0@ not found, got @1@'.format(hotdoc_req, hotdoc_version))
Expand Down Expand Up @@ -118,12 +118,8 @@ import json
with open("@0@") as f:
print(':'.join(json.load(f).keys()), end='')
'''.format(plugins_cache))

assert(list_plugin_res.returncode() == 0,
'Could not list plugins from @0@\n@1@\n@1@'.format(plugins_cache, list_plugin_res.stdout(), list_plugin_res.stderr()))


'''.format(plugins_cache),
check: true)
foreach plugin_name: list_plugin_res.stdout().split(':')
plugins_doc += [hotdoc.generate_doc(plugin_name,
project_version: apiversion,
Expand Down
22 changes: 8 additions & 14 deletions subprojects/gst-editing-services/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,17 @@ elif build_gir
if not cc.compiles('#include <Python.h>', dependencies: [python_dep])
error_msg = 'Could not compile a simple program against python'
elif pylib_loc == ''
check_path_exists = 'import os, sys; assert(os.path.exists(sys.argv[1]))'
fsmod = import('fs')
pylib_loc = python.get_variable('LIBPL', '')
if host_machine.system() != 'windows' and host_machine.system() != 'darwin'
pylib_ldlibrary = python.get_variable('LDLIBRARY', '')
if run_command(python, '-c', check_path_exists, join_paths(pylib_loc, pylib_ldlibrary)).returncode() != 0
if not fsmod.exists(pylib_loc / pylib_ldlibrary)
# Workaround for Fedora
pylib_loc = python.get_variable('LIBDIR', '')
message('pylib_loc = @0@'.format(pylib_loc))
endif

res = run_command(python, '-c', check_path_exists, join_paths(pylib_loc, pylib_ldlibrary))
if res.returncode() != 0
if not fsmod.exists(pylib_loc / pylib_ldlibrary)
error_msg = '@0@ doesn\' exist, can\'t use python'.format(join_paths(pylib_loc, pylib_ldlibrary))
endif
endif
Expand Down Expand Up @@ -310,7 +309,7 @@ else:
'''
pygi_override_dir = get_option('pygi-overrides-dir')
if pygi_override_dir == ''
cres = run_command(python3, '-c', override_detector, get_option('prefix'))
cres = run_command(python3, '-c', override_detector, get_option('prefix'), check: false)
if cres.returncode() == 0
pygi_override_dir = cres.stdout().strip()
endif
Expand All @@ -327,15 +326,10 @@ endif
# Set release date
if gst_version_nano == 0
extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
run_result = run_command(extract_release_date, gst_version, files('gst-editing-services.doap'))
if run_result.returncode() == 0
release_date = run_result.stdout().strip()
cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
message('Package release date: ' + release_date)
else
# Error out if our release can't be found in the .doap file
error(run_result.stderr())
endif
run_result = run_command(extract_release_date, gst_version, files('gst-editing-services.doap'), check: true)
release_date = run_result.stdout().strip()
cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
message('Package release date: ' + release_date)
endif

if gio_dep.version().version_compare('< 2.67.4')
Expand Down
2 changes: 1 addition & 1 deletion subprojects/gst-examples/webrtc/check/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ tests = [
]

check_test = find_program ('configure_test_check.py')
have_webrtc_check_deps = run_command (check_test).returncode() == 0
have_webrtc_check_deps = run_command (check_test, check: false).returncode() == 0

if openssl.found() and have_webrtc_check_deps
test_deps = [certs]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,16 @@ nuget = find_program('nuget.py')
dependencies = []
foreach dependency, version: { 'Newtonsoft.Json': '11.0.2', 'WebSocketSharp': '1.0.3-rc11'}
message('Getting @0@:@1@'.format(dependency, version))
get_dep= run_command(nuget, 'get',
get_dep = run_command(nuget, 'get',
'--builddir', dependency,
'--nuget-name', dependency,
'--nuget-version', version,
'--csharp-version=net45',
'--current-builddir', meson.current_build_dir(),
'--builddir', meson.global_build_root(), # FIXME: --builddir specified twice?!
check: true,
)

if get_dep.returncode() != 0
error('Failed to get @0@-@1@: @2@'.format(dependency, version, get_dep.stderr()))
endif

link_args = get_dep.stdout().split()
dependencies += [declare_dependency(link_args: link_args, version: version)]
foreach path: get_dep.stdout().split()
Expand Down
2 changes: 1 addition & 1 deletion subprojects/gst-libav/docs/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if not hotdoc_p.found()
endif

hotdoc_req = '>= 0.11.0'
hotdoc_version = run_command(hotdoc_p, '--version').stdout()
hotdoc_version = run_command(hotdoc_p, '--version', check: false).stdout()
if not hotdoc_version.version_compare(hotdoc_req)
if get_option('doc').enabled()
error('Hotdoc version @0@ not found, got @1@'.format(hotdoc_req, hotdoc_version))
Expand Down
13 changes: 4 additions & 9 deletions subprojects/gst-libav/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,10 @@ subdir('tests')
# Set release date
if gst_version_nano == 0
extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
run_result = run_command(extract_release_date, gst_version, files('gst-libav.doap'))
if run_result.returncode() == 0
release_date = run_result.stdout().strip()
cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
message('Package release date: ' + release_date)
else
# Error out if our release can't be found in the .doap file
error(run_result.stderr())
endif
run_result = run_command(extract_release_date, gst_version, files('gst-libav.doap'), check: true)
release_date = run_result.stdout().strip()
cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
message('Package release date: ' + release_date)
endif

configure_file(output: 'config.h', configuration: cdata)
13 changes: 4 additions & 9 deletions subprojects/gst-omx/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,10 @@ subdir('docs')
# Set release date
if gst_version_nano == 0
extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
run_result = run_command(extract_release_date, gst_version, files('gst-omx.doap'))
if run_result.returncode() == 0
release_date = run_result.stdout().strip()
cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
message('Package release date: ' + release_date)
else
# Error out if our release can't be found in the .doap file
error(run_result.stderr())
endif
run_result = run_command(extract_release_date, gst_version, files('gst-omx.doap'), check: true)
release_date = run_result.stdout().strip()
cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
message('Package release date: ' + release_date)
endif

configure_file(output: 'config.h', configuration: cdata)
8 changes: 3 additions & 5 deletions subprojects/gst-plugins-bad/docs/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ if not hotdoc_p.found()
endif

hotdoc_req = '>= 0.11.0'
hotdoc_version = run_command(hotdoc_p, '--version').stdout()
hotdoc_version = run_command(hotdoc_p, '--version', check: false).stdout()
if not hotdoc_version.version_compare(hotdoc_req)
if get_option('doc').enabled()
error('Hotdoc version @0@ not found, got @1@'.format(hotdoc_req, hotdoc_version))
Expand Down Expand Up @@ -215,10 +215,8 @@ import json
with open("@0@") as f:
print(':'.join(json.load(f).keys()), end='')
'''.format(plugins_cache))

assert(list_plugin_res.returncode() == 0,
'Could not list plugins from @0@'.format(plugins_cache))
'''.format(plugins_cache),
check: true)

plugins_doc = []
foreach plugin_name: list_plugin_res.stdout().split(':')
Expand Down
6 changes: 3 additions & 3 deletions subprojects/gst-plugins-bad/ext/opencv/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ if opencv_found

# Check the data dir used by opencv for its xml data files
# Use prefix from pkg-config to be compatible with cross-compilation
r = run_command('test', '-d', opencv_prefix + '/share/opencv')
r = run_command('test', '-d', opencv_prefix + '/share/opencv', check: false)
if r.returncode() == 0
gstopencv_cargs += '-DOPENCV_PATH_NAME="opencv"'
else
r = run_command('test', '-d', opencv_prefix + '/share/OpenCV')
r = run_command('test', '-d', opencv_prefix + '/share/OpenCV', check: false)
if r.returncode() == 0
gstopencv_cargs += '-DOPENCV_PATH_NAME="OpenCV"'
else
r = run_command('test', '-d', opencv_prefix + '/share/opencv4')
r = run_command('test', '-d', opencv_prefix + '/share/opencv4', check: false)
if r.returncode() == 0
gstopencv_cargs += '-DOPENCV_PATH_NAME="opencv4"'
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ if ['ios', 'darwin'].contains(host_system)
# https://github.com/KhronosGroup/MoltenVK/issues/492
vulkan_dep = cc.find_library('MoltenVK', required : get_option('vulkan'))
elif host_system == 'windows'
vulkan_root = run_command(python3, '-c', 'import os; print(os.environ.get("VK_SDK_PATH"))').stdout().strip()
vulkan_root = run_command(python3, '-c', 'import os; print(os.environ.get("VK_SDK_PATH"))', check: false).stdout().strip()
if vulkan_root != '' and vulkan_root != 'None'
vulkan_lib_dir = ''
if build_machine.cpu_family() == 'x86_64'
Expand Down
13 changes: 4 additions & 9 deletions subprojects/gst-plugins-bad/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -536,15 +536,10 @@ subdir('scripts')
# Set release date
if gst_version_nano == 0
extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
run_result = run_command(extract_release_date, gst_version, files('gst-plugins-bad.doap'))
if run_result.returncode() == 0
release_date = run_result.stdout().strip()
cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
message('Package release date: ' + release_date)
else
# Error out if our release can't be found in the .doap file
error(run_result.stderr())
endif
run_result = run_command(extract_release_date, gst_version, files('gst-plugins-bad.doap'), check: true)
release_date = run_result.stdout().strip()
cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
message('Package release date: ' + release_date)
endif

if glib_dep.version().version_compare('< 2.67.4')
Expand Down
2 changes: 1 addition & 1 deletion subprojects/gst-plugins-bad/sys/msdk/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if mfx_api != 'oneVPL'
use_msdk = true
else
# Old versions of MediaSDK don't provide a pkg-config file
mfx_root = run_command(python3, '-c', 'import os; print(os.environ.get("INTELMEDIASDKROOT", os.environ.get("MFX_HOME", "")))').stdout().strip()
mfx_root = run_command(python3, '-c', 'import os; print(os.environ.get("INTELMEDIASDKROOT", os.environ.get("MFX_HOME", "")))', check: false).stdout().strip()

if mfx_root != ''
mfx_libdir = [mfx_root + '/lib/lin_x64', mfx_root + '/lib/x64', mfx_root + '/lib64', mfx_root + '/lib']
Expand Down
10 changes: 3 additions & 7 deletions subprojects/gst-plugins-base/docs/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ if not hotdoc_p.found()
endif

hotdoc_req = '>= 0.11.0'
hotdoc_version = run_command(hotdoc_p, '--version').stdout()
hotdoc_version = run_command(hotdoc_p, '--version', check: false).stdout()
if not hotdoc_version.version_compare(hotdoc_req)
if get_option('doc').enabled()
error('Hotdoc version @0@ not found, got @1@'.format(hotdoc_req, hotdoc_version))
Expand Down Expand Up @@ -202,12 +202,8 @@ import json
with open("@0@") as f:
print(':'.join(json.load(f).keys()), end='')
'''.format(plugins_cache))

assert(list_plugin_res.returncode() == 0,
'Could not list plugins from @0@\n@1@\n@1@'.format(plugins_cache, list_plugin_res.stdout(), list_plugin_res.stderr()))


'''.format(plugins_cache),
check: true)
foreach plugin_name: list_plugin_res.stdout().split(':')
plugins_doc += [hotdoc.generate_doc(plugin_name,
project_version: api_version,
Expand Down
13 changes: 4 additions & 9 deletions subprojects/gst-plugins-base/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -524,15 +524,10 @@ endif
# Set release date
if gst_version_nano == 0
extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
run_result = run_command(extract_release_date, gst_version, files('gst-plugins-base.doap'))
if run_result.returncode() == 0
release_date = run_result.stdout().strip()
core_conf.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
message('Package release date: ' + release_date)
else
# Error out if our release can't be found in the .doap file
error(run_result.stderr())
endif
run_result = run_command(extract_release_date, gst_version, files('gst-plugins-base.doap'), check: true)
release_date = run_result.stdout().strip()
core_conf.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
message('Package release date: ' + release_date)
endif

if gio_dep.version().version_compare('< 2.67.4')
Expand Down
9 changes: 3 additions & 6 deletions subprojects/gst-plugins-good/docs/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if not hotdoc_p.found()
endif

hotdoc_req = '>= 0.11.0'
hotdoc_version = run_command(hotdoc_p, '--version').stdout()
hotdoc_version = run_command(hotdoc_p, '--version', check: false).stdout()
if not hotdoc_version.version_compare(hotdoc_req)
if get_option('doc').enabled()
error('Hotdoc version @0@ not found, got @1@'.format(hotdoc_req, hotdoc_version))
Expand Down Expand Up @@ -83,11 +83,8 @@ import json
with open("@0@") as f:
print(':'.join(json.load(f).keys()), end='')
'''.format(plugins_cache))

assert(list_plugin_res.returncode() == 0,
'Could not list plugins from @0@'.format(plugins_cache))

'''.format(plugins_cache),
check: true)
foreach plugin_name: list_plugin_res.stdout().split(':')
plugins_doc += [hotdoc.generate_doc(plugin_name,
project_version: api_version,
Expand Down
15 changes: 5 additions & 10 deletions subprojects/gst-plugins-good/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ if host_cpu == 'x86_64'
if nasm.found()
# We can't use the version: kwarg for find_program because old versions
# of nasm don't support --version
ret = run_command(nasm, '-v')
ret = run_command(nasm, '-v', check: false)
if ret.returncode() == 0
nasm_version = ret.stdout().strip().split()[2]
nasm_req = '>=2.13'
Expand Down Expand Up @@ -489,15 +489,10 @@ subdir('scripts')
# Set release date
if gst_version_nano == 0
extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
run_result = run_command(extract_release_date, gst_version, files('gst-plugins-good.doap'))
if run_result.returncode() == 0
release_date = run_result.stdout().strip()
cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
message('Package release date: ' + release_date)
else
# Error out if our release can't be found in the .doap file
error(run_result.stderr())
endif
run_result = run_command(extract_release_date, gst_version, files('gst-plugins-good.doap'), check: true)
release_date = run_result.stdout().strip()
cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
message('Package release date: ' + release_date)
endif

if gio_dep.version().version_compare('< 2.67.4')
Expand Down
Loading

0 comments on commit 1be6d6c

Please sign in to comment.