-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
Makefile
126 lines (95 loc) · 4.88 KB
/
Makefile
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
.PHONY: submodules test quick-test docs eastwood cljfmt kondo install deploy clean lein-repl repl lint
.DEFAULT_GOAL := install
# Set bash instead of sh for the @if [[ conditions,
# and use the usual safety flags:
SHELL = /bin/bash -Ee
HOME=$(shell echo $$HOME)
CLOJURE_VERSION ?= 1.11
TEST_PROFILES ?= "-user,-dev,+test,+spec2,+cljs"
# The Lein profiles that will be selected for `lein-repl`.
# Feel free to upgrade this, or to override it with an env var named LEIN_PROFILES.
# Expected format: "+dev,+test"
# Don't use spaces here.
LEIN_PROFILES ?= "+dev,+test,+1.11,+cljs"
# The enrich-classpath version to be injected.
# Feel free to upgrade this.
ENRICH_CLASSPATH_VERSION="1.18.2"
resources/clojuredocs/export.edn:
curl -o $@ https://github.com/clojure-emacs/clojuredocs-export-edn/raw/master/exports/export.compact.edn
# We need Java sources to test Java parsing functionality, but the Docker images
# we use on CircleCI doesn't include src.zip. So we have to download them from
# Github and repackage in a form that is resemblant to src.zip from normal
# distributions.
base-src-jdk8.zip:
echo 'Currently not testing with sources for JDK8.'
base-src-jdk11.zip:
bash download-jdk-sources.sh https://github.com/adoptium/jdk11u/archive/refs/tags/jdk-11.0.25+9.zip jdk11 $@
base-src-jdk17.zip:
bash download-jdk-sources.sh https://github.com/adoptium/jdk17u/archive/refs/tags/jdk-17.0.13+11.zip jdk17 $@
base-src-jdk21.zip:
bash download-jdk-sources.sh https://github.com/adoptium/jdk21u/archive/refs/tags/jdk-21.0.5+3.zip jdk21 $@
base-src-jdk23.zip:
bash download-jdk-sources.sh https://github.com/adoptium/jdk23u/archive/refs/tags/jdk-23.0.1+11.zip jdk23 $@
# Placeholder job for When JDK_SRC_VERSION is unset.
base-src-.zip:
echo 'JDK_SRC_VERSION is unset.'
test: base-src-$(JDK_SRC_VERSION).zip submodules clean
lein with-profile $(TEST_PROFILES),+$(CLOJURE_VERSION) test
# Sanity check that we don't break if Clojurescript or Spec2 aren't present.
test-no-extra-deps: base-src-$(JDK_SRC_VERSION).zip
lein with-profile -user,-dev,+test,+$(CLOJURE_VERSION) test
quick-test: test
eastwood:
lein with-profile $(TEST_PROFILES),+$(CLOJURE_VERSION),+eastwood eastwood
cljfmt:
lein with-profile -user,-dev,+$(CLOJURE_VERSION),+cljfmt cljfmt check
# Note that -dev is necessary for not hitting OOM errors in CircleCI
.make_kondo_prep: project.clj .clj-kondo/config.edn
lein with-profile -dev,+test,+clj-kondo clj-kondo --copy-configs --dependencies --parallel --lint '$$classpath' > $@
kondo: .make_kondo_prep clean
lein with-profile -dev,+test,+clj-kondo clj-kondo
lint: kondo cljfmt eastwood
# Deployment is performed via CI by creating a git tag prefixed with "v".
# Please do not deploy locally as it skips various measures.
deploy: check-env clean
lein with-profile -user,-dev,+$(CLOJURE_VERSION),-provided deploy clojars
# Usage: PROJECT_VERSION=99.99 make install
install: clean check-install-env
lein with-profile -user,-dev,+$(CLOJURE_VERSION),-provided install
clean:
lein with-profile -user,-dev clean
submodules: submodules/test-runner/deps.edn
submodules/test-runner/deps.edn:
git submodule init
git submodule update
.javac: $(wildcard test-java/orchard/*.clj)
lein with-profile +test javac
touch $@
# Create and cache a `java` command. project.clj is mandatory; the others are optional but are taken into account for cache recomputation.
# It's important not to silence with step with @ syntax, so that Enrich progress can be seen as it resolves dependencies.
.enrich-classpath-lein-repl: .javac submodules Makefile project.clj $(wildcard checkouts/*/project.clj) $(wildcard deps.edn) $(wildcard $(HOME)/.clojure/deps.edn) $(wildcard profiles.clj) $(wildcard $(HOME)/.lein/profiles.clj) $(wildcard $(HOME)/.lein/profiles.d) $(wildcard /etc/leiningen/profiles.clj)
bash 'lein' 'update-in' ':plugins' 'conj' "[mx.cider/lein-enrich-classpath \"$(ENRICH_CLASSPATH_VERSION)\"]" '--' 'with-profile' $(LEIN_PROFILES) 'update-in' ':middleware' 'conj' 'cider.enrich-classpath.plugin-v2/middleware' '--' 'repl' | grep " -cp " > $@
# Launches a repl, falling back to vanilla lein repl if something went wrong during classpath calculation.
lein-repl: .enrich-classpath-lein-repl
@if grep --silent " -cp " .enrich-classpath-lein-repl; then \
export YOURKIT_SESSION_NAME="$(basename $(PWD))"; \
eval "$$(cat .enrich-classpath-lein-repl) --interactive"; \
else \
echo "Falling back to lein repl... (you can avoid further falling back by removing .enrich-classpath-lein-repl)"; \
lein with-profiles $(LEIN_PROFILES) repl; \
fi
repl: lein-repl
check-env:
ifndef CLOJARS_USERNAME
$(error CLOJARS_USERNAME is undefined)
endif
ifndef CLOJARS_PASSWORD
$(error CLOJARS_PASSWORD is undefined)
endif
ifndef CIRCLE_TAG
$(error CIRCLE_TAG is undefined. Please only perform deployments by publishing git tags. CI will do the rest.)
endif
check-install-env:
ifndef PROJECT_VERSION
$(error Please set PROJECT_VERSION as an env var beforehand.)
endif