Browse Source

Add Chainer script (#337)

Lutz Roeder 6 years ago
parent
commit
67f4ceaf87
2 changed files with 46 additions and 0 deletions
  1. 1 0
      Makefile
  2. 45 0
      tools/chainer

+ 1 - 0
Makefile

@@ -23,6 +23,7 @@ update:
 	@[ -d node_modules ] || npm install
 	@./tools/caffe sync schema
 	@./tools/coreml sync install schema
+	@./tools/chainer sync
 	@./tools/cntk sync schema
 	@./tools/darknet sync
 	@./tools/dl4j sync

+ 45 - 0
tools/chainer

@@ -0,0 +1,45 @@
+#!/bin/bash
+
+set -e
+
+root=$(cd $(dirname ${0})/..; pwd)
+build=${root}/build
+test=${root}/test
+third_party=${root}/third_party
+tools=${root}/tools
+
+identifier=chainer
+virtualenv=${third_party}/virtualenv/${identifier}
+
+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}" pull --quiet --prune
+    else
+        git -C "${third_party}" clone --quiet --recursive ${2}
+    fi
+    git -C "${third_party}/${1}" submodule sync --quiet
+    git -C "${third_party}/${1}" submodule update --quiet --init --recursive
+}
+
+clean() {
+    bold "chainer clean"
+    rm -rf ${third_party}/${identifier}
+}
+
+sync() {
+    bold "chainer sync"
+    git_sync chainer https://github.com/chainer/chainer.git
+}
+
+while [ "$#" != 0 ]; do
+    command="$1" && shift
+    case "${command}" in
+        "clean") clean;;
+        "sync") sync;;
+    esac
+done