tweak makefile to recompile all dirty java files in a single javac invocation for efficiency

This commit is contained in:
Joel Dice 2007-11-02 08:01:10 -06:00
parent b71d5104ba
commit d3592f2dbd

View File

@ -187,6 +187,7 @@ classpath-sources = $(shell find $(classpath) -name '*.java')
classpath-classes = \
$(call java-classes,$(classpath-sources),$(classpath),$(classpath-build))
classpath-object = $(native-build)/classpath-jar.o
classpath-dep = $(classpath-build)/dep
ifeq ($(platform),darwin)
classpath-object =
@ -194,6 +195,7 @@ endif
test-sources = $(wildcard $(test)/*.java)
test-classes = $(call java-classes,$(test-sources),$(test),$(test-build))
test-dep = $(test-build)/dep
class-name = $(patsubst $(1)/%.class,%,$(2))
class-names = $(foreach x,$(2),$(call class-name,$(1),$(x)))
@ -202,17 +204,9 @@ flags = -cp $(test-build)
args = $(flags) $(call class-name,$(test-build),$(input))
.PHONY: build
build: $(interpreter) $(archive) $(classpath-classes) $(test-classes)
build: $(interpreter) $(archive) $(classpath-dep) $(test-dep)
.PHONY: classes
classes:
@mkdir -p $(classpath-build)
$(javac) -d $(classpath-build) -bootclasspath $(classpath) \
$(classpath-sources)
@mkdir -p $(test-build)
$(javac) -d $(test-build) -bootclasspath $(classpath-build) $(test-sources)
$(test-classes): $(classpath-classes)
$(test-classes): $(classpath-dep)
.PHONY: run
run: build
@ -251,26 +245,24 @@ $(generated-code): %.cpp: $(src)/types.def $(generator)
$(native-build)/type-generator.o: \
$(generator-headers)
define compile-class
@echo "compiling $(@)"
@mkdir -p $(dir $(@))
$(javac) -bootclasspath $(classpath) -classpath $(classpath) \
-d $(1) $(<)
@touch $(@)
endef
$(classpath-build)/%.class: $(classpath)/%.java
@echo "compiling $(@)"
@mkdir -p $(dir $(@))
$(javac) -bootclasspath $(classpath) -classpath $(classpath) \
-d $(classpath-build) $(<)
@touch $(@)
@echo $(<)
$(test-build)/%.class: $(test)/%.java
@echo "compiling $(@)"
@echo $(<)
$(classpath-dep): $(classpath-sources)
@echo "compiling classpath classes"
@mkdir -p $(dir $(@))
$(javac) -bootclasspath $(classpath) -classpath $(classpath) \
-d $(test-build) $(<)
$(javac) -d $(dir $(@)) -bootclasspath $(classpath-build) \
$(shell make -s $(classpath-classes))
@touch $(@)
$(test-dep): $(test-sources)
@echo "compiling test classes"
@mkdir -p $(dir $(@))
$(javac) -d $(dir $(@)) -bootclasspath $(classpath-build) \
$(shell make -s $(test-classes))
@touch $(@)
define compile-object
@ -289,7 +281,7 @@ $(interpreter-asm-objects): $(native-build)/%-asm.o: $(src)/%.S
$(driver-object): $(native-build)/%.o: $(src)/%.cpp
$(compile-object)
$(build)/classpath.jar: $(classpath-classes)
$(build)/classpath.jar: $(classpath-dep)
(wd=$$(pwd); \
cd $(classpath-build); \
$(jar) c0f $${wd}/$(@) $$(find . -name '*.class'))