forked from mlabs-haskell/ply
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
58 lines (45 loc) · 2.17 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
.PHONY: hoogle build-all test-core format lint requires_nix_shell
build-all:
nix -L --show-trace build .#build-all.x86_64-linux
hoogle: requires_nix_shell
hoogle server --local --port=8070 > /dev/null &
ifdef FLAGS
GHC_FLAGS = --ghc-options "$(FLAGS)"
endif
test-core:
nix -L --show-trace build .#test-core.x86_64-linux
EXTENSIONS := -o -XTypeApplications -o -XPatternSynonyms
# Run fourmolu formatter
format: requires_nix_shell
env -C ply-core fourmolu -i --check-idempotence $(EXTENSIONS) $(shell env -C ply-core fd -ehs)
env -C ply-plutarch fourmolu -i --check-idempotence $(EXTENSIONS) $(shell env -C ply-plutarch fd -ehs)
env -C example/offchain fourmolu -i --check-idempotence $(EXTENSIONS) $(shell env -C example/offchain fd -ehs)
env -C example/onchain fourmolu -i --check-idempotence $(EXTENSIONS) $(shell env -C example/onchain fd -ehs)
nixpkgs-fmt $(NIX_SOURCES)
cabal-fmt -i $(CABAL_SOURCES)
# Check formatting (without making changes)
format_check:
env -C ply-core fourmolu --mode check --check-idempotence $(EXTENSIONS) $(shell env -C ply-core fd -ehs)
env -C ply-plutarch fourmolu --mode check --check-idempotence $(EXTENSIONS) $(shell env -C ply-plutarch fd -ehs)
env -C example/offchain fourmolu -i --check-idempotence $(EXTENSIONS) $(shell env -C example/offchain fd -ehs)
env -C example/onchain fourmolu -i --check-idempotence $(EXTENSIONS) $(shell env -C example/onchain fd -ehs)
nixpkgs-fmt --check $(NIX_SOURCES)
cabal-fmt -c $(CABAL_SOURCES)
# Nix files to format
NIX_SOURCES := $(shell fd -enix)
# Cabal files to format
CABAL_SOURCES := $(shell fd -ecabal)
nixfmt: requires_nix_shell
nixfmt $(NIX_SOURCES)
nixfmt_check: requires_nix_shell
nixfmt --check $(NIX_SOURCES)
# Apply hlint suggestions
lint: requires_nix_shell
find -name '*.hs' -not -path './dist-*/*' -exec hlint --refactor --refactor-options="--inplace" {} \;
# Check hlint suggestions
lint_check: requires_nix_shell
hlint $(shell fd -ehs)
# Target to use as dependency to fail if not inside nix-shell
requires_nix_shell:
@ [ "$(IN_NIX_SHELL)" ] || echo "The $(MAKECMDGOALS) target must be run from inside a nix shell"
@ [ "$(IN_NIX_SHELL)" ] || (echo " run 'nix develop .#devEnv' first" && false)