Commit 02d345c2 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Improve devtools.

	* build-aux/devtools.sh: Improve MILENA_DEVTOOLS_PATH value
	detection.

	* build-aux/devtools_utils.sh,
	* build-aux/make_report_utils.sh: New. Set of functions to help
	writing devtools.

	* build-aux/mln_add_file,
	* build-aux/mln_check_source_has_test,
	* build-aux/mln_check_test_hierarchy: Update headers.


	* build-aux/mln_check_all_hh_headers: split into...
	* build-aux/mln_check_all_hh_inclusions,
	* build-aux/mln_check_missing_all_hh_headers: ... these files.

	* build-aux/mln_check_guards: move...
	* build-aux/mln_fix_guards: ... here.

	* build-aux/mln_check_guards: New.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@4303 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 26f18186
2009-07-15 Guillaume Lazzara <lazzara@lrde.epita.fr>
Improve devtools.
* build-aux/devtools.sh: Improve MILENA_DEVTOOLS_PATH value
detection.
* build-aux/devtools_utils.sh,
* build-aux/make_report_utils.sh: New. Set of functions to help
writing devtools.
* build-aux/mln_add_file,
* build-aux/mln_check_source_has_test,
* build-aux/mln_check_test_hierarchy: Update headers.
* build-aux/mln_check_all_hh_headers: split into...
* build-aux/mln_check_all_hh_inclusions,
* build-aux/mln_check_missing_all_hh_headers: ... these files.
* build-aux/mln_check_guards: move...
* build-aux/mln_fix_guards: ... here.
* build-aux/mln_check_guards: New.
2009-07-14 Roland Levillain <roland@lrde.epita.fr>
* configure.ac, NEWS: Version 1.0a.
......@@ -10,9 +35,9 @@
Aesthetic changes.
2009-07-13 Guillaume Lazzara <lazzara@lrde.epita.fr>
* lrde-upload.sh: Set permissions on specific directories only.
2009-07-13 Guillaume Lazzara <lazzara@lrde.epita.fr>
* lrde-upload.sh: Set writing permissions for group on uploaded
......
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
dname="`dirname $0`"
if [ "$dname" = "." ]; then
export PATH="$PWD:$PATH"
export MILENA_DEVTOOLS_PATH="$PWD"
elif [ -d "$PWD/$dname" ]; then
export PATH="$PWD/$MILENA_DEVTOOLS_PATH:$PATH"
export MILENA_DEVTOOLS_PATH="$PWD/$dname"
else
echo "Cannot guess Milena's devtools path. Please set MILENA_DEVTOOLS_PATH variable manually."
fi
#!/bin/sh
# $1: a file.
#
# Return the absolute file path.
#
abs_filepath()
{
path=$PWD
if [ "`dirname $1`" != "." ]; then
path=$path/`dirname $1`
fi
echo "$path"
}
# $1: a file.
#
# Return the relative path to mln
#
mln_based_path()
{
path=`abs_filepath "$1"`
local mln_path=""
while [ "`basename $path`" != "mln" ]; do
mln_path="`basename $path`/$mln_path"
path=`dirname $path`
done
mln_path="mln/$mln_path"
echo "$mln_path" | sed -e 's,/$,,'
}
#!/bin/sh
# Set of useful functions to generate HTML reports.
# $1: report file.
close_dir_entry()
{
echo "</ol>" >> $1
}
# $1: entry name.
# $2: report file.
open_dir_entry()
{
echo "<li><b>$1</b></li><ol>" >> $2
}
# $1: report file.
# $2: report title.
prepare_report()
{
cat >> $1 << EOF
<html>
<head>
<script language="javascript" src="http://api.uttk.org/javascripts/uttk.js"></script>
<style type="text/css">
@import url('http://api.uttk.org/stylesheets/uttk.css');
</style>
<title>
$2
</title>
</head>
<body>
<h1>$2</h2>
EOF
}
# $1: report file.
end_report()
{
close_dir_entry $1
cat >> $1 << EOF
</body>
</html>
EOF
}
\ No newline at end of file
#!/bin/sh
# Copyright (C) 2009 EPITA Research and Development Laboratory
# (LRDE)
# 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 file is part of Olena.
#
# This library is distributed in the hope that it will be useful,
# 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 this library; see the file COPYING. If not, write to
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
# Boston, MA 02111-1307, USA.
# along with Olena. If not, see <http://www.gnu.org/licenses/>.
# Usage: ./new_header.sh <mln/path/header.hh>
#
......
#!/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 -
#!/bin/sh
# Copyright (C) 2009 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/>.
if [ -z "$MILENA_DEVTOOLS_PATH" ]; then
echo "MILENA_DEVTOOLS_PATH is not set." >&2
exit 1
fi
source $MILENA_DEVTOOLS_PATH/make_report_utils.sh
source $MILENA_DEVTOOLS_PATH/devtools_utils.sh
last_path=""
check()
{
f=`basename $1`
abs_dir=`abs_filepath $1`
mln_based_dir=`mln_based_path $1`
# Checking local all.hh
if ! [ -e "$abs_dir/all.hh" ]; then
echo "WARNING: no all.hh header in $mln_based_dir" >&2
return
fi
result=`grep "include <$mln_based_dir/$f>" $abs_dir/all.hh`
if [ -z "$result" ]; then
if [ -z "$report" ]; then
echo " WARNING $f is not included in $mln_based_dir/all.hh" >&2
else
if [ "$last_path" != "$mln_based_dir" ]; then
close_dir_entry $2
open_dir_entry "$mln_based_dir" $2
last_path="$mln_based_dir"
fi
echo "<li>$f</li>" >> $2
fi
fi
}
if [ $# -lt 1 ]; then
echo "Usage: $0 [--report output.html] <file1> <file2> ..." >&2
echo "-----"
echo " Names of files which are not included in their respective"
echo " all.hh file will be printed out."
echo " A HTML report may be also generated."
exit 1
fi
report=""
if [ "$1" == "--report" ]; then
shift
report=$1
rm -f $1
touch $1
shift
fi
if ! [ -z "$report" ]; then
prepare_report $report "Files not included in all.hh."
fi
while [ $# -ne 0 ]; do
if [ "`basename $1`" != "all.hh" ]; then
check $1 "$report"
fi
shift
done
if ! [ -z "$report" ]; then
end_report $report
fi
#! /usr/bin/env perl
#!/bin/sh
# Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE).
#
# Copyright (C) 2009 EPITA Research and Development Laboratory
# (LRDE)
# This file is part of Olena.
#
# 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.
# 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.
#
# This library is distributed in the hope that it will be useful,
# 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 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 = $_;
# along with Olena. If not, see <http://www.gnu.org/licenses/>.
$_ = $boundupper;
s,%BASENAME%,$basename,g;
s,%CPPNAME%,$cppname,g;
my $xboundupper = $_;
# Usage: mln_check_guards [--report output.html] <file1> <file2> ...
$_ = $boundlower;
s,%BASENAME%,$basename,g;
s,%CPPNAME%,$cppname,g;
my $xboundlower = $_;
if [ -z "$MILENA_DEVTOOLS_PATH" ]; then
echo "MILENA_DEVTOOLS_PATH is not set." >&2
exit 1
fi
open(FILE, "<", $fname) or die "cannot open $fname: $!\n";
my $content;
while (<FILE>)
{
$content .= $_;
}
close FILE;
source $MILENA_DEVTOOLS_PATH/make_report_utils.sh
source $MILENA_DEVTOOLS_PATH/devtools_utils.sh
# 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)
last_path=""
check()
{
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;
local mln_path=`mln_based_path $1`
bname=`basename $1`
guards=`echo ${mln_path}/${bname} | sed -e 's,[/\.],_,g' | awk '{print toupper($0)}'`
nndef=`grep "^#ifndef $guards$" $1 | wc -l`
ndefine=`grep "^# define $guards$" $1 | wc -l`
nendif=`grep "^#endif // ! $guards" $1 | wc -l`
if [ $nndef -ne 1 ] || [ $ndefine -ne 1 ] || [ $nendif -ne 1 ]; then
if [ -z "$2" ]; then
echo "$1 has missing or invalid guards."
else
if [ "$last_path" != "$mln_path" ]; then
close_dir_entry $2
open_dir_entry "$mln_path" $2
last_path="$mln_path"
fi
echo "<li>$bname</li>" >> $2
fi
fi
}
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:
if [ $# -lt 1 ]; then
echo "Usage: $0 [--report output.html] <file1> <file2> ..." >&2
echo "-----"
echo " Names of files with missing or invalid guards will be printed out."
echo " A HTML report may be also generated."
exit 1
fi
report=""
if [ "$1" == "--report" ]; then
shift
report=$1
rm -f $1
touch $1
shift
fi
if ! [ -z "$report" ]; then
prepare_report $report "Files with invalid or missing guards."
fi
while [ $# -ne 0 ]; do
check $1 "$report"
shift
done
if ! [ -z "$report" ]; then
end_report $report
fi
#!/bin/sh
# Copyright (C) 2009 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/>.
if [ -z "$MILENA_DEVTOOLS_PATH" ]; then
echo "MILENA_DEVTOOLS_PATH is not set." >&2
exit 1
fi
source $MILENA_DEVTOOLS_PATH/make_report_utils.sh
source $MILENA_DEVTOOLS_PATH/devtools_utils.sh
check()
{
local mln_path=`mln_based_path $1/all.hh`
local abs_path=`abs_filepath $1/all.hh`
# Checking local all.hh
for dir in `find "$abs_path" -type d`; do
if ! [ -e "$dir/all.hh" ]; then
path=`mln_based_path $dir/all.hh`
if [ -z "$2" ]; then
echo "WARNING: no all.hh header in $path" >&2
else
close_dir_entry $2
open_dir_entry "$path" $2
fi
continue
fi
done
}
if [ $# -lt 1 ]; then
echo "Usage: $0 [--report output.html] <dir1> <dir2> ..." >&2
echo "-----"
echo " Directories without all.hh files will be printed out."
echo " A HTML report may be also generated."
exit 1
fi
report=""
if [ "$1" == "--report" ]; then
shift
report=$1
rm -f $1
touch $1
shift
fi
if ! [ -z "$report" ]; then
prepare_report $report "Missing all.hh headers."
fi
while [ $# -ne 0 ]; do
check $1 "$report"
shift
done
if ! [ -z "$report" ]; then
end_report $report
fi
#! /bin/sh
# Copyright (C) 2009 EPITA Research and Development Laboratory
# (LRDE)
# 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 file is part of Olena.
#
# This library is distributed in the hope that it will be useful,
# 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.