From 32d511684ea52e1c6e15495ec080281be3dd24b8 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 26 Nov 2020 16:50:04 +0100 Subject: [PATCH] meson: install plugins pc files --- cargo_wrapper.py | 25 +++++++++++++++++++++---- meson.build | 26 +++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/cargo_wrapper.py b/cargo_wrapper.py index 4a7d79b4..06bbde90 100644 --- a/cargo_wrapper.py +++ b/cargo_wrapper.py @@ -9,8 +9,8 @@ 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[ - 1:8] +command, meson_build_dir, meson_current_source_dir, meson_build_root, target, exclude, extra_env, prefix, libdir = sys.argv[ + 1:10] cargo_target_dir = os.path.join(meson_build_dir, 'target') @@ -28,10 +28,10 @@ if len(extra_env) > 0: if command == 'build': # cargo build - ext = sys.argv[8] + ext = sys.argv[10] # when using --default-library=both 2 extensions are passed try: - ext2 = sys.argv[9] + ext2 = sys.argv[11] except IndexError: ext2 = None @@ -46,6 +46,9 @@ else: print("Unknown command:", command) sys.exit(1) +cargo_cmd.extend(['--prefix', prefix, '--libdir', + os.path.join(prefix, libdir)]) + def run(cargo_cmd, env): try: @@ -71,3 +74,17 @@ if command == 'build': if ext2: for f in glob.glob(os.path.join(cargo_target_dir, target, '*.' + ext2)): shutil.copy(f, meson_build_dir) + # Copy generated pkg-config files + for f in glob.glob(os.path.join(cargo_target_dir, target, '*.pc')): + shutil.copy(f, meson_build_dir) + + # Move -uninstalled.pc to meson-uninstalled + uninstalled = os.path.join(meson_build_dir, 'meson-uninstalled') + if not os.path.exists(uninstalled): + os.mkdir(uninstalled) + for f in glob.glob(os.path.join(meson_build_dir, '*-uninstalled.pc')): + # move() does not allow us to update the file so remove it if it already exists + dest = os.path.join(uninstalled, os.path.basename(f)) + if os.path.exists(dest): + os.unlink(dest) + shutil.move(f, uninstalled) diff --git a/meson.build b/meson.build index 006a29f5..088dcd39 100644 --- a/meson.build +++ b/meson.build @@ -106,6 +106,12 @@ if get_option('default_library') == 'static' or get_option('default_library') == endforeach endif +pc_files = [] +foreach p, lib : plugins_rep + # skip the 'lib' prefix in plugin name + pc_files += [lib.substring(3) + '.pc'] +endforeach + # Need to depends on all gstreamer-rs deps to ensure they are built # before gstreamer-rs when building with gst-build. # Custom targets can't depend on dependency() objects so we have to depend @@ -144,6 +150,7 @@ endforeach extra_env_str = ','.join(extra_env_list) plugins_install_dir = get_option('libdir') / 'gstreamer-1.0' +pkgconfig_install_dir = get_option('libdir') / 'pkgconfig' # Always build the target so we don't have to list all source files as input rs_plugins = custom_target('gst-plugins-rs', @@ -162,10 +169,25 @@ rs_plugins = custom_target('gst-plugins-rs', target, exclude, extra_env_str, + get_option('prefix'), + get_option('libdir'), extensions]) plugins = rs_plugins.to_list() +# We don't need to pass a command as we depends on the target above +# but it is currently mandatory ( https://github.com/mesonbuild/meson/issues/8059 ) +# so use python as it's guaranteed to be present on any setup +python = import('python').find_installation() +custom_target('gst-plugins-rs-pc-files', + build_by_default: true, + output: pc_files, + console: true, + install: true, + install_dir: pkgconfig_install_dir, + depends: rs_plugins, + command: [python, '-c', '""']) + test('tests', cargo_wrapper, args: ['test', @@ -174,5 +196,7 @@ test('tests', meson.build_root(), target, exclude, - extra_env_str], + extra_env_str, + get_option('prefix'), + get_option('libdir')], timeout: 600)