-PKGS := \
+HaskellPackages := \
hjugement \
- hjugement-protocol
+ hjugement-protocol \
+ hjugement-cli
+PureScriptPackages := \
+ hjugement-web
+Packages := $(HaskellPackages) $(PureScriptPackages)
hjugement-protocol/test: TEST_FLAGS:=
-HS = $(shell find . -name '*.hs' -not -name 'HLint.hs')
+HS = $(shell find $(HaskellPackages) -name '*.hs' -not -name 'HLint.hs')
cabal := $(shell find . -name '*.cabal' -print -quit)
QUICKCHECK_TESTS = 1000
QUICKCHECK_MAXSIZE = 100
TEST_FLAGS = --quickcheck-tests $(QUICKCHECK_TESTS) --quickcheck-max-size $(QUICKCHECK_MAXSIZE)
-BENCH_HTML_FLAGS = --output benchmarks/html/$(shell sed -ne 's/^version: *\(.*\)/\1/p' $p/$p.cabal).html
+BENCH_HTML_FLAGS = --output benchmarks/html/$(shell sed -ne 's/^version: *\(.*\)/\1/p' $*/$(notdir $*).cabal).html
all: build
-build: $(PKGS:=/build)
-%/build:
+build: $(HaskellPackages:=/build)
+%/build: %/stack.yaml
cd $* && stack $(STACK_FLAGS) build $(STACK_BUILD_FLAGS)
-.PHONY: $(PKGS) $(foreach p,$(PKGS),$(eval $p: $p/build))
-
-test: $(PKGS:=/test)
-define test
-$p/test:
- ! grep -iq '^Test-Suite\>' $p/$p.cabal || \
- { cd $p && stack $$(STACK_FLAGS) test --test-arguments "$$(TEST_FLAGS)" $$(STACK_TEST_FLAGS); }
-endef
-$(foreach p,$(PKGS),$(eval $(call test)))
+%/build: %/spago.dhall
+ cd $* && yarn $(YARN_FLAGS) spago $(SPAGO_FLAGS) build $(SPAGO_BUILD_FLAGS)
+.PHONY: $(Packages) $(foreach p,$(Packages),$(eval $p: $p/build))
+
+test: $(Packages:=/test)
+%/test: %/stack.yaml
+ ! grep -iq '^Test-Suite\>' $*/$(notdir $*).cabal || \
+ { cd $* && stack $(STACK_FLAGS) test --test-arguments "$(TEST_FLAGS)" $(STACK_TEST_FLAGS); }
+%/test: %/spago.dhall
+ ! grep -iq '\<test/' $*/spago.dhall || \
+ { cd $* && yarn $(YARN_FLAGS) spago $(SPAGO_FLAGS) test; }
GHCID_TEST_ARGS ?=
GHCID_TEST ?= ":main $(GHCID_TEST_ARGS)"
-ghcid: $(PKGS:=/ghcid)
-%/ghcid:
+ghcid: $(HaskellPackages:=/ghcid)
+%/ghcid: %/stack.yaml
cd $* && ghcid \
--warnings \
--command "stack $(STACK_FLAGS) $(GHCID_STACK_FLAGS) ghci $(GHCID_GHCI_FLAGS) \
--test $(GHCID_TEST) \
$(GHCID_FLAGS)
-bench: $(PKGS:=/bench)
-define bench
-$p/bench:
- mkdir -p $p/benchmarks/html
- ! grep -iq '^Benchmark\>' $p/$p.cabal || \
- { cd $p && stack $$(STACK_FLAGS) bench \
- --benchmark-arguments "$(call BENCH_HTML_FLAGS) $$(BENCH_FLAGS)" \
- $$(STACK_BENCH_FLAGS); }
-endef
-$(foreach p,$(PKGS),$(eval $(call bench)))
-
-clean: $(PKGS:=/clean)
-cleaner: $(PKGS:=/cleaner)
+bench: $(HaskellPackages:=/bench)
+%/bench: %/stack.yaml
+ mkdir -p $*/benchmarks/html
+ ! grep -iq '^Benchmark\>' $*/$(notdir $*).cabal || \
+ { cd $* && stack $(STACK_FLAGS) bench \
+ --benchmark-arguments "$(BENCH_HTML_FLAGS) $(BENCH_FLAGS)" \
+ $(STACK_BENCH_FLAGS); }
+
+clean: $(Packages:=/clean)
+cleaner: $(Packages:=/cleaner)
%/clean:
cd $* && stack $(STACK_FLAGS) clean $(STACK_CLEAN_FLAGS)
%/cleaner:
%/accept: %
-doc: $(PKGS:=/doc)
-%/doc:
+doc: $(HaskellPackages:=/doc)
+%/doc: %/stack.yaml
cd $* && stack $(STACK_FLAGS) haddock $(STACK_HADDOCK_FLAGS)
+%/doc: %/spago.yaml
+ cd $* && yarn $(YARN_FLAGS) spago $(SPAGO_FLAGS) docs $(SPAGO_DOCS_FLAGS)
%.html: %.md
markdown $*.md >$*.html
%.html/view: %.html
HLint.hs: $(HS)
sed -i -e '/^-- BEGIN: generated hints/,/^-- END: Generated by hlint/d' HLint.hs
echo '-- BEGIN: generated hints' >> HLint.hs
- hlint $(foreach p,$(PKGS),--find $p) | grep '^'infix | sort -u >> HLint.hs
+ hlint $(foreach p,$(HaskellPackages),--find $p) | sed -ne 's/^- infix: \(.*\)/\1/p' | sort -u >>HLint.hs
echo '-- END: generated hints' >> HLint.hs
-lint: $(PKGS:=/lint) $(HS)
+lint: $(HaskellPackages:=/lint) $(HS)
%/lint: HLint.hs
cd $* && if hlint --quiet --report=hlint.html -XNoCPP \
$(shell cabal-cargs --format=ghc --only=default_extensions --sourcefile=$*) $(HLINT_FLAGS) .; \
then rm -f hlint.html; \
else sensible-browser ./hlint.html & fi
-tag: $(PKGS:=/tag)
-%/tag:
+tag: $(Packages:=/tag)
+%/tag: %/stack.yaml
cabal=$*/$*.cabal; \
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
-tar: $(PKGS:=/tar)
-%/tar:
+tar: $(Packages:=/tar)
+%/tar: %/stack.yaml
cd $* && stack $(STACK_FLAGS) sdist $(STACK_SDIST_FLAGS)
-upload: $(PKGS:=/upload)
-%/upload:
+upload: $(Packages:=/upload)
+%/upload: %/stack.yaml
cd $* && LANG=C stack $(STACK_FLAGS) upload $(STACK_UPLOAD_FLAGS) .
.PHONY: stats