]> Git — Sourcephile - haskell/literate-web.git/blob - Makefile
feat(live): init `Literate.Web.Live`
[haskell/literate-web.git] / Makefile
1 cabal := $(wildcard *.cabal)
2 package := $(notdir ./$(cabal:.cabal=))
3 version := $(shell sed -ne 's/^version: *\(.*\)/\1/p' $(cabal))
4 project := $(patsubst %.cabal,%,$(cabal))
5 cabal_builddir ?= dist-newstyle
6
7 override REPL_OPTIONS += -ignore-dot-ghci
8 override TEST_OPTIONS += --color=always
9 override GHCID_OPTIONS += --no-height-limit --reverse-errors --color=always --warnings --restart $(cabal)
10
11 all: build
12 build:
13 cabal build $(CABAL_BUILD_FLAGS)
14 clean c:
15 cabal clean
16 repl:
17 cabal repl $(CABAL_REPL_FLAGS) $(project)
18 ghcid:
19 ghcid $(GHCID_OPTIONS) --command 'cabal repl -fno-code $(CABAL_REPL_FLAGS) $(project) $(addprefix --repl-options ,$(REPL_OPTIONS))'
20
21 .PHONY: tests
22 t tests:
23 cabal test $(CABAL_TEST_FLAGS) \
24 --test-show-details always --test-options "$(TEST_OPTIONS)"
25 tests/prof-time: $(project)-tests.eventlog.json
26 tests/prof-heap: $(project)-tests.eventlog.html
27 .PHONY: $(project)-test.eventlog
28 $(project)-test.eventlog $(project)-test.prof:
29 cabal test $(CABAL_TEST_FLAGS) \
30 --test-show-details always --test-options "$(TEST_OPTIONS) +RTS $(RTS_OPTIONS)" \
31 --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) || true
32 t/repl tests/repl:
33 cabal repl $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) --enable-tests $(project)-tests
34 t/ghcid tests/ghcid:
35 ghcid $(GHCID_OPTIONS) --command 'cabal repl $(CABAL_REPL_FLAGS) $(project) $(addprefix --repl-options ,$(REPL_OPTIONS))' \
36 --run=':! ghcid $(GHCID_OPTIONS) --command "cabal repl $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) $(project):tests" --test ":main $(TEST_OPTIONS)"'
37
38 .PHONY: benchmarks/time
39 bt benchmarks/time:
40 cabal bench $(CABAL_BENCH_FLAGS) time \
41 --benchmark-options "$(BENCHMARKS_TIME_OPTIONS)"
42 .PHONY: benchmarks/weigh
43 bw benchmarks/weigh:
44 cabal bench $(CABAL_BENCH_FLAGS) weigh \
45 --benchmark-options "$(BENCHMARKS_WEIGH_OPTIONS)"
46 benchmarks/weigh/ghcid:
47 ghcid $(GHCID_OPTIONS) --target=relactive --run=':! ghcid $(GHCID_OPTIONS) --target=weigh --run'
48
49 executables/async/ghcid:
50 ghcid $(GHCID_OPTIONS) --target=relactive --run=':! ghcid $(GHCID_OPTIONS) --target=async --run'
51 executables/fsnotify/ghcid:
52 ghcid $(GHCID_OPTIONS) --target=relactive --run=':! ghcid $(GHCID_OPTIONS) --target=fsnotify --run'
53
54
55 %/accept: TEST_OPTIONS += --accept
56 %/accept: %
57
58 %/cover: CABAL_TEST_FLAGS += --enable-coverage
59 %/cover: %
60
61 %.eventlog.html: RTS_OPTIONS += -hy -l-au
62 %.eventlog.html: %.eventlog
63 eventlog2html $<
64 %.eventlog.json: RTS_OPTIONS += -p -l-au
65 %.eventlog.json: %.eventlog
66 hs-speedscope $<
67
68 doc:
69 cabal haddock --haddock-css ocean --haddock-hyperlink-source
70
71 .PHONY: ChangeLog.md
72 ChangeLog.md:
73 ! git tag --merged | grep -Fqx $(package)-$(version)
74 git diff --exit-code
75 git tag -f $(package)-$(version)
76 git-chglog --output $@.new --tag-filter-pattern '$(package)-.*' $(package)-$(version)
77 touch $@
78 cat $@ >>$@.new
79 mv -f $@.new $@
80 git tag -d $(package)-$(version)
81 git add '$@'
82 git commit -m 'doc: update `$@`'
83 tag: build ChangeLog.md
84 git tag -s -m $(package)-$(version) $(package)-$(version)
85
86 tar:
87 git diff --exit-code
88 reuse lint
89 cabal sdist
90 cabal haddock --haddock-for-hackage --enable-doc
91 upload: LANG=C
92 upload: tar
93 git tag --merged | grep -Fqx $(package)-$(version)
94 git push --follow-tags $(GIT_PUSH_FLAGS)
95 cabal upload $(CABAL_UPLOAD_FLAGS) "$(cabal_builddir)"/sdist/$(package)-$(version).tar.gz
96 cabal upload $(CABAL_UPLOAD_FLAGS) --documentation "$(cabal_builddir)"/$(package)-$(version)-docs.tar.gz
97 %/publish: CABAL_UPLOAD_FLAGS+=--publish
98 %/publish: %
99
100 publish: upload/publish
101
102 .PHONY: .hlint.yaml
103 .hlint.yaml: $(shell find src -name '*.hs' -not -name 'HLint.hs')
104 sed -i -e '/^# BEGIN: generated hints/,/^# END: generated hints/d' $@
105 echo >>$@ '# BEGIN: generated hints'
106 hlint --find . | grep -- '- fixity:' | sort -u >>$@
107 echo >>$@ '# END: generated hints'
108 lint: .hlint.yaml
109 if hlint --quiet --report=hlint.html -XNoCPP $(HLINT_FLAGS) .; \
110 then rm -f hlint.html; \
111 else sensible-browser ./hlint.html & fi