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

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

mkdir -p $BUILD_DIR

11
build_frontend_from_source() {
12
    cd $FRONTEND_DIR
P
Peter Pan 已提交
13 14 15
    PUBLIC_PATH="/app" API_URL="/api" ./scripts/build.sh
}

16 17
build_frontend() {
    local PACKAGE_NAME="visualdl"
18 19
    local PACKAGE=`(cd $BUILD_DIR && npm pack ${PACKAGE_NAME}@latest)`
    tar zxf "$BUILD_DIR/$PACKAGE" -C "$BUILD_DIR"
20 21
}

P
Peter Pan 已提交
22
build_frontend_fake() {
23
    mkdir -p "$BUILD_DIR/package/serverless"
24 25 26 27
}

build_backend() {
    cd $BUILD_DIR
O
Oraoto 已提交
28 29 30 31 32
    if [[ $WITH_PYTHON3 ]]; then
        cmake -DWITH_PYTHON3=ON .. ${PYTHON_FLAGS}
    else
        cmake .. ${PYTHON_FLAGS}
    fi
33 34 35 36 37
    make -j2
}

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

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*
50
    rm -rf $BUILD_DIR/*.tgz
51
    rm -rf $BUILD_DIR/package
52 53 54
}

package() {
P
Peter Pan 已提交
55
    mkdir -p $TOP_DIR/visualdl/server/dist
56
    cp -rf $BUILD_DIR/package/serverless/* $TOP_DIR/visualdl/server/dist
P
Peter Pan 已提交
57 58
    cp $BUILD_DIR/visualdl/logic/core.so $TOP_DIR/visualdl
    cp $BUILD_DIR/visualdl/logic/core.so $TOP_DIR/visualdl/python/
59 60 61 62 63
}

ARG=$1
echo "ARG: " $ARG

64 65
clean_env

P
Peter Pan 已提交
66 67 68 69 70 71
if [ "$ARG" = "travis-CI" ]; then
    build_frontend_fake
else
    build_frontend
fi

72 73 74
build_backend
build_onnx_graph
package