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