blob: f9f8f974aafd0f25fd3426f440e53263c5b18613 [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
James Conroy210897d2022-08-04 16:55:05 +010050TENSORFLOW_VERSION="tags/v2.5.0"
James Conroy919ec712022-07-13 12:57:53 +010051TENSORFLOW_SRC="$SOURCE_DIR"/tensorflow
52TFLITE_SRC="$TENSORFLOW_SRC"/tensorflow/lite
53SCHEMA_SRC="$TFLITE_SRC"/schema/schema.fbs
54
55# TF Lite Schema
56FLATC="$FLATBUFFERS_BUILD_HOST"/bin/flatc
57TFLITE_BUILD_ROOT="$BUILD_DIR"/tflite # Generated TF Lite Schema location
58TFLITE_BUILD_TARGET="$TFLITE_BUILD_ROOT"/"$TARGET_ARCH"_build
59
60# Protobuf
61PROTOBUF_VERSION=3.12.0
62PROTOBUF_SRC="$SOURCE_DIR"/protobuf-"$PROTOBUF_VERSION"
63PROTOBUF_BUILD_ROOT="$BUILD_DIR"/protobuf
64PROTOBUF_BUILD_HOST="$PROTOBUF_BUILD_ROOT"/"$HOST_ARCH"_build
65PROTOCOL_COMPILER_HOST="$PROTOBUF_BUILD_HOST"/bin/protoc
66PROTOBUF_BUILD_TARGET="$PROTOBUF_BUILD_ROOT"/"$TARGET_ARCH"_build
67PROTOBUF_LIBRARY_TARGET="$PROTOBUF_BUILD_TARGET"/lib/libprotobuf.so.23.0.0
68
69# ONNX
70ONNX_VERSION=1.6.0
71ONNX_SRC="$SOURCE_DIR"/onnx-"$ONNX_VERSION"
72ONNX_BUILD_TARGET="$BUILD_DIR"/onnx/"$TARGET_ARCH"_build
73
74# Arm NN / ACL
75ARMNN_SRC="$SOURCE_DIR"/armnn
James Conroy210897d2022-08-04 16:55:05 +010076ACL_SRC="$SOURCE_DIR"/acl
77
78# Check if directory at $1 is a repository or not
79check_if_repository()
80{
81 pushd "$1" > /dev/null
82
83 if [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" ]; then
84 popd > /dev/null
85 return 0
86 else
87 popd > /dev/null
88 return 1
89 fi
90}