From 3934a2c392e8d6c600b211afee871989a338a1fe Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 6 May 2018 07:37:28 +0200 Subject: [PATCH] build: set LD_LIBRARY_PATH and GI_TYPELIB_PATH variables in run-nm-test.sh With autotools, we use libtool so that the right libraries are automatically found. Still, we won't find the right GI typelib. Add a mechanism so that when make/meson invokes the run-nm-test.sh runner, it passes the build-root directory. Also, try to autodetect when invoked manually. --- configure.ac | 2 +- meson.build | 4 +--- tools/run-nm-test.sh | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 7ac11e1127..8c0014316a 100644 --- a/configure.ac +++ b/configure.ac @@ -1228,7 +1228,7 @@ else with_valgrind_suppressions='$(top_srcdir)/valgrind.suppressions' fi fi -AC_SUBST(NM_LOG_COMPILER, 'LOG_COMPILER = "$(top_srcdir)/tools/run-nm-test.sh" --called-from-make "$(LIBTOOL)" "$(with_valgrind)" "'"$with_valgrind_suppressions"'" --launch-dbus=auto') +AC_SUBST(NM_LOG_COMPILER, 'LOG_COMPILER = "$(top_srcdir)/tools/run-nm-test.sh" --called-from-make "$(abs_top_builddir)" "$(LIBTOOL)" "$(with_valgrind)" "'"$with_valgrind_suppressions"'" --launch-dbus=auto') AM_PATH_PYTHON([], [], [PYTHON=python]) AC_SUBST(PYTHON, [$PYTHON]) diff --git a/meson.build b/meson.build index dc1524aa0d..4564c5632a 100644 --- a/meson.build +++ b/meson.build @@ -741,15 +741,13 @@ endif test_args = [ '--called-from-make', + meson.build_root(), '', enable_valgrind ? valgrind.path() : '', enable_valgrind ? valgrind_suppressions_path : '', '--launch-dbus=auto' ] -# FIXME -#AC_SUBST(NM_LOG_COMPILER, 'LOG_COMPILER = "$(top_srcdir)/tools/run-nm-test.sh" --called-from-make "$(LIBTOOL)" "$(with_valgrind)" "'"$with_valgrind_suppressions"'" --launch-dbus=auto') - py3 = import('python3') python = py3.find_python() diff --git a/tools/run-nm-test.sh b/tools/run-nm-test.sh index 7f3053ce17..29ac7cd365 100755 --- a/tools/run-nm-test.sh +++ b/tools/run-nm-test.sh @@ -34,7 +34,11 @@ else CALLED_FROM_MAKE=0 fi +BUILDDIR= + if [ "$CALLED_FROM_MAKE" == 1 ]; then + BUILDDIR="$1" + shift if [ -n "$1" ]; then NMTST_LIBTOOL=($1 --mode=execute); else @@ -144,6 +148,7 @@ else ;; esac done + # we support calling the script directly. In this case, # only pass the path to the test to run. if test -z "${TEST+x}"; then @@ -153,6 +158,20 @@ else NMTST_SUPPRESSIONS="$SCRIPT_PATH/../valgrind.suppressions" fi + if [[ -z "$NMTST_BUILDDIR" ]]; then + if [[ "${NMTST_BUILDDIR-x}" == x ]]; then + # autodetect + BUILDDIR="$(readlink -f "$TEST")" + while [[ -n "$BUILDDIR" ]]; do + BUILDDIR="$(dirname "$BUILDDIR")" + [[ "$BUILDDIR" == / ]] && BUILDDIR= + [[ -z "$BUILDDIR" ]] && break + [[ -e "$BUILDDIR/libnm/.libs/libnm.so" ]] && break + [[ -e "$BUILDDIR/libnm/libnm.so" ]] && break + done + fi + fi + fi if [ "$NMTST_SET_DEBUG" == 1 -a -z "${NMTST_DEBUG+x}" ]; then @@ -198,6 +217,16 @@ fi [ -x "$TEST" ] || die "Cannot execute test \"$TEST\"" +if [[ -n "$BUILDDIR" ]]; then + if [[ -d "$BUILDDIR/libnm" ]]; then + export GI_TYPELIB_PATH="$BUILDDIR/libnm/${GI_TYPELIB_PATH:+:$GI_TYPELIB_PATH}" + if [[ -d "$BUILDDIR/libnm/.libs" ]]; then + export LD_LIBRARY_PATH="$BUILDDIR/libnm/.libs${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + else + export LD_LIBRARY_PATH="$BUILDDIR/libnm${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + fi + fi +fi if ! _is_true "$NMTST_USE_VALGRIND" 0; then "${NMTST_DBUS_RUN_SESSION[@]}" \