Update ACL pin to 6cd1c9bc312b65137da52a973489ba6a0f0180e3
[platform/upstream/armnn.git] / scripts / get_compute_library.sh
1 #!/bin/bash
2 #
3 # Copyright © 2017 Arm Ltd. All rights reserved.
4 # SPDX-License-Identifier: MIT
5 #
6
7 CMD=$( basename $0 )
8
9 # For pinning to a ref use this:
10 #DEFAULT_CLFRAMEWORKREVISION="branches/arm_compute_20_02" # Release 20.02
11 #
12 # For pinning to a revision use this:
13 DEFAULT_CLFRAMEWORKREVISION="6cd1c9bc312b65137da52a973489ba6a0f0180e3" #COMPMID-3277: (3RDPARTY_UPDATE) fix build issue related to constructors
14
15
16 usage() {
17     echo "Usage: $CMD (Use the default clframework SHA)"
18     echo "Usage: $CMD -s <CLFRAMEWORK_SHA>"
19     echo "Usage: $CMD -p (Print current default clframework SHA)"
20   exit 0
21 }
22
23 PrintDefaultClframeworkSha() {
24   echo $DEFAULT_CLFRAMEWORKREVISION
25   exit 0;
26 }
27
28 function AssertZeroExitCode {
29   EXITCODE=$?
30   if [ $EXITCODE -ne 0 ]; then
31     echo "$1"
32     echo "+++ Command exited with code $EXITCODE. Please fix the above errors and re-run"
33     exit 1
34   fi
35 }
36
37 # process the options given
38 while getopts "s:phg:" opt; do
39   case "$opt" in
40     s) CLFRAMEWORK_SHA="$OPTARG";;
41     p) PrintDefaultClframeworkSha;;
42     g) DUMMY="$OPTARG";; # continue to accept -g for backward compatibility
43     h|\?) usage;;
44   esac
45 done
46 shift $((OPTIND - 1))
47
48 #
49 # This script is designed to be called from anywhere
50 # so it will resolve where to checkout out the clframework
51 # relative to its own location in armnn/scripts
52 #
53 SRC="${BASH_SOURCE[0]}"
54 # resolve $SRC until it is no longer a symlink
55 while [ -h "$SRC" ]; do
56   DIR="$( cd -P "$( dirname "$SRC" )" >/dev/null && pwd )"
57   SRC="$(readlink "$SRC")"
58   # if $SRC was a relative symlink, we need to resolve it
59   # relative to the path where the symlink file originally was
60   [[ $SRC != /* ]] && SRC="$DIR/$SRC"
61 done
62 DIR="$( cd -P "$( dirname "$SRC" )" >/dev/null && pwd )"
63 pushd ${DIR} > /dev/null
64 cd ../..
65
66 if [ ! -d clframework ]; then
67   git clone https://review.mlplatform.org/ml/ComputeLibrary clframework
68   AssertZeroExitCode "Cloning CL Framework failed"
69 fi
70 pushd clframework > /dev/null
71
72 CLFRAMEWORKREVISION=$DEFAULT_CLFRAMEWORKREVISION
73 if [ ! -z "$CLFRAMEWORK_SHA" ]; then
74     CLFRAMEWORKREVISION=$CLFRAMEWORK_SHA
75 fi
76
77 git fetch && git fetch https://review.mlplatform.org/ml/ComputeLibrary && git checkout ${CLFRAMEWORKREVISION}
78 AssertZeroExitCode "Fetching and checking out ${CLFRAMEWORKREVISION} failed"
79
80 # Set commit hook so we can submit reviews to gerrit
81 (curl -Lo `git rev-parse --git-dir`/hooks/commit-msg https://review.mlplatform.org/tools/hooks/commit-msg; chmod +x `git rev-parse --git-dir`/hooks/commit-msg)
82 AssertZeroExitCode "Setting commit hooks failed"
83
84 popd > /dev/null # out of clframework
85 popd > /dev/null # back to wherever we were when called
86 # Make sure the SHA of the revision that was checked out is the last line
87 # of output from the script... just in case we ever need it.
88 echo $CLFRAMEWORKREVISION
89 exit 0