meson: use cargo-c

We now have to run 'cbuild' and 'ctest' on each plugin individually.
Replace plugins_rep key by the source path so we can easily discard the
excluded plugins.
This commit is contained in:
Guillaume Desmottes 2020-11-26 16:12:42 +01:00
parent 8bc2e5ebb8
commit dfdbd370f9
2 changed files with 45 additions and 39 deletions

View file

@ -7,6 +7,8 @@ import shutil
import subprocess import subprocess
import sys import sys
PLUGIN_DIRS = ['audio', 'generic', 'net', 'text', 'utils', 'video']
command, meson_build_dir, meson_current_source_dir, meson_build_root, target, exclude, extra_env = sys.argv[ command, meson_build_dir, meson_current_source_dir, meson_build_root, target, exclude, extra_env = sys.argv[
1:8] 1:8]
@ -33,31 +35,35 @@ if command == 'build':
except IndexError: except IndexError:
ext2 = None ext2 = None
cargo_cmd = ['cargo', 'build', '--all-targets', # Build with the 'static' feature enforcing the minimal gst version required for static builds
'--manifest-path', os.path.join( cargo_cmd = ['cargo', 'cbuild', '--features', 'static']
meson_current_source_dir, 'Cargo.toml'),
'--workspace']
if target == 'release': if target == 'release':
cargo_cmd.append('--release') cargo_cmd.append('--release')
elif command == 'test': elif command == 'test':
# cargo test # cargo test
cargo_cmd = ['cargo', 'test', '--no-fail-fast', '--color=always', '--manifest-path', cargo_cmd = ['cargo', 'ctest', '--no-fail-fast', '--color=always']
os.path.join(meson_current_source_dir, 'Cargo.toml'),
'--workspace']
else: else:
print("Unknown command:", command) print("Unknown command:", command)
sys.exit(1) sys.exit(1)
if len(exclude) > 0:
for e in exclude.split(','):
cargo_cmd.append('--exclude')
cargo_cmd.append(e)
try: def run(cargo_cmd, env):
try:
subprocess.run(cargo_cmd, env=env, check=True) subprocess.run(cargo_cmd, env=env, check=True)
except subprocess.SubprocessError: except subprocess.SubprocessError:
sys.exit(1) sys.exit(1)
for d in PLUGIN_DIRS:
for name in os.listdir(os.path.join(meson_current_source_dir, d)):
if '{}/{}'.format(d, name) in exclude:
continue
cargo_toml = os.path.join(
meson_current_source_dir, d, name, 'Cargo.toml')
cmd = cargo_cmd + ['--manifest-path', cargo_toml]
run(cmd, env)
if command == 'build': if command == 'build':
# Copy so files to build dir # Copy so files to build dir
for f in glob.glob(os.path.join(cargo_target_dir, target, '*.' + ext)): for f in glob.glob(os.path.join(cargo_target_dir, target, '*.' + ext)):

View file

@ -26,43 +26,43 @@ else
endif endif
plugins_rep = { plugins_rep = {
'gst-plugin-audiofx': 'libgstrsaudiofx', 'audio/audiofx': 'libgstrsaudiofx',
'gst-plugin-cdg': 'libgstcdg', 'video/cdg': 'libgstcdg',
'gst-plugin-claxon': 'libgstclaxon', 'audio/claxon': 'libgstclaxon',
'gst-plugin-closedcaption': 'libgstrsclosedcaption', 'video/closedcaption': 'libgstrsclosedcaption',
'gst-plugin-fallbackswitch': 'libgstfallbackswitch', 'utils/fallbackswitch': 'libgstfallbackswitch',
'gst-plugin-file': 'libgstrsfile', 'generic/file': 'libgstrsfile',
'gst-plugin-flv': 'libgstrsflv', 'video/flavors': 'libgstrsflv',
'gst-plugin-gif': 'libgstgif', 'video/gif': 'libgstgif',
'gst-plugin-lewton': 'libgstlewton', 'audio/lewton': 'libgstlewton',
'gst-plugin-rav1e': 'libgstrav1e', 'video/rav1e': 'libgstrav1e',
'gst-plugin-reqwest': 'libgstreqwest', 'net/reqwest': 'libgstreqwest',
'gst-plugin-rspng': 'libgstrspng', 'video/rspng': 'libgstrspng',
'gst-plugin-rusoto': 'libgstrusoto', 'net/rusoto': 'libgstrusoto',
'gst-plugin-textwrap': 'libgstrstextwrap', 'text/wrap': 'libgstrstextwrap',
'gst-plugin-threadshare': 'libgstthreadshare', 'generic/threadshare': 'libgstthreadshare',
'gst-plugin-togglerecord': 'libgsttogglerecord', 'utils/togglerecord': 'libgsttogglerecord',
'gst-plugin-hsv': 'libgsthsv', 'video/hsv': 'libgsthsv',
} }
exclude = [] exclude = []
extra_env = {} extra_env = {}
if dependency('dav1d', required : get_option('dav1d')).found() if dependency('dav1d', required : get_option('dav1d')).found()
plugins_rep += {'gst-plugin-dav1d' : 'libgstrsdav1d'} plugins_rep += {'video/dav1d' : 'libgstrsdav1d'}
else else
exclude += ['gst-plugin-dav1d'] exclude += ['video/dav1d']
endif endif
sodium = get_option ('sodium') sodium = get_option ('sodium')
if sodium == 'system' if sodium == 'system'
dependency('libsodium') dependency('libsodium')
plugins_rep += {'gst-plugin-sodium': 'libgstsodium'} plugins_rep += {'generic/sodium': 'libgstsodium'}
extra_env += {'SODIUM_USE_PKG_CONFIG': '1'} extra_env += {'SODIUM_USE_PKG_CONFIG': '1'}
elif sodium == 'built-in' elif sodium == 'built-in'
plugins_rep += {'gst-plugin-sodium': 'libgstsodium'} plugins_rep += {'generic/sodium': 'libgstsodium'}
else else
exclude += ['gst-plugin-sodium'] exclude += ['generic/sodium']
endif endif
cc = meson.get_compiler('c') cc = meson.get_compiler('c')
@ -82,9 +82,9 @@ if not csound_option.disabled()
endif endif
if csound_dep.found() if csound_dep.found()
plugins_rep += {'gst-plugin-csound' : 'libgstcsound'} plugins_rep += {'audio/csound' : 'libgstcsound'}
else else
exclude += ['gst-plugin-csound'] exclude += ['audio/csound']
endif endif
output = [] output = []