build_inside.sh 2.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/bin/sh

# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

PADDLE_DIR=/paddle
18
BUILD_DIR=$PWD/build
19

chen.zhiyu's avatar
chen.zhiyu 已提交
20
echo ">>> paddle: $PADDLE_DIR"
21 22
export PADDLE_ROOT="$PADDLE_DIR"

chen.zhiyu's avatar
chen.zhiyu 已提交
23
echo ">>> python: $PYTHON_VERSION"
24 25 26 27

# exit when any command fails
set -e

28
# setup build dir
chen.zhiyu's avatar
chen.zhiyu 已提交
29 30 31 32 33 34
echo ">>> setup build dir: $BUILD_DIR"
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"

# setup root dir
chown -R root:root /root
35

36
if [ "$HTTP_PROXY" ]; then 
chen.zhiyu's avatar
chen.zhiyu 已提交
37
    echo ">>> http_proxy: $HTTP_PROXY" 
38 39 40
    git config --global http.proxy "$HTTP_PROXY"
fi

41
if [ "$HTTP_PROXY" ]; then 
chen.zhiyu's avatar
chen.zhiyu 已提交
42
    echo ">>> https_proxy: $HTTPS_PROXY" 
43 44 45
    git config --global https.proxy "$HTTPS_PROXY"
fi

chen.zhiyu's avatar
chen.zhiyu 已提交
46 47 48 49 50 51 52 53 54 55 56 57
PIP_ARGS="--timeout 300"
if [ "$pip_index" ]; then
    PIP_DOMAIN=$(echo "$pip_index" | awk -F/ '{print $3}')
    PIP_ARGS="$PIP_ARGS -i $pip_index --trusted-host $PIP_DOMAIN"
    echo ">>> pip index: $pip_index"
fi

if [ "$WITH_REQUIREMENT" ]; then
    echo ">>> install python requirement: $WITH_REQUIREMENT";
    pip install $PIP_ARGS -r "$WITH_REQUIREMENT";
fi

58 59
BUILD_ARG=""
if [ "$WITH_TEST" == "1" ]; then
chen.zhiyu's avatar
chen.zhiyu 已提交
60
    echo ">>> build paddle with testing"
61 62 63
    BUILD_ARG="-DWITH_TESTING=ON"
else
    BUILD_ARG="-DWITH_TESTING=OFF"
64 65
fi

chen.zhiyu's avatar
chen.zhiyu 已提交
66 67 68
echo ">>> compile source code"
set -x

69
export FLAGS_call_stack_level="${FLAGS_call_stack_level-2}"
chen.zhiyu's avatar
chen.zhiyu 已提交
70

71 72 73 74
cmake "$PADDLE_DIR" \
    -DWITH_MUSL=ON \
    -DWITH_CRYPTO=OFF \
    -DWITH_MKL=OFF \
75 76
    -DWITH_GPU=OFF \
    "$BUILD_ARG"
77 78 79

# shellcheck disable=2068
make $@
chen.zhiyu's avatar
chen.zhiyu 已提交
80
set +x
81

82
OUTPUT_WHL="$(find python/dist/ -type f -name '*.whl'| head -n1)"
chen.zhiyu's avatar
chen.zhiyu 已提交
83
echo ">>> paddle wheel: $OUTPUT_WHL"
84

chen.zhiyu's avatar
chen.zhiyu 已提交
85 86
echo ">>> save paddle wheel package to /output"
cp -f "$OUTPUT_WHL" /output/
87 88 89

if [ "$WITH_TEST" == "1" ]; then

chen.zhiyu's avatar
chen.zhiyu 已提交
90 91 92 93 94 95 96
    if [ "$WITH_UT_REQUIREMENT" ]; then
        echo ">>> install unittest requirement: $WITH_UT_REQUIREMENT"
        pip install $PIP_ARGS -r "$WITH_UT_REQUIREMENT"
    fi

    echo ">>> install paddle wheel package"
    pip install "$OUTPUT_WHL"
97

chen.zhiyu's avatar
chen.zhiyu 已提交
98
    echo ">>> run ctest"
99 100
    ctest --output-on-failure
fi