Tensorflow has a tool called prototext
.
It is bundled with Tensorflow so tightly. This repo extracts essential code.
You have to install protobuf and then change the locations in CMakeLists.txt
On Mac:
brew install automake libtool
git clone https://github.com/google/protobuf
# cd to protobuf directory
mkdir output
./autogen.sh
./configure --prefix={path-to-output}
make && make install
INCLUDE_DIRECTORIES({path-to-output}/include)
TARGET_LINK_LIBRARIES({path-to-output}/lib)
mkdir build
cd build && cmake ..
# generate a binary called `proto_text` with path={path-to-proto-text}
# cd to the home to tensorflow
function bbbb() {
cmd="{path-to-proto-text}" # generated by previous process
file=$1
# to remove ./
file=${file:2}
${cmd} ${file}
cmd="/path/to/protoc"
SRC_DIR="./"
DST_DIR=`dirname ${file}`
${cmd} -I=$SRC_DIR --cpp_out="." ${file}
}
export -f bbbb
find . -name "*.proto" -exec bash -c 'bbbb "$0"' {} \;