1#!/bin/bash 2# Copyright 2019 The TensorFlow Authors. All Rights Reserved. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# ============================================================================== 16# 17# Called with following arguments: 18# 1 - Path to the downloads folder which is typically 19# tensorflow/lite/micro/tools/make/downloads 20# 21# This script is called from the Makefile and uses the following convention to 22# enable determination of sucess/failure: 23# 24# - If the script is successful, the only output on stdout should be SUCCESS. 25# The makefile checks for this particular string. 26# 27# - Any string on stdout that is not SUCCESS will be shown in the makefile as 28# the cause for the script to have failed. 29# 30# - Any other informational prints should be on stderr. 31 32set -e 33 34DOWNLOADS_DIR=${1} 35if [ ! -d ${DOWNLOADS_DIR} ]; then 36 echo "The top-level downloads directory: ${DOWNLOADS_DIR} does not exist." 37 exit 1 38fi 39 40# The BUILD files in the downloaded folder result in an error with: 41# bazel build tensorflow/lite/micro/... 42# 43# Parameters: 44# $1 - path to the downloaded flatbuffers code. 45function delete_build_files() { 46 rm -f `find ${1} -name BUILD` 47} 48 49DOWNLOADED_PIGWEED_PATH=${DOWNLOADS_DIR}/pigweed 50 51if [ -d ${DOWNLOADED_PIGWEED_PATH} ]; then 52 echo >&2 "${DOWNLOADED_PIGWEED_PATH} already exists, skipping the download." 53else 54 git clone https://pigweed.googlesource.com/pigweed/pigweed ${DOWNLOADED_PIGWEED_PATH} >&2 55 pushd ${DOWNLOADED_PIGWEED_PATH} > /dev/null 56 git checkout 47268dff45019863e20438ca3746c6c62df6ef09 >&2 57 58 # Patch for TFLM specific changes that are not currently upstreamed. 59 git apply ../../pigweed.patch 60 popd > /dev/null 61 62 delete_build_files ${DOWNLOADED_PIGWEED_PATH} 63fi 64 65echo "SUCCESS" 66