+override BENCHMARK_OPTIONS += --output benchmarks/html/$(version).html --match glob $b
+override GHCID_OPTIONS += --no-height-limit --reverse-errors
+override GHC_PROF_OPTIONS += -eventlog -fprof-auto -fprof-cafs
+#-fprof-auto-calls
+override REPL_OPTIONS += -ignore-dot-ghci
override RTS_OPTIONS += -L100
override TEST_OPTIONS += --color always --size-cutoff 1000000 $(addprefix -p ,$t)
-override GHC_PROF_OPTIONS += -fprof-auto -fprof-auto-calls
-override BENCHMARK_OPTIONS += --output benchmarks/html/$(version).html --match glob $b
+override CABAL_TEST_FLAGS += -j
cabal := $(wildcard *.cabal)
package := $(notdir ./$(cabal:.cabal=))
version := $(shell sed -ne 's/^version: *\(.*\)/\1/p' $(cabal))
project := $(patsubst %.cabal,%,$(cabal))
+cabal_builddir ?= dist-newstyle
all: build
build:
- cabal build
+ cabal build $(CABAL_BUILD_FLAGS)
clean c:
cabal clean
repl:
- cabal repl $(project)
+ cabal repl $(CABAL_REPL_FLAGS) $(project)
+ghcid:
+ ghcid $(GHCID_OPTIONS) --command 'cabal repl -fno-code $(CABAL_REPL_FLAGS) $(project) $(addprefix --repl-options ,$(REPL_OPTIONS))'
+.PHONY: parsers
+parsers:
+ cabal build $(CABAL_BUILD_FLAGS) $(project):parsers
parsers/repl:
- cabal repl $(project):parsers
+ cabal repl $(CABAL_REPL_FLAGS) $(project):parsers
+parsers/ghcid:
+ ghcid $(GHCID_OPTIONS) --command 'cabal repl -fno-code $(CABAL_REPL_FLAGS) $(project):parsers $(addprefix --repl-options ,$(REPL_OPTIONS))'
+parsers/prof-th:
+ cabal v2-build lib:$(project) --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) --write-ghc-environment-files=always
+ cabal build $(CABAL_BUILD_FLAGS) $(project):parsers \
+ --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) \
+ --ghc-options "$(addprefix -opti,+RTS $(RTS_OPTIONS))"
.PHONY: tests
-tests:
+t tests:
cabal test $(CABAL_TEST_FLAGS) \
--test-show-details always --test-options "$(TEST_OPTIONS)"
tests/prof-time: $(project)-test.eventlog.json
$(project)-test.eventlog $(project)-test.prof:
cabal test $(CABAL_TEST_FLAGS) \
--test-show-details always --test-options "$(TEST_OPTIONS) +RTS $(RTS_OPTIONS)" \
- --enable-profiling $(GHC_PROF_OPTIONS) || true
+ --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) || true
tests/prof-th:
- cabal v2-build lib:$(project) --enable-profiling $(GHC_PROF_OPTIONS) --write-ghc-environment-files=always
+ cabal v2-build lib:$(project) --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) --write-ghc-environment-files=always
cabal test $(CABAL_TEST_FLAGS) \
--test-show-details always --test-options "$(TEST_OPTIONS) +RTS $(RTS_OPTIONS)" \
- --enable-profiling $(GHC_PROF_OPTIONS) \
+ --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) \
--ghc-options "$(addprefix -opti,+RTS $(RTS_OPTIONS))"
-tests/repl:
- cabal repl --enable-tests $(project)-test
+t/repl tests/repl:
+ cabal repl $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) --enable-tests $(project)-test
+t/ghcid tests/ghcid:
+ ghcid $(GHCID_OPTIONS) --command 'cabal repl $(CABAL_REPL_FLAGS) $(CABAL_TEST_FLAGS) $(project):tests' --test ":main $(TEST_OPTIONS)"
%/accept: TEST_OPTIONS += --accept
%/accept: %
mkdir -p benchmarks/html
cabal bench $(CABAL_BENCH_FLAGS) --benchmark-options "$(BENCHMARK_OPTIONS)"
benchmarks/repl:
- cabal repl --enable-benchmarks $(project)-benchmark
+ cabal repl $(CABAL_REPL_FLAGS) --enable-benchmarks $(project)-benchmark
benchmarks/prof-time: $(project)-benchmark.eventlog.json
benchmarks/prof-heap: $(project)-benchmark.eventlog.html
.PHONY: $(project)-benchmark.eventlog
$(project)-benchmark.eventlog $(project)-benchmark.prof:
+ @echo "$$(tput setaf 1)WARNING: benchmarking with --enable-profiling can create significant biases$$(tput sgr0)"
cabal bench $(CABAL_BENCH_FLAGS) \
--benchmark-options "$(BENCHMARK_OPTIONS) +RTS $(RTS_OPTIONS)" \
--enable-profiling $(GHC_PROF_OPTIONS)
doc:
cabal haddock --haddock-css ocean --haddock-hyperlink-source
-tag:
- git tag --merged | grep -Fqx "$(package)-$(version)" || \
- git tag -f -s -m "$(package) v$(version)" $(package)-$(version)
+.PHONY: ChangeLog.md
+ChangeLog.md:
+ ! git tag --merged | grep -Fqx $(package)-$(version)
+ git diff --exit-code
+ git tag -f $(package)-$(version)
+ git-chglog --output $@.new $(package)-$(version)
+ touch $@
+ cat $@ >>$@.new
+ mv -f $@.new $@
+ git tag -d $(package)-$(version)
+ git add '$@'
+ git commit -m 'doc: update `$@`'
+tag: ChangeLog.md
+ git tag -s -m $(package)-$(version) $(package)-$(version)
tar:
+ git diff --exit-code
+ reuse lint
cabal sdist
cabal haddock --haddock-for-hackage --enable-doc
upload: LANG=C
-upload: tar
- cabal upload $(CABAL_UPLOAD_FLAGS) dist-newstyle/sdist/$(package)-$(version).tar.gz
- cabal upload $(CABAL_UPLOAD_FLAGS) --documentation dist-newstyle/$(package)-$(version)-docs.tar.gz
+upload: tar tag
+ git push --follow-tags $(GIT_PUSH_FLAGS)
+ cabal upload $(CABAL_UPLOAD_FLAGS) "$(cabal_builddir)"/sdist/$(package)-$(version).tar.gz
+ cabal upload $(CABAL_UPLOAD_FLAGS) --documentation "$(cabal_builddir)"/$(package)-$(version)-docs.tar.gz
%/publish: CABAL_UPLOAD_FLAGS+=--publish
%/publish: %
nix-relock:
nix flake update --recreate-lock-file
nix-repl:
- nix -L develop --command cabal repl
+ nix -L develop --command cabal repl $(CABAL_REPL_FLAGS)
nix-shell:
nix -L develop
+
+.hlint.yaml: $(shell find src -name '*.hs' -not -name 'HLint.hs')
+ sed -i -e '/^# BEGIN: generated hints/,/^# END: generated hints/d' $@
+ echo >>$@ '# BEGIN: generated hints'
+ hlint --find . | grep -- '- fixity:' | sort -u >>$@
+ echo >>$@ '# END: generated hints'
+lint: .hlint.yaml
+ if hlint --quiet --report=hlint.html -XNoCPP $(HLINT_FLAGS) .; \
+ then rm -f hlint.html; \
+ else sensible-browser ./hlint.html & fi