build.sh 1.8 KB
Newer Older
X
xiexionghang 已提交
1
#!bash
X
xiexionghang 已提交
2 3
RUN_DIR="$(cd "$(dirname "$0")"&&pwd)"
cd ${RUN_DIR}
X
xiexionghang 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
build_mode=$1
function print_usage() {
    echo "++++++++++++++++++++++++++++++++++++++++++++++++++++"
    echo "sh build.sh all|make|clean"
    echo "- all: will update all env && make it"
    echo "- make: just do make, never update env"
    echo "- clean: make clean"
    echo "++++++++++++++++++++++++++++++++++++++++++++++++++++"
    exit 0
}
if [ $# -lt 1 ];then
    print_usage
fi

cd ~
user_dir=`pwd`
cd -

python_binary=${user_dir}/.jumbo/bin/python2.7
python_library=${user_dir}/.jumbo/lib/python2.7.so
python_include_dir=${user_dir}/.jumbo/include/python2.7
if [ ! -f ${python_binary} ];then
    echo "Miss python ${python_binary}, please install with this cmd: jumbo install python"
    exit -1
fi

X
xiexionghang 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46

function copy_paddle_env() {
    cd ${RUN_DIR}
    rm -rf build_env
    mkdir build_env
    echo "xxh copy"
    cp -r ../../paddlepaddle/paddle/* build_env
    cp -r feed ./build_env/paddlepaddle/paddle/paddle/fluid/
    cd build_env
}

function apply_feed_code() {
    #apply feed code
    if [ -f "paddle/fluid/feed/apply_feed_code.sh" ];then
        sh paddle/fluid/feed/apply_feed_code.sh
    fi 
}
X
xiexionghang 已提交
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

function makeit() {
    cd build
    make -j8
    cd ..
}

function cmake_all() {
    mkdir build
    cd build
    #make clean
    cmake -DCMAKE_INSTALL_PREFIX=./output/ -DCMAKE_BUILD_TYPE=Release -DWITH_PYTHON=ON -DWITH_MKL=OFF -DWITH_GPU=OFF -DWITH_PSLIB=ON -DPYTHON_INCLUDE_DIR=${python_include_dir} -DPYTHON_LIBRARY=${python_library} -DPYTHON_EXECUTABLE=${python_binary} ..
    cd ..
}

X
xiexionghang 已提交
62 63 64 65 66
if [ ! -d build_env ];then
    copy_paddle_env
fi
cd ${RUN_DIR}/build_env

X
xiexionghang 已提交
67 68 69 70 71 72
if [ "${build_mode}" = "all" ];then
    cmake_all
    makeit
elif [ "${build_mode}" = "make" ];then
    makeit
elif "${build_mode}" = "clean" ];then
X
xiexionghang 已提交
73 74 75
    copy_paddle_env
    #cd build
    #make clean
X
xiexionghang 已提交
76
fi