| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
if [ "$#" -ne 1 ]; then |
| 4 |
echo "Please provide the path to the output directory as the only argument." |
| 5 |
exit 1 |
| 6 |
fi |
| 7 |
|
| 8 |
|
| 9 |
function execute() { |
| 10 |
stdbuf -o0 -e0 echo "% $@" ; |
| 11 |
if [ $# -gt 0 ] ; then |
| 12 |
if [ $1 == "module" ] ; then |
| 13 |
module "${@:2}" ; |
| 14 |
elif [ $1 == "source" ] ; then |
| 15 |
source "${@:2}" ; |
| 16 |
else |
| 17 |
eval "$@" ; |
| 18 |
fi |
| 19 |
fi |
| 20 |
if [ $? -ne 0 ] ; then |
| 21 |
echo "'$@' failed."; |
| 22 |
exit 1; |
| 23 |
fi |
| 24 |
} |
| 25 |
|
| 26 |
function cd_to_new_dir() |
| 27 |
{ |
| 28 |
execute rm -rf $1 |
| 29 |
execute mkdir $1 |
| 30 |
execute cd $1 |
| 31 |
} |
| 32 |
|
| 33 |
function exit_with_message() |
| 34 |
{ |
| 35 |
echo $1 |
| 36 |
exit 1 |
| 37 |
} |
| 38 |
|
| 39 |
function make_and_install() |
| 40 |
{ |
| 41 |
make -j 16 || exit_with_message "Failed building $1" |
| 42 |
make install || exit_with_message "Failed installing $1" |
| 43 |
} |
| 44 |
|
| 45 |
function pull_and_build_yaml() |
| 46 |
{ |
| 47 |
productName=yaml |
| 48 |
|
| 49 |
cd_to_new_dir ${output_dir}/${productName} |
| 50 |
|
| 51 |
execute git clone https://github.com/jbeder/yaml-cpp.git yaml-cpp |
| 52 |
cd yaml-cpp |
| 53 |
git checkout tags/yaml-cpp-0.6.3 |
| 54 |
cd .. |
| 55 |
|
| 56 |
cd_to_new_dir ${productName}_build |
| 57 |
|
| 58 |
execute cmake -DCMAKE_BUILD_TYPE=${build_type^^} -DYAML_CPP_BUILD_TESTS=false -DCMAKE_INSTALL_PREFIX=../${productName}_install ../yaml-cpp |
| 59 |
make_and_install $productName |
| 60 |
} |
| 61 |
|
| 62 |
function pull_Trilinos() |
| 63 |
{ |
| 64 |
productName=trilinos |
| 65 |
|
| 66 |
trilinos_dir=${output_dir}/${productName} |
| 67 |
if [ ! -d ${trilinos_dir} ] ; then |
| 68 |
execute mkdir ${trilinos_dir} |
| 69 |
fi |
| 70 |
execute cd ${trilinos_dir} |
| 71 |
|
| 72 |
if [ ! -d Trilinos ] ; then |
| 73 |
execute git clone -b develop https://github.com/trilinos/Trilinos.git Trilinos |
| 74 |
else |
| 75 |
execute cd Trilinos |
| 76 |
execute git checkout develop |
| 77 |
execute git clean -fd |
| 78 |
execute git reset --hard |
| 79 |
execute git pull |
| 80 |
execute cd .. |
| 81 |
fi |
| 82 |
} |
| 83 |
|
| 84 |
function build_krino_Trilinos_package() |
| 85 |
{ |
| 86 |
productName=trilinos |
| 87 |
|
| 88 |
execute cd ${output_dir}/${productName} |
| 89 |
|
| 90 |
rm -rf ${productName}_install |
| 91 |
cd_to_new_dir ${productName}_build |
| 92 |
|
| 93 |
export TRILINOS_INSTALL_DIR=../${productName}_install |
| 94 |
|
| 95 |
execute ../Trilinos/packages/krino/cmake_install_test/run_cmake_krino |
| 96 |
make_and_install $productName |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
function setup_environment() |
| 101 |
{ |
| 102 |
execute source /etc/profile.d/modules.sh |
| 103 |
execute module purge |
| 104 |
|
| 105 |
execute source ${output_dir}/${productName}/Trilinos/packages/krino/cmake_install_test/load_gcc_modules |
| 106 |
|
| 107 |
execute module list |
| 108 |
execute env |
| 109 |
} |
| 110 |
|
| 111 |
output_dir=$1 |
| 112 |
|
| 113 |
build_type=${CMAKE_BUILD_TYPE:-release} |
| 114 |
date_suffix=`date +%F_%H-%M-%S` |
| 115 |
|
| 116 |
if [ ! -d ${output_dir} ] ; then |
| 117 |
execute mkdir ${output_dir} |
| 118 |
fi |
| 119 |
|
| 120 |
pull_Trilinos |
| 121 |
setup_environment |
| 122 |
|
| 123 |
pull_and_build_yaml |
| 124 |
build_krino_Trilinos_package |