1
-
2
- CLOJURE_STDLIB_VERSION := clojure-1.12.1
3
- STDLIB_ORIGINALS_DIR := scripts/rewrite-core/originals
4
- STDLIB_ORIGINALS := $(shell find $(STDLIB_ORIGINALS_DIR ) -name '* .clj')
5
- STDLIB := $(STDLIB_ORIGINALS:scripts/rewrite-core/originals/%=% )
6
- STDLIB_ORIGINALS := $(addprefix scripts/rewrite-core/originals/,$(STDLIB ) )
7
- STDLIB_TARGETS := $(addprefix pkg/stdlib/clojure/,$(STDLIB:.clj=.glj ) )
1
+ # Usage:
2
+ # make clean all test GO-VERSION=1.25.1
3
+
4
+ SHELL := bash
5
+
6
+ GO-VERSION ?= 1.19.3
7
+ CLOJURE-VERSION ?= 1.12.1
8
+
9
+ CLOJURE-STDLIB-VERSION := clojure-$(CLOJURE-VERSION )
10
+ STDLIB-ORIGINALS-DIR := scripts/rewrite-core/originals
11
+ STDLIB-ORIGINALS := $(wildcard $(STDLIB-ORIGINALS-DIR ) /* .clj)
12
+ STDLIB-NAMES := $(STDLIB-ORIGINALS:scripts/rewrite-core/originals/%=% )
13
+ STDLIB-ORIGINALS := $(STDLIB-NAMES:%=scripts/rewrite-core/originals/,% )
14
+ STDLIB-TARGETS := $(addprefix pkg/stdlib/clojure/,$(STDLIB-NAMES:.clj=.glj ) )
15
+
16
+ AOT-NAMESPACES := \
17
+ clojure.core \
18
+ clojure.core.async \
19
+ clojure.string \
20
+ clojure.template \
21
+ clojure.test \
22
+ clojure.uuid \
23
+ clojure.walk \
24
+ glojure.go.io \
25
+ glojure.go.types \
26
+ $(EXTRA-AOT-NAMESPACES )
8
27
9
28
OS-TYPE := $(shell bash -c 'echo $$OSTYPE')
10
29
OS-NAME := \
@@ -23,88 +42,142 @@ OA-linux-arm64 := linux_arm64
23
42
OA-linux-int64 := linux_amd64
24
43
OA-macos-arm64 := darwin_arm64
25
44
OA-macos-int64 := darwin_amd64
26
- OA := $(OA-$(OS-ARCH ) )
27
- GLJ := bin/$(OA ) /glj
45
+ GLJ-CMD := bin/$(OA-$(OS-ARCH ) ) /glj
28
46
endif
29
47
endif
30
48
31
- TEST_FILES := $(shell find ./test -name '* .glj' | sort)
32
- TEST_TARGETS := $(addsuffix .test,$(TEST_FILES ) )
49
+ TEST-GLJ-DIR := test/glojure
50
+ TEST-GLJ-FILES := $(shell find $(TEST-GLJ-DIR ) -name '* .glj' | sort)
51
+ TEST-GLJ-TARGETS := $(addsuffix .test,$(TEST-GLJ-FILES ) )
52
+ TEST-SUITE-DIR := test/clojure-test-suite
53
+ TEST-SUITE-FILE := test-glojure.glj
54
+
55
+ GO-PLATFORMS := \
56
+ darwin_arm64 \
57
+ darwin_amd64 \
58
+ linux_arm64 \
59
+ linux_amd64 \
60
+ windows_arm \
61
+ windows_amd64 \
62
+ js_wasm \
63
+ $(EXTRA-GO-PLATFORMS )
64
+
65
+ GLJ-IMPORTS =$(foreach platform,$(GO-PLATFORMS ) \
66
+ ,pkg/gen/gljimports/gljimports_$(platform ) .go)
33
67
34
- GOPLATFORMS := darwin_arm64 darwin_amd64 linux_arm64 linux_amd64 windows_amd64 windows_arm js_wasm
35
- GLJIMPORTS =$(foreach platform,$(GOPLATFORMS ) ,pkg/gen/gljimports/gljimports_$(platform ) .go)
36
68
# wasm should have .wasm suffix; others should not
37
- BINS =$(foreach platform,$(GOPLATFORMS ) ,bin/$(platform ) /glj$(if $(findstring wasm,$(platform ) ) ,.wasm,) )
69
+ GLJ-BINS =$(foreach platform,$(GO-PLATFORMS ) \
70
+ ,bin/$(platform ) /glj$(if $(findstring wasm,$(platform ) ) ,.wasm,) )
71
+
72
+ GO-CMD := go$(GO-VERSION )
73
+
74
+ ALL-TARGETS := \
75
+ $(if $(force ) ,update-clojure-sources) \
76
+ stdlib-targets \
77
+ generate \
78
+ aot \
79
+ glj-imports \
80
+ glj-bins \
38
81
39
- # eventually, support multiple minor versions
40
- GO_VERSION := 1.19.3
41
- GO_CMD := go$(GO_VERSION )
82
+ # -------------------------------------------------------------------------------
83
+ default : all
42
84
43
- .PHONY : all
44
- all : gocmd $(STDLIB_TARGETS ) go-generate aot $(GLJIMPORTS ) $(BINS )
85
+ # Dummy target for commands like:
86
+ # make all force=1
87
+ # make stdlib-targets force=1
88
+ force :
89
+
90
+ all : $(ALL-TARGETS )
45
91
46
- .PHONY : gocmd
47
92
gocmd :
48
- @$(GO_CMD ) version 2>&1 > /dev/null || \
49
- (go install " golang.org/dl/$( GO_CMD) @latest" && \
50
- $(GO_CMD ) download > /dev/null && $(GO_CMD ) version > /dev/null)
93
+ @$(GO-CMD ) version & > /dev/null || { \
94
+ (go install " golang.org/dl/$( GO-CMD) @latest" && \
95
+ $(GO-CMD ) download > /dev/null && \
96
+ $(GO-CMD ) version > /dev/null); }
97
+
98
+ stdlib-targets : $(STDLIB-TARGETS )
51
99
52
- .PHONY : go-generate
53
100
generate :
54
- @ go generate ./...
101
+ go generate ./...
55
102
56
- .PHONY : aot
57
- aot : gocmd $(STDLIB_TARGETS )
58
- @echo " (map compile '[clojure.core clojure.core.async clojure.string clojure.template clojure.test clojure.uuid clojure.walk glojure.go.types glojure.go.io])" | \
59
- GLOJURE_USE_AOT=false GLOJURE_STDLIB_PATH=./pkg/stdlib $(GO_CMD ) run -tags glj_no_aot_stdlib ./cmd/glj
103
+ aot : gocmd $(STDLIB-TARGETS )
104
+ GLOJURE_USE_AOT=false \
105
+ GLOJURE_STDLIB_PATH=./pkg/stdlib \
106
+ $(GO-CMD ) run -tags glj_no_aot_stdlib ./cmd/glj \
107
+ <<< " (map compile '[$(AOT-NAMESPACES)])"
60
108
61
- .PHONY : build
62
- build : $(GLJ )
109
+ glj-imports : $(GLJ-IMPORTS )
63
110
64
- .PHONY : clean
65
- clean :
66
- $(RM ) -r bin/
111
+ glj-bins : $(GLJ-BINS )
67
112
68
- pkg/gen/gljimports/gljimports_% .go : ./scripts/gen-gljimports.sh ./cmd/gen-import-interop/main.go ./internal/genpkg/genpkg.go \
69
- $(wildcard ./pkg/lang/* .go) $(wildcard ./pkg/runtime/* .go)
113
+ build : $(GLJ-CMD )
114
+
115
+ clean :
116
+ $(RM ) report.html
117
+ $(RM ) -r bin/ scripts/rewrite-core/.cpcache/
118
+
119
+ pkg/gen/gljimports/gljimports_% .go : \
120
+ ./scripts/gen-gljimports.sh \
121
+ ./cmd/gen-import-interop/main.go \
122
+ ./internal/genpkg/genpkg.go \
123
+ $(wildcard ./pkg/lang/* .go) \
124
+ $(wildcard ./pkg/runtime/* .go) \
125
+ $(if $(force ) ,force)
70
126
@echo " Generating $@ "
71
- @ ./scripts/gen-gljimports.sh $@ $* $(GO_CMD )
127
+ ./scripts/gen-gljimports.sh $@ $* $(GO-CMD )
72
128
73
- pkg/stdlib/clojure/% .glj : scripts/rewrite-core/originals/% .clj scripts/rewrite-core/run.sh scripts/rewrite-core/rewrite.clj
129
+ pkg/stdlib/clojure/% .glj : \
130
+ scripts/rewrite-core/originals/%.clj \
131
+ scripts/rewrite-core/run.sh \
132
+ scripts/rewrite-core/rewrite.clj \
133
+ $(if $(force ) ,force)
74
134
@echo " Rewriting $< to $@ "
75
135
@mkdir -p $(dir $@ )
76
- @ scripts/rewrite-core/run.sh $< > $@
136
+ scripts/rewrite-core/run.sh $< > $@
77
137
78
- bin/% /glj : generate $(wildcard ./cmd/glj/* .go) $(wildcard ./pkg/** /* .go) $(wildcard ./internal/** /* .go)
138
+ bin/% /glj : generate \
139
+ $(wildcard ./cmd/glj/* .go) \
140
+ $(wildcard ./pkg/** /* .go) \
141
+ $(wildcard ./internal/** /* .go) \
142
+ $(if $(force ) ,force)
79
143
@echo " Building $@ "
80
144
@mkdir -p $(dir $@ )
81
- @ scripts/build-glj.sh $@ $*
145
+ scripts/build-glj.sh $@ $*
82
146
83
- bin/% /glj.wasm : $(wildcard ./cmd/glj/* .go) $(wildcard ./pkg/** /* .go) $(wildcard ./internal/** /* .go)
147
+ bin/% /glj.wasm : \
148
+ $(wildcard ./cmd/glj/* .go) \
149
+ $(wildcard ./pkg/** /* .go) \
150
+ $(wildcard ./internal/** /* .go) \
151
+ $(if $(force ) ,force)
84
152
@echo " Building $@ "
85
153
@mkdir -p $(dir $@ )
86
- @ scripts/build-glj.sh $@ $*
154
+ scripts/build-glj.sh $@ $*
87
155
88
- .PHONY : vet
89
156
vet :
90
- @go vet ./...
91
-
92
- .PHONY : $(TEST_TARGETS )
93
- $(TEST_TARGETS ) : gocmd $(GLJ )
94
- @$(GLJ ) $(basename $@ )
157
+ go vet ./...
95
158
96
159
.PHONY : test
97
- test : $(TEST_TARGETS ) # vet - vet is disabled until we fix errors in generated code
98
- @cd test/clojure-test-suite && \
99
- ../../$(GLJ ) test-glojure.glj --expect-failures 38 --expect-errors 151 2> /dev/null
160
+ # vet is disabled until we fix errors in generated code
161
+ test : test-glj test-suite # vet
162
+
163
+ test-glj : $(TEST-GLJ-TARGETS )
164
+
165
+ test-suite : $(GLJ-CMD )
166
+ cd $(TEST-SUITE-DIR ) && \
167
+ $(abspath $< ) $(TEST-SUITE-FILE ) \
168
+ --expect-failures 38 \
169
+ --expect-errors 151 \
170
+ 2> /dev/null
171
+
172
+ $(TEST-GLJ-TARGETS ) : $(GLJ-CMD )
173
+ $< $(basename $@ )
100
174
101
- .PHONY : format
102
175
format :
103
176
@if go fmt ./... | grep -q ' ' ; then \
104
177
echo " Files were formatted. Please commit the changes." ; \
105
178
exit 1; \
106
179
fi
107
180
108
- .PHONY : update-clojure-sources
109
181
update-clojure-sources :
110
- @scripts/rewrite-core/update-clojure-sources.sh $(CLOJURE_STDLIB_VERSION )
182
+ scripts/rewrite-core/update-clojure-sources.sh \
183
+ $(CLOJURE-STDLIB-VERSION )
0 commit comments