forked from PaddlePaddle/VisualDL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
76 lines (63 loc) · 1.47 KB
/
build.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
set -ex
TOP_DIR=$(pwd)
FRONTEND_DIR=$TOP_DIR/frontend
BACKEND_DIR=$TOP_DIR/visualdl
BUILD_DIR=$TOP_DIR/build
mkdir -p $BUILD_DIR
check_duplicated() {
filename_format=$1
file_num=`ls dist/${filename_format} | wc -l | awk '{$1=$1;print}'`
if [ "$file_num" != "1" ]; then
echo "dist have duplicate file for $file_num, please clean and rerun"
exit 1
fi
}
build_frontend() {
cd $FRONTEND_DIR
if [ ! -d "dist" ]; then
npm install
npm run build
fi
for file_name in "manifest.*.js" "index.*.js" "vendor.*.js"; do
echo $file_name
check_duplicated $file_name
done
}
build_frontend_fake() {
cd $FRONTEND_DIR
mkdir -p dist
}
build_backend() {
cd $BUILD_DIR
cmake .. ${PYTHON_FLAGS}
make -j2
}
build_onnx_graph() {
export PATH="$BUILD_DIR/third_party/protobuf/src/extern_protobuf-build/:$PATH"
cd $TOP_DIR/visualdl/server/onnx
protoc onnx.proto --python_out .
}
clean_env() {
rm -rf $TOP_DIR/visualdl/server/dist
rm -rf $BUILD_DIR/bdist*
rm -rf $BUILD_DIR/lib*
rm -rf $BUILD_DIR/temp*
rm -rf $BUILD_DIR/scripts*
}
package() {
cp -rf $FRONTEND_DIR/dist $TOP_DIR/visualdl/server/
cp $BUILD_DIR/visualdl/logic/core.so $TOP_DIR/visualdl
cp $BUILD_DIR/visualdl/logic/core.so $TOP_DIR/visualdl/python/
}
ARG=$1
echo "ARG: " $ARG
if [ "$ARG" = "travis-CI" ]; then
build_frontend_fake
else
build_frontend
fi
clean_env
build_backend
build_onnx_graph
package