]> Git — Sourcephile - haskell/symantic-document.git/blob - Makefile
iface: rename `Symantic.Document.{Lang => Class}`
[haskell/symantic-document.git] / Makefile
1 override GHCID_OPTIONS += --no-height-limit --reverse-errors
2 override REPL_OPTIONS += -ignore-dot-ghci
3
4 cabal := $(wildcard *.cabal)
5 package := $(notdir ./$(cabal:.cabal=))
6 version := $(shell sed -ne 's/^version: *\(.*\)/\1/p' $(cabal))
7 project := $(patsubst %.cabal,%,$(cabal))
8 cabal_builddir ?= dist-newstyle
9
10 all: build
11 build:
12 cabal build $(CABAL_BUILD_FLAGS)
13 clean c:
14 cabal clean
15 repl:
16 cabal repl $(CABAL_REPL_FLAGS) $(project)
17 ghcid:
18 ghcid $(GHCID_OPTIONS) --command 'cabal repl -fno-code $(CABAL_REPL_FLAGS) $(project) $(addprefix --repl-options ,$(REPL_OPTIONS))'
19
20 .PHONY: tests
21 t tests:
22 cabal test $(CABAL_TEST_FLAGS) \
23 --test-show-details always --test-options "$(TEST_OPTIONS)"
24 tests/prof-time: $(project)-test.eventlog.json
25 tests/prof-heap: $(project)-test.eventlog.html
26 .PHONY: $(project)-test.eventlog
27 $(project)-test.eventlog $(project)-test.prof:
28 cabal test $(CABAL_TEST_FLAGS) \
29 --test-show-details always --test-options "$(TEST_OPTIONS) +RTS $(RTS_OPTIONS)" \
30 --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) || true
31 t/repl tests/repl:
32 cabal repl $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) --enable-tests $(project)-test
33 t/ghcid tests/ghcid:
34 ghcid $(GHCID_OPTIONS) --command 'cabal repl $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) $(project):tests' --test ":main $(TEST_OPTIONS)"
35
36 %/accept: TEST_OPTIONS += --accept
37 %/accept: %
38
39 %/cover: CABAL_TEST_FLAGS += --enable-coverage
40 %/cover: %
41
42 %.eventlog.html: RTS_OPTIONS += -hy -l-au
43 %.eventlog.html: %.eventlog
44 eventlog2html $<
45 %.eventlog.json: RTS_OPTIONS += -p -l-au
46 %.eventlog.json: %.eventlog
47 hs-speedscope $<
48
49 doc:
50 cabal haddock --haddock-css ocean --haddock-hyperlink-source
51
52 tag:
53 git tag --merged | grep -Fqx "$(package)-$(version)" || \
54 git tag -f -s -m "$(package) v$(version)" $(package)-$(version)
55
56 tar:
57 git diff --exit-code
58 reuse lint
59 cabal sdist
60 cabal haddock --haddock-for-hackage --enable-doc
61 upload: LANG=C
62 upload: tar tag
63 git push --follow-tags $(GIT_PUSH_FLAGS)
64 cabal upload $(CABAL_UPLOAD_FLAGS) "$(cabal_builddir)"/sdist/$(package)-$(version).tar.gz
65 cabal upload $(CABAL_UPLOAD_FLAGS) --documentation "$(cabal_builddir)"/$(package)-$(version)-docs.tar.gz
66 %/publish: CABAL_UPLOAD_FLAGS+=--publish
67 %/publish: %
68
69 publish: upload/publish
70
71 nix-build:
72 nix -L build
73 nix-relock:
74 nix flake update --recreate-lock-file
75 nix-repl:
76 nix -L develop --command cabal repl $(CABAL_REPL_FLAGS)
77 nix-shell:
78 nix -L develop
79
80 .PHONY: .hlint.yaml
81 .hlint.yaml: $(shell find src -name '*.hs' -not -name 'HLint.hs')
82 sed -i -e '/^# BEGIN: generated hints/,/^# END: generated hints/d' $@
83 echo >>$@ '# BEGIN: generated hints'
84 hlint --find . | grep -- '- fixity:' | sort -u >>$@
85 echo >>$@ '# END: generated hints'
86 lint: .hlint.yaml
87 if hlint --quiet --report=hlint.html -XNoCPP $(HLINT_FLAGS) .; \
88 then rm -f hlint.html; \
89 else sensible-browser ./hlint.html & fi