blob: b44823f1ddb0a579bd0f356c3f932ea9156d1bdd [file] [log] [blame]
surmeh01bceff2f2018-03-29 16:29:27 +01001#!/bin/sh
2#
3# Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01004# SPDX-License-Identifier: MIT
surmeh01bceff2f2018-03-29 16:29:27 +01005#
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
James Conroy04cd6032022-04-20 17:16:50 +010027mkdir -p "${OUTPUT_DIR}"
surmeh01bceff2f2018-03-29 16:29:27 +010028ERR=$?
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
Sadik Armagan9e51cde2020-10-01 17:12:17 +010055OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
56#hardware_types.proto and autotuning.proto not required
James Conroy04cd6032022-04-20 17:16:50 +010057find 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" \
Sadik Armagan9e51cde2020-10-01 17:12:17 +010059 --proto_path=. \
60 --proto_path=${PROTOBUF_INSTALL_DIR}/include \
James Conroy04cd6032022-04-20 17:16:50 +010061 --cpp_out "$OUTPUT_DIR"
Sadik Armagand63e86c2020-10-09 13:39:17 +010062 EXIT_CODE=$?
63 if [ $EXIT_CODE -ne 0 ]; then
64 echo "Failed to make proto files"
65 exit 1
66 fi
Sadik Armagan9e51cde2020-10-01 17:12:17 +010067done