1#!/usr/bin/env bash
2# Copyright 2021 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
17set -e
18
19SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
20ROOT_DIR=${SCRIPT_DIR}/../../../../..
21cd "${ROOT_DIR}"
22pwd
23
24make -f tensorflow/lite/micro/tools/make/Makefile clean_downloads DISABLE_DOWNLOADS=true
25make -f tensorflow/lite/micro/tools/make/Makefile OPTIMIZED_KERNEL_DIR=cmsis_nn clean DISABLE_DOWNLOADS=true
26if [ -d tensorflow/lite/micro/tools/make/downloads ]; then
27  echo "ERROR: Downloads directory should not exist, but it does."
28  exit 1
29fi
30
31# Check that an incorrect optimized kernel directory results in an error.
32# Without such an error, an incorrect optimized kernel directory can result in
33# an unexpected fallback to reference kernels and which can be hard to debug. We
34# add some complexity to the CI to make sure that we do not repeat the same
35# mistake as described in http://b/183546742.
36INCORRECT_CMD="make -f tensorflow/lite/micro/tools/make/Makefile OPTIMIZED_KERNEL_DIR=does_not_exist clean"
37EXT_LIBS_INC=tensorflow/lite/micro/tools/make/ext_libs/does_not_exist.inc
38touch ${EXT_LIBS_INC}
39if ${INCORRECT_CMD} &> /dev/null ; then
40  echo "'${INCORRECT_CMD}' should have failed but it did not have any errors."
41  rm -f ${EXT_LIBS_INC}
42  exit 1
43fi
44rm -f ${EXT_LIBS_INC}
45