blob: df0d7bad860d7e0a28dbddb232912b7a04717a24 [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
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
55
56TF_PROTO_FILES=tensorflow/contrib/makefile/tf_proto_files.txt
57if [ -r $TF_PROTO_FILES ]
58then
59 OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
60 for i in `cat $TF_PROTO_FILES`
61 do
62 LD_LIBRARY_PATH=$OLD_LD_LIBRARY_PATH:${PROTOBUF_INSTALL_DIR}/lib \
63 $PROTOBUF_INSTALL_DIR/bin/protoc $i \
64 --proto_path=. \
65 --proto_path=${PROTOBUF_INSTALL_DIR}/include \
66 --cpp_out $OUTPUT_DIR
67 done
68else
69 echo "Couldn't find $TF_PROTO_FILES. This script should be run from the"
70 echo "tensorflow source directory."
71 exit 1
72fi
73