diff options
| author | Cliff Click <cliffc@acm.org> | 2026-09-17 14:36:22 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-09-17 14:36:22 -0700 |
| commit | 0c99d74c85b937e5d566a7f2899d75025d9c54ea (patch) | |
| tree | 9f4834d3fb1ec936fbea575d241f05a53c09336e /build-support/early-chapter.mk | |
| parent | 410ee209ba1db89959f8e6be9cdaf2350e70fd27 (diff) | |
| download | Simple-0c99d74c85b937e5d566a7f2899d75025d9c54ea.tar.gz Simple-0c99d74c85b937e5d566a7f2899d75025d9c54ea.zip | |
Get makefiles and fuzzer testing uniform across chapters
Diffstat (limited to 'build-support/early-chapter.mk')
| -rw-r--r-- | build-support/early-chapter.mk | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/build-support/early-chapter.mk b/build-support/early-chapter.mk new file mode 100644 index 00000000..939b7782 --- /dev/null +++ b/build-support/early-chapter.mk @@ -0,0 +1,45 @@ +# Chapters 1-3 and 5 previously only had Maven builds. +# Included with the chapter as the working directory. +SHELL := /bin/bash +.DEFAULT_GOAL := tests +.DELETE_ON_ERROR: +SIMPLE := com/seaofnodes/simple +SRC := src/main/java +TST := src/test/java +CLZDIR := build/classes +SEP := $(if $(filter Windows_NT,$(OS)),;,:) +CTAGS ?= ctags +JAVAC_ARGS ?= -g +main_javas := $(wildcard $(SRC)/$(SIMPLE)/*.java $(SRC)/$(SIMPLE)/*/*.java) +test_javas := $(wildcard $(TST)/$(SIMPLE)/*.java $(TST)/$(SIMPLE)/*/*.java) +test_cp := $(patsubst $(TST)/$(SIMPLE)/%.java,com.seaofnodes.simple.%,$(wildcard $(TST)/$(SIMPLE)/*Test.java)) +jars := lib/junit-4.12.jar$(SEP)lib/hamcrest-core-1.3.jar +main_classes := $(CLZDIR)/main/.mtag +test_classes := $(CLZDIR)/test/.ttag + +$(main_classes): $(main_javas) + @mkdir -p $(CLZDIR)/main + javac $(JAVAC_ARGS) -d $(CLZDIR)/main $(main_javas) + @touch $@ + +$(test_classes): $(test_javas) $(main_classes) lib/junit-4.12.jar lib/hamcrest-core-1.3.jar + @mkdir -p $(CLZDIR)/test + javac $(JAVAC_ARGS) -cp "$(CLZDIR)/main$(SEP)$(jars)" -d $(CLZDIR)/test $(test_javas) + @touch $@ + +.PHONY: tests tags lib +tests: $(test_classes) + java -ea -cp "$(CLZDIR)/main$(SEP)$(CLZDIR)/test$(SEP)$(jars)" org.junit.runner.JUnitCore $(test_cp) + +tags: + $(CTAGS) -e --recurse=yes --fields=+fksaiS $(SRC) $(TST) + +lib: lib/junit-4.12.jar lib/hamcrest-core-1.3.jar +lib/junit-4.12.jar: + @mkdir -p lib + wget -O $@ https://repo1.maven.org/maven2/junit/junit/4.12/junit-4.12.jar +lib/hamcrest-core-1.3.jar: + @mkdir -p lib + wget -O $@ https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar + +include ../build-support/chapter-release.mk |
