caffe 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 "caffe clean"
  9. rm -rf "./third_party/source/caffe"
  10. }
  11. sync() {
  12. bold "caffe sync"
  13. [ -d "./third_party/source/caffe" ] || git clone --quiet https://github.com/BVLC/caffe.git "./third_party/source/caffe"
  14. pushd "./third_party/source/caffe" > /dev/null
  15. git pull --quiet --prune
  16. popd > /dev/null
  17. }
  18. schema() {
  19. bold "caffe schema"
  20. [[ $(grep -U $'\x0D' ./source/caffe-proto.js) ]] && crlf=1
  21. temp=$(mktemp -d)
  22. sed 's/required float min = 1;/optional float min = 1;/g;s/required float max = 2;/optional float max = 2;/g' < ./third_party/source/caffe/src/caffe/proto/caffe.proto > ${temp}/caffe.proto
  23. node ./tools/protoc.js --text --root caffe --out ./source/caffe-proto.js ${temp}/caffe.proto
  24. rm -rf ${temp}
  25. if [[ -n ${crlf} ]]; then
  26. unix2dos --quiet --newfile ./source/caffe-proto.js ./source/caffe-proto.js
  27. fi
  28. }
  29. while [ "$#" != 0 ]; do
  30. command="$1" && shift
  31. case "${command}" in
  32. "clean") clean;;
  33. "sync") sync;;
  34. "schema") schema;;
  35. esac
  36. done