Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
153 lines (123 loc) · 7.01 KB
/
Copy pathMakefile
File metadata and controls
153 lines (123 loc) · 7.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
.DEFAULT_GOAL := help
ifeq ($(OS),Windows_NT)
MVN ?= mvn
else
MVN ?= $(if $(shell command -v mvnd 2>/dev/null),mvnd,mvn)
endif
MVNARGS ?= -e -ntp -T 1C
JAR := target/triptale.jar
JVMFLAGS := --enable-native-access=ALL-UNNAMED --sun-misc-unsafe-memory-access=allow
# Filters a benign, unsuppressable JavaFX startup warning (JavaFX is loaded from the
# classpath as an unnamed module — see AGENTS.md/CLAUDE.md if you ever revisit this).
FXFILTER := grep --line-buffered -v -e "Unsupported JavaFX configuration" -e "com.sun.javafx.application.PlatformImpl startup"
# AOT cache (JDK 25, JEP 483/514/515): the jar is extracted to an exploded layout (a nested
# fat jar can't be cached) and one training run records loaded/linked classes + profiles.
# The cache file name embeds the exact JDK build, so a JDK upgrade retrains automatically;
# a rebuilt jar retrains via the normal make dependency. See docs/43_startup_performance.md.
AOT_DIR := target/aot
AOT_JAR := $(AOT_DIR)/triptale.jar
JDK_BUILD := $(shell java -XshowSettings:properties -version 2>&1 | awk -F'= ' '/java.runtime.version/{print $$2}')
AOT_CACHE := $(AOT_DIR)/app-jdk$(JDK_BUILD).aot
.PHONY: run run-jar run-fast frun aot-train help build compile test package clean format deps major minor patch shortcut check-update
# -Dmvnd.rawStreams: mvnd otherwise prefixes every app log line with "[INFO] [stdout] ".
# Plain mvn just sees an unused system property.
ifeq ($(OS),Windows_NT)
RUN_CMD := $(MVN) $(MVNARGS) -Dmvnd.rawStreams=true -Pwindows-javafx javafx:run
else
RUN_CMD := $(MVN) $(MVNARGS) -Dmvnd.rawStreams=true javafx:run
endif
# Dev targets skip the artificial minimum splash time (default 2000 ms for real use).
# Override: make run TRIPTALE_SPLASH_MS=2000
run run-fast frun: export TRIPTALE_SPLASH_MS ?= 0
run: ## Launch the TripTale JavaFX app (via Maven plugin)
$(RUN_CMD)
# Pure-Make recursive file listing (no external `find`): on Windows, Git's PATH puts
# System32's find.exe (the DOS text-search command) ahead of GNU find, so `find src -type f`
# fails with "FIND: Parameterformat falsch". $(wildcard) is a Make built-in, immune to that.
# Don't match directories with a trailing-slash glob (`dir/*/`): GNU Make 3.81 (macOS
# /usr/bin/make) also returns plain files for it, which recursed forever and segfaulted make.
# Directories end up in the list too; harmless as prerequisites.
rwildcard = $(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
SOURCES := $(call rwildcard,src,*) pom.xml
$(JAR): $(SOURCES) ## Build the fat jar (skips tests, only when sources change)
$(MVN) $(MVNARGS) -DskipTests package
run-jar: $(JAR) ## Run the pre-built jar directly with java (no Maven required)
java $(JVMFLAGS) -Dlogging.level.net.timafe.triptale=INFO -jar $(JAR) 2>&1 | $(FXFILTER)
$(AOT_JAR): $(JAR)
rm -rf $(AOT_DIR)
java -Djarmode=tools -jar $(JAR) extract --destination $(AOT_DIR)
$(AOT_CACHE): $(AOT_JAR)
@echo "AOT training run: the window opens and closes by itself after a few seconds..."
rm -f $(AOT_DIR)/*.aot
java $(JVMFLAGS) -XX:AOTCacheOutput=$@ -Xlog:aot=error -Dtriptale.aot-training=true -jar $(AOT_JAR) 2>&1 | $(FXFILTER)
@test -f $@ || { echo "error: training run did not produce $@" >&2; exit 1; }
aot-train: ## Force a fresh AOT training run (normally automatic, see run-fast)
rm -f $(AOT_DIR)/*.aot
$(MAKE) $(AOT_CACHE)
run-fast: $(AOT_CACHE) ## Run with the JDK AOT cache (~1.5 s faster start; builds/trains on demand)
java $(JVMFLAGS) -XX:AOTCache=$(AOT_CACHE) -Dlogging.level.net.timafe.triptale=INFO -jar $(AOT_JAR) 2>&1 | $(FXFILTER)
frun: run-fast ## Alias for run-fast
help: ## Show this help
@awk 'BEGIN {FS = ":.*##"; printf "TripTale — available targets:\n\n"} \
/^[a-zA-Z_-]+:.*##/ { printf " \033[36m%-12s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
build: ## Compile and package (skips tests)
$(MVN) $(MVNARGS) -DskipTests package
compile: ## Compile sources only
$(MVN) $(MVNARGS) compile
test: ## Run unit tests
$(MVN) $(MVNARGS) test
package: ## Build the jar (runs tests)
$(MVN) $(MVNARGS) package
app: build ## Build a macOS .app bundle via jpackage (target/dist/TripTale.app)
packaging/macos/build-app.sh
DESKTOP_SHORTCUT_NAME := TripTale (Fast).command
shortcut: ## Create a macOS Desktop shortcut that launches TripTale in fast-run mode
ifeq ($(OS),Windows_NT)
@echo "shortcut is macOS-only (not supported on Windows)."
else
@mkdir -p "$(HOME)/Desktop"
@printf '#!/bin/bash\n# Generated by `make shortcut` in %s — re-run it after moving the repo.\ncd "%s" || exit 1\nexec make run-fast\n' "$(CURDIR)" "$(CURDIR)" > "$(HOME)/Desktop/$(DESKTOP_SHORTCUT_NAME)"
@chmod +x "$(HOME)/Desktop/$(DESKTOP_SHORTCUT_NAME)"
@echo "Created: $(HOME)/Desktop/$(DESKTOP_SHORTCUT_NAME)"
endif
clean: ## Remove target/ build output
$(MVN) $(MVNARGS) clean
deps: ## Print resolved dependency tree
$(MVN) $(MVNARGS) dependency:tree
RELEASES_API := https://api.github.com/repos/tillkuhn/triptale/releases/latest
check-update: ## Compare the current git tag with the latest GitHub release (curl only; Unix)
@json=$$(curl -fsS --max-time 10 $(RELEASES_API)) || { echo "error: could not query $(RELEASES_API)" >&2; exit 1; }; \
latest=$$(printf '%s' "$$json" | sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p' | head -n1); \
page=$$(printf '%s' "$$json" | sed -n 's/.*"html_url": *"\([^"]*\/releases\/tag\/[^"]*\)".*/\1/p' | head -n1); \
jar=$$(printf '%s' "$$json" | sed -n 's/.*"browser_download_url": *"\([^"]*\.jar\)".*/\1/p' | head -n1); \
current=$$(git describe --tags --abbrev=0 2>/dev/null || true); \
[ -n "$$latest" ] || { echo "error: no release found" >&2; exit 1; }; \
echo "current: $${current:-unknown}"; echo "latest: $$latest"; \
if [ -z "$$current" ]; then echo "? current version unknown (no git tag)"; \
elif [ "$$current" = "$$latest" ]; then echo "✔ up to date"; \
elif [ "$$(printf '%s\n%s\n' "$$current" "$$latest" | sort -V | tail -n1)" = "$$latest" ]; then echo "⬆ update available"; \
else echo "local build is ahead of the latest release"; fi; \
if [ "$$current" != "$$latest" ]; then echo "release: $$page"; echo "download: $$jar"; fi
define semtag_check
@if ! command -v semtag >/dev/null 2>&1; then \
echo "semtag not found in PATH."; \
echo "Install it with: brew install semtag (or see https://github.com/nico2sh/semtag)"; \
echo "Then run again."; \
exit 1; \
fi
endef
major: ## Bump major version tag via semtag and push to remote
$(call semtag_check)
@echo "Next version will be: $$(semtag final -s major -o)"
@printf "Press any key to tag and push, or Ctrl-C to abort... " && read -r _dummy
semtag final -s major
minor: ## Bump minor version tag via semtag and push to remote
$(call semtag_check)
@echo "Next version will be: $$(semtag final -s minor -o)"
@printf "Press any key to tag and push, or Ctrl-C to abort... " && read -r _dummy
semtag final -s minor
patch: ## Bump patch version tag via semtag and push to remote
$(call semtag_check)
@echo "Next version will be: $$(semtag final -s patch -o)"
@printf "Press any key to tag and push, or Ctrl-C to abort... " && read -r _dummy
semtag final -s patch