From 1dadf7ca8a14558f7bb5f0312a3eebcf33a69e40 Mon Sep 17 00:00:00 2001 From: Raja R Harinath Date: Wed, 7 Apr 2010 07:07:15 +0000 Subject: [PATCH] Greatly speed up gensources.sh and improve dependency handling * build/Makefile (DISTFILES): Add gensources.sh. * build/gensources.sh: New, improved version of tools/gensources.sh. * build/library.make ($(sourcefile)): Use the new gensources.sh. ($(makefrag)): Update to handle the optional makefrag generated by gensources.sh. * tools/Makefile (DISTFILES): Remove gensources.sh. * tools/gensources.sh: Remove. svn path=/trunk/mcs/; revision=154909 --- mcs/build/ChangeLog | 8 +++++ mcs/build/Makefile | 1 + mcs/build/gensources.sh | 48 +++++++++++++++++++++++++++++ mcs/build/library.make | 11 +++++-- mcs/tools/ChangeLog | 5 +++ mcs/tools/Makefile | 1 - mcs/tools/gensources.sh | 68 ----------------------------------------- 7 files changed, 71 insertions(+), 71 deletions(-) create mode 100644 mcs/build/gensources.sh delete mode 100755 mcs/tools/gensources.sh diff --git a/mcs/build/ChangeLog b/mcs/build/ChangeLog index d560cb6405c..cb960cc29ff 100644 --- a/mcs/build/ChangeLog +++ b/mcs/build/ChangeLog @@ -1,3 +1,11 @@ +2010-04-07 Raja R Harinath + + * Makefile (DISTFILES): Add gensources.sh. + * gensources.sh: New, improved version of tools/gensources.sh. + * library.make ($(sourcefile)): Use the new gensources.sh. + ($(makefrag)): Update to handle the optional makefrag generated by + gensources.sh. + 2010-04-01 Zoltan Varga * config-default.make (LIBRARY_FLAGS): Applied patch from Laurent Etiemble diff --git a/mcs/build/Makefile b/mcs/build/Makefile index af6ce7356b4..69721f73b68 100644 --- a/mcs/build/Makefile +++ b/mcs/build/Makefile @@ -40,6 +40,7 @@ DISTFILES = \ corcompare.make \ corcompare-api.xsl \ executable.make \ + gensources.sh \ library.make \ nunit-summary.xsl \ rules.make \ diff --git a/mcs/build/gensources.sh b/mcs/build/gensources.sh new file mode 100644 index 00000000000..cc76aa551ec --- /dev/null +++ b/mcs/build/gensources.sh @@ -0,0 +1,48 @@ +#! /bin/sh + +outfile=$1 +incfile=$2 +excfile=$3 + +process_includes_1() { + sed -e '/^[ \t]*$/d' -e '/^[ \t]*#/d' $1 > $2 + if cmp -s $1 $2; then + false + else + sed -n 's,^[ \t]*#include ,,p' $1 | + while read inc; do + cat $inc >> $2 + echo $outfile: $inc >> $outfile.makefrag + echo $inc: >> $outfile.makefrag + done + fi +} + +process_includes() { + i=$1; o=$2; t=${2}.tmp + while process_includes_1 $i $o; do + mv $o $t + i=$t + done + rm -f $t +} + +rm -f $outfile.makefrag + +process_includes $incfile $outfile.inc + +sort -u $outfile.inc > $outfile.inc_s + +if test -z "$excfile"; then + mv $outfile.inc_s $outfile +else + process_includes $excfile $outfile.exc + + sort -u $outfile.exc > $outfile.exc_s + + sort -m $outfile.inc_s $outfile.exc_s | uniq -u > $outfile + + rm -f $outfile.inc_s $outfile.exc_s +fi + + diff --git a/mcs/build/library.make b/mcs/build/library.make index 342be387b1e..d8811d9c199 100644 --- a/mcs/build/library.make +++ b/mcs/build/library.make @@ -16,9 +16,12 @@ ifeq ($(wildcard $(PROFILE_sources)), $(PROFILE_sources)) PROFILE_excludes = $(wildcard $(PROFILE)_$(LIBRARY).exclude.sources) COMMON_sourcefile := $(sourcefile) sourcefile = $(depsdir)/$(PROFILE)_$(LIBRARY).sources -$(sourcefile): $(PROFILE_sources) $(PROFILE_excludes) $(COMMON_sourcefile) + +# Note, gensources.sh can create a $(sourcefile).makefrag if it sees any '#include's +# We don't include it in the dependencies since it isn't always created +$(sourcefile): $(PROFILE_sources) $(PROFILE_excludes) $(COMMON_sourcefile) $(topdir)/build/gensources.sh @echo Creating the per profile list $@ ... - $(topdir)/tools/gensources.sh $(PROFILE_sources) $(PROFILE_excludes) > $@ + $(SHELL) $(topdir)/build/gensources.sh $@ $(PROFILE_sources) $(PROFILE_excludes) library_CLEAN_FILES += $(sourcefile) endif @@ -251,6 +254,10 @@ endif $(makefrag): $(sourcefile) @echo Creating $@ ... @sed 's,^,$(build_lib): ,' $< >$@ + @if test ! -f $(sourcefile).makefrag; then :; else \ + cat $(sourcefile).makefrag >> $@ ; \ + echo '$@: $(sourcefile).makefrag' >> $@; \ + echo '$(sourcefile).makefrag:' >> $@; fi ifneq ($(response),$(sourcefile)) $(response): $(sourcefile) $(PLATFORM_excludes) diff --git a/mcs/tools/ChangeLog b/mcs/tools/ChangeLog index 115c18f02f9..5916d229aeb 100644 --- a/mcs/tools/ChangeLog +++ b/mcs/tools/ChangeLog @@ -1,3 +1,8 @@ +2010-04-07 Raja R Harinath + + * Makefile (DISTFILES): Remove gensources.sh. + * gensources.sh: Remove. + 2010-04-03 Ankit Jain * Makefile: Move xbuild from net_4_0_dirs to per_profile_dirs. diff --git a/mcs/tools/Makefile b/mcs/tools/Makefile index 42d150b7850..970ac6d2e1a 100644 --- a/mcs/tools/Makefile +++ b/mcs/tools/Makefile @@ -72,7 +72,6 @@ DISTFILES = \ scan-tests.pl \ tinderbox/smtp.c \ tinderbox/tinderbox.sh \ - gensources.sh \ removecomments.sh test-local csproj-local run-test-local run-test-ondotnet-local all-local install-local uninstall-local doc-update-local: diff --git a/mcs/tools/gensources.sh b/mcs/tools/gensources.sh deleted file mode 100755 index 7e71029d8bc..00000000000 --- a/mcs/tools/gensources.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env bash - -includefile=$1 -excludefile=$2 - -## input variables: -## $filelist: -## A colon (':') separated list of files already read. -## Must be initialized to ":". -## $excludelist: -## A newline separated of element (support Shell Patterns) to exclude. -## $separator: -## The separator used in list for the output -## -## output variables: -## $list: -## A list of elements separated by the separator given in $separator. -## The new elements will be appended to the list. -readlist () { - local onelist - local onelistcontent - onelist=$1 - - if [ ":$onelist:" = "::" ] ; then return ; fi - if [ ! -f $onelist ] ; then return ; fi - if [ ":${filelist##*:$onelist:*}:" = "::" ] ; then return ; fi - filelist=":$onelist$filelist" - - onelistcontent=`cat $onelist | sed "s=[ \t]*$==g" | while read line ; do echo -n $line ; echo -n ":" ; done` - - OFS="$IFS" - IFS=":" - for line in $onelistcontent ; do - line2=${line##\#} - if [ ":$line:" = ":$line2:" ] ; then - for linex in $excludelist ; do - if [ ":${line##$linex}:" = "::" ] ; then line="" ; fi - done - if [ ":$line:" != "::" ] ; then - if [ ":$list:" = "::" ] ; then - list="$line" - else - list="$list$separator$line" - fi - fi - else - line3=${line2##include } - if [ ":$line3:" != ":$line2:" -a ":$line3:" != "::" ] ; then - readlist "$line3" - fi - fi - done - IFS="$OFS" -} - -list="" -filelist=":" -excludelist="" -separator=":" -readlist "$excludefile" - -excludelist="$list" -list="" -filelist=":" -separator=" -" -readlist "$includefile" -echo "$list" | sort | uniq -- 2.25.1