]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
src/script: add helper function has_build_dir
authorJohn Mulligan <jmulligan@redhat.com>
Mon, 14 Nov 2022 15:57:25 +0000 (10:57 -0500)
committerJohn Mulligan <jmulligan@redhat.com>
Wed, 5 Feb 2025 20:13:06 +0000 (15:13 -0500)
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 <jmulligan@redhat.com>
src/script/lib-build.sh

index a96a20ea826569cbba7228727d70ae5d84421946..25ce76b0cde741ebc22ee370e58ebfb2911a3220 100755 (executable)
@@ -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