build_inside.sh 1.8 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 20 21 22 23 24 25

echo "paddle: $PADDLE_DIR"
echo "python: $PYTHON_VERSION"

# exit when any command fails
set -e

26 27 28
# setup build dir
echo "setup build dir: $BUILD_DIR"
mkdir -p $BUILD_DIR
29

30 31
if [ "$HTTP_PROXY" ]; then 
    echo "http_proxy: $HTTP_PROXY" 
32 33 34
    git config --global http.proxy "$HTTP_PROXY"
fi

35 36
if [ "$HTTP_PROXY" ]; then 
    echo "https_proxy: $HTTPS_PROXY" 
37 38 39
    git config --global https.proxy "$HTTPS_PROXY"
fi

40 41 42 43 44 45
BUILD_ARG=""
if [ "$WITH_TEST" == "1" ]; then
    echo "build paddle with testing"
    BUILD_ARG="-DWITH_TESTING=ON"
else
    BUILD_ARG="-DWITH_TESTING=OFF"
46 47 48 49 50 51 52
fi

echo "configure with cmake"
cmake "$PADDLE_DIR" \
    -DWITH_MUSL=ON \
    -DWITH_CRYPTO=OFF \
    -DWITH_MKL=OFF \
53 54
    -DWITH_GPU=OFF \
    "$BUILD_ARG"
55 56 57 58 59

echo "compile with make: $*"
# shellcheck disable=2068
make $@

60 61 62 63 64 65 66 67 68 69 70 71 72 73
OUTPUT_WHL="$(find python/dist/ -type f -name '*.whl'| head -n1)"
echo "paddle wheel: $OUTPUT_WHL"

echo "save paddle wheel package to /output"
cp  "$OUTPUT_WHL" /output/

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

    echo "install paddle wheel package"
    pip3 install --no-cache --force-overwrite "$OUTPUT_WHL"

    echo "run ctest"
    ctest --output-on-failure
fi