classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] Patch: dependency tracking with gcj


From: Tom Tromey
Subject: [cp-patches] Patch: dependency tracking with gcj
Date: 28 Jun 2005 16:08:34 -0600
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

I'm not checking this in yet.  I thought I'd give folks a couple of
days to look at it first.

This patch adds real dependency tracking when compiling with gcj.  It
adopts the same tradeoff used in the libgcj build: it builds a whole
package a time... not just because this is relatively straightforward,
but also because compiling more at once uses too much memory (and does
too much work), and compiling less is too slow due to repeated
compiler invocations.

The way it works is fairly horrifying.  It is derived in concept from
the corresponding code in libgcj.

Tom

Index: ChangeLog
from  Tom Tromey  <address@hidden>

        * lib/Makefile.gcj: New file.
        * lib/Makefile.am (JAVAC): Changed for new gcj build approach.
        * lib/gen-classlist.sh.in: Don't split list for gcj.
        * lib/split-for-gcj.sh: New file.

Index: lib/Makefile.am
===================================================================
RCS file: /cvsroot/classpath/classpath/lib/Makefile.am,v
retrieving revision 1.90
diff -u -r1.90 Makefile.am
--- lib/Makefile.am 17 Jun 2005 19:32:13 -0000 1.90
+++ lib/Makefile.am 28 Jun 2005 21:55:09 -0000
@@ -13,13 +13,8 @@
 
 # handling source to bytecode compiler programs like gcj, jikes  and kjc
 if FOUND_GCJ
-## Like GCJ but include some common flags.
-GCJF = $(GCJ) -Wno-deprecated --encoding=UTF-8 \
-    --bootclasspath '' --classpath $(compile_classpath)
-JAVAC = $(GCJF) -C -d . @classes.standard \
-&& $(GCJF) -C -d . @classes.awt \
-&& $(GCJF) -C -d . @classes.xml \
-&& $(GCJF) -C -d . @classes.standardx
+JAVAC = $(srcdir)/split-for-gcj.sh && $(MAKE) -f $(srcdir)/Makefile.gcj \
+    GCJ='$(GCJ)' compile_classpath='$(compile_classpath)'
 else
 if FOUND_JIKES
 JAVAC = $(JIKES) +Pno-shadow +Pno-switchcheck +F $(JIKESENCODING) 
-bootclasspath '' -extdirs '' -sourcepath '' --classpath $(compile_classpath) 
-d . @classes
@@ -146,4 +141,3 @@
        rm -f $(top_distdir)/java/util/LocaleData.java
 # Omit files listed in standard.omit.
        ( cd $(top_distdir)/lib ; cat $(top_builddir)/lib/standard.omit | sed 
-e 's/\$$//' | sed -e 's/\/\.\*//' | xargs rm -fr )
-
Index: lib/Makefile.gcj
===================================================================
RCS file: lib/Makefile.gcj
diff -N lib/Makefile.gcj
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lib/Makefile.gcj 28 Jun 2005 21:55:09 -0000
@@ -0,0 +1,30 @@
+# This Makefile is used when building with gcj.  It is separate from
+# the ordinary Makefile as it does special GNU-make-specific things,
+# and this avoids making other builds unnecessarily ugly.
+
+# A .list file is made by split-for-gcj.sh.
+# It lists all the files in a given package.
+all_list_files := $(shell echo lists/*.list)
+# The corresponding stamp files.
+# Each .class file depends on its package's stamp file.
+# Each list file depends on the java files in its package.
+# Each stamp file depends on the corresponding list file.
+# This way touching a single java source will cause the minimum
+# number of rebuilds.
+all_stamp_files := $(all_list_files:.list=.stamp)
+# The dependency file generated by gcj.
+all_deps_files := $(all_list_files:.list=.deps)
+
+all: $(all_stamp_files)
+
+-include Makefile.deps $(all_deps_files)
+
+## Like GCJ but include some common flags.
+GCJF = $(GCJ) -Wno-deprecated --encoding=UTF-8 \
+    --bootclasspath '' --classpath $(compile_classpath) \
+    -C -d .
+
+# Rule to rebuild a stamp file and update the deps file.
+%.stamp: %.list
+       $(GCJF) -MD -MF ${@:.stamp=.deps} @$<
+       echo timestamp > $@
Index: lib/gen-classlist.sh.in
===================================================================
RCS file: /cvsroot/classpath/classpath/lib/gen-classlist.sh.in,v
retrieving revision 1.26
diff -u -r1.26 gen-classlist.sh.in
--- lib/gen-classlist.sh.in 15 Jun 2005 11:11:06 -0000 1.26
+++ lib/gen-classlist.sh.in 28 Jun 2005 21:55:09 -0000
@@ -84,13 +84,4 @@
   done
 fi
 
-# Split in multiple parts for gcj
-grep -v /javax/ classes | grep -v /awt/ \
-                        | grep -v /beans/ \
-                       | grep -v /xml/ > classes.standard
-grep /awt/ classes > classes.awt
-grep /beans/ classes >> classes.awt
-grep /xml/ classes > classes.xml
-grep /javax/ classes | grep -v /xml/ > classes.standardx
-
 exit 0
Index: lib/split-for-gcj.sh
===================================================================
RCS file: lib/split-for-gcj.sh
diff -N lib/split-for-gcj.sh
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lib/split-for-gcj.sh 28 Jun 2005 21:55:09 -0000
@@ -0,0 +1,28 @@
+#! /bin/sh
+
+# Split in multiple parts for gcj.  This uses a somewhat hacky
+# procedure for finding the package of a given file.
+echo "Splitting for gcj"
+rm -f Makefile.deps > /dev/null 2>&1
+test -d lists || mkdir lists
+for dir in java javax gnu org; do
+   for file in `cat classes | fgrep /$dir/`; do
+      pkg=`echo "$file " | sed -n -e "s,^.*/\($dir/.*\)/[^/]*$,\1,p"`
+      list=lists/`echo $pkg | sed -e 's,/,-,g'`
+      echo "$file" >> ${list}.list.1
+      f2=`echo "$file" | sed -n -e "s,^.*/\($dir/.*\)$,\1,p"`
+      f2=${f2%.java}.class
+      echo "$f2: ${list}.stamp" >> Makefile.deps
+      echo "${list}.stamp: $file" >> Makefile.deps
+   done
+done
+
+# Only update a .list file if it changed.
+for file in lists/*.list.1; do
+   real=${file%.1}
+   if ! cmp -s $real $file; then
+      mv $file $real
+   else
+      rm $file
+   fi
+done




reply via email to

[Prev in Thread] Current Thread [Next in Thread]