2
0

paddle 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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=paddle
  9. virtualenv=${root}/build/virtualenv/${identifier}
  10. if [ $(which python3) ] && [ $(which pip3) ]; then
  11. python="python3"
  12. pip="pip3"
  13. else
  14. python="python"
  15. pip="pip"
  16. fi
  17. bold() {
  18. echo "$(tty -s && tput bold)$1$(tty -s && tput sgr0)"
  19. }
  20. git_sync () {
  21. mkdir -p "${third_party}"
  22. if [ -d "${third_party}/${1}" ]; then
  23. git -C "${third_party}/${1}" fetch -p --quiet
  24. git -C "${third_party}/${1}" reset --quiet --hard origin/$(git -C "${third_party}/${1}" rev-parse --abbrev-ref HEAD)
  25. else
  26. echo "Clone ${2}..."
  27. git -C "${third_party}" clone --recursive ${2} ${1}
  28. fi
  29. }
  30. clean() {
  31. bold "paddle clean"
  32. rm -rf ${third_party}/paddle
  33. }
  34. sync() {
  35. bold "paddle sync"
  36. git_sync paddle https://github.com/PaddlePaddle/Paddle.git
  37. }
  38. install() {
  39. bold "paddle install"
  40. if [ ! -d "${virtualenv}" ]; then
  41. virtualenv --quiet -p ${python} ${virtualenv}
  42. fi
  43. source ${virtualenv}/bin/activate
  44. ${pip} install --quiet ${third_party}/${identifier}
  45. deactivate
  46. }
  47. schema() {
  48. bold "paddle schema"
  49. ${node_modules}/protobufjs/bin/pbjs -t static-module -w closure --no-encode --no-delimited --no-comments --keep-case -r paddle -o ${src}/paddle-proto.js ${third_party}/${identifier}/paddle/fluid/framework/framework.proto
  50. }
  51. while [ "$#" != 0 ]; do
  52. command="$1" && shift
  53. case "${command}" in
  54. "clean") clean;;
  55. "sync") sync;;
  56. "install") install;;
  57. "schema") schema;;
  58. esac
  59. done