caffe 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. set -e
  3. root=$(cd $(dirname ${0})/..; pwd)
  4. node_modules=${root}/node_modules
  5. src=${root}/src
  6. tools=${root}/tools
  7. third_party=${root}/third_party
  8. identifier=caffe
  9. bold() {
  10. echo "$(tty -s && tput bold)$1$(tty -s && tput sgr0)"
  11. }
  12. git_sync() {
  13. mkdir -p "${third_party}"
  14. if [ -d "${third_party}/${1}" ]; then
  15. git -C "${third_party}/${1}" fetch -p --quiet
  16. git -C "${third_party}/${1}" reset --quiet --hard origin/master
  17. else
  18. echo "Clone ${2}..."
  19. git -C "${third_party}" clone --recursive ${2}
  20. fi
  21. git submodule update --init
  22. }
  23. clean() {
  24. bold "caffe clean"
  25. rm -tf ${third_party}/caffe
  26. }
  27. sync() {
  28. bold "caffe sync"
  29. git_sync caffe https://github.com/BVLC/caffe.git
  30. }
  31. schema() {
  32. bold "caffe schema"
  33. cp ${third_party}/${identifier}/src/caffe/proto/caffe.proto ${tools}/caffe.proto
  34. node ${tools}/caffe-schema.js ${tools}/caffe.proto
  35. ${node_modules}/protobufjs/bin/pbjs -t static-module -w closure --no-encode --no-delimited --no-comments --keep-case --decode-text -r caffe -o ${src}/caffe-proto.js ${tools}/caffe.proto
  36. node ${tools}/update_pbjs.js array ${src}/caffe-proto.js data float 1
  37. rm -rf ${tools}/caffe.proto
  38. }
  39. while [ "$#" != 0 ]; do
  40. command="$1" && shift
  41. case "${command}" in
  42. "clean") clean;;
  43. "sync") sync;;
  44. "schema") schema;;
  45. esac
  46. done