caffe 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. set -e
  3. pushd $(cd $(dirname ${0})/..; pwd) > /dev/null
  4. clean() {
  5. echo "caffe clean"
  6. rm -rf "./third_party/source/caffe"
  7. }
  8. sync() {
  9. echo "caffe sync"
  10. [ -d "./third_party/source/caffe" ] || git clone --quiet https://github.com/BVLC/caffe.git "./third_party/source/caffe"
  11. pushd "./third_party/source/caffe" > /dev/null
  12. git pull --quiet --prune
  13. popd > /dev/null
  14. }
  15. schema() {
  16. echo "caffe schema"
  17. [[ $(grep -U $'\x0D' ./source/caffe-proto.js) ]] && crlf=1
  18. temp=$(mktemp -d)
  19. 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
  20. node ./tools/protoc.js --text --root caffe --out ./source/caffe-proto.js ${temp}/caffe.proto
  21. rm -rf ${temp}
  22. if [[ -n ${crlf} ]]; then
  23. unix2dos --quiet --newfile ./source/caffe-proto.js ./source/caffe-proto.js
  24. fi
  25. }
  26. while [ "$#" != 0 ]; do
  27. command="$1" && shift
  28. case "${command}" in
  29. "clean") clean;;
  30. "sync") sync;;
  31. "schema") schema;;
  32. esac
  33. done