-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathMakefile
More file actions
229 lines (194 loc) · 7.31 KB
/
Makefile
File metadata and controls
229 lines (194 loc) · 7.31 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# JAVA_TARGET_VER minor only
include scripts/java-target.mk
ECUXPLOT_UID := 20150620L
UNAME := $(shell uname -s | cut -f 1 -d -)
READLINK_Linux_flags:=-e
READLINK_CYGWIN_NT_flags:=-e
READLINK_Darwin_flags:= # SIGH
JAVAC := $(shell readlink $(READLINK_$(UNAME)_flags) "$(shell which javac 2> /dev/null)")
JAVAC_DIR := $(shell dirname "$(JAVAC)")/..
# lazy evaluation, these don't work on every arch, so only eval when needed
JAVA_HOME_CYGWIN_NT = $(shell cygpath -w "$(JAVAC_DIR)")
JAVA_HOME_Darwin = $(shell /usr/libexec/java_home)
JAVA_HOME_Linux := $(JAVAC_DIR)
JAVA_HOME ?= $(JAVA_HOME_$(UNAME))
export JAVA_HOME
# Version detection using helper script
# The following variables are generated by scripts/get-version.py:
# - ECUXPLOT_VER: Full version string based on last real v tag
# - SEM_VER: Semantic version (x.y.z format), overridable
# - ASSET_VER: Asset version for filenames, overridable
# - JPACKAGE_VER: Semantic version for jpackage (always valid)
# - RC: Release candidate/commit info
# - JCOMMON_VER, JFREECHART_VER, OPENCSV_VER, etc.: JAR file versions
# - JAVAC_VER, JAVAC_MAJOR_VER, JAVAC_MINOR_VER: Java compiler info
-include build/version.mk
ECUXPLOT_JARS := \
jcommon-$(JCOMMON_VER).jar \
jfreechart-$(JFREECHART_VER).jar \
jspline.jar \
flanagan.jar \
slf4j-api-$(SLF4J_API_VER).jar \
logback-classic-$(LOGBACK_CLASSIC_VER).jar \
logback-core-$(LOGBACK_CORE_VER).jar
COMMON_JARS := \
opencsv-$(OPENCSV_VER).jar \
commons-cli-$(COMMONS_CLI_VER).jar \
commons-lang3-$(COMMONS_LANG3_VER).jar
JARS:=$(addprefix lib/,$(ECUXPLOT_JARS) $(COMMON_JARS))
VERSION_JAVA:=src/org/nyet/util/Version.java
LOGGERS_XML:=src/org/nyet/ecuxplot/loggers.xml
# This MUST be in the same dir as ./lib or classpath will not be created correctly
TARGET:=ECUxPlot
# Filename for final assets (e.g. installers, archives)
ASSET_FILENAME:=$(TARGET)-$(ASSET_VER)
.PHONY: all compile run test test-debug test-detection binclean clean help
# ant build target
all $(TARGET).jar build/$(TARGET)-$(ECUXPLOT_VER).jar mapdump.jar: build/version.txt
@$(ANT) all
@cp $(TARGET).jar build/$(TARGET)-$(ECUXPLOT_VER).jar
# ant compile target
compile: build.xml build/build.properties $(VERSION_JAVA) $(LOGGERS_XML)
@$(ANT) compile
# ant run target
run: $(TARGET).jar
@$(ANT) run
# Test logger detection and parsing
test: compile
@echo "Running unit tests..."
@$(ANT) -e test || (echo "Tests failed!" && exit 1)
# Test logger detection and parsing with DEBUG
test-debug: compile
@echo "Running unit tests..."
@VERBOSTY=debug $(ANT) -e test || (echo "Tests failed!" && exit 1)
# Test only logger detection (faster, for debugging detection issues)
test-detection: compile
@echo "Running detection-only tests..."
@$(ANT) -e test-detection || (echo "Detection tests failed!" && exit 1)
# Test unit conversion functionality (Issue #103)
test-unit-conversion: compile
@echo "Running unit conversion tests..."
@$(ANT) -e test-unit-conversion || (echo "Unit conversion tests failed!" && exit 1)
# clean targets
binclean:
rm -f $(addprefix *.,jar zip tar gz exe)
rm -f $(addprefix build/*.,jar zip tar gz exe)
clean: binclean
rm -rf build
rm -f $(VERSION_JAVA)
# Rule to generate version.mk when needed
# Use git describe to detect actual git state changes
build/version.mk: Makefile scripts/get-version.py build/git-state.stamp
@echo "$? changed. Need to create a new $@..."
@mkdir -p build
@python3 scripts/get-version.py "$(JAVAC)" > $@
# Stamp file that tracks git state changes
build/git-state.stamp: scripts/get-version.py FORCE
@mkdir -p build
@git describe --tags --abbrev=4 --dirty --always > $@.tmp
@cmp -s $@.tmp $@ || mv $@.tmp $@
@rm -f $@.tmp
# hack to pass version to java app
.PHONY: FORCE
.PRECIOUS: $(VERSION_JAVA)
$(VERSION_JAVA): FORCE
@echo Creating $@
@cat $@.template | $(GEN) > $@
%.xml: scripts/yaml_to_xml.py %.yaml
@echo Converting $*.yaml to $@
@python3 scripts/yaml_to_xml.py $*.yaml $@
ANT:=ant
RSYNC:=rsync
help:
@echo "ECUxPlot Build System"
@echo "===================="
@echo ""
@echo "Most commonly used targets:"
@echo ""
@echo " make all - Build everything for current platform"
@echo " make archive - Create compressed archive (Unix/Linux/macOS)"
@echo " make installers - Build platform-appropriate installers"
@echo " make clean - Clean build artifacts"
@echo ""
@echo "Testing targets:"
@echo ""
@echo " make test - Run full tests (detection + parsing + validation)"
@echo " make test-debug - Run full tests with VERBOSITY=debug"
@echo " make test-detection - Run detection-only tests (faster, for debugging)"
@echo ""
@echo "Platform-specific targets:"
@echo ""
@echo " make dmg - Create macOS DMG installer (macOS only)"
@echo " make exes - Create Windows executable files (Linux/Windows)"
@echo ""
@echo "For detailed information, see INSTALL.md"
@echo ""
# used by wrapper scripts
build/version.txt: FORCE
@mkdir -p build
@echo '$(ECUXPLOT_VER)' | cmp -s - $@ || echo '$(ECUXPLOT_VER)' > $@
# used by subbuild.xml
PROPVARS:=ECUXPLOT_JARS COMMON_JARS TARGET JAVAC_MAJOR_VER JAVA_TARGET_VER
build/build.properties: Makefile build/version.txt
@mkdir -p build
@echo Creating $@
$(shell echo "" > $@) $(foreach V,$(PROPVARS),$(shell echo "$(V)=$($V)" >> $@))
tag:
@if [ -z $(VER) ]; then \
echo "usage: 'make tag VER=1.1.1'"; \
echo "Existing tags:"; \
git tag; \
false; \
fi
git tag -d v$(VER) > /dev/null 2>&1 || true
git tag -a v$(VER) -m "Version v$(VER)"
# debug
vars:
@echo '### Version Variables (from scripts/get-version.py) ###'
@echo 'ECUXPLOT_VER=$(ECUXPLOT_VER)'
@echo 'SEM_VER=$(SEM_VER)'
@echo 'ASSET_VER=$(ASSET_VER)'
@echo 'JPACKAGE_VER=$(JPACKAGE_VER)'
@echo 'RC=$(RC)'
@echo '### JAR Versions (from scripts/get-version.py) ###'
@echo 'JCOMMON_VER=$(JCOMMON_VER)'
@echo 'JFREECHART_VER=$(JFREECHART_VER)'
@echo 'OPENCSV_VER=$(OPENCSV_VER)'
@echo 'COMMONS_CLI_VER=$(COMMONS_CLI_VER)'
@echo 'COMMONS_LANG3_VER=$(COMMONS_LANG3_VER)'
@echo 'SLF4J_API_VER=$(SLF4J_API_VER)'
@echo 'LOGBACK_CLASSIC_VER=$(LOGBACK_CLASSIC_VER)'
@echo 'LOGBACK_CORE_VER=$(LOGBACK_CORE_VER)'
@echo '### Java Compiler Info (from scripts/get-version.py) ###'
@echo 'JAVAC_VER=$(JAVAC_VER)'
@echo 'JAVAC_MAJOR_VER=$(JAVAC_MAJOR_VER)'
@echo 'JAVAC_MINOR_VER=$(JAVAC_MINOR_VER)'
@echo '### Other Variables ###'
@echo 'JAVAC_DIR=$(JAVAC_DIR)'
@echo 'JAVA_HOME=$(JAVA_HOME)'
@echo 'JAVA_TARGET_VER=$(JAVA_TARGET_VER)'
@echo 'JARS=$(JARS)'
# templating machine
GEN:= sed -e 's/%VERSION/$(SEM_VER)/g' \
-e 's/%JAVAC_MAJOR_VER/$(JAVAC_MAJOR_VER)/g' \
-e 's/%JAVAC_MINOR_VER/$(JAVAC_MINOR_VER)/g' \
-e 's/%JAVA_TARGET_VER/$(JAVA_TARGET_VER)/g' \
-e 's/%ECUXPLOT_UID/$(ECUXPLOT_UID)/g' \
-e 's/%ECUXPLOT_VER/$(ECUXPLOT_VER)/g' \
-e 's/%JFREECHART_VER/$(JFREECHART_VER)/g' \
-e 's/%JCOMMON_VER/$(JCOMMON_VER)/g' \
-e 's/%OPENCSV_VER/$(OPENCSV_VER)/g' \
-e 's/%COMMONS_LANG3_VER/$(COMMONS_LANG3_VER)/g' \
-e 's/%COMMONS_CLI_VER/$(COMMONS_CLI_VER)/g' \
-e 's/%SLF4J_API_VER/$(SLF4J_API_VER)/g' \
-e 's/%LOGBACK_CLASSIC_VER/$(LOGBACK_CLASSIC_VER)/g' \
-e 's/%LOGBACK_CORE_VER/$(LOGBACK_CORE_VER)/g'
%: %.template Makefile
@echo Creating $@
@cat $< | $(GEN) > $@
# Wrapper/installer builders
# Behaves the same on all hosts
include scripts/installer.mk
# Used to create runtime tar files
# Behaves differently on each host type
include scripts/jpackage.mk