IVGCVSW-8172 Add macOS support to build tool setup
* Updates build rules for platform
* Failing unit tests excluded (dynamic backends, profiling)
* install-packages.sh generates manual setup information
Signed-off-by: Tracy Narine <tracy.narine@arm.com>
Change-Id: I2d3d434aa615a8796c0cb94cd5b9c35a5acfd148
diff --git a/build-tool/scripts/setup-armnn.sh b/build-tool/scripts/setup-armnn.sh
index 6b87d6f..a445356 100755
--- a/build-tool/scripts/setup-armnn.sh
+++ b/build-tool/scripts/setup-armnn.sh
@@ -13,6 +13,26 @@
rel_path=$(dirname "$0") # relative path from where script is executed to script location
+# Figure out platform specific settings
+osname=$(uname)
+osgetopt=getopt
+os_darwin=0
+if [ "$osname" == "Darwin" ]; then
+ os_darwin=1
+ osgetoptsys="/opt/homebrew/opt/gnu-getopt/bin/getopt"
+ osgetopthome="$HOME/homebrew/opt/gnu-getopt/bin/getopt"
+ if [ -f "$osgetoptsys" ]; then
+ echo "gnu-getopt found at: $osgetoptsys"
+ osgetopt=$osgetoptsys
+ elif [ -f "$osgetopthome" ]; then
+ echo "gnu-getopt found at: $osgetopthome"
+ osgetopt=$osgetopthome
+ else
+ echo "Run $rel_path/install-packages.sh and follow the instructions to configure the environment for $osname"
+ exit 1
+ fi
+fi
+
# Download an archive using wget and extract using tar
# Takes three arguments:
# 1. Name of dependency being downloaded e.g. Flatbuffers
@@ -138,6 +158,9 @@
target_arch="$HOST_ARCH"
mkdir -p "$FLATBUFFERS_BUILD_HOST"
build_dir="$FLATBUFFERS_BUILD_HOST"
+ if [ "$os_darwin" -eq 1 ]; then
+ cmake_flags+="$AARCH64_COMPILER_FLAGS"
+ fi
fi
echo -e "\n***** Building flatbuffers for $target_arch *****"
@@ -184,6 +207,14 @@
echo -e "\n***** TensorFlow downloaded *****"
}
+build_tflite_cpuinfo()
+{
+ cd "$TFLITE_BUILD_TARGET"/cpuinfo
+ cmake .
+ make
+ cp *.a ../_deps/cpuinfo-build
+}
+
build_tflite()
{
mkdir -p "$TFLITE_BUILD_TARGET"
@@ -194,9 +225,13 @@
case "$TARGET_ARCH" in
"aarch64")
+ cmake_system="Linux"
+ if [ "$os_darwin" -eq 1 ]; then
+ cmake_system="Darwin"
+ fi
cmake_flags+="$AARCH64_COMPILER_FLAGS"
target_arch_cmd="-DCMAKE_SYSTEM_PROCESSOR=aarch64 \
- -DCMAKE_SYSTEM_NAME=Linux "
+ -DCMAKE_SYSTEM_NAME=$cmake_system "
if [ "$NATIVE_BUILD" -eq 0 ]; then
cmake_flags+="ARMCC_FLAGS='-funsafe-math-optimizations' "
@@ -226,6 +261,11 @@
"$TFLITE_SRC"
cmake --build . -j "$NUM_THREADS"
+ if [ "$os_darwin" -eq 1 ]; then
+ # Workaround undefined link error for this platform
+ build_tflite_cpuinfo
+ fi
+
echo -e "\n***** Built TF Lite for $TARGET_ARCH *****"
}
@@ -324,7 +364,7 @@
exit 1
fi
-args=$(getopt -ohx -l tflite-classic-delegate,tflite-opaque-delegate,tflite-parser,onnx-parser,all,target-arch:,num-threads:,help -n "$name" -- "$@")
+args=$($osgetopt -ohx -l tflite-classic-delegate,tflite-opaque-delegate,tflite-parser,onnx-parser,all,target-arch:,num-threads:,help -n "$name" -- "$@")
eval set -- "$args"
while [ $# -gt 0 ]; do
if [ -n "${opt_prev:-}" ]; then