| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #!/bin/bash
- set -e
- pushd $(cd $(dirname ${0})/..; pwd) > /dev/null
- bold() {
- echo "$(tty -s && tput bold)$1$(tty -s && tput sgr0)"
- }
- clean() {
- bold "mnn clean"
- rm -rf "./third_party/src/mnn"
- }
- sync() {
- bold "mnn sync"
- [ -d "./third_party/src/mnn" ] || git clone --quiet https://github.com/alibaba/MNN.git "./third_party/src/mnn"
- pushd "./third_party/src/mnn" > /dev/null
- git pull --quiet --prune
- popd > /dev/null
- }
- schema() {
- bold "mnn schema"
- case "${OSTYPE}" in
- linux*)
- flatc_version=$(curl -s https://api.github.com/repos/google/flatbuffers/releases/latest | grep tag_name | cut -f 2 -d : | cut -f 2 -d '"')
- flatc_dir=./third_party/bin/flatbuffers/${flatc_version}
- if [ ! -f "${flatc_dir}/flatc" ]; then
- mkdir -p "${flatc_dir}"
- pushd "${flatc_dir}" > /dev/null
- curl -sL https://github.com/google/flatbuffers/archive/${flatc_version}.tar.gz | tar zx --strip-components 1
- cmake -G "Unix Makefiles" . &> /dev/null
- make > /dev/null
- popd > /dev/null
- fi
- export PATH=${flatc_dir}:${PATH}
- ;;
- darwin*)
- brew list flatbuffers > /dev/null 2>&1 || brew install flatbuffers > /dev/null
- ;;
- msys*)
- [ -x "$(command -v flatc)" ] || $(choco install flatc) > /dev/null
- ;;
- esac
- [[ $(grep -U $'\x0D' ./src/mnn-schema.js) ]] && crlf=1
- flatc --no-js-exports --gen-all -o ./tools/. --js ./third_party/src/mnn/schema/default/MNN.fbs
- mv ./tools/MNN_generated.js ./src/mnn-schema.js
- cat <<EOT >> ./src/mnn-schema.js
- if (typeof module !== 'undefined' && typeof module.exports === 'object') {
- module.exports = MNN;
- }
- EOT
- if [[ -n ${crlf} ]]; then
- unix2dos --quiet --newfile ./src/mnn-schema.js ./src/mnn-schema.js
- fi
- }
- while [ "$#" != 0 ]; do
- command="$1" && shift
- case "${command}" in
- "clean") clean;;
- "sync") sync;;
- "schema") schema;;
- esac
- done
|