summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-08-10 11:11:18 -0700
committerCliff Click <cliffc@acm.org>2026-08-10 15:21:17 -0700
commit28209703c72fb7e9955961dbdb84e24a0f871acd (patch)
tree8e4df2c1a5e6811696b454bbc4d7cd1cc30e42e7 /Makefile
parente57bdd315a7918a0d130e1c95648ca4a1b4f08ed (diff)
downloadSimple-28209703c72fb7e9955961dbdb84e24a0f871acd.tar.gz
Simple-28209703c72fb7e9955961dbdb84e24a0f871acd.zip
Chapter 25: Moduleslinear-chapter25
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile132
1 files changed, 92 insertions, 40 deletions
diff --git a/Makefile b/Makefile
index 6547a73a..1ab66a60 100644
--- a/Makefile
+++ b/Makefile
@@ -65,14 +65,33 @@ main_javas := $(wildcard $(SRC)/$(SIMPLE)/*java $(SRC)/$(SIMPLE)/*/*java $(SRC
test_javas := $(wildcard $(TST)/$(SIMPLE)/*java $(TST)/$(SIMPLE)/*/*java)
main_classes := $(patsubst $(SRC)/%java,$(CLZDIR)/main/%class,$(main_javas))
test_classes := $(patsubst $(TST)/%java,$(CLZDIR)/test/%class,$(test_javas))
-test_cp := $(patsubst $(TST)/$(SIMPLE)/%.java,com.seaofnodes.simple.%,$(wildcard $(TST)/$(SIMPLE)/*Test.java))
+# These tests do not rely on the stdlib
+test_alone := com.seaofnodes.simple.BrainFuckTest com.seaofnodes.simple.MergeSortTest com.seaofnodes.simple.TypeTest
+test_raw_nums0 := 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21
+test_raw_nums1 := 22 23 24
+# These tests DO rely on the stdlib
+test_raw_sys := 25
+
+# Convert chapter numbers to test files
+test_raw0 := $(patsubst %,com.seaofnodes.simple.Chapter%Test,$(test_raw_nums0))
+test_raw1 := $(patsubst %,com.seaofnodes.simple.Chapter%Test,$(test_raw_nums1))
+test_sys := $(patsubst %,com.seaofnodes.simple.Chapter%Test,$(test_raw_sys) )
+# All the 'src/test/java' files ending in 'Test'
+test_cp0 := $(patsubst $(TST)/$(SIMPLE)/%.java,com.seaofnodes.simple.%,$(wildcard $(TST)/$(SIMPLE)/*Test.java))
+# Minus raw0, raw1, alone tests
+test_cp1 := $(filter-out $(test_raw0) ,$(test_cp0))
+test_cp2 := $(filter-out $(test_raw1) ,$(test_cp1))
+test_cp3 := $(filter-out $(test_alone),$(test_cp2))
+test_cp4 := $(filter-out com.seaofnodes.simple.Chapter25Test,$(test_cp3))
+test_cp := $(filter-out $(test_sys) ,$(test_cp4))
+# All the classes to compile
classes = $(main_classes) $(test_classes)
# All the libraries
libs = $(wildcard lib/*jar)
jars = $(subst $(space),$(SEP),$(libs))
-default_targets := $(CLZDIR)/.tag $(test_classes)
+default_targets := TAGS release tests
# Optionally add ctags to the default target if a reasonable one was found.
ifneq ($(CTAGS),)
default_targets += tags
@@ -81,81 +100,114 @@ endif
default: $(default_targets)
#######################################################
-# Compile just the out-of-date files
-
-OODM :=
-$(CLZDIR)/main/.mtag: $(main_classes) $(main_javas)
+# Compile Java as a whole source set. javac tracks Java dependencies
+# internally, so compiling only the directly out-of-date .java files can leave
+# stale dependent .class files behind.
+$(CLZDIR)/main/.mtag: $(main_javas)
@[ -d $(CLZDIR)/main ] || mkdir -p $(CLZDIR)/main
@# 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 , $(OODM))
- @if [ ! -z "$(OODM)" ] ; 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 $(OODM) >& .out.txt ; then \
+ $(file > .argsM.txt, $(main_javas))
+ @echo "compiling main " `wc -w < .argsM.txt` " files"
+ @if ! javac $(JAVAC_ARGS) -cp "$(CLZDIR)/main$(SEP)$(jars)" -sourcepath $(SRC) -d $(CLZDIR)/main @.argsM.txt >& .out.txt ; then \
cat .out.txt ; \
exit 1; \
- fi ; \
- rm -rf .out.txt ; \
fi
+ @rm -rf .out.txt
@touch $(CLZDIR)/main/.mtag
@rm -f .argsM.txt
-# Collect just the out-of-date files
-$(main_classes): $(CLZDIR)/main/%class: $(SRC)/%java
- $(eval OODM += $$<)
-
#######################################################
-OODT :=
-$(CLZDIR)/test/.ttag: $(test_classes) $(test_javas) $(CLZDIR)/main/.mtag
+$(CLZDIR)/test/.ttag: $(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 \
+ $(file > .argsT.txt, $(test_javas))
+ @echo "compiling test " `wc -w < .argsT.txt` " files"
+ @if ! javac $(JAVAC_ARGS) -cp "$(CLZDIR)/test$(SEP)$(CLZDIR)/main$(SEP)$(jars)" -sourcepath $(TST) -d $(CLZDIR)/test @.argsT.txt >& .out.txt ; then \
cat .out.txt ; \
exit 1; \
- fi ; \
- rm -rf .out.txt ; \
fi
+ @rm -rf .out.txt
@touch $(CLZDIR)/test/.ttag
@rm -f .argsT.txt
-# Collect just the out-of-date files
-$(test_classes): $(CLZDIR)/test/%class: $(TST)/%java
- $(eval OODT += $$<)
+#######################################################
+
+# Default Simple .o target is build/objs which is where all the test .o's get
+# dumped. The default sys search needs to NOT include all the dumped test
+# files; move it down into lib/
+OBJS:= build/objs
+SYS_SMPS:= $(wildcard src/main/smp/*.smp src/main/smp/*/*.smp)
+CPU_PORT:= x86_64_v2
+CALL_CONV:= win64
+CPU_ABI:= $(CPU_PORT)_$(CALL_CONV)
+RELEASE:= build/release
+RELEASE_SYS:= $(RELEASE)/$(CPU_ABI)/sys.o
+
+$(OBJS)/lib_$(CPU_ABI)/sys.o: $(CLZDIR)/main/.mtag $(CLZDIR)/test/.ttag $(SYS_SMPS)
+ @echo "simping " $@
+ @$(JVM) com.seaofnodes.simple.Simple --cpu $(CPU_PORT) --abi $(CALL_CONV) --norun -o $@ src/main/smp/sys.smp
+
+$(RELEASE_SYS): $(OBJS)/lib_$(CPU_ABI)/sys.o
+ @echo "copying " $@
+ @[ -d $(dir $@) ] || mkdir -p $(dir $@)
+ @cp $< $@
#######################################################
# Base launch line for JVM tests
JVM=nice java -ea -cp "$(CLZDIR)/main${SEP}${jars}${SEP}$(CLZDIR)/test"
-
-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
+# Tests that do NOT need sys.smp
+tests_raw0: $(CLZDIR)/main/.mtag $(CLZDIR)/test/.ttag
+ @echo "testing " $(test_raw0)
+ @[ -d $(OBJS) ] || mkdir -p $(OBJS)
+ @$(JVM) org.junit.runner.JUnitCore $(test_raw0)
+
+tests_raw1: $(CLZDIR)/main/.mtag $(CLZDIR)/test/.ttag
+ @echo "testing " $(test_raw1)
+ @[ -d $(OBJS) ] || mkdir -p $(OBJS)
+ @$(JVM) org.junit.runner.JUnitCore $(test_raw1)
+
+# Larger standalone tests, still JUnits, still no sys.smp
+tests_alone: $(CLZDIR)/main/.mtag $(CLZDIR)/test/.ttag
+ @echo "testing " $(test_alone)
+ @[ -d $(OBJS) ] || mkdir -p $(OBJS)
+ @$(JVM) org.junit.runner.JUnitCore $(test_alone)
+
+# Tests that DO need sys.smp
+tests_sys: $(CLZDIR)/main/.mtag $(CLZDIR)/test/.ttag $(RELEASE_SYS)
+ @echo "testing " $(test_sys)
+ @[ -d $(OBJS) ] || mkdir -p $(OBJS)
+ @$(JVM) org.junit.runner.JUnitCore $(test_sys)
fuzzer: $(CLZDIR)/main/.mtag $(CLZDIR)/test/.ttag
- @echo "fuzzing " $(test_cp)
+ @echo "fuzzing "
@$(JVM) org.junit.runner.JUnitCore com.seaofnodes.simple.FuzzerWrap
-# Build a Simple jar
-release: build/release/simple.jar
+tests: $(CLZDIR)/main/.mtag $(CLZDIR)/test/.ttag $(RELEASE_SYS) tests_raw0 tests_raw1 tests_alone tests_sys
+ @echo "All tests"
+ @[ -d $(OBJS) ] || mkdir -p $(OBJS)
+ @$(JVM) org.junit.runner.JUnitCore $(test_cp)
+
+
+# Build a Simple jar and release stdlib
+release: build/release/Simple.jar $(RELEASE_SYS)
# Build a Simple jar
-build/release/simple.jar: $(CLZDIR)/main/.mtag $(CLZDIR)/test/.ttag
+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) .
+ @printf "Main-Class: com.seaofnodes.simple.Simple\nClass-Path: ../../lib/junit-4.12.jar ../../lib/hamcrest-core-1.3.jar\n\n" > build/release/MANIFEST.MF
+ @jar cfm $@ build/release/MANIFEST.MF -C $(CLZDIR)/main . -C $(CLZDIR)/test . -C $(SRC)/$(SIMPLE) . -C $(TST)/$(SIMPLE) .
# Launch viewer
view: $(main_classes)
@echo "viewing "
@$(JVM) com.seaofnodes.simple.JSViewer
+#######################################################
.PHONY: clean
clean:
rm -rf build
@@ -175,6 +227,6 @@ lib/hamcrest-core-1.3.jar:
@(cd lib; wget https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar)
# Build emacs tags (part of a tasty emacs ide experience)
-tags: $(main_javas) $(test_javas)
+TAGS: $(main_javas) $(test_javas)
@rm -f TAGS
- @$(CTAGS) -e --recurse=yes --extras=+q --fields=+fksaiS $(SRC) $(TST)
+ @$(CTAGS) -e --recurse=yes --fields=+fksaiS $(SRC) $(TST)