This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Ping some build machinery patches


* Tom Tromey wrote on Thu, Apr 17, 2008 at 01:45:13AM CEST:
> >>>>> "Ralf" == Ralf Wildenhues <Ralf.Wildenhues@gmx.de> writes:
> 
> Ralf> [PATCH, classpath] speed up gen-classlist.sh
> Ralf> <http://gcc.gnu.org/ml/gcc-patches/2008-03/msg01403.html>
> 
> Ok.  To answer your questions here -- it is probably better to
> explicitly call AC_PROG_AWK, and yes, I think running genclasses each
> time is intentional.

OK, thanks.  I enabled the AC_PROG_AWK there.

> I will push these into Classpath.  If you don't mind, email me an
> updated copy of the second patch.

Here you go.  Please note that the other classpath patch caused lots of
regenerated files.

Cheers,
Ralf

2008-04-18  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>

	* lib/gen-classlist.sh.in: Avoid grepping each omission, by
	building an awk script with a hash for literal files, and
	awk regular expressions for the rest.
	* configure.ac: Call AC_PROG_AWK.
	* configure: Regenerate.

Index: libjava/classpath/configure.ac
===================================================================
--- libjava/classpath/configure.ac	(revision 134412)
+++ libjava/classpath/configure.ac	(working copy)
@@ -375,7 +375,7 @@
 dnl Initialize libtool
 AC_DISABLE_STATIC
 AC_PROG_LIBTOOL
-dnl AC_PROG_AWK
+AC_PROG_AWK
 AC_PROG_CC
 AM_PROG_CC_C_O
 AC_PROG_CPP
Index: libjava/classpath/lib/gen-classlist.sh.in
===================================================================
--- libjava/classpath/lib/gen-classlist.sh.in	(revision 134412)
+++ libjava/classpath/lib/gen-classlist.sh.in	(working copy)
@@ -82,26 +82,48 @@
    fi
 done
 
-# FIXME: could be more efficient by constructing a series of greps.
-for filexp in `cat tmp.omit`; do
-   grep -v ${filexp} < ${top_builddir}/lib/classes.1 > ${top_builddir}/lib/classes.tmp
-   mv ${top_builddir}/lib/classes.tmp ${top_builddir}/lib/classes.1
-done
+# Mangle the omit expressions into a script suitable for old awk.
+# Exploit the fact that many omissions are not regular expressions:
+# assume a single file is listed if it does not contain '*', '$',
+# and ends in '.java'.
+sed_omit_hash='
+1i\
+  BEGIN {\
+    omit[""] = 1
+$a\
+  }
+/[*$]/d
+/\.java$/!d
+s|^|    omit["|
+s|$|"] = 1|'
+sed_omit_main_loop='
+1i\
+  {\
+    if (omit[$3]) next
+$a\
+    print\
+  }
+/^[^*$]*\.java$/d
+s|/|\\/|g
+s|^|  if ($3 ~ /|
+s|$|/) next|'
 
+sed "$sed_omit_hash" <tmp.omit >tmp.awk
+sed "$sed_omit_main_loop" <tmp.omit >>tmp.awk
+@AWK@ -f tmp.awk < ${top_builddir}/lib/classes.1 > ${top_builddir}/lib/classes.tmp
+mv ${top_builddir}/lib/classes.tmp ${top_builddir}/lib/classes.1
 
+vm_omitlist=
 for dir in $vm_dirlist; do
    if test -f $dir/$1.omit; then
-      for filexp in `cat $dir/$1.omit`; do
-	 grep -v $filexp < vm.add > vm.add.1
-	 mv vm.add.1 vm.add
-      done
+      vm_omitlist="$vm_omitlist $dir/$1.omit"
    fi
 done
-cat vm.add >> classes.1
+cat $vm_omitlist | sed "$sed_omit_hash" > tmp.awk
+cat $vm_omitlist | sed "$sed_omit_main_loop" >> tmp.awk
+@AWK@ -f tmp.awk < vm.add >>${top_builddir}/lib/classes.1
 
-rm vm.omit
-rm vm.add
-rm tmp.omit
+rm -f vm.omit vm.add tmp.omit tmp.awk
 
 new=
 if test -f ${top_builddir}/lib/classes.2; then


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]