]> Git — Sourcephile - haskell/symantic-plaintext.git/blob - Makefile
wip
[haskell/symantic-plaintext.git] / Makefile
1 override GHCID_OPTIONS += --no-height-limit --reverse-errors --color=always
2 override REPL_OPTIONS += -ignore-dot-ghci
3 override TEST_OPTIONS += --color=always
4
5 cabal := $(wildcard *.cabal)
6 package := $(notdir ./$(cabal:.cabal=))
7 version := $(shell sed -ne 's/^version: *\(.*\)/\1/p' $(cabal))
8 project := $(patsubst %.cabal,%,$(cabal))
9 cabal_builddir ?= dist-newstyle
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) $(CABAL_TEST_FLAGS) $(project):tests' --test ":main $(TEST_OPTIONS)"
36
37 %/accept: TEST_OPTIONS += --accept
38 %/accept: %
39
40 %/cover: CABAL_TEST_FLAGS += --enable-coverage
41 %/cover: %
42
43 %.eventlog.html: RTS_OPTIONS += -hy -l-au
44 %.eventlog.html: %.eventlog
45 eventlog2html $<
46 %.eventlog.json: RTS_OPTIONS += -p -l-au
47 %.eventlog.json: %.eventlog
48 hs-speedscope $<
49
50 doc:
51 cabal haddock --haddock-css ocean --haddock-hyperlink-source
52
53 .PHONY: ChangeLog.md
54 ChangeLog.md:
55 ! git tag --merged | grep -Fqx $(package)-$(version)
56 git diff --exit-code
57 git tag -f $(package)-$(version)
58 git-chglog --output $@.new --tag-filter-pattern '$(package)-.*' $(package)-$(version)
59 touch $@
60 cat $@ >>$@.new
61 mv -f $@.new $@
62 git tag -d $(package)-$(version)
63 git add '$@'
64 git commit -m 'doc: update `$@`'
65 tag: ChangeLog.md
66 git tag -s -m $(package)-$(version) $(package)-$(version)
67
68 tar:
69 git diff --exit-code
70 reuse lint
71 cabal sdist
72 cabal haddock --haddock-for-hackage --enable-doc
73 upload: LANG=C
74 upload: tar
75 git tag --merged | grep -Fqx $(package)-$(version)
76 git push --follow-tags $(GIT_PUSH_FLAGS)
77 cabal upload $(CABAL_UPLOAD_FLAGS) "$(cabal_builddir)"/sdist/$(package)-$(version).tar.gz
78 cabal upload $(CABAL_UPLOAD_FLAGS) --documentation "$(cabal_builddir)"/$(package)-$(version)-docs.tar.gz
79 %/publish: CABAL_UPLOAD_FLAGS+=--publish
80 %/publish: %
81
82 publish: upload/publish
83
84 .PHONY: .hlint.yaml
85 .hlint.yaml: $(shell find src -name '*.hs' -not -name 'HLint.hs')
86 sed -i -e '/^# BEGIN: generated hints/,/^# END: generated hints/d' $@
87 echo >>$@ '# BEGIN: generated hints'
88 hlint --find . | grep -- '- fixity:' | sort -u >>$@
89 echo >>$@ '# END: generated hints'
90 lint: .hlint.yaml
91 if hlint --quiet --report=hlint.html -XNoCPP $(HLINT_FLAGS) .; \
92 then rm -f hlint.html; \
93 else sensible-browser ./hlint.html & fi