build.sh 1.7 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 20
    local SRC=`npm view ${PACKAGE_NAME}@latest dist.tarball`
    # wget $SRC -O "$BUILD_DIR/$PACKAGE_NAME.tar.gz"
    curl -o "$BUILD_DIR/$PACKAGE_NAME.tar.gz" $SRC
21 22 23
    tar zxf "$BUILD_DIR/$PACKAGE_NAME.tar.gz" -C "$BUILD_DIR"
}

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

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

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

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*
52 53
    rm -rf $BUILD_DIR/*.tar.gz
    rm -rf $BUILD_DIR/package
54 55 56
}

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

ARG=$1
echo "ARG: " $ARG

66 67
clean_env

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

74 75 76
build_backend
build_onnx_graph
package