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