blob: f0e02df9c9a8fffacb90eeee5d793d38fe3fba1d [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++ "
James Conroy919ec712022-07-13 12:57:53 +010040
41# Flatbuffers
James Conroy2d273bf2022-10-05 11:21:53 +010042FLATBUFFERS_VERSION=2.0.6
James Conroy919ec712022-07-13 12:57:53 +010043FLATBUFFERS_SRC="$SOURCE_DIR"/flatbuffers-"$FLATBUFFERS_VERSION"
44FLATBUFFERS_BUILD_ROOT="$BUILD_DIR"/flatbuffers
45FLATBUFFERS_BUILD_TARGET="$FLATBUFFERS_BUILD_ROOT"/"$TARGET_ARCH"_build
46FLATBUFFERS_BUILD_HOST="$FLATBUFFERS_BUILD_ROOT"/"$HOST_ARCH"_build # Location of flatc compiler
47
48# Tensorflow
James Conroy2d273bf2022-10-05 11:21:53 +010049TENSORFLOW_VERSION="tags/v2.10.0"
James Conroy919ec712022-07-13 12:57:53 +010050TENSORFLOW_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
James Conroy210897d2022-08-04 16:55:05 +010075ACL_SRC="$SOURCE_DIR"/acl
76
77# Check if directory at $1 is a repository or not
78check_if_repository()
79{
80 pushd "$1" > /dev/null
81
82 if [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" ]; then
83 popd > /dev/null
84 return 0
85 else
86 popd > /dev/null
87 return 1
88 fi
89}