4277: Add new dev tools.

* build-aux/check_source_has_test.sh, * build-aux/check_test_hierarchy.sh: rename to... * build-aux/mln_check_source_has_test, * build-aux/mln_check_test_hierarchy: ... this. * build-aux/devtools.sh: Set the path to these tools. * build-aux/mln_add_file, * build-aux/mln_check_all_hh_headers, * build-aux/mln_check_guards: new tools. Signed-off-by: Guillaume Lazzara <z@lrde.epita.fr> --- ChangeLog | 23 +++- build-aux/check_source_has_test.sh | 70 ---------- build-aux/check_test_hierarchy.sh | 57 -------- build-aux/devtools.sh | 9 ++ build-aux/mln_add_file | 242 +++++++++++++++++++++++++++++++++++ build-aux/mln_check_all_hh_headers | 55 ++++++++ build-aux/mln_check_guards | 134 +++++++++++++++++++ build-aux/mln_check_source_has_test | 88 +++++++++++++ build-aux/mln_check_test_hierarchy | 75 +++++++++++ 9 files changed, 625 insertions(+), 128 deletions(-) delete mode 100755 build-aux/check_source_has_test.sh delete mode 100755 build-aux/check_test_hierarchy.sh create mode 100644 build-aux/devtools.sh create mode 100755 build-aux/mln_add_file create mode 100755 build-aux/mln_check_all_hh_headers create mode 100755 build-aux/mln_check_guards create mode 100755 build-aux/mln_check_source_has_test create mode 100755 build-aux/mln_check_test_hierarchy diff --git a/ChangeLog b/ChangeLog index 16747a4..8c596b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,20 @@ -2009-07-09 Guillaume Lazzara <lazzara@lrde.epita.fr> +2009-07-13 Guillaume Lazzara <lazzara@lrde.epita.fr> + + Add new dev tools. + + * build-aux/check_source_has_test.sh, + * build-aux/check_test_hierarchy.sh: rename to... + + * build-aux/mln_check_source_has_test, + * build-aux/mln_check_test_hierarchy: ... this. + + * build-aux/devtools.sh: Set the path to these tools. + + * build-aux/mln_add_file, + * build-aux/mln_check_all_hh_headers, + * build-aux/mln_check_guards: new tools. + +2009-07-13 Guillaume Lazzara <lazzara@lrde.epita.fr> Improve snapshot generation. @@ -12,6 +28,11 @@ 2009-07-09 Guillaume Lazzara <lazzara@lrde.epita.fr> + * mln/geom/rotate.hh: Avoid an ICE with gcc 4.0.1 on MacOs + X (leopard 10.5). + +2009-07-09 Guillaume Lazzara <lazzara@lrde.epita.fr> + * lrde-upload.sh: Call chmod before copying files. 2009-07-08 Guillaume Lazzara <lazzara@lrde.epita.fr> diff --git a/build-aux/check_source_has_test.sh b/build-aux/check_source_has_test.sh deleted file mode 100755 index 2c269c5..0000000 --- a/build-aux/check_source_has_test.sh +++ /dev/null @@ -1,70 +0,0 @@ -#! /bin/sh - -failed_tests=0 -all_tests=0 - -check_directory () -{ - echo "Current directories: $1 $2" - - for file in `ls $1`; do - - if [ -f ${1}/$file ]; then - ext=${file##*.} - base=${file%.*} - - if [ "$ext" = "hh" -a \ - "${base##*.}" != "spe" ]; then - test_file=${file%.hh}.cc - all_tests=$(($all_tests + 1)) - - if [ -f ${2}/$test_file ]; then - echo "\t\e[0;32mOK\e[m $file <-> $test_file" > /dev/null - else - if [ "$file" != "all.hh" -a \ - "$file" != "essential.hh" ]; then - echo "\tFAIL Test \"$test_file\" does not exist." - failed_tests=$(($failed_tests + 1)) - fi - fi - - fi - - fi - - if [ -d ${1}/$file ]; then - if [ -d ${2}/$file ]; then - echo "" - check_directory ${1}/$file ${2}/$file - else - if [ "$file" != "internal" ]; then - echo "FAIL Test directory \"${2}/$file\" does not exist." - fi - fi - fi - - done -} - -if [ $# -ne 2 ]; then - echo "Usage: ./check_test_hierarchy mln/ tests/" - exit 1 -fi - -echo "Source directory: $1" -echo "Test directory: $2" -echo "---" - -if [ -d ${1} ]; then - if [ -d ${2} ]; then - check_directory ${1} ${2} - else - echo "\e[0;31mFAIL\e[m Test directory $2 does not exist." - fi -else - echo "\e[0;31mFAIL\e[m Source directory $1 does not exist." -fi - -echo "\n=====" -echo "Missing tests: $failed_tests" - diff --git a/build-aux/check_test_hierarchy.sh b/build-aux/check_test_hierarchy.sh deleted file mode 100755 index 891ce31..0000000 --- a/build-aux/check_test_hierarchy.sh +++ /dev/null @@ -1,57 +0,0 @@ -#! /bin/sh - -failed_tests=0 -all_tests=0 - -check_directory () -{ - echo "Current directories: $1 $2" - for file in `ls $1`; do - - source_file=${file%.cc}.hh - if [ -f ${1}/$file ]; then - all_tests=$(($all_tests + 1)) - if [ -f ${2}/$source_file ]; then - echo "\t\e[0;32mOK\e[m $file <-> $source_file" > /dev/null - else -# FIXME: Manage exceptions. - if [ "$file" != "Makefile.am" ]; then - echo "\t\e[0;31mFAIL\e[m $source_file source does not exist." - failed_tests=$(($failed_tests + 1)) - fi - fi - fi - - if [ -d ${1}/$file ]; then - if [ -d ${2}/$file ]; then - echo "" - check_directory ${1}/$file ${2}/$file - else -# FIXME: Manage exceptions. - echo "\e[0;31mFAIL\e[m ${2}/$file source directory does not exist." - fi - fi - - done -} - -if [ $# -ne 2 ]; then - echo "Usage: ./check_test_hierarchy tests/ mln/" - exit 1 -fi - -echo "Test directory: $1" -echo "Source directory: $2" -echo "---" - -if [ -d ${1} ]; then - if [ -d ${2} ]; then - check_directory ${1} ${2} - else - echo "\e[0;31mFAIL\e[m ${1} source directory does not exist." - fi -fi - -echo "\n=====" -echo "Uncorrect tests: $failed_tests" - diff --git a/build-aux/devtools.sh b/build-aux/devtools.sh new file mode 100644 index 0000000..fc5465a --- /dev/null +++ b/build-aux/devtools.sh @@ -0,0 +1,9 @@ +export MILENA_DEVTOOLS_PATH=`dirname $0` + +if [ -d "$PWD/$MILENA_DEVTOOLS_PATH" ]; then + export PATH=$PWD/$MILENA_DEVTOOLS_PATH:$PATH +elif [ -d "$MILENA_DEVTOOLS_PATH" ] && [ -z "`echo $MILENA_DEVTOOLS_PATH | cut -d '/' -f 1`" ]; then + export PATH=$MILENA_DEVTOOLS_PATH:$PATH +else + echo "Cannot guess Milena's devtools path. Please set MILENA_DEVTOOLS_PATH variable manually." +fi diff --git a/build-aux/mln_add_file b/build-aux/mln_add_file new file mode 100755 index 0000000..f92801f --- /dev/null +++ b/build-aux/mln_add_file @@ -0,0 +1,242 @@ +#!/bin/sh + +# Copyright (C) 2009 EPITA Research and Development Laboratory +# (LRDE) +# +# This file is part of the Milena Library. This library is free +# software; you can redistribute it and/or modify it under the terms +# of the GNU General Public License version 2 as published by the +# Free Software Foundation. +# +# This library 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 this library; see the file COPYING. If not, write to +# the Free Software Foundation, 51 Franklin Street, Fifth Floor, +# Boston, MA 02111-1307, USA. + +# Usage: ./new_header.sh <mln/path/header.hh> +# +# Add a new header in milena and include it in all.hh if exists. +# + + +if [ $# -ne 1 ] && [ $# -ne 2 ]; then + echo "Usage: `basename $0` [--with-test] <mln/path/headername.hh>" + exit 1 +fi + + +with_test=0 +if [ "$1" == "--with-test" ]; then + with_test=1; + shift +fi + +output_dir=`dirname $1` + + +add_license() +{ + cat >> $1 <<EOF +// Copyright (C) `date +'%Y'` EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena 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, version 2 of the License. +// +// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>. +// +// As a special exception, you may use this file as part of a free +// software project without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to produce +// an executable, this file does not by itself cause the resulting +// executable to be covered by the GNU General Public License. This +// exception does not however invalidate any other reasons why the +// executable file might be covered by the GNU General Public License. + +EOF + +} + + +add_doxygen_headers() +{ + cat >> $1 <<EOF + +/// \\file +/// +/// FIXME. + + +EOF +} + +prepare_file() +{ + + guards=`echo "$1" | tr "[a-z]" "[A-Z]" | sed -e 's/[\/\.]/_/g'` + + # Add licence and guards. + add_license $1 + + cat >> $1 <<EOF +#ifndef $guards +# define $guards +EOF + + add_doxygen_headers $1 + +# opening sub namespaces + dir=`echo $output_dir | cut -d '/' -f 1` + indent="" + i=1 + + while ! [ -z "$dir" ]; do + cat >> $1 <<EOF +${indent}namespace $dir +${indent}{ + +EOF + + indent="$indent " + i=$(($i + 1)) + dir=`echo $output_dir | cut -d '/' -f $i` + done + indent=`echo "$indent" | sed -e 's/ $//'` + + + +# Adding few comments and MLN_INCLUDE_ONLY guards. + cat >> $1 <<EOF +${indent}// Add facade declaration here. + + +# ifndef MLN_INCLUDE_ONLY + + + +${indent}// Implement the facade here. + + + +# endif // ! MLN_INCLUDE_ONLY + +EOF + + + +# closing sub namespaces + path=`dirname $1` + while [ "$path" != "." ]; do + namespace=`echo $path | sed -e 's/\//::/g'` + + cat >> $1 <<EOF +${indent}} // end of namespace $namespace + +EOF + + path=`dirname $path` + indent=`echo "$indent" | sed -e 's/ $//'` + done + + +# End of file. +cat >> $1 <<EOF +#endif // ! $guards +EOF + +} + +add_to_all_hh() +{ + if ! [ -f "$output_dir/all.hh" ]; then + echo "Warning: $output_dir/all.hh does not exist, you may want to \ +create it." 1>&2 + return + fi + + if ! [ -z "`grep "# include <$1>" $output_dir/all.hh`" ]; then + echo "File already included in $output_dir/all.hh" 1>&2 + return + fi + + line=`grep -nE '^#endif // ! ' $output_dir/all.hh | tail -n 1 | cut -d ':' -f 1` + line=$(($line - 1)) + sed -i "${line}i\# include <$1> +" $output_dir/all.hh +} + +add_to_test_makefile() +{ + test_dir=`dirname $1` + test_name=`basename $1` + test_bname=`basename $test_name .cc` + + if ! [ -f "$test_dir/Makefile.am" ]; then + echo "Warning: $test_dir/Makefile.am does not exist, you may want to \ +create it." 1>&2 + return + fi + + if ! [ -z "`grep "$test_name" $test_dir/Makefile.am`" ]; then + echo "File already added to $test_dir/Makefile.am" 1>&2 + return + fi + + line=`grep -nE "_SOURCES = " $test_dir/Makefile.am | tail -n 1 | cut -d ':' -f 1` + line=$(($line + 1)) + sed -i "${line}i${test_bname}_SOURCES = $test_name +" $test_dir/Makefile.am + + line=`grep -nE '\\\' $test_dir/Makefile.am | grep -B 1 'CLEANFILES = ' | head -n 1 | cut -d ':' -f 1` + line=$(($line + 1)) + sed -i "${line}i\\\t${test_bname} \\\\" $test_dir/Makefile.am + +} + + +add_test() +{ + test_file=tests/`echo $1 | sed -e 's,mln/,,g' | sed -e 's,\.hh,.cc,g'` + + add_license $test_file + add_doxygen_headers $test_file + + cat >> $test_file <<EOF + +#include <$1> + +int main() +{ + using namespace mln; + + +} +EOF + + add_to_test_makefile $test_file +} + + +touch $1 +prepare_file $1 +add_to_all_hh $1 + + +if [ $with_test -eq 1 ]; then + add_test $1 +fi + diff --git a/build-aux/mln_check_all_hh_headers b/build-aux/mln_check_all_hh_headers new file mode 100755 index 0000000..80d394d --- /dev/null +++ b/build-aux/mln_check_all_hh_headers @@ -0,0 +1,55 @@ +#!/bin/sh + +# Copyright (C) 2009 EPITA Research and Development Laboratory +# (LRDE) +# +# This file is part of the Milena Library. This library is free +# software; you can redistribute it and/or modify it under the terms +# of the GNU General Public License version 2 as published by the +# Free Software Foundation. +# +# This library 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 this library; see the file COPYING. If not, write to +# the Free Software Foundation, 51 Franklin Street, Fifth Floor, +# Boston, MA 02111-1307, USA. + +if [ $# -ne 2 ]; then + echo "Usage: `basename $0` <path to mln> <output_log_dir>" 1>&2 + exit 1; +fi + + +path_to_mln=`dirname $1` + +echo "" > $2/missing_all_hh.log +echo "" > $2/not_included_in_all_hh.log + +cd $path_to_mln + +# Checking local all.hh +for dir in `find mln -mindepth 1 -type d`; do + + if ! [ -e "$dir/all.hh" ]; then + echo "WARNING: no all.hh header in $dir" >&2 + echo "$dir/all.hh" >> $2/missing_all_hh.log + continue + fi + + for f in `ls $dir/*.hh | grep -vE '*.spe.hh'`; do + if [ "`basename $f`" != "all.hh" ]; then + result=`grep "include <$f>" $dir/all.hh` + if [ -z "$result" ]; then + echo " WARNING $f is not included in $dir/all.hh" >&2 + echo "$f" >> $2/not_included_in_all_hh.log + fi + fi + done + +done + +#cd - diff --git a/build-aux/mln_check_guards b/build-aux/mln_check_guards new file mode 100755 index 0000000..3a2a95b --- /dev/null +++ b/build-aux/mln_check_guards @@ -0,0 +1,134 @@ +#! /usr/bin/env perl +# +# Copyright (C) 2009 EPITA Research and Development Laboratory +# (LRDE) +# +# This file is part of the Milena Library. This library is free +# software; you can redistribute it and/or modify it under the terms +# of the GNU General Public License version 2 as published by the +# Free Software Foundation. +# +# This library 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 this library; see the file COPYING. If not, write to +# the Free Software Foundation, 51 Franklin Street, Fifth Floor, +# Boston, MA 02111-1307, USA. +# +# +# check_guards.pl: this file comes from the Vaucanson project. +# +# Usage: ./mln_check_guards <file1> <file2> .... +# +# Check guards and fix them if needed. + +use warnings; +use strict; + +my $boundupper = "#ifndef %CPPNAME% +# define %CPPNAME%"; +my $boundlower = "#endif // ! %CPPNAME%"; + +sub check_guards ($) +{ + my $fname = $_[0]; + + # The short name, without the path from builddir to srcdir. + $_ = $fname; + s,^.*milena/mln/,,g; + my $shortname = $_; + s,.*/,,g; + my $basename = $_; + + $_ = $shortname; + s,^[./]*,,g; + s,^,MLN_,g; + s,[^a-zA-Z0-9],_,g; + y/[a-z]./[A-Z]_/; + my $cppname = $_; + + $_ = $boundupper; + s,%BASENAME%,$basename,g; + s,%CPPNAME%,$cppname,g; + my $xboundupper = $_; + + $_ = $boundlower; + s,%BASENAME%,$basename,g; + s,%CPPNAME%,$cppname,g; + my $xboundlower = $_; + + + open(FILE, "<", $fname) or die "cannot open $fname: $!\n"; + + my $content; + while (<FILE>) + { + $content .= $_; + } + close FILE; + + # Prepare the new contents. + $_ = $content; + + # Kill trailing spaces. +# s/[ \t]+$//mg; + +# s,([ \t\n])*$,\n,sg; + + # Adjust cpp guards. + if (/\# *ifndef[^\n]*\n[\n\t ]*\# *define[^\n]*\n/s) + { + s,\# *ifndef[^\n]*\n[\n\t ]*\# *define[^\n]*\n,$xboundupper\n,sg; + } + + if (/\# *endif[^\n]*\n[\n\t ]*$/s) + { + s,\# *endif[^\n]*\n[\n\t ]*$,$xboundlower\n,sg; + } + + # Make sure we have a unique ending eol. + s/\n+\z/\n/; + + $content = $_; + + my @mv = ("mv", "-f", "$fname", "$fname.bak"); + system(@mv) == 0 or die "system @mv failed: $?\n"; + + open(FILE, ">", $fname) or die "cannot open $fname for writing: $!\n"; + print FILE $content; +} + +if ($#ARGV == -1) +{ + print "mln_check_guards <file1> <file2> ...\n"; + print "----\n"; + print "Check guards in a list of files and fix them if needed.\n"; + exit 1; +} + +foreach my $file (@ARGV) +{ + check_guards ($file); +} + +exit 0; + +### Setup "GNU" style for perl-mode and cperl-mode. +## Local Variables: +## perl-indent-level: 2 +## perl-continued-statement-offset: 2 +## perl-continued-brace-offset: 0 +## perl-brace-offset: 0 +## perl-brace-imaginary-offset: 0 +## perl-label-offset: -2 +## cperl-indent-level: 2 +## cperl-brace-offset: 0 +## cperl-continued-brace-offset: 0 +## cperl-label-offset: -2 +## cperl-extra-newline-before-brace: t +## cperl-merge-trailing-else: nil +## cperl-continued-statement-offset: 2 +## End: diff --git a/build-aux/mln_check_source_has_test b/build-aux/mln_check_source_has_test new file mode 100755 index 0000000..3b9e564 --- /dev/null +++ b/build-aux/mln_check_source_has_test @@ -0,0 +1,88 @@ +#! /bin/sh + +# Copyright (C) 2009 EPITA Research and Development Laboratory +# (LRDE) +# +# This file is part of the Milena Library. This library is free +# software; you can redistribute it and/or modify it under the terms +# of the GNU General Public License version 2 as published by the +# Free Software Foundation. +# +# This library 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 this library; see the file COPYING. If not, write to +# the Free Software Foundation, 51 Franklin Street, Fifth Floor, +# Boston, MA 02111-1307, USA. + +failed_tests=0 +all_tests=0 + +check_directory () +{ + echo "Current directories: $1 $2" + + for file in `ls $1`; do + + if [ -f ${1}/$file ]; then + ext=${file##*.} + base=${file%.*} + + if [ "$ext" = "hh" -a \ + "${base##*.}" != "spe" ]; then + test_file=${file%.hh}.cc + all_tests=$(($all_tests + 1)) + + if [ -f ${2}/$test_file ]; then + echo "\t\e[0;32mOK\e[m $file <-> $test_file" > /dev/null + else + if [ "$file" != "all.hh" -a \ + "$file" != "essential.hh" ]; then + echo "\tFAIL Test \"$test_file\" does not exist." + failed_tests=$(($failed_tests + 1)) + fi + fi + + fi + + fi + + if [ -d ${1}/$file ]; then + if [ -d ${2}/$file ]; then + echo "" + check_directory ${1}/$file ${2}/$file + else + if [ "$file" != "internal" ]; then + echo "FAIL Test directory \"${2}/$file\" does not exist." + fi + fi + fi + + done +} + +if [ $# -ne 2 ]; then + echo "Usage: ./check_test_source_has_test mln/ tests/" + exit 1 +fi + +echo "Source directory: $1" +echo "Test directory: $2" +echo "---" + +if [ -d ${1} ]; then + if [ -d ${2} ]; then + check_directory ${1} ${2} + else + echo "\e[0;31mFAIL\e[m Test directory $2 does not exist." + fi +else + echo "\e[0;31mFAIL\e[m Source directory $1 does not exist." +fi + +echo "\n=====" +echo "Missing tests: $failed_tests" + diff --git a/build-aux/mln_check_test_hierarchy b/build-aux/mln_check_test_hierarchy new file mode 100755 index 0000000..91dddcb --- /dev/null +++ b/build-aux/mln_check_test_hierarchy @@ -0,0 +1,75 @@ +#! /bin/sh + +# Copyright (C) 2009 EPITA Research and Development Laboratory +# (LRDE) +# +# This file is part of the Milena Library. This library is free +# software; you can redistribute it and/or modify it under the terms +# of the GNU General Public License version 2 as published by the +# Free Software Foundation. +# +# This library 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 this library; see the file COPYING. If not, write to +# the Free Software Foundation, 51 Franklin Street, Fifth Floor, +# Boston, MA 02111-1307, USA. + +failed_tests=0 +all_tests=0 + +check_directory () +{ + echo "Current directories: $1 $2" + for file in `ls $1`; do + + source_file=${file%.cc}.hh + if [ -f ${1}/$file ]; then + all_tests=$(($all_tests + 1)) + if [ -f ${2}/$source_file ]; then + echo "\t\e[0;32mOK\e[m $file <-> $source_file" > /dev/null + else +# FIXME: Manage exceptions. + if [ "$file" != "Makefile.am" ]; then + echo "\t\e[0;31mFAIL\e[m $source_file source does not exist." + failed_tests=$(($failed_tests + 1)) + fi + fi + fi + + if [ -d ${1}/$file ]; then + if [ -d ${2}/$file ]; then + echo "" + check_directory ${1}/$file ${2}/$file + else +# FIXME: Manage exceptions. + echo "\e[0;31mFAIL\e[m ${2}/$file source directory does not exist." + fi + fi + + done +} + +if [ $# -ne 2 ]; then + echo "Usage: ./check_test_hierarchy tests/ mln/" + exit 1 +fi + +echo "Test directory: $1" +echo "Source directory: $2" +echo "---" + +if [ -d ${1} ]; then + if [ -d ${2} ]; then + check_directory ${1} ${2} + else + echo "\e[0;31mFAIL\e[m ${1} source directory does not exist." + fi +fi + +echo "\n=====" +echo "Uncorrect tests: $failed_tests" + -- 1.5.6.5
participants (1)
-
Guillaume Lazzara