mirror of https://github.com/CGAL/cgal
200 lines
4.9 KiB
Bash
Executable File
200 lines
4.9 KiB
Bash
Executable File
#! /bin/bash
|
|
#
|
|
# =============================================================================
|
|
# $URL: svn+ssh://fcacciola@scm.gforge.inria.fr/svn/cgal/trunk/Scripts/developer_scripts/create_cgal_test $
|
|
# $Id: create_cgal_test 36975 2007-03-09 22:52:40Z spion $
|
|
#
|
|
# author(s) : Wieger Wesselink, Geert-Jan Giezeman
|
|
#
|
|
# coordinator : Utrecht University
|
|
# =============================================================================
|
|
#
|
|
# This script creates a cgal_test_with_cmake script with entries for files with a common
|
|
# C++ file extension (as mentioned in the g++ man page) in the current test directory.
|
|
|
|
VERSION=1.1
|
|
|
|
DO_RUN="y"
|
|
|
|
usage()
|
|
{
|
|
echo 'Usage : create_cgal_test [--no-run]'
|
|
echo
|
|
echo ' --help : prints this usage help'
|
|
echo ' --no-run : produces a cgal_test_with_cmake script that only does compilation, no execution'
|
|
exit
|
|
}
|
|
|
|
while [ $1 ]; do
|
|
case "$1" in
|
|
-h|-help|--h|--help)
|
|
usage;
|
|
;;
|
|
--no-run)
|
|
DO_RUN=""
|
|
shift; continue
|
|
;;
|
|
*)
|
|
echo "Unknown option: $1"
|
|
usage
|
|
;;
|
|
esac
|
|
done
|
|
|
|
|
|
header()
|
|
{
|
|
echo "#---------------------------------------------------------------------#"
|
|
echo "# $1"
|
|
echo "#---------------------------------------------------------------------#"
|
|
}
|
|
|
|
create_script()
|
|
{
|
|
echo "#! /bin/sh"
|
|
echo
|
|
echo "# This is a script for the CGAL test suite. Such a script must obey"
|
|
echo "# the following rules:"
|
|
echo "#"
|
|
echo "# - the name of the script is cgal_test_with_cmake"
|
|
echo "# - for every target two one line messages are written to the file 'error.txt'"
|
|
echo "# the first one indicates if the compilation was successful"
|
|
echo "# the second one indicates if the execution was successful"
|
|
echo "# if one of the two was not successful, the line should start with 'ERROR:'"
|
|
echo "# - running the script should not require any user interaction"
|
|
echo "# - the script should clean up object files and executables"
|
|
echo
|
|
cat << EOF
|
|
ERRORFILE=error.txt
|
|
DO_RUN=${DO_RUN}
|
|
if [ -z "\${MAKE_CMD}" ]; then
|
|
MAKE_CMD=make
|
|
fi
|
|
NEED_CLEAN=
|
|
|
|
EOF
|
|
header "configure"
|
|
cat << 'EOF'
|
|
|
|
configure()
|
|
{
|
|
echo "Configuring... "
|
|
|
|
if eval 'cmake ${INIT_FILE:+"-C${INIT_FILE}"} "$CMAKE_GENERATOR" -DRUNNING_CGAL_AUTO_TEST=TRUE \
|
|
-DCGAL_DIR="$CGAL_DIR" \
|
|
--no-warn-unused-cli \
|
|
.' ; then
|
|
|
|
echo " successful configuration" >> $ERRORFILE
|
|
else
|
|
echo " ERROR: configuration" >> $ERRORFILE
|
|
fi
|
|
}
|
|
|
|
EOF
|
|
header "compile_and_run <target>"
|
|
cat << EOF
|
|
|
|
compile_and_run()
|
|
{
|
|
echo "Compiling \$1 ... "
|
|
SUCCESS="y"
|
|
|
|
if eval '"\${MAKE_CMD}" VERBOSE=ON -fMakefile \$1' ; then
|
|
echo " successful compilation of \$1" >> \$ERRORFILE
|
|
else
|
|
echo " ERROR: compilation of \$1" >> \$ERRORFILE
|
|
SUCCESS=""
|
|
fi
|
|
|
|
if [ -n "\$DO_RUN" ] ; then
|
|
if [ -n "\${SUCCESS}" ] ; then
|
|
OUTPUTFILE=ProgramOutput.\$1.\$PLATFORM
|
|
rm -f \$OUTPUTFILE
|
|
COMMAND="./\$1"
|
|
if [ -f \$1.cmd ] ; then
|
|
COMMAND="\$COMMAND \`cat \$1.cmd\`"
|
|
fi
|
|
if [ -f \$1.cin ] ; then
|
|
COMMAND="cat \$1.cin | \$COMMAND"
|
|
fi
|
|
echo "Executing \$1 ... "
|
|
echo
|
|
ulimit -t 3600 2> /dev/null
|
|
if eval \$COMMAND > \$OUTPUTFILE 2>&1 ; then
|
|
echo " successful execution of \$1" >> \$ERRORFILE
|
|
else
|
|
echo " ERROR: execution of \$1" >> \$ERRORFILE
|
|
fi
|
|
else
|
|
echo " ERROR: not executed \$1" >> \$ERRORFILE
|
|
fi
|
|
fi
|
|
}
|
|
|
|
EOF
|
|
header "remove the previous error file"
|
|
cat << EOF
|
|
|
|
rm -f \$ERRORFILE
|
|
touch \$ERRORFILE
|
|
|
|
EOF
|
|
header "configure, compile and run the tests"
|
|
cat << EOF
|
|
|
|
configure
|
|
|
|
if [ \$# -ne 0 ] ; then
|
|
for file in \$* ; do
|
|
compile_and_run \$file
|
|
done
|
|
else
|
|
echo "Run all tests."
|
|
EOF
|
|
|
|
# workaround for Cygwin, to avoid that the 'sort' from
|
|
# C:\Windows\system32 is used instead of /usr/bin/sort
|
|
PATH=/usr/bin:$PATH
|
|
|
|
for file in `ls *.cc *.cp *.cxx *.cpp *.CPP *.c++ *.C 2> /dev/null | sort` ; do
|
|
if [ -n "`grep '\<main\>' $file`" ] ; then
|
|
BASE=`basename $file .cc`
|
|
BASE=`basename $BASE .cp`
|
|
BASE=`basename $BASE .cxx`
|
|
BASE=`basename $BASE .cpp`
|
|
BASE=`basename $BASE .CPP`
|
|
BASE=`basename $BASE .c++`
|
|
BASE=`basename $BASE .C`
|
|
cat <<EOF
|
|
if grep -qE "^${BASE}:" Makefile; then
|
|
compile_and_run $BASE
|
|
NEED_CLEAN=y
|
|
fi
|
|
EOF
|
|
fi
|
|
done
|
|
cat << EOF
|
|
fi
|
|
|
|
#
|
|
# The clean target generated by CMake under cygwin
|
|
# always fails for some reason
|
|
#
|
|
if [ -n "\${NEED_CLEAN}" ]; then
|
|
if ! ( uname | grep -q "CYGWIN" ) ; then
|
|
"\${MAKE_CMD}" -fMakefile clean
|
|
fi
|
|
fi
|
|
EOF
|
|
|
|
}
|
|
|
|
if [ -f cgal_test_with_cmake ] ; then
|
|
echo "moving cgal_test_with_cmake to cgal_test_with_cmake.bak ..."
|
|
mv -f cgal_test_with_cmake cgal_test_with_cmake.bak
|
|
fi
|
|
create_script > cgal_test_with_cmake
|
|
chmod 755 cgal_test_with_cmake
|
|
echo "created cgal_test_with_cmake, version $VERSION, in $PWD ..."
|