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
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
54
    echo "pyyaml" >> $WITH_REQUIREMENT
chen.zhiyu's avatar
chen.zhiyu 已提交
55 56 57 58
    echo ">>> install python requirement: $WITH_REQUIREMENT";
    pip install $PIP_ARGS -r "$WITH_REQUIREMENT";
fi

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

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

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

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

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

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

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

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

chen.zhiyu's avatar
chen.zhiyu 已提交
91 92 93 94 95 96 97
    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"
98

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