4168: Add build_unit_test.sh and generate_dist_headers.sh to build-aux.

* build-aux/build_unit_test.sh, * build-aux/generate_dist_headers.sh: copy scripts from milena/ and milena/tests/unit_test. * build-aux/Makefile.am: add the previous scripts to EXTRA_DIST. * bootstrap, * Makefile.am: update the use of these scripts. --- ChangeLog | 13 +++++ Makefile.am | 4 ++ bootstrap | 8 ++-- build-aux/Makefile.am | 1 + build-aux/build_unit_test.sh | 92 ++++++++++++++++++++++++++++++++++++ build-aux/generate_dist_headers.sh | 39 +++++++++++++++ 6 files changed, 153 insertions(+), 4 deletions(-) create mode 100755 build-aux/build_unit_test.sh create mode 100755 build-aux/generate_dist_headers.sh diff --git a/ChangeLog b/ChangeLog index ac210a6..3fbe99f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2009-06-19 Guillaume Lazzara <lazzara@lrde.epita.fr> + + Add build_unit_test.sh and generate_dist_headers.sh to build-aux. + + * build-aux/build_unit_test.sh, + * build-aux/generate_dist_headers.sh: copy scripts from milena/ and + milena/tests/unit_test. + + * build-aux/Makefile.am: add the previous scripts to EXTRA_DIST. + + * bootstrap, + * Makefile.am: update the use of these scripts. + 2009-06-18 Roland Levillain <roland@lrde.epita.fr> * m4/with-swilena.m4 (_OLN_WITH_SWIG): Require Python 2.5. diff --git a/Makefile.am b/Makefile.am index 000fd42..3657461 100644 --- a/Makefile.am +++ b/Makefile.am @@ -97,6 +97,10 @@ dist-hook: $(top_srcdir)/build-aux/strip-lrde $$f; \ done; \ rm -rf $(LRDE_NODIST_FILES) && \ + $(top_srcdir)/build-aux/build_unit_test.sh \ + $(distdir)/milena/mln \ + $(distdir)/milena/tests/unit_test \ + $(top_srcdir)/milena/tests/unit_test/disabled_tests && \ ( \ cd $(distdir); \ set -evx; \ diff --git a/bootstrap b/bootstrap index 9827b9c..7273e79 100755 --- a/bootstrap +++ b/bootstrap @@ -129,20 +129,20 @@ require $libtoolize 1.5.22 set -x # Generate milena/headers.mk -run milena ./generate_dist_headers.sh +run milena `pwd`/build-aux/generate_dist_headers.sh mln ./headers.mk ./nodist-headers # Generate scribo/headers.mk -run scribo ./generate_dist_headers.sh +run . `pwd`/build-aux/generate_dist_headers.sh scribo scribo/headers.mk scribo/nodist-headers # Generate lists of files to be part of the distribution # for the tutorial. run milena/doc ./generate_dist_files.sh # Generate unit test files. -run milena/tests/unit_test ./build_unit_test.sh `pwd`/milena/mln +run . ./build-aux/build_unit_test.sh `pwd`/milena/mln milena/tests/unit_test milena/tests/unit_test/disabled_tests # Generate unit test files for Scribo. -run scribo/tests/unit_test ./build_unit_test.sh `pwd`/scribo +run scribo/tests/unit_test ./build_unit_test.sh `pwd`/scribo . # Install the GNU Build System. autoreconf -f -v -i diff --git a/build-aux/Makefile.am b/build-aux/Makefile.am index 7a2901f..1185eaf 100644 --- a/build-aux/Makefile.am +++ b/build-aux/Makefile.am @@ -16,3 +16,4 @@ # ## Process this file through Automake to produce Makefile.in. +EXTRA_DIST = generate_dist_headers.sh build_unit_test.sh diff --git a/build-aux/build_unit_test.sh b/build-aux/build_unit_test.sh new file mode 100755 index 0000000..8080ef2 --- /dev/null +++ b/build-aux/build_unit_test.sh @@ -0,0 +1,92 @@ +#! /bin/sh + +# Copyright (C) 2007, 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/>. + +## FIXME: Don't use `echo -n', as echo's options are not portable. +## +## http://www.gnu.org/software/autoconf/manual/html_node/Limitations-of-Builtin... +## +## As an ugly workaround, use `printf' instead. The right approach +## would be to only emit lines ended with newlines. +ECHO_N=printf + +# Use the C locale to have a deterministic sort. +export LC_ALL=C + +test $# -eq 3 || { echo "Usage: $0 <scanned dir> <output_dir> <disabled_tests>" && exit 1; } + +scanned_dir=$1 +output_dir=$2 +disabled_tests=$3 + +## FIXME: We do not include these directories +## +## mln/io/dicom +## mln/io/fits +## mln/io/magick +## mln/io/tiff +## +## because they contain files depending on optional (external) +## libraries. We should test them conditionally. +HEADERS=$(find $scanned_dir -type f -name "*.hh" \ + | sort \ + | sed -e 's/.*\/mln\/\(.*\)/mln\/\1/g' | sed 's/\.\.\/\.\.\///g' \ + | comm -23 - "$disabled_tests") + +output="$output_dir/unit-tests.mk" + +rm -f "$output" +rm -f mln_*.cc + +# Build unit-tests.mk. +echo "## Generated by $0, do not modify." >"$output" +echo >>"$output" +$ECHO_N "check_PROGRAMS = " >>"$output" + +for i in $HEADERS; do + FILE_CC=`echo $i | sed 's/[/.]/_/g' | sed 's/_hh/\.cc/g'` + + # Build .cc. + cat > $output_dir/$FILE_CC << EOF +// Unit test for $i. +// Generated by $0, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <$i> +#include <$i> + +int main() +{ + // Nothing. +} +EOF + + # Build unit-tests.mk. + TARGET=`echo "${FILE_CC}" | sed 's/\.cc//'` + echo " \\" >>"$output" + $ECHO_N "${TARGET}" >>"$output" +done + +# Build "$output". +echo "" >>"$output" +echo "" >>"$output" +for i in $HEADERS; do + FILE_CC=`echo $i | sed 's/[/.]/_/g' | sed 's/_hh/\.cc/g'` + NAME=`echo $FILE_CC | sed 's/\.cc//g'` + echo "${NAME}_SOURCES = $FILE_CC" >>"$output" +done diff --git a/build-aux/generate_dist_headers.sh b/build-aux/generate_dist_headers.sh new file mode 100755 index 0000000..60aa946 --- /dev/null +++ b/build-aux/generate_dist_headers.sh @@ -0,0 +1,39 @@ +#! /bin/sh + +# Generate a list of distributed files w.r.t. a list of file which must +# be excluded. +# -------------------- +# List all the headers in order to make them part of distribution. + +# Use the C locale to have a deterministic sort. +export LC_ALL=C + +if [ $# -ne 3 ]; then + echo "$0 <scanned_dir> <output> <nodist-headers>" + exit 1 +fi + +me=`basename $0` +scanned_dir=$1 +output=$2 +nodist_headers=$3 +test -f "$nodist_headers" \ + || { echo "$me: Cannot find \`$nodist_headers' in `pwd`."; exit 1; } + +echo "Generating $output..." >&2 +rm -f "$output" +cat <<EOF >"$output" +## Generated by \`$me', do not edit by hand. + +nobase_include_HEADERS = \\ +EOF + +find $scanned_dir -type f -a \( -name '*.hh' -o -name '*.hxx' \) \ + | sort \ + | comm -23 - "$nodist_headers" \ + | sed -e 's/$/ \\/g' >> $output + +last_line=`tail -n 1 $output | sed -e 's/\\\//g'` # remove '\' in last line +sed '$d' < $output > $output.tmp # remove last line +mv $output.tmp $output +echo $last_line >> $output # put the cleaned last line back. -- 1.5.6.5
participants (1)
-
Guillaume Lazzara