X-Git-Url: https://git.sourcephile.fr/haskell/symantic-parser.git/blobdiff_plain/df17cc0e3434b2a0c53af558a77ef86b26708113..8766a95f27a57dfabb3a1179be7a22e485f03b03:/Makefile diff --git a/Makefile b/Makefile index 6f4711e..e076466 100644 --- a/Makefile +++ b/Makefile @@ -1,43 +1,121 @@ -cabal = $(wildcard *.cabal) -package = $(notdir ./$(cabal:.cabal=)) +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 CABAL_TEST_FLAGS += -j + +cabal := $(wildcard *.cabal) +package := $(notdir ./$(cabal:.cabal=)) +version := $(shell sed -ne 's/^version: *\(.*\)/\1/p' $(cabal)) +project := $(patsubst %.cabal,%,$(cabal)) + all: build build: - cabal build -clean: + cabal build $(CABAL_BUILD_FLAGS) +clean c: cabal clean repl: - cabal repl - -t: - cabal test -fdump-splice --test-show-details always --test-options "--color always --size-cutoff 100000" -t/repl: - cabal repl --enable-tests symantic-parser-test -t/prof: - cabal test --enable-profiling --enable-library-coverage --enable-coverage --test-show-details always -t/accept: - cabal test --test-show-details always --test-options "--accept --color always --size-cutoff 100000" -t/splices: t - shopt -s globstar; $$EDITOR dist-newstyle/build/**/t/**/*.dump-splices + 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 $(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 +t tests: + cabal test $(CABAL_TEST_FLAGS) \ + --test-show-details always --test-options "$(TEST_OPTIONS)" +tests/prof-time: $(project)-test.eventlog.json +tests/prof-heap: $(project)-test.eventlog.html +.PHONY: $(project)-test.eventlog +$(project)-test.eventlog $(project)-test.prof: + cabal test $(CABAL_TEST_FLAGS) \ + --test-show-details always --test-options "$(TEST_OPTIONS) +RTS $(RTS_OPTIONS)" \ + --enable-profiling $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) || true +tests/prof-th: + 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 $(addprefix --ghc-options ,$(GHC_PROF_OPTIONS)) \ + --ghc-options "$(addprefix -opti,+RTS $(RTS_OPTIONS))" +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: % + +%/cover: CABAL_TEST_FLAGS += --enable-coverage +%/cover: % + +%.eventlog.html: RTS_OPTIONS += -hy -l-au +%.eventlog.html: %.eventlog + eventlog2html $< +%.eventlog.json: RTS_OPTIONS += -p -l-au +%.eventlog.json: %.eventlog + hs-speedscope $< + +.PHONY: benchmarks/html/$(version).html +b benchmarks: benchmarks/html/$(version).html +benchmarks/html/$(version).html: + mkdir -p benchmarks/html + cabal bench $(CABAL_BENCH_FLAGS) --benchmark-options "$(BENCHMARK_OPTIONS)" +benchmarks/repl: + 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) +$(project)-benchmark.prof2: + cabal v2-build lib:$(project) --enable-profiling $(GHC_PROF_OPTIONS) --write-ghc-environment-files=always + cabal bench $(CABAL_BENCH_FLAGS) \ + --benchmark-options "$(BENCHMARK_OPTIONS)" \ + --enable-profiling $(GHC_PROF_OPTIONS) \ + --ghc-options "$(addprefix -opti,+RTS $(RTS_OPTIONS))" doc: cabal haddock --haddock-css ocean --haddock-hyperlink-source tag: - name=$$(sed -ne 's/^name: *\(.*\)/\1/p' "$(cabal)"); \ - version=$$(sed -ne 's/^version: *\(.*\)/\1/p' "$(cabal)"); \ - git tag --merged | grep -Fqx "$$name-$$version" || \ - git tag -f -s -m "$$name v$$version" $$name-$$version + git tag --merged | grep -Fqx "$(package)-$(version)" || \ + git tag -f -s -m "$(package) v$(version)" $(package)-$(version) tar: + reuse lint cabal sdist -upload: - LANG=C cabal upload . + 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 +%/publish: CABAL_UPLOAD_FLAGS+=--publish +%/publish: % + +publish: upload/publish nix-build: nix -L build 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