Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (95 loc) · 4.41 KB
/
Copy pathMakefile
File metadata and controls
133 lines (95 loc) · 4.41 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
# Copyright 2023 Bahman Movaqar
#
# This file is part of bjForth.
#
# bjForth is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# bjForth is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with bjForth. If not, see <https://www.gnu.org/licenses/>.
####################################################################################################
SHELL := /usr/bin/env bash
.DEFAULT_GOAL := test
####################################################################################################
export ROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
export root.docs = $(ROOT)docs/
export root.build = $(ROOT)bjforth/build/libs/
export root.forth = $(ROOT)bjforth/src/main/forth/
####################################################################################################
###################### bmakelib: download, install and include.
BMAKELIB_VERSION ?= v0.9.1
-include $(or $(BMAKELIB_DIR),$(PWD)/.bmakelib)/bmakelib.mk
$(or $(BMAKELIB_DIR),$(PWD)/.bmakelib)/bmakelib.mk:
@mkdir -p $(@D)
@curl -fsSL https://github.com/bahmanm/bmakelib/releases/$(if $(BMAKELIB_VERSION),download/$(BMAKELIB_VERSION),latest/download)/bmakelib-portable.tar.gz \
| tar -xz -C $(@D) --strip-components=3
###################### bmakelib: done
####################################################################################################
gradle.gradle ?= ./gradlew
gradle.options ?= --console plain
gradle.command = $(gradle.gradle) $(gradle.options)
####################################################################################################
.PHONY : gradle-options(%)
gradle.options(%) :
$(eval gradle.options += $(*))
####################################################################################################
.PHONY : gradle(%)
gradle(%) :
$(gradle.command) $(*)
####################################################################################################
.PHONY : test
test : gradle( check )
####################################################################################################
.PHONY : e2e-test
e2e-test : bmakelib.error-if-blank( VERSION )
e2e-test : package
@bjforth/src/test/e2e/e2e-test-runner.pl \
$(root.build)/bjForth-$(VERSION).jar \
bjforth/src/test/e2e/e2e-expected-output.txt \
bjforth/src/test/e2e/e2e-tests.forth \
bjforth/src/main/forth/bjForth.forth
####################################################################################################
.PHONY : format
format : gradle( spotlessApply )
####################################################################################################
.PHONY : compile
compile : gradle( classes )
####################################################################################################
.PHONY : clean
clean : gradle( clean )
clean:
-@rm -rf build bjforth/build
####################################################################################################
.PHONY : package
package : bmakelib.error-if-blank( VERSION )
package : gradle( shadowJar )
package : package-path := $(ROOT)bjforth/build/libs/bjForth-$(VERSION).tar.gz
package :
cp $(root.forth)*.forth $(root.build)
mkdir -p $(root.build)docs
cp $(root.docs)*.md $(root.build)docs
cp $(ROOT)bjForth $(root.build)
cd $(root.build) && tar -cf bjForth-$(VERSION).tar *
####################################################################################################
.PHONY : docs
docs :
$(ROOT)docs/extract.pl $(ROOT)bjforth/src/main/forth/bjForth.forth $(ROOT)docs/bjForth.forth.md
####################################################################################################
.PHONY : run
run : bmakelib.error-if-blank( VERSION )
run : gradle( shadowJar )
@cat $(root.forth)bjForth.forth - \
| java \
--add-opens=java.base/java.lang=ALL-UNNAMED \
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
--add-opens=java.base/java.io=ALL-UNNAMED \
--add-opens=java.base/java.util=ALL-UNNAMED \
--add-opens=java.base/java.util.stream=ALL-UNNAMED \
-jar $(root.build)bjForth-$(VERSION).jar