build_inside.sh 2.4 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 21
echo ">>> paddle: $PADDLE_DIR"
echo ">>> python: $PYTHON_VERSION"
22 23 24 25

# exit when any command fails
set -e

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

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

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

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

chen.zhiyu's avatar
chen.zhiyu 已提交
44 45 46 47 48 49 50 51 52 53 54 55
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

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

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

export FLAGS_call_stack_level=2

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

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

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

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

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

chen.zhiyu's avatar
chen.zhiyu 已提交
88 89 90 91 92 93 94
    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"
95

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