| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #!/bin/bash
- set -e
- if [ "$#" == 0 ]; then
- __sync=true
- __build=true
- __update=true
- else
- while test $# -gt 0
- do
- case "$1" in
- sync) __sync=true;;
- build) __build=true;;
- update) __update=true;;
- esac
- shift
- done
- fi
- root=$(cd $(dirname ${0})/../..; pwd)
- src=${root}/src
- tools=${root}/tools
- third_party=${root}/third_party
- mkdir -p ${third_party}
- identifier=tensorflow
- if [ ${__sync} ]; then
- repository=https://github.com/google/flatbuffers.git
- if [ -d "${third_party}/flatbuffers" ]; then
- git -C "${third_party}/flatbuffers" fetch -p
- git -C "${third_party}/flatbuffers" reset --hard origin/master
- else
- echo "Clone ${repository}..."
- git -C "${third_party}" clone --recursive ${repository}
- fi
- repository=https://github.com/tensorflow/${identifier}.git
- if [ -d "${third_party}/${identifier}" ]; then
- git -C "${third_party}/${identifier}" fetch -p
- git -C "${third_party}/${identifier}" reset --hard origin/master
- else
- echo "Clone ${repository}..."
- git -C "${third_party}" clone --recursive ${repository}
- fi
- fi
- if [ ${__build} ]; then
- pushd "${third_party}/flatbuffers" > /dev/null
- cmake -G "Unix Makefiles"
- make
- popd > /dev/null
- fi
- if [ ${__update} ]; then
- echo "Generate '../src/tflite-schema.js'"
- cp ${third_party}/tensorflow/tensorflow/lite/schema/schema.fbs ${tools}/metadata/tflite.schema.fbs
- sed -i 's/namespace tflite\;/namespace tflite_schema\;/' ${tools}/metadata/tflite.schema.fbs
- ${third_party}/flatbuffers/flatc --no-js-exports --js ${tools}/metadata/tflite.schema.fbs
- mv ./tflite.schema_generated.js ${src}/tflite-schema.js
- rm ${tools}/metadata/tflite.schema.fbs
- cat <<EOT >> ${src}/tflite-schema.js
- if (typeof module !== 'undefined' && typeof module.exports === 'object') {
- module.exports = tflite_schema;
- }
- EOT
- fi
|