From 327f9159bef6e7dade58cbdefe703d1382dab4fd Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 20 Oct 2021 11:43:39 +1000 Subject: [PATCH] media-session-uninstalled: build this script with the meson dirs filled in This matches WirePlumber commit 52aaf9617 ./builddir/media-session-uninstalled.sh can now be called without a -b argument, it'll automatically set the full paths. This is useful when building as a subproject. meson has a limitation: the configure_file() object is just a file wrapper object. Wrap this into a custom_target() whose return value has a full_path() method. This way, pipewire can use media_session_uninstalled.full_path() without having to build the directory structure itself. --- media-session-uninstalled.sh | 15 +++++++++------ meson.build | 21 +++++++++++++++++++-- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/media-session-uninstalled.sh b/media-session-uninstalled.sh index 97bbea8cf..cae737f35 100755 --- a/media-session-uninstalled.sh +++ b/media-session-uninstalled.sh @@ -2,7 +2,15 @@ set -e -SOURCEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +# This is unset by meson +# shellcheck disable=SC2157 +if [ -z "@MESON@" ]; then + SOURCEDIR="@MESON_SOURCE_ROOT@" + BUILDDIR="@MESON_BUILD_ROOT@" +else + SOURCEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + BUILDDIR=${SOURCEDIR}/builddir +fi while getopts ":b:v:" opt; do case ${opt} in @@ -24,11 +32,6 @@ while getopts ":b:v:" opt; do esac done -if [ -z "${BUILDDIR}" ]; then - BUILDDIR=${SOURCEDIR}/builddir - echo "Using default build directory: ${BUILDDIR}" -fi - if [ ! -d "${BUILDDIR}" ]; then echo "Invalid build directory: ${BUILDDIR}" exit 1 diff --git a/meson.build b/meson.build index e20b782d4..3f06dc7e6 100644 --- a/meson.build +++ b/meson.build @@ -121,9 +121,26 @@ if doxygen.found() subdir('doc') endif -setenv = find_program('media-session-uninstalled.sh') +conf_uninstalled = configuration_data() +conf_uninstalled.set('MESON', '') +conf_uninstalled.set('MESON_SOURCE_ROOT', meson.project_source_root()) +conf_uninstalled.set('MESON_BUILD_ROOT', meson.project_build_root()) + +ms_uninstalled = configure_file( + input : 'media-session-uninstalled.sh', + output : 'media-session-uninstalled.sh.in', + configuration : conf_uninstalled, +) + +media_session_uninstalled = custom_target('media-session-uninstalled', + output : 'media-session-uninstalled.sh', + input : ms_uninstalled, + build_by_default : true, + command : ['cp', '@INPUT@', '@OUTPUT@'], +) + run_target('media-session-uninstalled', - command : [setenv, + command : [media_session_uninstalled, '-b@0@'.format(meson.project_build_root()), '-v@0@'.format(media_session_version)] )