]> Git — Sourcephile - haskell/symantic-parser.git/blob - Makefile
replace ValueCode by Production
[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
15 clean c:
16 cabal clean
17 repl:
18 cabal repl $(project)
19 ghcid:
20 ghcid -c 'cabal repl $(project) --repl-options "$(REPL_OPTIONS)"' --reverse-errors
21 .PHONY: parsers
22 parsers:
23 cabal build $(project):parsers
24 parsers/repl:
25 cabal repl $(project):parsers
26 parsers/ghcid:
27 ghcid -c 'cabal repl $(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 $(project):parsers $(CABAL_BUILD_FLAGS) \
31 --enable-profiling $(GHC_PROF_OPTIONS) \
32 --ghc-options "$(addprefix -opti,+RTS $(RTS_OPTIONS))"
33
34 .PHONY: tests
35 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 --enable-tests $(project)-test
53
54 %/accept: TEST_OPTIONS += --accept
55 %/accept: %
56
57 %/cover: CABAL_TEST_FLAGS += --enable-coverage
58 %/cover: %
59
60 %.eventlog.html: RTS_OPTIONS += -hy -l-au
61 %.eventlog.html: %.eventlog
62 eventlog2html $<
63 %.eventlog.json: RTS_OPTIONS += -p -l-au
64 %.eventlog.json: %.eventlog
65 hs-speedscope $<
66
67 .PHONY: benchmarks/html/$(version).html
68 b benchmarks: benchmarks/html/$(version).html
69 benchmarks/html/$(version).html:
70 mkdir -p benchmarks/html
71 cabal bench $(CABAL_BENCH_FLAGS) --benchmark-options "$(BENCHMARK_OPTIONS)"
72 benchmarks/repl:
73 cabal repl --enable-benchmarks $(project)-benchmark
74 benchmarks/prof-time: $(project)-benchmark.eventlog.json
75 benchmarks/prof-heap: $(project)-benchmark.eventlog.html
76 .PHONY: $(project)-benchmark.eventlog
77 $(project)-benchmark.eventlog $(project)-benchmark.prof:
78 @echo "$$(tput setaf 1)WARNING: benchmarking with --enable-profiling can create significant biases$$(tput sgr0)"
79 cabal bench $(CABAL_BENCH_FLAGS) \
80 --benchmark-options "$(BENCHMARK_OPTIONS) +RTS $(RTS_OPTIONS)" \
81 --enable-profiling $(GHC_PROF_OPTIONS)
82 $(project)-benchmark.prof2:
83 cabal v2-build lib:$(project) --enable-profiling $(GHC_PROF_OPTIONS) --write-ghc-environment-files=always
84 cabal bench $(CABAL_BENCH_FLAGS) \
85 --benchmark-options "$(BENCHMARK_OPTIONS)" \
86 --enable-profiling $(GHC_PROF_OPTIONS) \
87 --ghc-options "$(addprefix -opti,+RTS $(RTS_OPTIONS))"
88
89 doc:
90 cabal haddock --haddock-css ocean --haddock-hyperlink-source
91
92 tag:
93 git tag --merged | grep -Fqx "$(package)-$(version)" || \
94 git tag -f -s -m "$(package) v$(version)" $(package)-$(version)
95
96 tar:
97 cabal sdist
98 cabal haddock --haddock-for-hackage --enable-doc
99 upload: LANG=C
100 upload: tar
101 cabal upload $(CABAL_UPLOAD_FLAGS) dist-newstyle/sdist/$(package)-$(version).tar.gz
102 cabal upload $(CABAL_UPLOAD_FLAGS) --documentation dist-newstyle/$(package)-$(version)-docs.tar.gz
103 %/publish: CABAL_UPLOAD_FLAGS+=--publish
104 %/publish: %
105
106 publish: upload/publish
107
108 nix-build:
109 nix -L build
110 nix-relock:
111 nix flake update --recreate-lock-file
112 nix-repl:
113 nix -L develop --command cabal repl
114 nix-shell:
115 nix -L develop
116
117 .PHONY: debug-ppr
118 debug-ppr: debug-ppr/PprSplice.hs debug-ppr/AutoSplice.hs
119 debug-ppr/PprSplice.hs.ppr: parsers/Parsers/Brainfuck/SymanticParser/PprSplice.hs.ppr Makefile
120 mkdir -p $(@D)
121 sed $< >$@ -e '1s/^/parser = /' -e 's/\x00//g'
122 debug-ppr/AutoSplice.dump-splices: dist-newstyle/build/x86_64-linux/ghc-9.0.1/symantic-parser-$(version)/l/parsers/build/parsers/parsers/Parsers/Brainfuck/SymanticParser/AutoSplice.dump-splices Makefile
123 mkdir -p $(@D)
124 sed $< >$@ -e '1,/^ ======>/d;' -e '4s/^/parser = /' -e 's/\x00//g'
125 %.hs: %.hs.ppr
126 ormolu -m stdout >$@ -o -XBangPatterns -o -XUnboxedTuples -o -XMagicHash -o -XTypeApplications -o -XUnboxedTuples <$<
127 #sed -i $@ -e 'N;s/\n\s*#)/ #)/;P;D'
128 %.hs: %.dump-splices
129 ormolu -m stdout >$@ -o -XBangPatterns -o -XUnboxedTuples -o -XMagicHash -o -XTypeApplications -o -XUnboxedTuples <$<
130 #sed -i $@ -e 'N;s/\n\s*#)/ #)/;P;D'