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.
This commit is contained in:
Guillaume Desmottes 2021-05-26 11:07:27 +02:00
parent e9f0a3b8ac
commit 1ec1352c88
2 changed files with 23 additions and 16 deletions

View file

@ -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

View file

@ -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