]> Git — Sourcephile - majurity.git/blob - GNUmakefile
yarn: upgrade to purescript@^0.13.5 and spago@^0.12.1
[majurity.git] / GNUmakefile
1 HaskellPackages := \
2 hjugement \
3 hjugement-protocol \
4 hjugement-cli
5 PureScriptPackages := \
6 hjugement-web
7 Packages := $(HaskellPackages) $(PureScriptPackages)
8 hjugement-protocol/test: TEST_FLAGS:=
9
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
16
17 all: build
18
19 build: $(HaskellPackages:=/build)
20 %/build: %/stack.yaml
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))
25
26 test: $(Packages:=/test)
27 %/test: %/stack.yaml
28 ! grep -iq '^Test-Suite\>' $*/$(notdir $*).cabal || \
29 { cd $* && stack $(STACK_FLAGS) test --test-arguments "$(TEST_FLAGS)" $(STACK_TEST_FLAGS); }
30 %/test: %/spago.dhall
31 ! grep -iq '\<test/' $*/spago.dhall || \
32 { cd $* && yarn $(YARN_FLAGS) spago $(SPAGO_FLAGS) test; }
33
34 GHCID_TEST_ARGS ?=
35 GHCID_TEST ?= ":main $(GHCID_TEST_ARGS)"
36 ghcid: $(HaskellPackages:=/ghcid)
37 %/ghcid: %/stack.yaml
38 cd $* && ghcid \
39 --warnings \
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) \
44 $(GHCID_FLAGS)
45
46 bench: $(HaskellPackages:=/bench)
47 %/bench: %/stack.yaml
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); }
53
54 clean: $(Packages:=/clean)
55 cleaner: $(Packages:=/cleaner)
56 %/clean:
57 cd $* && stack $(STACK_FLAGS) clean $(STACK_CLEAN_FLAGS)
58 %/cleaner:
59 cd $* && stack $(STACK_FLAGS) clean --full $(STACK_CLEAN_FLAGS)
60
61 %/quickcheck: override QUICKCHECK_TESTS=10000
62 %/quickcheck: override QUICKCHECK_MAXSIZE=1000
63 %/quickcheck: %
64
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
70 %/fast: %
71
72
73 %/debug: override STACK_BUILD_FLAGS+=--flag $(cabal:.cabal=):debug
74 %/debug: override STACK_TEST_FLAGS+=--flag $(cabal:.cabal=):debug
75 %/debug: %
76
77
78 %/accept: override STACK_TEST_ARGS+=--accept
79 %/accept: %
80
81
82 doc: $(HaskellPackages:=/doc)
83 %/doc: %/stack.yaml
84 cd $* && stack $(STACK_FLAGS) haddock $(STACK_HADDOCK_FLAGS)
85 %/doc: %/spago.yaml
86 cd $* && yarn $(YARN_FLAGS) spago $(SPAGO_FLAGS) docs $(SPAGO_DOCS_FLAGS)
87 %.html: %.md
88 markdown $*.md >$*.html
89 %.html/view: %.html
90 sensible-browser $*.html
91
92 HLint.hs: $(HS)
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
97
98 lint: $(HaskellPackages:=/lint) $(HS)
99 %/lint: HLint.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
104
105 tag: $(Packages:=/tag)
106 %/tag: %/stack.yaml
107 cabal=$*/$*.cabal; \
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
112
113 tar: $(Packages:=/tar)
114 %/tar: %/stack.yaml
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) .
119
120 .PHONY: stats
121 stats:
122 gitstats . $@
123 stats/view: stats
124 sensible-browser stats/index.html