diff options
| author | Cliff Click <cliffc@acm.org> | 2025-04-21 14:18:23 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-10-08 16:52:27 -0700 |
| commit | 2475516bee0ca64ffb1bff184e671db9b69bd617 (patch) | |
| tree | a1afa6182faed5cf5c9a2dd22f00fa5e18181357 /Makefile | |
| parent | 53308013c3f2bad224208805df0f54416067b8be (diff) | |
| download | Simple-2475516bee0ca64ffb1bff184e671db9b69bd617.tar.gz Simple-2475516bee0ca64ffb1bff184e671db9b69bd617.zip | |
Chapter 22: A Hello, World!
Co-authored-by: godalming123 <68993177+godalming123@users.noreply.github.com>
Co-authored-by: Tamás Hadházy <85063808+Hels15@users.noreply.github.com>
Co-authored-by: Hsiang-Ying Fu <66062782+fuhsnn@users.noreply.github.com>
Co-authored-by: fuhsnn <66062782+fuhsnn@users.noreply.github.com>
Co-authored-by: Symious <14933944+symious@users.noreply.github.com>
Co-authored-by: Jun Kawasaki <jun784@gmail.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 92 |
1 files changed, 78 insertions, 14 deletions
@@ -1,6 +1,34 @@ +# +# Makefile expects to run at the project root, and not nested inside anywhere +# +# cd $DESK/Simple/chapterXX; make +# +# +# first time only - this is the only thing that hits the Interwebs +# +# make lib +# +# any time you want to nuke everything from space: +# +# make clean tags +# +# run the tests +# +# make tests + +####################################################### +# +# Boilerplate because make syntax isn't the best +# + +# Use bash for recipes SHELL := /bin/bash + +# Remove target on error (no broken leftover files) .DELETE_ON_ERROR: +# Keep partial builds but not partial recipes; keeping them speeds up the next `make` +.NOTINTERMEDIATE: # for printing variable values # usage: make print-VARIABLE @@ -47,7 +75,7 @@ libs = $(wildcard lib/*jar) jars = $(subst $(space),$(SEP),$(libs)) -default_targets := $(main_classes) $(test_classes) +default_targets := $(CLZDIR)/main/.mtag $(CLZDIR)/test/.ttag # Optionally add ctags to the default target if a reasonable one was found. ifneq ($(CTAGS),) default_targets += tags @@ -55,33 +83,69 @@ endif default: $(default_targets) -# Compile just the out-of-date files -$(main_classes): $(CLZDIR)/main/%class: $(SRC)/%java $(graph_javas) $(print_javas) $(isa_javas) - @echo "compiling " $@ " because " $? +####################################################### +# Compile the chapter and shared viewer sources together + +$(CLZDIR)/main/.mtag: $(main_javas) Makefile @[ -d $(CLZDIR)/main ] || mkdir -p $(CLZDIR)/main - @javac $(JAVAC_ARGS) -cp "$(CLZDIR)/main$(SEP)$(jars)" -sourcepath $(SRC) -d $(CLZDIR)/main $(main_javas) + @# This crap is really just "javac", but with a beautiful error message. + @# The very very long list of java files is suppressed and counted. + @# The required output "Note: blah blah deprecated blah" is suppressed. + $(file >.argsM.txt,$(main_javas)) + @if [ ! -z "$(main_javas)" ] ; then \ + echo "compiling main because " $< " and " `wc -w < .argsM.txt` " more files" ; \ + if ! javac $(JAVAC_ARGS) -cp "$(CLZDIR)/main$(SEP)$(jars)" -sourcepath $(SRC) -d $(CLZDIR)/main $(main_javas) >& .out.txt ; then \ + cat .out.txt ; \ + exit 1; \ + fi ; \ + rm -rf .out.txt ; \ + fi + @touch $(CLZDIR)/main/.mtag + @rm -f .argsM.txt + +$(main_classes): $(CLZDIR)/main/.mtag -$(test_classes): $(CLZDIR)/test/%class: $(TST)/%java $(main_classes) $(isa_test_javas) - @echo "compiling " $@ " because " $? - @[ -d $(CLZDIR)/test ] || mkdir -p $(CLZDIR)/test - @javac $(JAVAC_ARGS) -cp "$(CLZDIR)/test$(SEP)$(CLZDIR)/main$(SEP)$(jars)" -sourcepath $(TST) -d $(CLZDIR)/test $(test_javas) $(isa_test_javas) + +####################################################### + +OODT := $(isa_test_javas) +$(CLZDIR)/test/.ttag: $(test_classes) $(test_javas) $(isa_test_javas) $(CLZDIR)/main/.mtag + @[ -d $(CLZDIR)/test ] || mkdir -p $(CLZDIR)/test + $(file >.argsT.txt,$(OODT)) + @if [ ! -z "$(OODT)" ] ; then \ + echo "compiling test because " $< " and " `wc -w < .argsT.txt` " more files" ; \ + if ! javac $(JAVAC_ARGS) -cp "$(CLZDIR)/test$(SEP)$(CLZDIR)/main$(SEP)$(jars)" -sourcepath $(TST) -d $(CLZDIR)/test $(OODT) >& .out.txt ; then \ + cat .out.txt ; \ + exit 1; \ + fi ; \ + rm -rf .out.txt ; \ + fi + @touch $(CLZDIR)/test/.ttag + @rm -f .argsT.txt + +# Collect just the out-of-date files +$(test_classes): $(CLZDIR)/test/%class: $(TST)/%java + $(eval OODT += $$<) + +####################################################### # Base launch line for JVM tests JVM=nice java -ea -cp "$(CLZDIR)/main${SEP}${jars}${SEP}$(CLZDIR)/test" -tests: $(default_targets) + +tests: $(CLZDIR)/main/.mtag $(CLZDIR)/test/.ttag @echo "testing " $(test_cp) @[ -d build/objs ] || mkdir -p build/objs @$(JVM) org.junit.runner.JUnitCore $(test_cp) @$(JVM) org.junit.runner.JUnitCore com.seaofnodes.simple.FuzzerWrap -spill-stats: $(default_targets) +spill-stats: $(CLZDIR)/main/.mtag $(CLZDIR)/test/.ttag @[ -d build/objs ] || mkdir -p build/objs @$(JVM) com.seaofnodes.simple.SpillStats .PHONY: spill-stats -fuzzer: $(default_targets) +fuzzer: $(CLZDIR)/main/.mtag $(CLZDIR)/test/.ttag @echo "fuzzing " $(test_cp) @$(JVM) org.junit.runner.JUnitCore com.seaofnodes.simple.FuzzerWrap @@ -89,7 +153,7 @@ fuzzer: $(default_targets) release: build/release/simple.jar # Build a Simple jar -build/release/simple.jar: $(main_classes) $(test_classes) +build/release/simple.jar: $(CLZDIR)/main/.mtag $(CLZDIR)/test/.ttag @echo "jarring " $@ " because " $? @[ -d $(dir $@) ] || mkdir -p $(dir $@) @jar cf build/release/simple.jar -C $(CLZDIR)/main . -C $(CLZDIR)/test . -C $(SRC)/$(SIMPLE) . -C $(TST)/$(SIMPLE) . @@ -119,4 +183,4 @@ tags: $(main_javas) $(test_javas) @$(CTAGS) -e --recurse=yes --extra=+q --fields=+fksaiS $(SRC) $(TST) .PHONY: build -build: $(main_classes) +build: $(CLZDIR)/main/.mtag |
