-
Notifications
You must be signed in to change notification settings - Fork 261
Expand file tree
/
Copy pathMakefile
More file actions
191 lines (151 loc) · 4.69 KB
/
Makefile
File metadata and controls
191 lines (151 loc) · 4.69 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#
# Configurations
#
CABAL ?= cabal
DEV_TARGETS ?= test
TEST_SHOW_DETAILS_MODE ?= direct # alternatively: always | failure | never
TEST_PROP_NUM_RUNS ?= 1000
TEST_BUILDDIR ?= dist-test
TEST_COVERAGE_BUILDDIR ?= dist-coverage
DOCS_BUILDDIR ?= dist-docs
WASM_BUILDDIR ?= dist-wasm
CABAL_TEST = $(CABAL) --builddir=$(TEST_BUILDDIR)
CABAL_COVERAGE = $(CABAL) --builddir=$(TEST_COVERAGE_BUILDDIR)
CABAL_DOCS = $(CABAL) --builddir=$(DOCS_BUILDDIR)
CABAL_WASM = $(CABAL) --builddir=$(WASM_BUILDDIR)
TEST_OPTIONS = \
-O0 \
--test-show-details=$(TEST_SHOW_DETAILS_MODE) \
--test-options="--maximum-generated-tests=$(TEST_PROP_NUM_RUNS)"
default: build
.PHONY: check
#
# Build
#
build:
$(CABAL) v2-build all
build-test:
$(CABAL_TEST) v2-build all
build-wasm:
$(CABAL_WASM) v2-build -v --with-compiler wasm32-wasi-ghc --with-hc-pkg wasm32-wasi-ghc-pkg semantic-money
wasm32-wasi-ghc \
-odir $(PWD)/$(WASM_BUILDDIR)/wasm -hidir $(PWD)/$(WASM_BUILDDIR)/wasm -stubdir $(PWD)/$(WASM_BUILDDIR)/wasm \
-o $(PWD)/$(WASM_BUILDDIR)/semantic-money.wasm -no-hs-main \
-optl-mexec-model=reactor -optl-Wl,--export=hs_init,--export=uu_flow2 \
-ipkgs/semantic-money/src \
-package-db ~/.cabal/store/ghc-$$(wasm32-wasi-ghc --numeric-version)/package.db \
-package data-default \
pkgs/semantic-money/wasm/Exports.hs
clean:
rm -rf $(DOCS_BUILDDIR)
rm -rf $(TEST_BUILDDIR)
rm -rf $(TEST_COVERAGE_BUILDDIR)
rm -rf dist-*
.PHONY: default build* clean
#
# Testing
#
test:
$(CABAL_TEST) v2-test all --enable-tests \
$(TEST_OPTIONS)
test-sm:
$(CABAL_TEST) v2-test semantic-money --enable-tests \
$(TEST_OPTIONS)
test-coverage:
$(CABAL_COVERAGE) v2-build all --enable-tests --enable-coverage
$(CABAL_COVERAGE) v2-test all --enable-tests --enable-coverage \
$(TEST_OPTIONS)
.PHONY: test test-*
#
# Demos
#
demo-expo: build-test
$(CABAL_TEST) v2-exec superfluid-validator -- --demo expo
demo-dfa: build-test
$(CABAL_TEST) v2-exec superfluid-validator -- --demo dfa | ./utils/self-gnuplot.sh
demo-cfda: build-test
$(CABAL_TEST) v2-exec superfluid-validator -- --demo cfda | ./utils/self-gnuplot.sh
.PHONY: demo-*
#
# Docs
#
docs-haddock:
$(CABAL_DOCS) haddock all
YELLOWPAPER_ROOT = $(DOCS_BUILDDIR)/yellowpaper
$(YELLOWPAPER_ROOT)/tex:
mkdir -p "$@"
$(YELLOWPAPER_ROOT)/tex/lhsfmt.tex:
echo '%include lhs2TeX.fmt' | lhs2TeX > "$@"
.SECONDEXPANSION:
$(YELLOWPAPER_ROOT)/tex/%.lhs.tex: pkgs/core/src/Money/Theory/%.lhs
./utils/lhs2tex.sh "$<" > "$@"
.SECONDEXPANSION:
$(YELLOWPAPER_ROOT)/tex/%.tex: yellowpaper/$$(notdir $$*).tex
cp "$<" "$@"
.SECONDEXPANSION:
$(YELLOWPAPER_ROOT)/tex/%.bib: yellowpaper/$$(notdir $$*).bib
cp "$<" "$@"
YELLOWPAPER1_FILENAME=semantic-money-yellowpaper1
YELLOWPAPER1_INPUTS = $(YELLOWPAPER_ROOT)/tex \
$(YELLOWPAPER_ROOT)/tex/MoneyDistribution.lhs.tex \
$(YELLOWPAPER_ROOT)/tex/FinancialContract.lhs.tex \
$(YELLOWPAPER_ROOT)/tex/PaymentExecutionEnvironment.lhs.tex \
$(YELLOWPAPER_ROOT)/tex/MoneyMedium.lhs.tex \
$(YELLOWPAPER_ROOT)/tex/PaymentPrimitives.lhs.tex \
$(YELLOWPAPER_ROOT)/tex/lhsfmt.tex \
$(YELLOWPAPER_ROOT)/tex/preamble.tex \
$(YELLOWPAPER_ROOT)/tex/Biblio.bib \
$(YELLOWPAPER_ROOT)/tex/Paper1.tex
$(YELLOWPAPER_ROOT)/pdflatex/$(YELLOWPAPER1_FILENAME).pdf: $(YELLOWPAPER1_INPUTS)
ls $(YELLOWPAPER_ROOT)/tex
rm -rf $(YELLOWPAPER_ROOT)/pdflatex
mkdir -p $(YELLOWPAPER_ROOT)/pdflatex
rm -rf $(YELLOWPAPER_ROOT)/assets
cp -r yellowpaper/assets $(YELLOWPAPER_ROOT)/assets
cp $(YELLOWPAPER_ROOT)/tex/preamble.tex $(YELLOWPAPER_ROOT)/pdflatex/
cd $(YELLOWPAPER_ROOT)/pdflatex; \
P=$(YELLOWPAPER1_FILENAME); \
{ \
pdflatex -shell-escape -jobname=$$P ../tex/Paper1.tex && \
biber $$P.bcf && \
pdflatex -shell-escape -jobname=$$P ../tex/Paper1.tex; \
}
docs-yellowpapers: $(YELLOWPAPER_ROOT)/pdflatex/$(YELLOWPAPER1_FILENAME).pdf
docs: docs-haddock docs-yellowpaper
.PHONY: docs-haddock docs
#
# Dev Environment
#
dev:
nodemon \
-e lhs,hs,cabal \
-i dist-newstyle/ -i "$(TEST_BUILDDIR)/" -i "$(TEST_COVERAGE_BUILDDIR)/" \
-i "#*" -i "flycheck_*.hs" \
-x "make $(DEV_TARGETS) || exit 1"
freeze:
rm -f cabal.project.freeze
$(CABAL) v2-freeze
lint:
for i in $$PWD/pkgs/*/*.cabal;do cd $$(dirname $$i);pwd;cabal -vnormal check || exit 1;done
hlint pkgs
repl-sm:
$(CABAL_TEST) repl semantic-money-test-suite
repl-simple:
$(CABAL_TEST) repl superfluid-protocol-system-simple-test-suite
cloc:
@echo '**** Core Source Files ****'
cloc pkgs/core/src/
@echo
@echo '**** Simple System Source Files ****'
cloc pkgs/simple/src/
@echo
@echo '**** Validator Source Files ****'
cloc pkgs/validator/src/
@echo
@echo '**** Internal Source ****'
cloc pkgs/src-internal/
@echo
@echo '**** Test Files ****'
cloc pkgs/*/test
@echo
.PHONY: dev freeze lint repl-* cloc