From 1b8f67055b5b258ea282f9dc1f8d644524a7c747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 4 Oct 2024 13:10:35 +0200 Subject: [PATCH] tools/toolbox: Small refactor Handing the various options to different meson commands in meson-build gets a bit tedious. Instead of handling them all on the toplevel, split out *_command() functions that generate the commandline for the corresponding meson command. That way, options are handled locally where they matter, which makes future changes and additions a bit easier. Part-of: --- tools/toolbox/meson-build.sh | 41 ++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/tools/toolbox/meson-build.sh b/tools/toolbox/meson-build.sh index fc17cb70e..cd9869d5c 100755 --- a/tools/toolbox/meson-build.sh +++ b/tools/toolbox/meson-build.sh @@ -37,9 +37,28 @@ find_toplevel() { done } -needs_reconfigure() { - [[ ${#MESON_OPTIONS[*]} > 0 ]] && - [[ -d $BUILD_DIR ]] +setup_command() { + if [[ ${#MESON_OPTIONS[*]} > 0 && -d $BUILD_DIR ]]; then + RECONFIGURE=--reconfigure + fi + + echo -n "meson setup --prefix=/usr $RECONFIGURE $WIPE ${MESON_OPTIONS[*]} $BUILD_DIR" +} + +compile_command() { + echo -n "meson compile -C $BUILD_DIR" +} + +install_command() { + echo -n "sudo meson install -C $BUILD_DIR" +} + +dist_command() { + if [[ $RUN_DIST ]]; then + echo -n "meson dist -C $BUILD_DIR --include-subprojects" + else + echo -n : + fi } # load defaults @@ -100,16 +119,12 @@ while true; do esac done +BUILD_DIR=build-$TOOLBOX + find_toplevel -BUILD_DIR=build-$TOOLBOX -[[ $RUN_DIST ]] && DIST="meson dist -C $BUILD_DIR --include-subprojects" || DIST=: - -needs_reconfigure && RECONFIGURE=--reconfigure - toolbox run --container $TOOLBOX sh -c " - meson setup --prefix=/usr $RECONFIGURE $WIPE ${MESON_OPTIONS[*]} $BUILD_DIR && - meson compile -C $BUILD_DIR && - sudo meson install -C $BUILD_DIR && - $DIST -" + $(setup_command) && + $(compile_command) && + $(install_command) && + $(dist_command)"