]> Git — Sourcephile - haskell/symantic-parser.git/blob - Makefile
doc: clarify the scope of HideName instances
[haskell/symantic-parser.git] / Makefile
1 override BENCHMARK_OPTIONS += --output benchmarks/html/$(version).html --match glob $b
2 override GHCID_OPTIONS += --no-height-limit --reverse-errors
3 override GHC_PROF_OPTIONS += -eventlog -fprof-auto -fprof-cafs
4 #-fprof-auto-calls
5 override REPL_OPTIONS += -ignore-dot-ghci
6 override RTS_OPTIONS += -L100
7 override TEST_OPTIONS += --color always --size-cutoff 1000000 $(addprefix -p ,$t)
8 override CABAL_TEST_FLAGS += -j
9
10 cabal := $(wildcard *.cabal)
11 package := $(notdir ./$(cabal:.cabal=))
12 version := $(shell sed -ne 's/^version: *\(.*\)/\1/p' $(cabal))
13 project := $(patsubst %.cabal,%,$(cabal))
14 cabal_builddir ?= dist-newstyle
15
16 all: build
17 build:
18 cabal build $(CABAL_BUILD_FLAGS)
19 clean c:
20 cabal clean
21 repl:
22 cabal repl $(CABAL_REPL_FLAGS) $(project)
23 ghcid:
24 ghcid $(GHCID_OPTIONS) --command 'cabal repl -fno-code $(CABAL_REPL_FLAGS) $(project) $(addprefix --repl-options ,$(REPL_OPTIONS))'
25 .PHONY: parsers
26 parsers:
27 cabal build $(CABAL_BUILD_FLAGS) $(project):parsers
28 parsers/repl:
29 cabal repl $(CABAL_REPL_FLAGS) $(project):parsers
30 parsers/ghcid:
31 ghcid $(GHCID_OPTIONS) --command 'cabal repl -fno-code $(CABAL_REPL_FLAGS) $(project):parsers $(addprefix --repl-options ,$(REPL_OPTIONS))'
32 parsers/prof-th:
33 cabal v2-build lib:$(project) --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) --write-ghc-environment-files=always
34 cabal build $(CABAL_BUILD_FLAGS) $(project):parsers \
35 --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) \
36 --ghc-options "$(addprefix -opti,+RTS $(RTS_OPTIONS))"
37
38 .PHONY: tests
39 t tests:
40 cabal test $(CABAL_TEST_FLAGS) \
41 --test-show-details always --test-options "$(TEST_OPTIONS)"
42 tests/prof-time: $(project)-test.eventlog.json
43 tests/prof-heap: $(project)-test.eventlog.html
44 .PHONY: $(project)-test.eventlog
45 $(project)-test.eventlog $(project)-test.prof:
46 cabal test $(CABAL_TEST_FLAGS) \
47 --test-show-details always --test-options "$(TEST_OPTIONS) +RTS $(RTS_OPTIONS)" \
48 --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) || true
49 tests/prof-th:
50 cabal v2-build lib:$(project) --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) --write-ghc-environment-files=always
51 cabal test $(CABAL_TEST_FLAGS) \
52 --test-show-details always --test-options "$(TEST_OPTIONS) +RTS $(RTS_OPTIONS)" \
53 --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) \
54 --ghc-options "$(addprefix -opti,+RTS $(RTS_OPTIONS))"
55 t/repl tests/repl:
56 cabal repl $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) --enable-tests $(project)-test
57 t/ghcid tests/ghcid:
58 ghcid $(GHCID_OPTIONS) --command 'cabal repl $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) $(project):tests' --test ":main $(TEST_OPTIONS)"
59
60 %/accept: TEST_OPTIONS += --accept
61 %/accept: %
62
63 %/cover: CABAL_TEST_FLAGS += --enable-coverage
64 %/cover: %
65
66 %.eventlog.html: RTS_OPTIONS += -hy -l-au
67 %.eventlog.html: %.eventlog
68 eventlog2html $<
69 %.eventlog.json: RTS_OPTIONS += -p -l-au
70 %.eventlog.json: %.eventlog
71 hs-speedscope $<
72
73 .PHONY: benchmarks/html/$(version).html
74 b benchmarks: benchmarks/html/$(version).html
75 benchmarks/html/$(version).html:
76 mkdir -p benchmarks/html
77 cabal bench $(CABAL_BENCH_FLAGS) --benchmark-options "$(BENCHMARK_OPTIONS)"
78 benchmarks/repl:
79 cabal repl $(CABAL_REPL_FLAGS) --enable-benchmarks $(project)-benchmark
80 benchmarks/prof-time: $(project)-benchmark.eventlog.json
81 benchmarks/prof-heap: $(project)-benchmark.eventlog.html
82 .PHONY: $(project)-benchmark.eventlog
83 $(project)-benchmark.eventlog $(project)-benchmark.prof:
84 @echo "$$(tput setaf 1)WARNING: benchmarking with --enable-profiling can create significant biases$$(tput sgr0)"
85 cabal bench $(CABAL_BENCH_FLAGS) \
86 --benchmark-options "$(BENCHMARK_OPTIONS) +RTS $(RTS_OPTIONS)" \
87 --enable-profiling $(GHC_PROF_OPTIONS)
88 $(project)-benchmark.prof2:
89 cabal v2-build lib:$(project) --enable-profiling $(GHC_PROF_OPTIONS) --write-ghc-environment-files=always
90 cabal bench $(CABAL_BENCH_FLAGS) \
91 --benchmark-options "$(BENCHMARK_OPTIONS)" \
92 --enable-profiling $(GHC_PROF_OPTIONS) \
93 --ghc-options "$(addprefix -opti,+RTS $(RTS_OPTIONS))"
94
95 doc:
96 cabal haddock --haddock-css ocean --haddock-hyperlink-source
97
98 .PHONY: ChangeLog.md
99 ChangeLog.md:
100 ! git tag --merged | grep -Fqx $(package)-$(version)
101 git diff --exit-code
102 git tag -f $(package)-$(version)
103 git-chglog --output $@.new --tag-filter-pattern '$(package)-.*' $(package)-$(version)
104 touch $@
105 cat $@ >>$@.new
106 mv -f $@.new $@
107 git tag -d $(package)-$(version)
108 git add '$@'
109 git commit -m 'doc: update `$@`'
110 tag: ChangeLog.md
111 git tag -s -m $(package)-$(version) $(package)-$(version)
112
113 tar:
114 git diff --exit-code
115 reuse lint
116 cabal sdist
117 cabal haddock --haddock-for-hackage --enable-doc
118 upload: LANG=C
119 upload: tar tag
120 git push --follow-tags $(GIT_PUSH_FLAGS)
121 cabal upload $(CABAL_UPLOAD_FLAGS) "$(cabal_builddir)"/sdist/$(package)-$(version).tar.gz
122 cabal upload $(CABAL_UPLOAD_FLAGS) --documentation "$(cabal_builddir)"/$(package)-$(version)-docs.tar.gz
123 %/publish: CABAL_UPLOAD_FLAGS+=--publish
124 %/publish: %
125
126 publish: upload/publish
127
128 .hlint.yaml: $(shell find src -name '*.hs' -not -name 'HLint.hs')
129 sed -i -e '/^# BEGIN: generated hints/,/^# END: generated hints/d' $@
130 echo >>$@ '# BEGIN: generated hints'
131 hlint --find . | grep -- '- fixity:' | sort -u >>$@
132 echo >>$@ '# END: generated hints'
133 lint: .hlint.yaml
134 if hlint --quiet --report=hlint.html -XNoCPP $(HLINT_FLAGS) .; \
135 then rm -f hlint.html; \
136 else sensible-browser ./hlint.html & fi