Commit d76722cb authored by Roland Levillain's avatar Roland Levillain
Browse files

Generate the list of split examples in the documentation.

	* doc/gen-split-examples-mk: New script.
	* doc/Makefile.am: Include ($(srcdir)/split-examples.mk).
	($(srcdir)/split-examples.mk): New target.
	(EXTRA_DIST, MAINTAINERCLEANFILES): Add $(SPLIT_EXAMPLES).
	(refman_dependencies)
	(tutorial_dependencies)
	(ref_guide_dependencies):
	Remove $(doc_dir)/split-examples.stamp.
	Add $(SPLIT_EXAMPLES).
	(regen-split-examples-mk): New (phony) target.
	(regen-am): Remake regen-split-examples-mk instead of using
	generate_dist_files.sh.
	($(srcdir)/headers.stamp): No longer call generate_dist_files.sh
	to regen doc/examples/examples.mk.
	No longer include $(srcdir)/examples/examples.mk.
	($(srcdir)/examples/examples.mk, $(srcdir)/split-examples.stamp):
	Remove rules.
	(EXTRA_DIST, MAINTAINERCLEANFILES):
	Remove $(srcdir)/split-examples.stamp.
	(EXTRA_DIST): Add gen-split-examples-mk.
	* doc/split-examples.mk: New (generated) Make helper.
	* doc/examples/examples.mk: Remove.
parent 073d3d95
2010-03-16 Roland Levillain <roland@lrde.epita.fr>
Generate the list of split examples in the documentation.
* doc/gen-split-examples-mk: New script.
* doc/Makefile.am: Include ($(srcdir)/split-examples.mk).
($(srcdir)/split-examples.mk): New target.
(EXTRA_DIST, MAINTAINERCLEANFILES): Add $(SPLIT_EXAMPLES).
(refman_dependencies)
(tutorial_dependencies)
(ref_guide_dependencies):
Remove $(doc_dir)/split-examples.stamp.
Add $(SPLIT_EXAMPLES).
(regen-split-examples-mk): New (phony) target.
(regen-am): Remake regen-split-examples-mk instead of using
generate_dist_files.sh.
($(srcdir)/headers.stamp): No longer call generate_dist_files.sh
to regen doc/examples/examples.mk.
No longer include $(srcdir)/examples/examples.mk.
($(srcdir)/examples/examples.mk, $(srcdir)/split-examples.stamp):
Remove rules.
(EXTRA_DIST, MAINTAINERCLEANFILES):
Remove $(srcdir)/split-examples.stamp.
(EXTRA_DIST): Add gen-split-examples-mk.
* doc/split-examples.mk: New (generated) Make helper.
* doc/examples/examples.mk: Remove.
2010-03-16 Roland Levillain <roland@lrde.epita.fr>
 
