Skip to content

Commit 1a67d9d

Browse files
committed
feat(Makefile): add stack support, default to cabal
1 parent e09615c commit 1a67d9d

File tree

1 file changed

+63
-11
lines changed

1 file changed

+63
-11
lines changed

Makefile

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
HS_FILES := $(shell git ls-files '*.hs')
22

3+
# BUILD_TOOL selects the Haskell build tool: cabal (default) or stack.
4+
BUILD_TOOL ?= cabal
5+
6+
# --- Shared ---
7+
38
.PHONY: format
49
format:
510
@test -n "$(HS_FILES)" || { echo "No tracked .hs files found"; exit 0; }
@@ -10,6 +15,8 @@ format-check:
1015
@test -n "$(HS_FILES)" || { echo "No tracked .hs files found"; exit 0; }
1116
fourmolu -m check $(HS_FILES)
1217

18+
# --- Cabal ---
19+
1320
.PHONY: cabal-check
1421
cabal-check:
1522
cabal check
@@ -18,26 +25,71 @@ cabal-check:
1825
cabal-update:
1926
cabal update
2027

21-
.PHONY: configure
22-
configure:
28+
.PHONY: cabal-configure
29+
cabal-configure:
2330
cabal configure --enable-tests --enable-benchmarks --disable-documentation $(CABAL_CONFIGURE_FLAGS)
2431
cabal build --dry-run
2532

26-
.PHONY: deps
27-
deps:
33+
.PHONY: cabal-deps
34+
cabal-deps:
2835
cabal build --only-dependencies
2936

30-
.PHONY: build
31-
build:
37+
.PHONY: cabal-build
38+
cabal-build:
3239
cabal build all
3340

34-
.PHONY: test
35-
test:
41+
.PHONY: cabal-test
42+
cabal-test:
3643
cabal test all
3744

38-
.PHONY: docs
39-
docs:
45+
.PHONY: cabal-docs
46+
cabal-docs:
4047
cabal haddock all --disable-documentation
4148

49+
.PHONY: cabal-ci
50+
cabal-ci: format-check cabal-check cabal-update cabal-configure cabal-deps cabal-build cabal-test cabal-docs
51+
52+
# --- Stack ---
53+
54+
.PHONY: stack-update
55+
stack-update:
56+
stack update
57+
58+
.PHONY: stack-deps
59+
stack-deps:
60+
stack build --only-dependencies --test --no-run-tests
61+
62+
.PHONY: stack-build
63+
stack-build:
64+
stack build
65+
66+
.PHONY: stack-test
67+
stack-test:
68+
stack test
69+
70+
.PHONY: stack-docs
71+
stack-docs:
72+
stack haddock --no-haddock-deps
73+
74+
.PHONY: stack-ci
75+
stack-ci: format-check stack-update stack-deps stack-build stack-test stack-docs
76+
77+
# ── Generic (delegates to BUILD_TOOL) ────────────────────────────────
78+
79+
.PHONY: update
80+
update: $(BUILD_TOOL)-update
81+
82+
.PHONY: deps
83+
deps: $(BUILD_TOOL)-deps
84+
85+
.PHONY: build
86+
build: $(BUILD_TOOL)-build
87+
88+
.PHONY: test
89+
test: $(BUILD_TOOL)-test
90+
91+
.PHONY: docs
92+
docs: $(BUILD_TOOL)-docs
93+
4294
.PHONY: ci
43-
ci: format-check cabal-check cabal-update configure deps build test docs
95+
ci: $(BUILD_TOOL)-ci

0 commit comments

Comments
 (0)