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