5 PureScriptPackages := \
7 Packages := $(HaskellPackages) $(PureScriptPackages)
8 hjugement-protocol/test: TEST_FLAGS:=
10 HS = $(shell find $(HaskellPackages) -name '*.hs' -not -name 'HLint.hs')
11 cabal := $(shell find . -name '*.cabal' -print -quit)
12 QUICKCHECK_TESTS = 1000
13 QUICKCHECK_MAXSIZE = 100
14 TEST_FLAGS = --quickcheck-tests $(QUICKCHECK_TESTS) --quickcheck-max-size $(QUICKCHECK_MAXSIZE)
15 BENCH_HTML_FLAGS = --output benchmarks/html/$(shell sed -ne 's/^version: *\(.*\)/\1/p' $*/$(notdir $*).cabal).html
19 build: $(HaskellPackages:=/build)
21 cd $* && stack $(STACK_FLAGS) build $(STACK_BUILD_FLAGS)
22 %/build: %/spago.dhall
23 cd $* && yarn $(YARN_FLAGS) spago $(SPAGO_FLAGS) build $(SPAGO_BUILD_FLAGS)
24 .PHONY: $(Packages) $(foreach p,$(Packages),$(eval $p: $p/build))
26 test: $(Packages:=/test)
28 ! grep -iq '^Test-Suite\>' $*/$(notdir $*).cabal || \
29 { cd $* && stack $(STACK_FLAGS) test --test-arguments "$(TEST_FLAGS)" $(STACK_TEST_FLAGS); }
31 ! grep -iq '\<test/' $*/spago.dhall || \
32 { cd $* && yarn $(YARN_FLAGS) spago $(SPAGO_FLAGS) test; }
35 GHCID_TEST ?= ":main $(GHCID_TEST_ARGS)"
36 ghcid: $(HaskellPackages:=/ghcid)
40 --command "stack $(STACK_FLAGS) $(GHCID_STACK_FLAGS) ghci $(GHCID_GHCI_FLAGS) \
41 $$(2>&1 stack ide targets | grep -v :test:) \
42 --ghci-options=-fobject-code" \
43 --test $(GHCID_TEST) \
46 bench: $(HaskellPackages:=/bench)
48 mkdir -p $*/benchmarks/html
49 ! grep -iq '^Benchmark\>' $*/$(notdir $*).cabal || \
50 { cd $* && stack $(STACK_FLAGS) bench \
51 --benchmark-arguments "$(BENCH_HTML_FLAGS) $(BENCH_FLAGS)" \
52 $(STACK_BENCH_FLAGS); }
54 clean: $(Packages:=/clean)
55 cleaner: $(Packages:=/cleaner)
57 cd $* && stack $(STACK_FLAGS) clean $(STACK_CLEAN_FLAGS)
59 cd $* && stack $(STACK_FLAGS) clean --full $(STACK_CLEAN_FLAGS)
61 %/quickcheck: override QUICKCHECK_TESTS=10000
62 %/quickcheck: override QUICKCHECK_MAXSIZE=1000
65 %/fast: override STACK_BUILD_FLAGS+=--fast
66 %/fast: override STACK_HADDOCK_FLAGS+=--fast
67 %/fast: override STACK_TEST_FLAGS+=--fast
68 %/fast: override QUICKCHECK_TESTS=100
69 %/fast: override QUICKCHECK_MAXSIZE=100
73 %/debug: override STACK_BUILD_FLAGS+=--flag $(cabal:.cabal=):debug
74 %/debug: override STACK_TEST_FLAGS+=--flag $(cabal:.cabal=):debug
78 %/accept: override STACK_TEST_ARGS+=--accept
82 doc: $(HaskellPackages:=/doc)
84 cd $* && stack $(STACK_FLAGS) haddock $(STACK_HADDOCK_FLAGS)
86 cd $* && yarn $(YARN_FLAGS) spago $(SPAGO_FLAGS) docs $(SPAGO_DOCS_FLAGS)
88 markdown $*.md >$*.html
90 sensible-browser $*.html
93 sed -i -e '/^-- BEGIN: generated hints/,/^-- END: Generated by hlint/d' HLint.hs
94 echo '-- BEGIN: generated hints' >> HLint.hs
95 hlint $(foreach p,$(HaskellPackages),--find $p) | sed -ne 's/^- infix: \(.*\)/\1/p' | sort -u >>HLint.hs
96 echo '-- END: generated hints' >> HLint.hs
98 lint: $(HaskellPackages:=/lint) $(HS)
100 cd $* && if hlint --quiet --report=hlint.html -XNoCPP \
101 $(shell cabal-cargs --format=ghc --only=default_extensions --sourcefile=$*) $(HLINT_FLAGS) .; \
102 then rm -f hlint.html; \
103 else sensible-browser ./hlint.html & fi
105 tag: $(Packages:=/tag)
108 name=$$(sed -ne 's/^name: *\(.*\)/\1/p' "$$cabal"); \
109 version=$$(sed -ne 's/^version: *\(.*\)/\1/p' "$$cabal"); \
110 git tag --merged | grep -Fqx "$$name-$$version" || \
111 git tag -f -s -m "$$name v$$version" $$name-$$version
113 tar: $(Packages:=/tar)
115 cd $* && stack $(STACK_FLAGS) sdist $(STACK_SDIST_FLAGS)
116 upload: $(Packages:=/upload)
117 %/upload: %/stack.yaml
118 cd $* && LANG=C stack $(STACK_FLAGS) upload $(STACK_UPLOAD_FLAGS) .
124 sensible-browser stats/index.html