aboutsummaryrefslogtreecommitdiff
path: root/build-tool/scripts/common.sh
blob: 522bfb68cd54f5059fd3448e834bc35f0699ee1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
#
# Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
# SPDX-License-Identifier: MIT
#

# Script which stores common variables and paths used by setup-armnn.sh and build-armnn.sh

# shellcheck disable=SC2034
# SC2034: false positives for variables appear unused - variables are used in setup-armnn.sh and build-armnn.sh

set -o nounset  # Catch references to undefined variables.
set -o pipefail # Catch non zero exit codes within pipelines.
set -o errexit  # Catch and propagate non zero exit codes.

# ROOT_DIR is the directory in which a script is called from
ROOT_DIR=$(pwd)
SOURCE_DIR="$ROOT_DIR"/source
BUILD_DIR="$ROOT_DIR"/build

# Host architecture e.g. x86_64, aarch64
HOST_ARCH=$(uname -m)

# Number of online cores on host
NUM_THREADS=$(getconf _NPROCESSORS_ONLN)

# Validate common user-defined options
# shellcheck source=validation.sh
source "$rel_path"/validation.sh

# target_arch supplied as command line arg
TARGET_ARCH="$target_arch"

NATIVE_BUILD=0
if [ "$TARGET_ARCH" == "$HOST_ARCH" ]; then
  NATIVE_BUILD=1
fi

AARCH64_COMPILER_FLAGS+="CC=/usr/bin/aarch64-linux-gnu-gcc CXX=/usr/bin/aarch64-linux-gnu-g++ "
AARCH32_COMPILER_FLAGS+="CC=/usr/bin/arm-linux-gnueabihf-gcc CXX=/usr/bin/arm-linux-gnueabihf-g++ "

# Flatbuffers
FLATBUFFERS_VERSION=1.12.0
FLATBUFFERS_SRC="$SOURCE_DIR"/flatbuffers-"$FLATBUFFERS_VERSION"
FLATBUFFERS_BUILD_ROOT="$BUILD_DIR"/flatbuffers
FLATBUFFERS_BUILD_TARGET="$FLATBUFFERS_BUILD_ROOT"/"$TARGET_ARCH"_build
FLATBUFFERS_BUILD_HOST="$FLATBUFFERS_BUILD_ROOT"/"$HOST_ARCH"_build # Location of flatc compiler

# Tensorflow
TENSORFLOW_SRC="$SOURCE_DIR"/tensorflow
TFLITE_SRC="$TENSORFLOW_SRC"/tensorflow/lite
SCHEMA_SRC="$TFLITE_SRC"/schema/schema.fbs

# TF Lite Schema
FLATC="$FLATBUFFERS_BUILD_HOST"/bin/flatc
TFLITE_BUILD_ROOT="$BUILD_DIR"/tflite # Generated TF Lite Schema location
TFLITE_BUILD_TARGET="$TFLITE_BUILD_ROOT"/"$TARGET_ARCH"_build

# Protobuf
PROTOBUF_VERSION=3.12.0
PROTOBUF_SRC="$SOURCE_DIR"/protobuf-"$PROTOBUF_VERSION"
PROTOBUF_BUILD_ROOT="$BUILD_DIR"/protobuf
PROTOBUF_BUILD_HOST="$PROTOBUF_BUILD_ROOT"/"$HOST_ARCH"_build
PROTOCOL_COMPILER_HOST="$PROTOBUF_BUILD_HOST"/bin/protoc
PROTOBUF_BUILD_TARGET="$PROTOBUF_BUILD_ROOT"/"$TARGET_ARCH"_build
PROTOBUF_LIBRARY_TARGET="$PROTOBUF_BUILD_TARGET"/lib/libprotobuf.so.23.0.0

# ONNX
ONNX_VERSION=1.6.0
ONNX_SRC="$SOURCE_DIR"/onnx-"$ONNX_VERSION"
ONNX_BUILD_TARGET="$BUILD_DIR"/onnx/"$TARGET_ARCH"_build

# Arm NN / ACL
ARMNN_SRC="$SOURCE_DIR"/armnn
ACL_SRC="$SOURCE_DIR"/acl