This is the mail archive of the java@gcc.gnu.org mailing list for the Java 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]

Getting gcj to compile what it finds when scanning


javac, given a -d option, a single class and a classpath, will hunt down
all the .java sources it needs, and if they're not already build, it
will compile them (a behaviour partly inspired by certain other
platforms not having an effective tool like `make`)

gcj does this if you are having it generate .class files (-C) and you
give it a -d flag, but for reasons that were discussed about 4 years
ago, gcj -d -c does not follow that behaviour; although it will scan the
classpath, it will only compile source files that were listed on the
command line.

ie, where I can get away with:

javac -d tmp/classes -classpath tmp/classes:$(CLASSPATH):src \
                src/xseq/client/ProcedureClient.java

as a single invocation to build the enitre program, with GCJ I end up
needing to list every single source file manually and either compile
them directly in one gcj invocation, or do an implicit make rule along
the lines of 

tmp/native/%.o: src/%.java
       mkdir -p $(@D)
       gcj --classpath $(CLASSPATH):src -g -O o $@ -c $<

Either way, it means figuring out the exact list & order of sources that
need to be built, which is moderately annoying [or, at least, is
something I haven't personally had to worry about since I stopped
programming in C]

It would be so much more elegant if I could combine -d and -c in a
single gcj invocation have it create the output directories, and have it
get on with creating individual .o files that result from whichever
classes need compiling.

[I ran into this question in no small part because I was getting away
with having unused, incomplete sources in my tree because javac was only
picking up the things that were actually referenced; on the other hand,
to come up with the list of .java files to feed to gcj manually I just
used a `find`, but that of course picked up all the work that isn't yet
for distribution with obscure dependencies, and so it barfed]


Is having gcj automatically compile necessary complements hypothetically
possible, or does it violate some ancient deeply held religious
superstition? If it were to be doable, I don't suppose there is any
chance that it might sneak its way into GCJ-4?

Cheers,

AfC
Sydney

-- 
Andrew Frederick Cowie

Helping you succeed at flawlessly executing Massive
Changes and Upgrades to your Mission Critical Systems
http://www.operationaldynamics.com/

Sydney   New York   Toronto   London


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