]> Git — Sourcephile - haskell/symantic-parser.git/blob - Makefile
impl: update `symantic-base` dependency
[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 tag:
99 git tag --merged | grep -Fqx "$(package)-$(version)" || \
100 git tag -f -s -m "$(package) v$(version)" $(package)-$(version)
101
102 tar:
103 git diff --exit-code
104 reuse lint
105 cabal sdist
106 cabal haddock --haddock-for-hackage --enable-doc
107 upload: LANG=C
108 upload: tar tag
109 git push --follow-tags $(GIT_PUSH_FLAGS)
110 cabal upload $(CABAL_UPLOAD_FLAGS) "$(cabal_builddir)"/sdist/$(package)-$(version).tar.gz
111 cabal upload $(CABAL_UPLOAD_FLAGS) --documentation "$(cabal_builddir)"/$(package)-$(version)-docs.tar.gz
112 %/publish: CABAL_UPLOAD_FLAGS+=--publish
113 %/publish: %
114
115 publish: upload/publish
116
117 nix-build:
118 nix -L build
119 nix-relock:
120 nix flake update --recreate-lock-file
121 nix-repl:
122 nix -L develop --command cabal repl $(CABAL_REPL_FLAGS)
123 nix-shell:
124 nix -L develop
125
126 .hlint.yaml: $(shell find src -name '*.hs' -not -name 'HLint.hs')
127 sed -i -e '/^# BEGIN: generated hints/,/^# END: generated hints/d' $@
128 echo >>$@ '# BEGIN: generated hints'
129 hlint --find . | grep -- '- fixity:' | sort -u >>$@
130 echo >>$@ '# END: generated hints'
131
132 lint: .hlint.yaml
133 if hlint --quiet --report=hlint.html -XNoCPP $(HLINT_FLAGS) .; \
134 then rm -f hlint.html; \
135 else sensible-browser ./hlint.html & fi