-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathgenerate.sh
executable file
·50 lines (41 loc) · 1.2 KB
/
generate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash -ue
JUBATUS_DIR="jubatus-generate"
JUBATUS_BRANCH="master"
CLIENT_DIR="$(cd $(dirname ${0}) && echo ${PWD})"
[ $# -eq 0 ] || JUBATUS_BRANCH="${1}"
rm -rf "${JUBATUS_DIR}"
git clone https://github.com/jubatus/jubatus.git "${JUBATUS_DIR}"
pushd "${JUBATUS_DIR}"
git checkout "${JUBATUS_BRANCH}"
popd
# Python
capitalize() {
python -c "print(''.join(map(str.capitalize, '${1}'.split('_'))))"
}
for DIR in "${CLIENT_DIR}/jubatus/"*; do
NAME="$(basename "${DIR}")"
if [ "${NAME}" != "common" -a "${NAME}" != "embedded.py" ]; then
rm -rf $DIR
fi
done
SERVICE_LIST=()
pushd "${JUBATUS_DIR}/jubatus/server/server"
for IDL in *.idl; do
NAMESPACE="$(basename "${IDL}" ".idl")"
SERVICE_LIST[${#SERVICE_LIST[@]}]="${NAMESPACE}"
IDL_HASH=`git log -1 --format=%H -- ${IDL}`
IDL_VER=`git describe ${IDL_HASH}`
jenerator -l python "${IDL}" -o "${CLIENT_DIR}/jubatus" --idl-version ${IDL_VER}
done
popd
cat << _EOF_ > "${CLIENT_DIR}/jubatus/__init__.py"
__all__ = [$(
for SERVICE in ${SERVICE_LIST[@]}; do
echo -n '"'${SERVICE}'", ';
done
)]
$(for SERVICE in ${SERVICE_LIST[@]}; do
echo "from jubatus.${SERVICE}.client import $(capitalize "${SERVICE}")";
done)
_EOF_
rm -rf "${JUBATUS_DIR}"