mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-22 18:16:28 +00:00
add meson support
This is needed to integrate gst-plugins-rs with gst-build, see https://gitlab.freedesktop.org/gstreamer/gst-build/issues/63
This commit is contained in:
parent
ccfb8246be
commit
9390295281
2 changed files with 105 additions and 0 deletions
41
cargo.py
Normal file
41
cargo.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import glob
|
||||
import os
|
||||
import os.path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
meson_build_dir, meson_current_source_dir, meson_build_root, target, ext = sys.argv[1:]
|
||||
|
||||
cargo_target_dir = os.path.join(meson_build_dir, 'target')
|
||||
|
||||
env = os.environ.copy()
|
||||
env['CARGO_TARGET_DIR'] = cargo_target_dir
|
||||
|
||||
# FIXME: hack so cargo will find gst libs when building inside gst-build.
|
||||
# We should fetch this from meson deps instead of hardcoding the paths,
|
||||
# when Meson will generate -uninstalled.pc files, they all will be in
|
||||
# <meson_build_root>/meson-uninstalled/
|
||||
pkg_config_path = env.get('PKG_CONFIG_PATH', '').split(':')
|
||||
pkg_config_path.append(os.path.join(
|
||||
meson_build_root, 'subprojects', 'gstreamer', 'pkgconfig'))
|
||||
pkg_config_path.append(os.path.join(
|
||||
meson_build_root, 'subprojects', 'gst-plugins-base', 'pkgconfig'))
|
||||
env['PKG_CONFIG_PATH'] = ':'.join(pkg_config_path)
|
||||
|
||||
# cargo build
|
||||
cargo_cmd = ['cargo', 'build', '--manifest-path',
|
||||
os.path.join(meson_current_source_dir, 'Cargo.toml')]
|
||||
if target == 'release':
|
||||
cargo_cmd.append('--release')
|
||||
|
||||
try:
|
||||
subprocess.run(cargo_cmd, env=env, check=True)
|
||||
except subprocess.SubprocessError:
|
||||
sys.exit(1)
|
||||
|
||||
# Copy so files to build dir
|
||||
for f in glob.glob(os.path.join(cargo_target_dir, target, '*.' + ext)):
|
||||
shutil.copy(f, meson_build_dir)
|
64
meson.build
Normal file
64
meson.build
Normal file
|
@ -0,0 +1,64 @@
|
|||
project('gst-plugins-rs',
|
||||
'rust',
|
||||
version: '0.13.0',
|
||||
meson_version : '>= 0.52')
|
||||
|
||||
if get_option('debug')
|
||||
target = 'debug'
|
||||
else
|
||||
target = 'release'
|
||||
endif
|
||||
|
||||
cargo = find_program('cargo', version:'>=1.39')
|
||||
cargo_script = find_program('cargo.py')
|
||||
|
||||
system = build_machine.system()
|
||||
if system == 'windows'
|
||||
ext = 'dll'
|
||||
elif system == 'darwin'
|
||||
ext = 'dylib'
|
||||
else
|
||||
ext = 'so'
|
||||
endif
|
||||
|
||||
plugins_rep = {
|
||||
'gst-plugin-audiofx': 'libgstrsaudiofx',
|
||||
'gst-plugin-cdg': 'libgstcdg',
|
||||
'gst-plugin-closedcaption': 'libgstrsclosedcaption',
|
||||
'gst-plugin-fallbackswitch': 'libgstfallbackswitch',
|
||||
'gst-plugin-file': 'libgstrsfile',
|
||||
'gst-plugin-flv': 'libgstrsflv',
|
||||
'gst-plugin-lewton': 'libgstlewton',
|
||||
'gst-plugin-rav1e': 'libgstrav1e',
|
||||
'gst-plugin-reqwest': 'libgstreqwest',
|
||||
'gst-plugin-rusoto': 'libgstrusoto',
|
||||
'gst-plugin-sodium': 'libgstsodium',
|
||||
'gst-plugin-threadshare': 'libgstthreadshare',
|
||||
'gst-plugin-togglerecord': 'libgsttogglerecord',
|
||||
}
|
||||
|
||||
output = []
|
||||
|
||||
foreach p, lib : plugins_rep
|
||||
# Add the plugin file as output
|
||||
output += [lib + '.' + ext]
|
||||
endforeach
|
||||
|
||||
# Always build the target so we don't have to list all source files as input
|
||||
rs_plugins = custom_target('gst-plugins-rs',
|
||||
build_by_default: true,
|
||||
output: output,
|
||||
console: true,
|
||||
install: false,
|
||||
build_always_stale: true,
|
||||
command: [cargo_script,
|
||||
meson.current_build_dir(),
|
||||
meson.current_source_dir(),
|
||||
meson.build_root(),
|
||||
target,
|
||||
ext])
|
||||
|
||||
# FIXME: raises a warning as the target has multiple outputs and meson will use
|
||||
# only the first one. All the plugins have the same basedir, hence
|
||||
# GST_PLUGIN_PATH will include them all, so that's ok.
|
||||
plugins = [rs_plugins]
|
Loading…
Reference in a new issue