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: rules:
- if: '$UPDATE_IMG == null || $UPDATE_IMG == "nightly"' - if: '$UPDATE_IMG == null || $UPDATE_IMG == "nightly"'
meson shared: .meson:
extends: .img-stable extends: .img-stable
rules:
- if: '$UPDATE_IMG == null || $UPDATE_IMG == "stable"'
variables:
CSOUND_LIB_DIR: '/usr/lib'
meson shared:
extends: .meson
script: script:
- meson build --default-library=shared --prefix=$(pwd)/install - meson build --default-library=shared --prefix=$(pwd)/install
- ninja -C build install - ninja -C build install
- ./ci/check-plugins-installed.py install - ./ci/check-plugins-installed.py install
rules:
- if: '$UPDATE_IMG == null || $UPDATE_IMG == "stable"'
meson static: meson static:
extends: .img-stable extends: .meson
script: script:
- meson build --default-library=static --prefix=$(pwd)/install -Dsodium=built-in - meson build --default-library=static --prefix=$(pwd)/install -Dsodium=built-in
- ninja -C build install - 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 - PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$(pwd)/../install/lib/x86_64-linux-gnu/pkgconfig meson build
- ninja -C build - ninja -C build
- ./build/test-gst-static - ./build/test-gst-static
rules:
- if: '$UPDATE_IMG == null || $UPDATE_IMG == "stable"'
rustfmt: rustfmt:
extends: .img-stable extends: .img-stable

View file

@ -78,23 +78,27 @@ endif
cc = meson.get_compiler('c') cc = meson.get_compiler('c')
csound_option = get_option('csound') csound_option = get_option('csound')
csound_dep = dependency('', required: false) # not-found dependency # try first to find csound using pkg-config
if not csound_option.disabled() csound_dep = dependency('', required: false)
csound_dep = cc.find_library('csound64', required: false) if not csound_dep.found() and not csound_option.disabled()
if not csound_dep.found() # 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') python3 = import('python').find_installation('python3')
res = run_command(python3, '-c', 'import os; print(os.environ["CSOUND_LIB_DIR"])') res = run_command(python3, '-c', 'import os; print(os.environ["CSOUND_LIB_DIR"])')
if res.returncode() == 0 if res.returncode() == 0
csound_dep = cc.find_library('csound64', dirs: res.stdout(), required: csound_option) csound_libdir = res.stdout().strip()
elif csound_option.enabled() csound_dep = cc.find_library('csound64', dirs: csound_libdir, required: false)
error('csound option is enabled, but csound64 library could not be found and CSOUND_LIB_DIR was not set') if csound_dep.found()
extra_env += {'CSOUND_LIB_DIR': csound_libdir}
endif endif
endif endif
endif endif
if csound_dep.found() if csound_dep.found()
plugins_rep += {'audio/csound' : 'libgstcsound'} 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 else
message('csound not found, disabling its plugin')
exclude += ['audio/csound'] exclude += ['audio/csound']
endif endif