summaryrefslogtreecommitdiff
path: root/build-support
diff options
context:
space:
mode:
authorDibyendu Majumdar <mobile@majumdar.org.uk>2023-08-19 08:52:57 -0700
committerDibyendu Majumdar <mobile@majumdar.org.uk>2026-10-04 13:30:41 -0700
commit787a37d6b1753bb7c6abd36cba293737ad6b9a0a (patch)
treed26601274ec93203ca8df7bd2e71cf8b52d12d9b /build-support
downloadSimple-787a37d6b1753bb7c6abd36cba293737ad6b9a0a.tar.gz
Simple-787a37d6b1753bb7c6abd36cba293737ad6b9a0a.zip
Chapter 1: Introduction
Co-authored-by: Cliff Click <cliffc@acm.org> Co-authored-by: Thalia Archibald <thalia@archibald.dev> Co-authored-by: hadha <helsgithub15@gmail.com> Co-authored-by: XmiliaH <45106915+XmiliaH@users.noreply.github.com> Co-authored-by: Tamás Hadházy <85063808+Hels15@users.noreply.github.com>
Diffstat (limited to 'build-support')
-rw-r--r--build-support/chapter-release.mk7
-rw-r--r--build-support/early-chapter.mk51
2 files changed, 58 insertions, 0 deletions
diff --git a/build-support/chapter-release.mk b/build-support/chapter-release.mk
new file mode 100644
index 00000000..74e216f4
--- /dev/null
+++ b/build-support/chapter-release.mk
@@ -0,0 +1,7 @@
+# Jar packaging for chapters predating the existing release target.
+.PHONY: release
+release: build/release/simple.jar
+
+build/release/simple.jar: $(main_classes) $(test_classes)
+ @mkdir -p build/release
+ jar cf $@ -C $(CLZDIR)/main . -C $(CLZDIR)/test .
diff --git a/build-support/early-chapter.mk b/build-support/early-chapter.mk
new file mode 100644
index 00000000..d0135b74
--- /dev/null
+++ b/build-support/early-chapter.mk
@@ -0,0 +1,51 @@
+# 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
+
+include $(firstword $(wildcard ../graph/graph.mk graph/graph.mk))
+include $(firstword $(wildcard ../print/print.mk print/print.mk))
+
+.PHONY: build
+build: $(main_classes)
+
+$(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 $(firstword $(wildcard ../build-support/chapter-release.mk build-support/chapter-release.mk))