Skip to content

Commit 3046f78

Browse files
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 <[email protected]>
1 parent 7fcd9cb commit 3046f78

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/script/lib-build.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ function get_processors() {
4949
fi
5050
}
5151

52+
# has_build_dir returns true if a build directory exists and can be used
53+
# for builds. has_build_dir is designed to interoperate with do_cmake.sh
54+
# and uses the same BUILD_DIR environment variable. It checks for the
55+
# directory relative to the current working directory.
56+
function has_build_dir() {
57+
( cd "${BUILD_DIR:=build}" && [[ -f build.ninja || -f Makefile ]] )
58+
}
59+
5260
# discover_compiler takes one argument, purpose, which may be used
5361
# to adjust the results for a specific need. It sets three environment
5462
# variables `discovered_c_compiler`, `discovered_cxx_compiler` and

0 commit comments

Comments
 (0)