1#!/bin/sh 2# 3# Copyright © 2017 Arm Ltd. All rights reserved. 4# SPDX-License-Identifier: MIT 5# 6 7THIS_SCRIPT=$0 8OUTPUT_DIR=$1 9PROTOBUF_INSTALL_DIR=$2 10 11usage() 12{ 13 echo 14 echo "Usage: ${THIS_SCRIPT} <OUTPUT_DIR> [PROTOBUF_INSTALL_DIR]" 15 echo 16 echo " <OUTPUT_DIR> is the location where the generated files will be placed" 17 echo " [PROTOBUF_INSTALL_DIR] the location of the protobuf installation" 18 echo 19} 20 21if [ "x$OUTPUT_DIR" = "x" ] 22then 23 usage 24 exit 1 25fi 26 27mkdir -p "${OUTPUT_DIR}" 28ERR=$? 29if [ $ERR -ne 0 ] 30then 31 echo 32 echo "Cannot create output dir: ${OUTPUT_DIR}" 33 echo "mkdir returned: $ERR" 34 echo 35 usage 36 exit 1 37fi 38 39 40if [ "x${PROTOBUF_INSTALL_DIR}" = "x" ] 41then 42 PROTOBUF_INSTALL_DIR=/usr/local 43fi 44 45if [ ! -x "${PROTOBUF_INSTALL_DIR}/bin/protoc" ] 46then 47 echo 48 echo "No usable protocol buffer (protoc) compiler found in ${PROTOBUF_INSTALL_DIR}/bin/" 49 echo "You can specify the location of the protobuf installation as the second" 50 echo "argument of ${THIS_SCRIPT}." 51 usage 52 exit 1 53fi 54 55OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH 56#hardware_types.proto and autotuning.proto not required 57find tensorflow -type f -name '*.proto' | grep -v autotuning | grep -v hardware_types | while read -r i; do 58 LD_LIBRARY_PATH=$OLD_LD_LIBRARY_PATH:${PROTOBUF_INSTALL_DIR}/lib $PROTOBUF_INSTALL_DIR/bin/protoc "$i" \ 59 --proto_path=. \ 60 --proto_path=${PROTOBUF_INSTALL_DIR}/include \ 61 --cpp_out "$OUTPUT_DIR" 62 EXIT_CODE=$? 63 if [ $EXIT_CODE -ne 0 ]; then 64 echo "Failed to make proto files" 65 exit 1 66 fi 67done