Permalink
Browse files

Started converting to redo

  • Loading branch information...
mildred committed Oct 10, 2011
1 parent 2279582 commit 6294ab7e1802d188d509e8509a24ba2a576eb295
View
@@ -8,4 +8,6 @@
/.cucumber-rerun*.txt
/GNAT-TEMP-*.TMP
/.redo/
-
+/.do_built
+/.do_built.dir/
+/config
View
@@ -1,5 +1,11 @@
## Copyright (C) 2010, Sogilis ##
+ifeq ($(shell which redo 2>/dev/null),)
+REDO=redoconf/minimal-redo
+else
+REDO=redo
+endif
+
GNATMAKE=gnatmake
TEST_SUITES=test coverage
CONFIG=dbg
@@ -294,43 +300,11 @@ bin/feature_tests.cov: bin/xreq features/*.feature
tests: bin/unit_tests bin/feature_tests
-doc: dir $(DOC_FILES)
+doc:
+ $(REDO) doc
-clean: cov-clean dir
- -gprclean -q -Pxreq.gpr -Xtype=dynamic -Xmode=debug
- -gprclean -q -Pxreq.gpr -Xtype=static -Xmode=release
- -gprclean -q -Pxreq.gpr -Xtype=dynamic -Xmode=coverage
- -gprclean -q -Pxreq.gpr -Xtype=static -Xmode=debug
- -gprclean -q -Pxreq.gpr -Xtype=dynamic -Xmode=release
- -gprclean -q -Pxreq.gpr -Xtype=static -Xmode=coverage
- -gprclean -q -Plibxreq.gpr -Xtype=dynamic -Xmode=debug
- -gprclean -q -Plibxreq.gpr -Xtype=dynamic -Xmode=coverage
- -gprclean -q -Plibxreq.gpr -Xtype=dynamic -Xmode=release
- -gprclean -q -Pxreqlib.gpr -Xtype=dynamic -Xmode=debug
- -gprclean -q -Pxreqlib.gpr -Xtype=static -Xmode=release
- -gprclean -q -Pxreqlib.gpr -Xtype=dynamic -Xmode=coverage
- -gprclean -q -Pxreqlib.gpr -Xtype=static -Xmode=debug
- -gprclean -q -Pxreqlib.gpr -Xtype=dynamic -Xmode=release
- -gprclean -q -Pxreqlib.gpr -Xtype=static -Xmode=coverage
- -$(RM) -rf tmp
- -$(RM) -rf obj/*/*
- -$(RM) -rf lib/*/*
- -$(RM) bin/*
- -$(RM) README.html
- -$(RM) src/README.html
- -$(RM) reports/*.aunit.xml
- -$(RM) reports/gnatcheck*.out
- -$(RM) reports/gnatcheck*.log
- -$(RM) reports/*.gcov
- -$(RM) reports/features*.html
- -$(RM) reports/features*.junit/*
- -$(RM) features/data/tmp-*
- -$(RM) features/data/step_definitions*/*.[od]
- -$(RM) features/data/step_definitions*/*.gcda
- -$(RM) features/data/step_definitions*/*.gcno
- -$(RM) -rf features/tests/*
- -$(RM) -rf tests/features/tests/*
- -find . -name "*~" -print0 | xargs -0 rm
+clean:
+ $(REDO) clean
_tests_requirements: bin lib
@@ -1041,28 +1015,19 @@ src/lib/xreqlib-format_html_template.ads src/lib/xreqlib-format_html_template.ad
## MARKDOWN ##
## ##
####################
-
-MARKDOWN_URL=http://daringfireball.net/projects/downloads/Markdown_1.0.1.zip
-MARKDOWN_DIR=Markdown_1.0.1
MARKDOWN_CMDLINE=tools/Markdown.pl <$< >$@
-tools/Markdown.zip:
- @echo "WGET $@"
- wget $(MARKDOWN_URL) -O $@
-
tools/Markdown.pl:
- $(MAKE) Markdown.zip
- @echo "UNZIP $@"
- unzip -u -j tools/Markdown.zip $(MARKDOWN_DIR)/Markdown.pl -d tools
- @echo "CHMOD $@"
- chmod +x $@
- @echo "RM tools/Markdown.zip"
- -$(RM) tools/Markdown.zip
+ $(REDO) tools/Markdown.pl
%.html: %.mdwn tools/Markdown.pl
@echo "MDWN $@"
$(MARKDOWN_CMDLINE)
+%.html: %.md tools/Markdown.pl
+ @echo "MDWN $@"
+ $(MARKDOWN_CMDLINE)
+
%.html: % tools/Markdown.pl
@echo "MDWN $@"
$(MARKDOWN_CMDLINE)
View
@@ -0,0 +1,48 @@
+eval $(redoconf/sh-init)
+
+set +e
+
+(
+
+make cov-clean
+
+gprclean -q -Pxreq.gpr -Xtype=dynamic -Xmode=debug
+gprclean -q -Pxreq.gpr -Xtype=static -Xmode=release
+gprclean -q -Pxreq.gpr -Xtype=dynamic -Xmode=coverage
+gprclean -q -Pxreq.gpr -Xtype=static -Xmode=debug
+gprclean -q -Pxreq.gpr -Xtype=dynamic -Xmode=release
+gprclean -q -Pxreq.gpr -Xtype=static -Xmode=coverage
+gprclean -q -Plibxreq.gpr -Xtype=dynamic -Xmode=debug
+gprclean -q -Plibxreq.gpr -Xtype=dynamic -Xmode=coverage
+gprclean -q -Plibxreq.gpr -Xtype=dynamic -Xmode=release
+gprclean -q -Pxreqlib.gpr -Xtype=dynamic -Xmode=debug
+gprclean -q -Pxreqlib.gpr -Xtype=static -Xmode=release
+gprclean -q -Pxreqlib.gpr -Xtype=dynamic -Xmode=coverage
+gprclean -q -Pxreqlib.gpr -Xtype=static -Xmode=debug
+gprclean -q -Pxreqlib.gpr -Xtype=dynamic -Xmode=release
+gprclean -q -Pxreqlib.gpr -Xtype=static -Xmode=coverage
+
+rm -rf tmp
+rm -rf obj/*/*
+rm -rf lib/*/*
+rm bin/*
+rm README.html
+rm src/README.html
+rm reports/*.aunit.xml
+rm reports/gnatcheck*.out
+rm reports/gnatcheck*.log
+rm reports/*.gcov
+rm reports/features*.html
+rm reports/features*.junit/*
+rm features/data/tmp-*
+rm features/data/step_definitions*/*.[od]
+rm features/data/step_definitions*/*.gcda
+rm features/data/step_definitions*/*.gcno
+rm -rf features/tests/*
+rm -rf tests/features/tests/*
+
+find . -name "*~" -print0 | xargs -0 rm
+
+) 2>/dev/null >&2
+
+
View
@@ -0,0 +1,16 @@
+eval $(redoconf/sh-init)
+
+rc_record TOPDIR="$(pwd)"
+
+cat <<"EOF"
+
+eval $("$TOPDIR/redoconf/sh-init")
+
+compile_md(){
+ redo-ifchange "$TOPDIR/tools/Markdown.pl"
+ "$TOPDIR/tools/Markdown.pl" < "$1"
+}
+
+
+EOF
+
View
@@ -0,0 +1,11 @@
+eval $(redoconf/sh-init)
+rc_source ./config
+
+if [ -f "$1.mdwn" ]; then
+ compile_md "$1.mdwn"
+elif [ -f "$1.md" ]; then
+ compile_md "$1.md"
+elif [ -f "$1" ]; then
+ compile_md "$1"
+fi
+
View
1 doc.do
@@ -0,0 +1 @@
+redo-ifchange README.html HISTORY.html src/README.html reports/index.html
View
@@ -0,0 +1,3 @@
+eval $(./sh-init)
+
+rc_clean
View
@@ -0,0 +1,35 @@
+#!/bin/sh
+REDOCONF=$(dirname "$0")
+eval $("$REDOCONF"/sh-init)
+
+BASEDIR="$1"
+
+# Try and find a redo implementation.
+WHICH_REDO=
+for d in "$REDO" "redo" "$REDOCONF/minimal-redo"; do
+ if "$d" "$REDOCONF/null" 2>/dev/null; then
+ WHICH_REDO="$d"
+ break
+ fi
+done
+if [ -n "$WHICH_REDO" ]; then
+ REDO="$WHICH_REDO"
+else
+ die "Can't find a working version of the 'redo' program."
+fi
+
+# Use our redo implementation to build a config file.
+echo 'Constructing configuration file...'
+if ! "$REDO" "$BASEDIR/config" ; then
+ die "Configuration failed."
+fi
+
+# Everything worked! Tell the user what to do next.
+cat << EOF
+
+Edit "$BASEDIR/config" to change the configuration.
+
+Run the following command to build this software package:
+
+ $REDO $BASEDIR/all
+EOF
View
@@ -0,0 +1,150 @@
+#!/bin/sh
+#
+# A minimal alternative to djb redo that doesn't support incremental builds.
+# For the full version, visit http://github.com/apenwarr/redo
+#
+# The author disclaims copyright to this source file and hereby places it in
+# the public domain. (2010 12 14)
+#
+
+# By default, no output coloring.
+GREEN=""
+BOLD=""
+PLAIN=""
+
+if [ -n "$TERM" -a "$TERM" != "dumb" ] && tty <&2 >/dev/null 2>&1; then
+ GREEN="$(printf '\033[32m')"
+ BOLD="$(printf '\033[1m')"
+ PLAIN="$(printf '\033[m')"
+fi
+
+_dirsplit()
+{
+ base=${1##*/}
+ dir=${1%$base}
+}
+
+_dirsplit "$0"
+export REDO=$(cd "${dir:-.}" && echo "$PWD/$base")
+
+DO_TOP=
+if [ -z "$DO_BUILT" ]; then
+ DO_TOP=1
+ [ -n "$*" ] || set all # only toplevel redo has a default target
+ export DO_BUILT=$PWD/.do_built
+ : >>"$DO_BUILT"
+ echo "Removing previously built files..." >&2
+ sort -u "$DO_BUILT" | tee "$DO_BUILT.new" |
+ while read f; do printf "%s\0%s.did\0" "$f" "$f"; done |
+ xargs -0 rm -f 2>/dev/null
+ mv "$DO_BUILT.new" "$DO_BUILT"
+ DO_PATH=$DO_BUILT.dir
+ export PATH=$DO_PATH:$PATH
+ rm -rf "$DO_PATH"
+ mkdir "$DO_PATH"
+ for d in redo redo-ifchange; do
+ ln -s "$REDO" "$DO_PATH/$d";
+ done
+ [ -e /bin/true ] && TRUE=/bin/true || TRUE=/usr/bin/true
+ for d in redo-ifcreate redo-stamp redo-always; do
+ ln -s $TRUE "$DO_PATH/$d";
+ done
+fi
+
+
+_find_dofile_pwd()
+{
+ DOFILE=default.$1.do
+ while :; do
+ DOFILE=default.${DOFILE#default.*.}
+ [ -e "$DOFILE" -o "$DOFILE" = default.do ] && break
+ done
+ EXT=${DOFILE#default}
+ EXT=${EXT%.do}
+ BASE=${1%$EXT}
+}
+
+
+_find_dofile()
+{
+ PREFIX=
+ while :; do
+ _find_dofile_pwd "$1"
+ [ -e "$DOFILE" ] && break
+ [ "$PWD" = "/" ] && break
+ TARGET=${PWD##*/}/$TARGET
+ PREFIX=${PWD##*/}/$PREFIX
+ cd ..
+ done
+ BASE=$PREFIX$BASE
+}
+
+
+_run_dofile()
+{
+ export DO_DEPTH="$DO_DEPTH "
+ export REDO_TARGET=$PWD/$TARGET
+ set -e
+ read line1 <"$PWD/$DOFILE"
+ cmd=${line1#"#!/"}
+ if [ "$cmd" != "$line1" ]; then
+ /$cmd "$PWD/$DOFILE" "$@" >"$TARGET.tmp2"
+ else
+ :; . "$PWD/$DOFILE" >"$TARGET.tmp2"
+ fi
+}
+
+
+_do()
+{
+ DIR=$1
+ TARGET=$2
+ if [ ! -e "$TARGET" ] || [ -e "$TARGET/." -a ! -e "$TARGET.did" ]; then
+ printf '%sdo %s%s%s%s\n' \
+ "$GREEN" "$DO_DEPTH" "$BOLD" "$DIR$TARGET" "$PLAIN" >&2
+ echo "$PWD/$TARGET" >>"$DO_BUILT"
+ DOFILE=$TARGET.do
+ BASE=$TARGET
+ EXT=
+ [ -e "$TARGET.do" ] || _find_dofile "$TARGET"
+ if [ ! -e "$DOFILE" ]; then
+ echo "do: $TARGET: no .do file" >&2
+ return 1
+ fi
+ [ ! -e "$DO_BUILD" ] || : >>"$TARGET.did"
+ ( _run_dofile "$BASE" "$EXT" "$TARGET.tmp" )
+ RV=$?
+ if [ $RV != 0 ]; then
+ printf "do: %s%s\n" "$DO_DEPTH" \
+ "$DIR$TARGET: got exit code $RV" >&2
+ rm -f "$TARGET.tmp" "$TARGET.tmp2"
+ return $RV
+ fi
+ mv "$TARGET.tmp" "$TARGET" 2>/dev/null ||
+ ! test -s "$TARGET.tmp2" ||
+ mv "$TARGET.tmp2" "$TARGET" 2>/dev/null
+ rm -f "$TARGET.tmp2"
+ else
+ echo "do $DO_DEPTH$TARGET exists." >&2
+ fi
+}
+
+
+redo()
+{
+ for i in "$@"; do
+ _dirsplit "$i"
+ ( cd "$dir" && _do "$dir" "$base" ) || return 1
+ done
+}
+
+
+set -e
+redo "$@"
+
+if [ -n "$DO_TOP" ]; then
+ echo "Removing stamp files..." >&2
+ [ ! -e "$DO_BUILT" ] ||
+ while read f; do printf "%s.did\0" "$f"; done <"$DO_BUILT" |
+ xargs -0 rm -f 2>/dev/null
+fi
Oops, something went wrong.

0 comments on commit 6294ab7

Please sign in to comment.