]> Git — Sourcephile - haskell/symantic-parser.git/blob - Makefile
doc: update
[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-auto-calls
4 override REPL_OPTIONS += -ignore-dot-ghci
5 override RTS_OPTIONS += -L100
6 override TEST_OPTIONS += --color always --size-cutoff 1000000 $(addprefix -p ,$t)
7
8 cabal := $(wildcard *.cabal)
9 package := $(notdir ./$(cabal:.cabal=))
10 version := $(shell sed -ne 's/^version: *\(.*\)/\1/p' $(cabal))
11 project := $(patsubst %.cabal,%,$(cabal))
12
13 all: build
14 build:
15 cabal build $(CABAL_BUILD_FLAGS)
16 clean c:
17 cabal clean
18 repl:
19 cabal repl $(CABAL_REPL_FLAGS) $(project)
20 ghcid:
21 ghcid $(GHCID_OPTIONS) -c 'cabal repl $(CABAL_REPL_FLAGS) $(project) $(addprefix --repl-options ,$(REPL_OPTIONS))'
22 .PHONY: parsers
23 parsers:
24 cabal build $(CABAL_BUILD_FLAGS) $(project):parsers
25 parsers/repl:
26 cabal repl $(CABAL_REPL_FLAGS) $(project):parsers
27 parsers/ghcid:
28 ghcid $(GHCID_OPTIONS) -c 'cabal repl $(CABAL_REPL_FLAGS) $(project):parsers $(addprefix --repl-options ,$(REPL_OPTIONS))'
29 parsers/prof-th:
30 cabal v2-build lib:$(project) --enable-profiling $(GHC_PROF_OPTIONS) --write-ghc-environment-files=always
31 cabal build $(CABAL_BUILD_FLAGS) $(project):parsers \
32 --enable-profiling $(GHC_PROF_OPTIONS) \
33 --ghc-options "$(addprefix -opti,+RTS $(RTS_OPTIONS))"
34
35 .PHONY: tests
36 t tests:
37 cabal test $(CABAL_TEST_FLAGS) \
38 --test-show-details always --test-options "$(TEST_OPTIONS)"
39 tests/prof-time: $(project)-test.eventlog.json
40 tests/prof-heap: $(project)-test.eventlog.html
41 .PHONY: $(project)-test.eventlog
42 $(project)-test.eventlog $(project)-test.prof:
43 cabal test $(CABAL_TEST_FLAGS) \
44 --test-show-details always --test-options "$(TEST_OPTIONS) +RTS $(RTS_OPTIONS)" \
45 --enable-profiling $(GHC_PROF_OPTIONS) || true
46 tests/prof-th:
47 cabal v2-build lib:$(project) --enable-profiling $(GHC_PROF_OPTIONS) --write-ghc-environment-files=always
48 cabal test $(CABAL_TEST_FLAGS) \
49 --test-show-details always --test-options "$(TEST_OPTIONS) +RTS $(RTS_OPTIONS)" \
50 --enable-profiling $(GHC_PROF_OPTIONS) \
51 --ghc-options "$(addprefix -opti,+RTS $(RTS_OPTIONS))"
52 tests/repl:
53 cabal repl $(CABAL_REPL_FLAGS) --enable-tests $(project)-test
54 tests/ghcid:
55 ghcid $(GHCID_OPTIONS) -c 'cabal repl $(CABAL_REPL_FLAGS) $(project):tests --test-options "$(TEST_OPTIONS)"'
56
57 %/accept: TEST_OPTIONS += --accept
58 %/accept: %
59
60 %/cover: CABAL_TEST_FLAGS += --enable-coverage
61 %/cover: %
62
63 %.eventlog.html: RTS_OPTIONS += -hy -l-au
64 %.eventlog.html: %.eventlog
65 eventlog2html $<
66 %.eventlog.json: RTS_OPTIONS += -p -l-au
67 %.eventlog.json: %.eventlog
68 hs-speedscope $<
69
70 .PHONY: benchmarks/html/$(version).html
71 b benchmarks: benchmarks/html/$(version).html
72 benchmarks/html/$(version).html:
73 mkdir -p benchmarks/html
74 cabal bench $(CABAL_BENCH_FLAGS) --benchmark-options "$(BENCHMARK_OPTIONS)"
75 benchmarks/repl:
76 cabal repl $(CABAL_REPL_FLAGS) --enable-benchmarks $(project)-benchmark
77 benchmarks/prof-time: $(project)-benchmark.eventlog.json
78 benchmarks/prof-heap: $(project)-benchmark.eventlog.html
79 .PHONY: $(project)-benchmark.eventlog
80 $(project)-benchmark.eventlog $(project)-benchmark.prof:
81 @echo "$$(tput setaf 1)WARNING: benchmarking with --enable-profiling can create significant biases$$(tput sgr0)"
82 cabal bench $(CABAL_BENCH_FLAGS) \
83 --benchmark-options "$(BENCHMARK_OPTIONS) +RTS $(RTS_OPTIONS)" \
84 --enable-profiling $(GHC_PROF_OPTIONS)
85 $(project)-benchmark.prof2:
86 cabal v2-build lib:$(project) --enable-profiling $(GHC_PROF_OPTIONS) --write-ghc-environment-files=always
87 cabal bench $(CABAL_BENCH_FLAGS) \
88 --benchmark-options "$(BENCHMARK_OPTIONS)" \
89 --enable-profiling $(GHC_PROF_OPTIONS) \
90 --ghc-options "$(addprefix -opti,+RTS $(RTS_OPTIONS))"
91
92 doc:
93 cabal haddock --haddock-css ocean --haddock-hyperlink-source
94
95 tag:
96 git tag --merged | grep -Fqx "$(package)-$(version)" || \
97 git tag -f -s -m "$(package) v$(version)" $(package)-$(version)
98
99 tar:
100 cabal sdist
101 cabal haddock --haddock-for-hackage --enable-doc
102 upload: LANG=C
103 upload: tar
104 cabal upload $(CABAL_UPLOAD_FLAGS) dist-newstyle/sdist/$(package)-$(version).tar.gz
105 cabal upload $(CABAL_UPLOAD_FLAGS) --documentation dist-newstyle/$(package)-$(version)-docs.tar.gz
106 %/publish: CABAL_UPLOAD_FLAGS+=--publish
107 %/publish: %
108
109 publish: upload/publish
110
111 nix-build:
112 nix -L build
113 nix-relock:
114 nix flake update --recreate-lock-file
115 nix-repl:
116 nix -L develop --command cabal repl $(CABAL_REPL_FLAGS)
117 nix-shell:
118 nix -L develop