Klasses.jar may be incorrectly rebuilt.

Pavel Roskin pavel_roskin at geocities.com
Fri Sep 11 08:23:05 PDT 1998


Hello!

I noticed that some recent changes had not affected
kaffe/libraries/javalib/rebuildLib.in which still doesn't rebuild
kaffe/applet/*.
Indeed, it is really a pain to change rebuildLib.in every time. I think
that it is the right time to apply following patch. What it does:

1) kaffe/libraries/javalib/rebuildLib.in is removed
2) this file in no longer mentioned in configure.in
3) makeJava is enhanced. It retains all its functionality, but also
understands the word "all" as an alias to all java sources found in java
and kaffe subdirectories.
4) kaffe/libraries/javalib/Makefile.in calls makeJava on "make classes".
5) It is also possible to run "make update-classes" from
kaffe/libraries/javalib/

I tried to ensure that "make classes" does the same thing as before and
even the same switches are used for kaffe and pizza. I have successfully
rebuilt Klasses.jar on Linux (after adding 50 Mb to swap :-)).

Pavel Roskin.
-------------- next part --------------
--- kaffe/configure.in.orig	Fri Sep 11 13:50:34 1998
+++ kaffe/configure.in	Fri Sep 11 13:55:16 1998
@@ -715,7 +715,6 @@
 
 dnl A few extra files to process.
 output="$make_output \
-libraries/javalib/rebuildLib \
 kaffe/scripts/install-jar \
 kaffe/scripts/kaffe \
 "
--- kaffe/libraries/javalib/makeJava.orig	Tue Jul 14 15:02:12 1998
+++ kaffe/libraries/javalib/makeJava	Fri Sep 11 14:44:41 1998
@@ -3,7 +3,7 @@
 # Simple little script which builds the .class files which are older
 # than the .java files.
 #
-# usage: makeJava [-srcdir path] [-dstdir path] java files ....
+# Exit codes: 0 - Ok, 1 - bad options, 2 - compile errors, 3 - fatal errors
 #
 # Copyright (c) 1997, 1998
 #      Transvirtual Technologies, Inc.  All rights reserved.
@@ -12,42 +12,171 @@
 # of this file.
 #
 
-if test "$JAVAC" = "" ; then
-	JAVAC="javac"
+if test "$*" = "" ; then
+	echo "usage: makeJava options {java files|all}"
+	echo "-srcdir path   where sources are placed (default is '.')"
+	echo "-dstdir path   where compiled classes will be placed (default is 'lib')"
+	echo "-force         don't check whether classes are newer than sources"
+	echo "-unsafe        don't check whether classes are created"
+	echo "-batch         compile all newer sources together (implies -unsafe)"
+	echo "Use 'all' to compile all sources in java and kaffe directories"
+	exit 1
 fi
 
+remap()
+{
+#	This is needed because java/awt/widgets/* goes to lib/java/awt/*
+	echo $1 | sed 's/java\/awt\/widgets\//java\/awt\//'
+}
+
 srcdir=.
-dstdir=.
+dstdir=lib
+alltopdirs="java kaffe"
+batch=0
+force=0
+unsafe=0
+otherargs=""
+errorlist=""
+batchlist=""
 
-if test "$*" = "" ; then
-	echo "usage: makeJava [-srcdir path] [-dstdir path] java files ...."
+while test x$1 != x; do
+
+case $1 in
+-srcdir)
+	if test x$2 = x; then
+		echo argument to $1 missing
+		exit 1
+	fi
+	srcdir=$2; shift; shift;;
+-dstdir)
+	if test x$2 = x; then
+		echo argument to $1 missing
+		exit 1
+	fi
+	dstdir=$2; shift; shift;;
+-batch)
+	batch=1; shift;;
+-force)
+	force=1; shift;;
+-unsafe)
+	unsafe=1; shift;;
+-*)
+	echo "Unknown option $1"; exit 1;;
+*)
+	if test x"$otherargs" = x; then
+		otherargs="$1"
+	else
+		otherargs="$otherargs $1"
+	fi
+	shift;;
+esac
+
+done
+
+if test x"$otherargs" = x; then
+	echo "No files to compile"
 	exit 1
+elif test x"$otherargs" = xall; then
+	files=`cd $srcdir; find $alltopdirs -type f -name \*.java -print`
+else
+	files=""
+	for file in $otherargs; do
+		if test -f $srcdir/$file; then
+			files="$files $file"
+		elif test -f $srcdir/${file}.java; then
+			files="$files ${file}.java"
+		elif test -d $srcdir/$file; then
+			files="$files `cd $srcdir; find $file -type f -name \*.java -print`"
+		else
+			echo File or directory $srcdir/$file not found
+			exit 1
+		fi
+	done
 fi
-if test "$1" = "-srcdir" ; then
-	srcdir=$2
-	shift
-	shift
-fi
-if test "$1" = "-dstdir" ; then
-	dstdir=$2
-	shift
-	shift
+
+if test "$JAVA" = "" ; then
+	JAVA="kaffe -ms 8M -mx 64M"
 fi
 
-for file in $*
+if test "$JAVAC" = "" ; then
+	JAVAC="$JAVA pizza.compiler.Main"
+fi
+
+if test "$JAVAC_CP" = "" ; then
+	JAVAC_CP="$dstdir:$srcdir/Klasses.jar"
+fi
+
+if test "$JFLAGS" = "" ; then
+	JFLAGS="-verbose"
+fi
+
+if test "$JAVAC_CP" != "none" ; then
+	JFLAGS="-classpath $JAVAC_CP $JFLAGS"
+fi
+
+for file in $files
 do
-	b=`echo $file | sed s/\\.java//`
-	jf=$b.java
-	cf=$b.class
+	jf=$srcdir/$file
+	cf=$dstdir/`echo $file | sed s/\\.java$//`.class
+	cf=`remap $cf`
 	docompile=0
-	if test ! -f $dstdir/$cf ; then
+	if test ! -f $cf ; then
 		docompile=1
-	elif test $dstdir/$cf -ot $srcdir/$jf ; then
+	elif test $force = 1 -o $cf -ot $jf ; then
 		docompile=1
 	fi
 	if test "$docompile" = "1" ; then
-		echo -n "Compiling $jf ... "
-		$JAVAC -classpath $dstdir:$srcdir:.:$CLASSPATH:./Klasses.jar -d $dstdir $srcdir/$jf || exit 1
-		echo "done"
+		outdir=`dirname $cf`
+		if test ! -d $outdir; then
+			echo Creating directory $outdir
+			mkdir -p $outdir
+		fi
+		if test $batch = 1; then
+			if test x"$batchlist" = x; then
+				batchlist="$jf"
+			else
+				batchlist="$batchlist $jf"
+			fi
+		else
+			echo "Compiling $jf"
+			$JAVAC $JFLAGS -d $dstdir $jf
+			if test $? = 0; then
+				if test -f $cf; then
+					echo "done"
+				elif test $unsafe = 0; then
+					echo Fatal error while processing $jf
+					echo belonging to `grep ^package $jf`
+					exit 3
+				fi
+			else
+				if test x"$errorlist" = x; then
+					errorlist="$jf"
+				else
+					errorlist="$errorlist $jf"
+				fi
+				echo "not done"
+			fi
+		fi
 	fi
 done
+
+if test $batch = 1; then
+	if test x"$batchlist" = x; then
+		echo "Everything seems to be up-to-date"
+		exit 0
+	else
+		echo "Compiling $batchlist"
+		$JAVAC $JFLAGS -d $dstdir $batchlist
+		if test $? = 0; then
+			echo "done"
+		else
+			echo "not done"
+		fi
+	fi
+elif test x"$errorlist" != x; then
+	echo There were errors while compiling:
+	echo $errorlist
+	exit 2
+else
+	echo No errors encountered
+fi
--- kaffe/libraries/javalib/Makefile.in.orig	Fri Aug 28 21:35:09 1998
+++ kaffe/libraries/javalib/Makefile.in	Fri Sep 11 15:52:21 1998
@@ -45,7 +45,10 @@
 		rm -f Makefile .dir-stamp rebuildLib .depend
 
 classes:	.dir-stamp
-		sh rebuildLib
+		JAVAC_CP=lib $(MAKEJAVA) -force -batch -srcdir $(srcdir) all
+
+update-classes:	.dir-stamp
+		$(MAKEJAVA) -batch -srcdir $(srcdir) all
 
 .dir-stamp:
 		test -d $(LIBDIR) || $(MKDIR) $(LIBDIR)
diff -urN kaffe/libraries/javalib.orig/rebuildLib.in kaffe/libraries/javalib/rebuildLib.in
--- kaffe/libraries/javalib.orig/rebuildLib.in	Fri Sep 11 12:31:32 1998
+++ kaffe/libraries/javalib/rebuildLib.in	Thu Jan  1 01:00:00 1970
@@ -1,57 +0,0 @@
-#!/bin/sh
-#
-# rebuildLib - rebuild everything in one sweep
-#              (without using any pre-compiled classes)
-#
-# Copyright (c) 1998
-#      Transvirtual Technologies, Inc.  All rights reserved.
-#
-# See the file "license.terms" for information on usage and redistribution
-# of this file.
-#
-
-SRCDIR=@srcdir@
-
-if [ -z "$JAVA" ]; then
-	JAVA="kaffe -ms 8M -mx 64M"
-fi
-if [ -z "$JAVAC" ]; then
-	JAVAC="$JAVA pizza.compiler.Main"
-fi
-
-rm -rf lib
-mkdir lib
-
-CLASSES="\
- $SRCDIR/java/applet/*.java \
- $SRCDIR/java/awt/*.java \
- $SRCDIR/java/awt/datatransfer/*.java \
- $SRCDIR/java/awt/event/*.java \
- $SRCDIR/java/awt/image/*.java \
- $SRCDIR/java/awt/peer/*.java \
- $SRCDIR/java/awt/widgets/*.java \
- $SRCDIR/java/beans/*.java \
- $SRCDIR/java/io/*.java \
- $SRCDIR/java/lang/*.java \
- $SRCDIR/java/lang/reflect/*.java \
- $SRCDIR/java/net/*.java \
- $SRCDIR/java/text/*.java \
- $SRCDIR/java/util/*.java \
- $SRCDIR/java/util/mime/*.java \
- $SRCDIR/java/util/zip/*.java \
- $SRCDIR/kaffe/awt/*.java \
- $SRCDIR/kaffe/beans/editors/*.java \
- $SRCDIR/kaffe/io/*.java \
- $SRCDIR/kaffe/jar/*.java \
- $SRCDIR/kaffe/lang/*.java \
- $SRCDIR/kaffe/management/*.java \
- $SRCDIR/kaffe/net/*.java \
- $SRCDIR/kaffe/net/www/protocol/file/*.java \
- $SRCDIR/kaffe/net/www/protocol/system/*.java \
- $SRCDIR/kaffe/util/*.java \
- $SRCDIR/kaffe/text/dateformat/*.java \
- $SRCDIR/kaffe/text/numberformat/*.java \
-"
-
-echo "Compiling classes ..."
-$JAVAC -verbose -d lib -classpath lib $CLASSES


More information about the kaffe mailing list