Commit 4ea319ab authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

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's avatarGuillaume Lazzara <z@lrde.epita.fr>

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@4277 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 8103a498
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.
......@@ -10,6 +26,11 @@
* Makefile.am: Add a FIXME.
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.
......
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
#!/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
#!/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 -
#! /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:
#! /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
......@@ -47,7 +65,7 @@ check_directory ()
}
if [ $# -ne 2 ]; then
echo "Usage: ./check_test_hierarchy mln/ tests/"
echo "Usage: ./check_test_source_has_test mln/ tests/"
exit 1
fi
......
#! /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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment