From: John Mulligan Date: Mon, 14 Nov 2022 15:57:25 +0000 (-0500) Subject: src/script: add helper function has_build_dir X-Git-Tag: v18.2.5~81^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b12f175e63983b1248d0e3d3610b2f93f1f2d6d8;p=ceph.git src/script: add helper function has_build_dir This function returns successfully if $BUILD_DIR exists and is valid. This is a useful building block for automation around the build and can be used to avoid re-running commands that fail is the build dir exists already. Signed-off-by: John Mulligan (cherry picked from commit 3046f78d69ea1b6937ce84e53f72934201a105db) --- diff --git a/src/script/lib-build.sh b/src/script/lib-build.sh index 6c4455344379d..0e915831a51aa 100644 --- a/src/script/lib-build.sh +++ b/src/script/lib-build.sh @@ -49,6 +49,14 @@ function get_processors() { fi } +# has_build_dir returns true if a build directory exists and can be used +# for builds. has_build_dir is designed to interoperate with do_cmake.sh +# and uses the same BUILD_DIR environment variable. It checks for the +# directory relative to the current working directory. +function has_build_dir() { + ( cd "${BUILD_DIR:=build}" && [[ -f build.ninja || -f Makefile ]] ) +} + # discover_compiler takes one argument, purpose, which may be used # to adjust the results for a specific need. It sets three environment # variables `discovered_c_compiler`, `discovered_cxx_compiler` and