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