-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
80 lines (65 loc) · 2.29 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Quickstart guide for using ghcid for Haskell development
# https://www.parsonsmatt.org/2018/05/19/ghcid_for_the_win.html
package = scale-by-the-bay
main_exe = demo
test_exe = tests
prof_dir = '.stack-work-profiling'
# Use GHC options informed by this blog post:
# https://rybczak.net/2016/03/26/how-to-reduce-compilation-times-of-haskell-projects/
ghc_opts = -j +RTS -A128m -RTS
# Use the top-level stack.yaml file
stack_yaml = STACK_YAML="stack.yaml"
stack = $(stack_yaml) stack
# Standard build (implies default optimization settings)
build:
$(stack) build $(package) \
--ghc-options='$(ghc_opts)'
# Force rebuild of packages, even when it doesn't seem necessary, based on file
# dirtiness
build-dirty:
$(stack) build $(package) \
--ghc-options='$(ghc_opts)' \
--force-dirty
# Fast build (implies O0 optimizations)
build-fast:
$(stack) build $(package) \
--ghc-options='$(ghc_opts)' \
--fast
# Compile a profiling build, caching artifacts in a separate work directory
# TODO(jkachmar): Figure out if we should be cleaning before profiling runs
build-profile:
$(stack) build \
--work-dir $(prof_dir) \
--profile \
--ghc-options='$(ghc_opts)'
# Clean the normal working directory
clean:
$(stack) clean
# Clean the profiling directory, as specified in $(prof_dir)
clean-profile:
$(stack) clean --work-dir $(prof_dir)
# Create a ghci REPL for the entire project
ghci:
$(stack) ghci $(package):lib $(package):test:$(test_exe) \
--ghci-options='-fobject-code $(ghc_opts)' \
--main-is $(package):$(main_exe)
# Run ghcid against the entire project
ghcid:
$(stack) exec -- ghcid \
--command "stack ghci \
$(package):lib $(package):test:$(test_exe) \
--ghci-options='-fobject-code $(ghc_opts)' \
--main-is $(package):$(main_exe)"
# Have ghcid run the test suite on successful recompilation
ghcid-test:
$(stack) exec -- ghcid \
--command "stack ghci \
$(package):lib $(package):test:$(test_exe) \
--ghci-options='-fobject-code $(ghc_opts)'" \
--test "main"
# Print documentation
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
test:
$(stack) test $(package) --ghc-options='$(ghc_opts)' --fast
.PHONY: build build-dirty build-fast build-profile clean clean-profile ghci ghcid ghcid-test help test