build.sh 1.3 KB
Newer Older
1
#!/bin/bash
P
Peter Pan 已提交
2
set -e
3 4 5 6 7 8 9 10 11 12

TOP_DIR=$(pwd)
FRONTEND_DIR=$TOP_DIR/frontend
BACKEND_DIR=$TOP_DIR/visualdl
BUILD_DIR=$TOP_DIR/build

mkdir -p $BUILD_DIR

build_frontend() {
    cd $FRONTEND_DIR
P
Peter Pan 已提交
13 14 15 16 17 18
    PUBLIC_PATH="/app" API_URL="/api" ./scripts/build.sh
}

build_frontend_fake() {
    cd $FRONTEND_DIR
    mkdir -p out
19 20 21 22
}

build_backend() {
    cd $BUILD_DIR
O
Oraoto 已提交
23 24 25 26 27
    if [[ $WITH_PYTHON3 ]]; then
        cmake -DWITH_PYTHON3=ON .. ${PYTHON_FLAGS}
    else
        cmake .. ${PYTHON_FLAGS}
    fi
28 29 30 31 32
    make -j2
}

build_onnx_graph() {
    export PATH="$BUILD_DIR/third_party/protobuf/src/extern_protobuf-build/:$PATH"
P
Peter Pan 已提交
33
    cd $TOP_DIR/visualdl/server/model/onnx
34
    protoc onnx.proto --python_out .
P
Peter Pan 已提交
35 36
    cd $TOP_DIR/visualdl/server/model/paddle
    protoc framework.proto --python_out .
37 38 39 40 41 42 43 44 45 46 47
}

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() {
P
Peter Pan 已提交
48 49 50 51
    mkdir -p $TOP_DIR/visualdl/server/dist
    cp -rf $FRONTEND_DIR/out/* $TOP_DIR/visualdl/server/dist
    cp $BUILD_DIR/visualdl/logic/core.so $TOP_DIR/visualdl
    cp $BUILD_DIR/visualdl/logic/core.so $TOP_DIR/visualdl/python/
52 53 54 55 56
}

ARG=$1
echo "ARG: " $ARG

P
Peter Pan 已提交
57 58 59 60 61 62
if [ "$ARG" = "travis-CI" ]; then
    build_frontend_fake
else
    build_frontend
fi

63 64 65 66
clean_env
build_backend
build_onnx_graph
package