Allow cmake 'out-of-source' builds
Allow mbed TLS to be build in a subdirectory. Also add a test in
all.sh
diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh
index be32dce..5060f10 100755
--- a/tests/scripts/all.sh
+++ b/tests/scripts/all.sh
@@ -34,6 +34,8 @@
SHORT=0
FORCE=0
+: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
+
usage()
{
echo "Usage: $0"
@@ -41,6 +43,7 @@
echo -e " -m|--memory\t\tAdditional optional memory tests."
echo -e " -s|--short\t\tSubset of tests."
echo -e " -f|--force\t\tForce the tests to overwrite any modified files."
+ echo -e " --out-of-source-dir\t\tDirectory used for CMake out-of-source build tests."
}
# remove built files as well as the cmake cache/config
@@ -80,6 +83,10 @@
--force|-f)
FORCE=1
;;
+ --out-of-source-dir)
+ shift
+ OUT_OF_SOURCE_DIR="$1"
+ ;;
--help|-h|*)
usage()
exit 1
@@ -89,7 +96,7 @@
done
if [ $FORCE -eq 1 ]; then
- rm -rf yotta/module
+ rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
git checkout-index -f -q $CONFIG_H
cleanup
else
@@ -101,6 +108,13 @@
exit 1
fi
+ if [ -d "$OUT_OF_SOURCE_DIR" ]; then
+ echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
+ echo "You can either delete this directory manually, or force the test by rerunning"
+ echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
+ exit 1
+ fi
+
if ! git diff-files --quiet include/mbedtls/config.h; then
echo $?
echo "Warning - the configuration file 'include/mbedtls/config.h' has been edited. " >&2
@@ -400,6 +414,19 @@
fi # MemSan
+msg "build: cmake 'out-of-source' build"
+cleanup
+MBEDTLS_ROOT_DIR="$PWD"
+mkdir "$OUT_OF_SOURCE_DIR"
+cd "$OUT_OF_SOURCE_DIR"
+cmake "$MBEDTLS_ROOT_DIR"
+make
+
+msg "test: cmake 'out-of-source' build"
+make test
+cd "$MBEDTLS_ROOT_DIR"
+rm -rf "$OUT_OF_SOURCE_DIR"
+
msg "Done, cleaning up"
cleanup