From 1ec1352c8819b328504b58cd7018428c41804f15 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 26 May 2021 11:07:27 +0200 Subject: [PATCH] meson: fix csound detection csound-sys can detect the system lib using either pkg-config or using the CSOUND_LIB_DIR env variable. The former case just work but the second is trickier as we need to ensure that CSOUND_LIB_DIR is defined when building. So we no longer try to detect the lib using find_library() if user didn't define the env variable as the build will fail later. Also explicitly pass the env variable to cargo so user can now call 'CSOUND_LIB_DIR=/usr/lib64 meson build && ninja -C build' and have it work without repassing the env variable to ninja. --- .gitlab-ci.yml | 15 +++++++++------ meson.build | 24 ++++++++++++++---------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5b481397..14577e6f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -153,17 +153,22 @@ test nightly: rules: - if: '$UPDATE_IMG == null || $UPDATE_IMG == "nightly"' -meson shared: +.meson: extends: .img-stable + rules: + - if: '$UPDATE_IMG == null || $UPDATE_IMG == "stable"' + variables: + CSOUND_LIB_DIR: '/usr/lib' + +meson shared: + extends: .meson script: - meson build --default-library=shared --prefix=$(pwd)/install - ninja -C build install - ./ci/check-plugins-installed.py install - rules: - - if: '$UPDATE_IMG == null || $UPDATE_IMG == "stable"' meson static: - extends: .img-stable + extends: .meson script: - meson build --default-library=static --prefix=$(pwd)/install -Dsodium=built-in - ninja -C build install @@ -172,8 +177,6 @@ meson static: - PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$(pwd)/../install/lib/x86_64-linux-gnu/pkgconfig meson build - ninja -C build - ./build/test-gst-static - rules: - - if: '$UPDATE_IMG == null || $UPDATE_IMG == "stable"' rustfmt: extends: .img-stable diff --git a/meson.build b/meson.build index 51965565..710bafe3 100644 --- a/meson.build +++ b/meson.build @@ -78,23 +78,27 @@ endif cc = meson.get_compiler('c') csound_option = get_option('csound') -csound_dep = dependency('', required: false) # not-found dependency -if not csound_option.disabled() - csound_dep = cc.find_library('csound64', required: false) - if not csound_dep.found() - python3 = import('python').find_installation('python3') - res = run_command(python3, '-c', 'import os; print(os.environ["CSOUND_LIB_DIR"])') - if res.returncode() == 0 - csound_dep = cc.find_library('csound64', dirs: res.stdout(), required: csound_option) - elif csound_option.enabled() - error('csound option is enabled, but csound64 library could not be found and CSOUND_LIB_DIR was not set') +# try first to find csound using pkg-config +csound_dep = dependency('', required: false) +if not csound_dep.found() and not csound_option.disabled() + # if csound isn't distributed with pkg-config then user needs to define CSOUND_LIB_DIR with its location + python3 = import('python').find_installation('python3') + res = run_command(python3, '-c', 'import os; print(os.environ["CSOUND_LIB_DIR"])') + if res.returncode() == 0 + csound_libdir = res.stdout().strip() + csound_dep = cc.find_library('csound64', dirs: csound_libdir, required: false) + if csound_dep.found() + extra_env += {'CSOUND_LIB_DIR': csound_libdir} endif endif endif if csound_dep.found() plugins_rep += {'audio/csound' : 'libgstcsound'} +elif csound_option.enabled() + error('csound option is enabled, but csound64 library could not be found and CSOUND_LIB_DIR was not set') else + message('csound not found, disabling its plugin') exclude += ['audio/csound'] endif