Generate the list of examples in the documentation.
......@@ -216,6 +216,27 @@ regen-examples-mk:
mv -f $(srcdir)/examples.mk.tmp $(srcdir)/examples.mk
chmod -w $(srcdir)/examples.mk
## ---------------- ##
## Split examples. ##
## ---------------- ##
$(srcdir)/split-examples.mk: $(srcdir)/gen-split-examples-mk
rm -f $@.tmp
cd $(srcdir) && ./gen-split-examples-mk >split-examples.mk.tmp
mv -f $@.tmp $@
chmod -w $@
include $(srcdir)/split-examples.mk
EXTRA_DIST += $(SPLIT_EXAMPLES)
MAINTAINERCLEANFILES += $(SPLIT_EXAMPLES)
.PHONY: regen-split-examples-mk
regen-split-examples-mk:
rm -f $(srcdir)/split-examples.mk.tmp
cd $(srcdir) && ./gen-split-examples-mk >split-examples.mk.tmp
mv -f $(srcdir)/split-examples.mk.tmp $(srcdir)/split-examples.mk
chmod -w $(srcdir)/split-examples.mk
## ----------------------- ##
## Doxygen documentation. ##
## ----------------------- ##
......@@ -225,7 +246,7 @@ regen-examples-mk:
# 2. It'd be better to depend on actual files rather than timestamps
# corresponding to a bunch of files.
refman_dependencies = \
$(srcdir)/split-examples.stamp \
$(SPLIT_EXAMPLES) \
$(srcdir)/split-outputs.stamp \
$(PNG_FIGURES) \
$(srcdir)/tutorial/tutorial.hh \
......@@ -521,7 +542,7 @@ tutorial_dir = $(doc_dir)/tutorial
# 2. It'd be better to depend on actual files rather than timestamps
# corresponding to a bunch of files.
tutorial_dependencies = \
$(doc_dir)/split-examples.stamp \
$(SPLIT_EXAMPLES) \
$(doc_dir)/split-outputs.stamp \
$(PNG_FIGURES)
......@@ -721,7 +742,7 @@ ref_guide_dir = $(doc_dir)/ref_guide
# 2. It'd be better to depend on actual files rather than timestamps
# corresponding to a bunch of files.
ref_guide_dependencies = \
$(doc_dir)/split-examples.stamp \
$(SPLIT_EXAMPLES) \
$(doc_dir)/split-outputs.stamp \
$(PNG_FIGURES)
......@@ -1022,31 +1043,9 @@ regen-examples-outputs-mk:
MAINTAINERCLEANFILES += $(OUTPUTS)
# FIXME: Warning: $(SPLIT_EXAMPLES_SRCDIR) might not exist. Ensure it
# exists.
# FIXME: Place split files in their own directory, e.g.: split
# `examples/foo.cc' into `examples/split/foo.dir/foo-1.cc',
# `examples/split/foo.dir/foo-2.cc', etc. It makes removal of these
# files easier. We probably also nee a stamp file to keep track of
# dependencies.
EXTRA_DIST += $(srcdir)/split-examples.stamp
MAINTAINERCLEANFILES += $(srcdir)/split-examples.stamp
# FIXME: Loops are bad, as they prevent parallelism. And we prefer
# data-driven actions anyway. This would imply that we know in
# advance the list out outputs (here, split examples). Maybe we can
# infer it from the LaTeX document.
$(srcdir)/split-examples.stamp: $(EXAMPLES)
@rm -f $@.tmp
@touch $@.tmp
failcom='exit 1'; \
for file in $(EXAMPLES); do \
$(DOC_SRCDIR)/tools/split_sample.sh \
$$file cc raw $(SPLIT_EXAMPLES_SRCDIR) \
|| eval $$failcom; \
done
@mv -f $@.tmp $@
## --------------- ##
## Split outputs. ##
## --------------- ##
EXTRA_DIST += $(srcdir)/split-outputs.stamp
MAINTAINERCLEANFILES += $(srcdir)/split-outputs.stamp
......@@ -1082,13 +1081,12 @@ regen-am:
$(MAKE) $(AM_MAKEFLAGS) regen-pgm-figures-mk
$(MAKE) $(AM_MAKEFLAGS) regen-ppm-figures-mk
$(MAKE) $(AM_MAKEFLAGS) regen-examples-mk
$(MAKE) $(AM_MAKEFLAGS) regen-split-examples-mk
$(MAKE) $(AM_MAKEFLAGS) regen-examples-outputs-mk
@cd $(srcdir) && \
./generate_dist_files.sh outputs txt && \
./generate_dist_files.sh examples cc.raw
@mv -f $(srcdir)/headers.stamp.tmp $(srcdir)/headers.stamp
$(srcdir)/examples/examples.mk: $(srcdir)/headers.stamp
$(srcdir)/outputs/outputs.mk: $(srcdir)/headers.stamp
......@@ -1097,11 +1095,9 @@ $(srcdir)/headers.stamp: $(srcdir)/generate_dist_files.sh
@touch $@.tmp
@cd $(srcdir) && \
./generate_dist_files.sh outputs txt && \
./generate_dist_files.sh examples cc.raw
@mv -f $@.tmp $@
include $(srcdir)/examples/examples.mk
include $(srcdir)/outputs/outputs.mk
......@@ -1160,3 +1156,5 @@ EXTRA_DIST += \
EXTRA_DIST += gen-make-variable
# FIXME: Can't we implement this using `gen-make-variable'?
EXTRA_DIST += gen-examples-outputs-mk
# Generate a Makefile handling the generation of split examples.
EXTRA_DIST += gen-split-examples-mk
## Generated by ../generate_dist_files, do not modify.
EXTRA_DIST += \
examples/accu-wrong-instanciation.cc.raw \
examples/devel/dispatch.cc.raw \
examples/devel/facade.cc.raw \
examples/devel/impl.cc.raw \
examples/fill-proto.cc.raw \
examples/ima2d-restricted-1.cc.raw \
examples/ima2d-restricted-2.cc.raw \
examples/ima2d-restricted-3.cc.raw \
examples/split/accu-right-instanciation-1.cc.raw \
examples/split/borderthickness-1.cc.raw \
examples/split/box2d-bbox-1.cc.raw \
examples/split/domain-display-1.cc.raw \
examples/split/dpoint-1-1.cc.raw \
examples/split/estim-sites-1.cc.raw \
examples/split/extend-1.cc.raw \
examples/split/extend-2.cc.raw \
examples/split/extend-3.cc.raw \
examples/split/extend-4.cc.raw \
examples/split/extend-5.cc.raw \
examples/split/extension-ignore-1.cc.raw \
examples/split/fill-1.cc.raw \
examples/split/fill-2.cc.raw \
examples/split/fill-3.cc.raw \
examples/split/fill-call-1-1.cc.raw \
examples/split/fill-call-1-2.cc.raw \
examples/split/fill-call-1-3.cc.raw \
examples/split/fill-imageif-cfun-1.cc.raw \
examples/split/fill-imageif-cfun-2.cc.raw \
examples/split/fill-imageif-cfun-3.cc.raw \
examples/split/fill-part-image-1.cc.raw \
examples/split/fill-part-image-2.cc.raw \
examples/split/fill-subdomain-1.cc.raw \
examples/split/fill-subdomain-2.cc.raw \
examples/split/fill-subdomain-3.cc.raw \
examples/split/fill-subdomain-4.cc.raw \
examples/split/fill-subdomain-shorter-1.cc.raw \
examples/split/fill-subdomain-shorter-2.cc.raw \
examples/split/forall-piter-1.cc.raw \
examples/split/fun-p2v-1-1.cc.raw \
examples/split/graph-data-1.cc.raw \
examples/split/graph-data-2.cc.raw \
examples/split/graph-data-3.cc.raw \
examples/split/graph-data-4.cc.raw \
examples/split/graph-data-5.cc.raw \
examples/split/graph-data-6.cc.raw \
examples/split/graph-iter-1.cc.raw \
examples/split/graph-iter-2.cc.raw \
examples/split/graph-iter-3.cc.raw \
examples/split/graph-iter-4.cc.raw \
examples/split/ima-has-1.cc.raw \
examples/split/ima-load-1.cc.raw \
examples/split/ima-save-1.cc.raw \
examples/split/ima-size-1.cc.raw \
examples/split/ima2d-1-1.cc.raw \
examples/split/ima2d-2-1.cc.raw \
examples/split/ima2d-3-1.cc.raw \
examples/split/ima2d-4-1.cc.raw \
examples/split/ima2d-5-1.cc.raw \
examples/split/ima2d-6-clone-1.cc.raw \
examples/split/ima2d-7-1.cc.raw \
examples/split/ima2d-rot-1.cc.raw \
examples/split/labeling-compute-1.cc.raw \
examples/split/labeling-compute-2.cc.raw \
examples/split/labeling-compute-3.cc.raw \
examples/split/labeling-compute-4.cc.raw \
examples/split/logical-not-1.cc.raw \
examples/split/logical-not-2.cc.raw \
examples/split/logical-not-3.cc.raw \
examples/split/mln_var-1.cc.raw \
examples/split/mln_var-2.cc.raw \
examples/split/mln_var-3.cc.raw \
examples/split/parray-append-1.cc.raw \
examples/split/parray-bbox-1.cc.raw \
examples/split/paste-1.cc.raw \
examples/split/paste-call-1-1.cc.raw \
examples/split/point-1-1.cc.raw \
examples/split/predicate-1-1.cc.raw \
examples/split/tuto2_first_image-1.cc.raw \
examples/split/tuto2_first_image-2.cc.raw \
examples/split/tuto2_first_image-3.cc.raw \
examples/split/tuto2_first_image-4.cc.raw \
examples/split/tuto3_colorize-1.cc.raw \
examples/split/tuto3_first_routine-1.cc.raw \
examples/split/tuto3_first_routine-2.cc.raw \
examples/split/tuto3_first_routine-3.cc.raw \
examples/split/tuto3_first_routine-4.cc.raw \
examples/split/tuto3_first_routine-5.cc.raw \
examples/split/tuto3_first_routine-6.cc.raw \
examples/split/tuto3_first_routine-7.cc.raw \
examples/split/tuto3_first_routine-8.cc.raw \
examples/split/tuto3_println-1.cc.raw \
examples/split/tuto3_println-2.cc.raw \
examples/split/tuto3_rw_image-1.cc.raw \
examples/split/tuto3_rw_image-2.cc.raw \
examples/split/tuto3_rw_image-3.cc.raw \
examples/split/tuto3_rw_image-4.cc.raw \
examples/split/tuto3_rw_image-5.cc.raw \
examples/split/tuto3_rw_image-6.cc.raw \
examples/split/tuto3_rw_image-7.cc.raw \
examples/split/tuto3_trace-1.cc.raw \
examples/split/tuto3_trace-2.cc.raw \
examples/split/tuto4_genericity_and_algorithms-1.cc.raw \
examples/split/tuto4_genericity_and_algorithms-10.cc.raw \
examples/split/tuto4_genericity_and_algorithms-11.cc.raw \
examples/split/tuto4_genericity_and_algorithms-12.cc.raw \
examples/split/tuto4_genericity_and_algorithms-2.cc.raw \
examples/split/tuto4_genericity_and_algorithms-3.cc.raw \
examples/split/tuto4_genericity_and_algorithms-4.cc.raw \
examples/split/tuto4_genericity_and_algorithms-5.cc.raw \
examples/split/tuto4_genericity_and_algorithms-6.cc.raw \
examples/split/tuto4_genericity_and_algorithms-7.cc.raw \
examples/split/tuto4_genericity_and_algorithms-8.cc.raw \
examples/split/tuto4_genericity_and_algorithms-9.cc.raw \
examples/split/tuto4_point2d-1.cc.raw \
examples/split/tuto4_site_set_create-1.cc.raw \
examples/split/tuto4_site_set_create-2.cc.raw \
examples/split/tuto4_site_set_create-3.cc.raw \
examples/split/tuto4_site_set_create-4.cc.raw \
examples/split/tuto4_site_set_create-5.cc.raw \
examples/split/win-create-1-1.cc.raw \
examples/split/win-create-2-1.cc.raw \
examples/tuto3/fill_non_generic.cc.raw
#! /bin/sh
# Copyright (C) 2010 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/>.
# To be used from milena/doc/'s source directory.
me=`basename $0`
die ()
{
echo >&2 "$me: $@"
exit 1
}
# backslashify
# ------------
# Read lines from the standard input and write them on the standard
# output with an extra trailing backslash, except for the last line.
backslashify()
{
# Set IFS to nothing to prevent `read' from trimming spaces or tabs.
IFS= read last_line
while IFS= read line; do
echo "$last_line \\"
last_line=$line
done
echo "$last_line"
}
# Get this list as argument?
inputs()
{
find examples -name \*.cc
}
output_dir=examples/split
# Use a temporary file to dump rules at the end of the output.
tempfile=`mktemp`
# Set up automatic cleanup.
cleanup() { rm -f "$tempfile"; exit; }
trap cleanup 0 1 2 3 6 15
# Header.
cat <<EOF
## Generated by $me. Do not edit by hand.
EOF
# Output target names in a variable.
{
echo "SPLIT_EXAMPLES ="
inputs | while read file; do
# Count the number of opening and closing marks.
nopening=`grep -c '// *\\\{' "$file"`
nclosing=`grep -c '// *\\\}' "$file"`
test "$nopening" -eq "$nclosing" \
|| die "Unbalanced marks in $file ($nopening vs $nclosing)"
# If there is no mark, skip this file.
test "$nopening" -eq 0 && continue
# FIXME: Programs of which sources are located in a subdirectory of
# examples/ take the path as prefix of their name. This is a pain.
# It'd be much simpler to have all sources in the same directory.
canonical_name=`echo "$file" \
| sed -e 's,examples/,,' \
-e 'y,/,_,' \
-e 's,\.cc$,,'`
# Timestamp split examples (outputs) depend on.
timestamp="\$(srcdir)/$output_dir/$canonical_name.cc.stamp"
# List of targets associated to FILE.
targets=
{
i=1
while test "$i" -le "$nopening"; do
# i-th part of the split file.
part="\$(srcdir)/$output_dir/$canonical_name-$i.cc.raw"
if test -z "$targets"; then
targets="$part"
else
targets="$targets $part"
fi
echo " $part"
i=`expr $i + 1`
done
# Collect rules in a temporary file...
cat >>"$tempfile" <<EOF
$timestamp: \$(srcdir)/$file
@rm -f \$@.tmp
@touch \$@.tmp
\$(srcdir)/tools/split_sample.sh \$< cc raw \$(srcdir)/$output_dir
@mv -f \$@.tmp \$@
EXTRA_DIST += $timestamp
MAINTAINERCLEANFILES += $timestamp
$targets: $timestamp
## Recover from the removal of \$@
@if test -f \$@; then :; else \\
rm -f \$<; \\
\$(MAKE) \$(AM_MAKEFLAGS) \$<; \\
fi
EOF
}
done
} | backslashify
# ...and output them at the end.
cat "$tempfile"
This diff is collapsed.
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