armnn 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash
  2. set -e
  3. pushd $(cd $(dirname ${0})/..; pwd) > /dev/null
  4. bold() {
  5. echo "$(tty -s && tput bold)$1$(tty -s && tput sgr0)"
  6. }
  7. clean() {
  8. bold "armnn clean"
  9. rm -rf ./third_party/src/armnn
  10. }
  11. sync() {
  12. bold "armnn sync"
  13. [ -d "./third_party/src/armnn" ] || git clone --quiet --branch master https://github.com/ARM-software/armnn.git "./third_party/src/armnn"
  14. pushd "./third_party/src/armnn" > /dev/null
  15. git pull --quiet --prune
  16. popd > /dev/null
  17. }
  18. schema() {
  19. bold "armnn schema"
  20. case "${OSTYPE}" in
  21. linux*)
  22. flatc_version=$(curl -s https://api.github.com/repos/google/flatbuffers/releases/latest | grep tag_name | cut -f 2 -d : | cut -f 2 -d '"')
  23. flatc_dir=./third_party/bin/flatbuffers/${flatc_version}
  24. if [ ! -f "${flatc_dir}/flatc" ]; then
  25. mkdir -p "${flatc_dir}"
  26. pushd "${flatc_dir}" > /dev/null
  27. curl -sL https://github.com/google/flatbuffers/archive/${flatc_version}.tar.gz | tar zx --strip-components 1
  28. cmake -G "Unix Makefiles" . &> /dev/null
  29. make > /dev/null
  30. popd > /dev/null
  31. fi
  32. export PATH=${flatc_dir}:${PATH}
  33. ;;
  34. darwin*)
  35. brew list flatbuffers > /dev/null 2>&1 || brew install flatbuffers > /dev/null
  36. ;;
  37. msys*)
  38. [ -x "$(command -v flatc)" ] || $(choco install flatc) > /dev/null
  39. ;;
  40. esac
  41. [[ $(grep -U $'\x0D' ./src/armnn-schema.js) ]] && crlf=1
  42. flatc --no-js-exports -o ./tools/. --js ./third_party/src/armnn/src/armnnSerializer/ArmnnSchema.fbs
  43. mv ./tools/ArmnnSchema_generated.js ./src/armnn-schema.js
  44. cat <<EOT >> ./src/armnn-schema.js
  45. if (typeof module !== 'undefined' && typeof module.exports === 'object') {
  46. module.exports = armnnSerializer;
  47. }
  48. EOT
  49. if [[ -n ${crlf} ]]; then
  50. unix2dos --quiet --newfile ./src/armnn-schema.js ./src/armnn-schema.js
  51. fi
  52. }
  53. while [ "$#" != 0 ]; do
  54. command="$1" && shift
  55. case "${command}" in
  56. "clean") clean;;
  57. "sync") sync;;
  58. "schema") schema;;
  59. esac
  60. done