#! /bin/bash # # $Id$ # # Copyright 1989-2016 MINES ParisTech # # This file is part of PIPS. # # PIPS is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # any later version. # # PIPS is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. # # See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with PIPS. If not, see . # # what to do at night... function err() { local msg=$1 code=${2:-1} echo -e "$0 ...\n" echo $msg >&2 exit $code } # what to do download= update= clean=clean compile= valids= validate=validate unvalidate= # The default options for the validation: vopt="VOPT=--archive --diff" mopt='' # where to do it by default target=~/PIPS sdir=prod email= setup='https://svn.cri.mines-paristech.fr/svn/nlpmake/trunk/makes/setup_pips.sh' # compute load & jobs # is it portable? if [ -f /proc/cpuinfo ] then nproc=$(grep '^processor' /proc/cpuinfo | wc -l) load=$(($nproc + 1)) jobs=$(($nproc * 2)) make="make -j $jobs -l $load" else make=make fi while [ "$1" ] do opt=$1 case $opt in --) shift ; break ;; -*) shift ;; *) break ;; esac case $opt in -m|--mail) vopt="$vopt -m '$1'" ; email=$1 ; shift ;; -n|--name) mopt="$mopt VNAME='$1'" ; shift ;; # what to do -d|--download) download=1 ;; -nd|--no-download) download= ;; -u|--update) update=1 ;; -nu|--no-update) update= ;; -c|--compile) compile=recompile ;; -fc|--full-compile) compile=full-compile ;; -b|--build) compile=build ; clean=unbuild ;; -nc|--no-compile) compile= ;; # where to do it -t|--target) target=$1 ; shift ;; --target=*) target=${opt#*=} ;; # subdirectory within $target where the sources are -sd|--source-directory) sdir=$1 ; shift ;; --source-directory=*) sdir=${opt#*=} ;; # validation directories -pv|--parallel-validate) validate=new-validate unvalidate=parallel-unvalidate ;; -mv|--mail-validate) validate=mail-validate unvalidate=parallel-unvalidate ;; -nv|--no-validate) valids= ;; -v|--validate) valids="$valids validation" ;; -av|--add-validation) valids="$valids $1" ; shift ;; --add-validation=*) valids="$valids ${opt#*=}" ;; -wto|--with-timeout) vopt="$vopt -T 1000" ;; -T|--timeout) vopt="$vopt -T $1" ; mopt="$mopt TIMEOUT=$1" ; shift ;; --timeout=*) vopt="$vopt -T ${opt#*=}" ;; # help -h|--help) err 'display help message' 0 ;; *) err "unexpected option '$opt'" 1 ;; esac done # force dowload if target does not exist test -d $target || download=1 if [[ $download ]] then test -d $target && err "will not overwrite target directory: $target" 4 # full download wget --no-directories --no-verbose $setup # should be silent? chmod u+rx ./setup_pips.sh ./setup_pips.sh $target elif [[ $update ]] then test -d $target || err "no target directory: $target" 2 pushd $target svn update $sdir $valids test $? -ne 0 && err "svn update failed" 5 popd else echo '### no download, no update...' fi # use this PIPS test -d $target || err "no target directory: $target" 3 #export NEWGEN_ROOT=$target/$sdir/newgen #export LINEAR_ROOT=$target/$sdir/linear #export PIPS_ROOT=$target/$sdir/pips test -f $target/pipsrc.sh || err "no pipsrc.sh file in $target" 7 source $target/pipsrc.sh # check for *_ROOT variables? set them? rely on pipsrc.sh? if [[ $compile && ! $download ]] then pushd $target/$sdir $make $mopt $clean cd newgen $make $mopt $compile cd ../linear $make $mopt $compile cd ../pips $make $mopt $compile if [ -f bin/$PIPS_ARCH/tpips ] then echo "### recompilation succeeded" else err "recompilation failed, no tpips" 6 fi popd else echo '### no compile' fi if [[ $valids ]] ; then for d in $valids ; do if [[ -d $target/$d/. ]] ; then echo "### validating $d" pushd $target/$d $make $mopt clean $make $mopt "$vopt" EMAIL="$email" $validate # full cleanup: the validation directory is cleaned, # so that subsequent "svn up" should work properly. # *.diff and *.err files still hold validationr results [ "$unvalidate" ] && $make $mopt $unvalidate popd else echo "### skipping validation $d, no such directory" fi done else echo '### no validation...' fi exit 0