James Conroy | 919ec71 | 2022-07-13 12:57:53 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright © 2022 Arm Ltd and Contributors. All rights reserved. |
| 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
| 7 | # Script which stores common variables and paths used by setup-armnn.sh and build-armnn.sh |
| 8 | |
| 9 | # shellcheck disable=SC2034 |
| 10 | # SC2034: false positives for variables appear unused - variables are used in setup-armnn.sh and build-armnn.sh |
| 11 | |
| 12 | set -o nounset # Catch references to undefined variables. |
| 13 | set -o pipefail # Catch non zero exit codes within pipelines. |
| 14 | set -o errexit # Catch and propagate non zero exit codes. |
| 15 | |
| 16 | # ROOT_DIR is the directory in which a script is called from |
| 17 | ROOT_DIR=$(pwd) |
| 18 | SOURCE_DIR="$ROOT_DIR"/source |
| 19 | BUILD_DIR="$ROOT_DIR"/build |
| 20 | |
| 21 | # Host architecture e.g. x86_64, aarch64 |
| 22 | HOST_ARCH=$(uname -m) |
| 23 | |
| 24 | # Number of online cores on host |
| 25 | NUM_THREADS=$(getconf _NPROCESSORS_ONLN) |
| 26 | |
| 27 | # Validate common user-defined options |
| 28 | # shellcheck source=validation.sh |
| 29 | source "$rel_path"/validation.sh |
| 30 | |
| 31 | # target_arch supplied as command line arg |
| 32 | TARGET_ARCH="$target_arch" |
| 33 | |
| 34 | NATIVE_BUILD=0 |
| 35 | if [ "$TARGET_ARCH" == "$HOST_ARCH" ]; then |
| 36 | NATIVE_BUILD=1 |
| 37 | fi |
| 38 | |
| 39 | AARCH64_COMPILER_FLAGS+="CC=/usr/bin/aarch64-linux-gnu-gcc CXX=/usr/bin/aarch64-linux-gnu-g++ " |
| 40 | AARCH32_COMPILER_FLAGS+="CC=/usr/bin/arm-linux-gnueabihf-gcc CXX=/usr/bin/arm-linux-gnueabihf-g++ " |
| 41 | |
| 42 | # Flatbuffers |
| 43 | FLATBUFFERS_VERSION=1.12.0 |
| 44 | FLATBUFFERS_SRC="$SOURCE_DIR"/flatbuffers-"$FLATBUFFERS_VERSION" |
| 45 | FLATBUFFERS_BUILD_ROOT="$BUILD_DIR"/flatbuffers |
| 46 | FLATBUFFERS_BUILD_TARGET="$FLATBUFFERS_BUILD_ROOT"/"$TARGET_ARCH"_build |
| 47 | FLATBUFFERS_BUILD_HOST="$FLATBUFFERS_BUILD_ROOT"/"$HOST_ARCH"_build # Location of flatc compiler |
| 48 | |
| 49 | # Tensorflow |
| 50 | TENSORFLOW_SRC="$SOURCE_DIR"/tensorflow |
| 51 | TFLITE_SRC="$TENSORFLOW_SRC"/tensorflow/lite |
| 52 | SCHEMA_SRC="$TFLITE_SRC"/schema/schema.fbs |
| 53 | |
| 54 | # TF Lite Schema |
| 55 | FLATC="$FLATBUFFERS_BUILD_HOST"/bin/flatc |
| 56 | TFLITE_BUILD_ROOT="$BUILD_DIR"/tflite # Generated TF Lite Schema location |
| 57 | TFLITE_BUILD_TARGET="$TFLITE_BUILD_ROOT"/"$TARGET_ARCH"_build |
| 58 | |
| 59 | # Protobuf |
| 60 | PROTOBUF_VERSION=3.12.0 |
| 61 | PROTOBUF_SRC="$SOURCE_DIR"/protobuf-"$PROTOBUF_VERSION" |
| 62 | PROTOBUF_BUILD_ROOT="$BUILD_DIR"/protobuf |
| 63 | PROTOBUF_BUILD_HOST="$PROTOBUF_BUILD_ROOT"/"$HOST_ARCH"_build |
| 64 | PROTOCOL_COMPILER_HOST="$PROTOBUF_BUILD_HOST"/bin/protoc |
| 65 | PROTOBUF_BUILD_TARGET="$PROTOBUF_BUILD_ROOT"/"$TARGET_ARCH"_build |
| 66 | PROTOBUF_LIBRARY_TARGET="$PROTOBUF_BUILD_TARGET"/lib/libprotobuf.so.23.0.0 |
| 67 | |
| 68 | # ONNX |
| 69 | ONNX_VERSION=1.6.0 |
| 70 | ONNX_SRC="$SOURCE_DIR"/onnx-"$ONNX_VERSION" |
| 71 | ONNX_BUILD_TARGET="$BUILD_DIR"/onnx/"$TARGET_ARCH"_build |
| 72 | |
| 73 | # Arm NN / ACL |
| 74 | ARMNN_SRC="$SOURCE_DIR"/armnn |
| 75 | ACL_SRC="$SOURCE_DIR"/acl |