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