Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.com>2020-01-02 19:07:47 +0300
committerGuillaume Desmottes <guillaume.desmottes@collabora.com>2020-01-03 07:05:10 +0300
commite158f4ef88b2f418d2a5ba0b4ec5e1d78fdf3ce4 (patch)
treede2af89ab71e97f4ff8ba3a236d92981726f8b6b /cargo_wrapper.py
parente2a2a17f09f35bb9751213c728362588a5889ef2 (diff)
meson: rename cargo.py to cargo_wrapper.py
Fix 'cargo build' on Windows as its $PATH includes $PWD, it seems to pick our script rather than the actual cargo.
Diffstat (limited to 'cargo_wrapper.py')
-rw-r--r--cargo_wrapper.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/cargo_wrapper.py b/cargo_wrapper.py
new file mode 100644
index 000000000..3e8bdef86
--- /dev/null
+++ b/cargo_wrapper.py
@@ -0,0 +1,46 @@
+#!/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, exclude = 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'),
+ '--workspace']
+if target == 'release':
+ cargo_cmd.append('--release')
+
+for e in exclude.split(','):
+ cargo_cmd.append('--exclude')
+ cargo_cmd.append(e)
+
+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)