| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #!/bin/bash
- set -e
- root=$(cd $(dirname ${0})/..; pwd)
- node_modules=${root}/node_modules
- src=${root}/src
- tools=${root}/tools
- third_party=${root}/third_party
- identifier=paddle
- virtualenv=${root}/build/virtualenv/${identifier}
- if [ $(which python3) ] && [ $(which pip3) ]; then
- python="python3"
- pip="pip3"
- else
- python="python"
- pip="pip"
- fi
- bold() {
- echo "$(tty -s && tput bold)$1$(tty -s && tput sgr0)"
- }
- git_sync () {
- mkdir -p "${third_party}"
- if [ -d "${third_party}/${1}" ]; then
- git -C "${third_party}/${1}" fetch -p --quiet
- git -C "${third_party}/${1}" reset --quiet --hard origin/$(git -C "${third_party}/${1}" rev-parse --abbrev-ref HEAD)
- else
- echo "Clone ${2}..."
- git -C "${third_party}" clone --recursive ${2} ${1}
- fi
- }
- clean() {
- bold "paddle clean"
- rm -rf ${third_party}/paddle
- }
- sync() {
- bold "paddle sync"
- git_sync paddle https://github.com/PaddlePaddle/Paddle.git
- }
- install() {
- bold "paddle install"
- if [ ! -d "${virtualenv}" ]; then
- virtualenv --quiet -p ${python} ${virtualenv}
- fi
- source ${virtualenv}/bin/activate
- ${pip} install --quiet ${third_party}/${identifier}
- deactivate
- }
- schema() {
- bold "paddle schema"
- ${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
- }
- while [ "$#" != 0 ]; do
- command="$1" && shift
- case "${command}" in
- "clean") clean;;
- "sync") sync;;
- "install") install;;
- "schema") schema;;
- esac
- done
|