This repository has been archived by the owner on Nov 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
220 lines (153 loc) · 7.64 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
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#
# Copyright 2020, Offchain Labs, Inc. All rights reserved.
#
# Add your mexe as an output file
generics_files = basic simple nested func closure colorful queue
generics_outputs = $(patsubst %,generics/%, $(generics_files))
minitest_outputs = arithmetic codeloadtest default globaltest modexp simple-closure closure stack-safety quick wide-tuples $(generics_outputs)
upgrade_outputs = regcopy_new regcopy_old upgrade1_new upgrade1_old
looptest_outputs = upgrade2_new upgrade2_old
builtin_outputs = arraytest kvstest maptest
stdlib_outputs = addressSetTest biguinttest blstest bytearraytest expandingIntArrayTest fixedpointtest keccaktest priorityqtest queuetest ripemd160test rlptest storageMapTest sha256test
stdlib2_outputs = arraytest priorityqtest
builtin_mexes = $(patsubst %,builtin/%.mexe, $(builtin_outputs))
stdlib_mexes = $(patsubst %,stdlib/%.mexe, $(stdlib_outputs))
stdlib2_mexes = $(patsubst %,stdlib2/%.mexe, $(stdlib2_outputs))
minitest_mexes = $(patsubst %,minitests/%.mexe, $(minitest_outputs))
upgrade_mexes = $(patsubst %,upgradetests/%.mexe, $(upgrade_outputs))
looptest_mexes = $(patsubst %,looptest/%.mexe, $(looptest_outputs))
libs_mexes = $(builtin_mexes) $(stdlib_mexes) $(minitest_mexes)
test_mexes = $(builtin_mexes) $(stdlib_mexes) $(stdlib2_mexes) $(minitest_mexes) $(upgrade_mexes) $(looptest_mexes)
target = ./target/release/mini
compile = ./target/release/mini compile $(compile_options)
upgrade = ./target/release/mini gen-upgrade-code
run = ./target/release/mini
consts = arb_os/constants.json
globals = arb_os/globals.txt
done = "\e[38;5;161;1mdone!\e[0;0m\n"
# user targets
.make/all: always arb_os/arbos.mexe $(test_mexes) arb_os/arbos-upgrade.mexe arb_os/upgrade.json .make/test
@printf "\e[38;5;161;1mdone building %s\e[0;0m\n" $$(expr $$(echo $? | wc -w) - 1)
@touch .make/all
arbos: arb_os/arbos.mexe
@printf $(done)
upgrade: arb_os/arbos-upgrade.mexe arb_os/upgrade.json
@printf $(done)
libs: .make/libs
cargo test --release
@printf $(done)
contracts: .make/solidity
@printf $(done)
paramslist: parameters.json
@printf $(done)
evmtest: arb_os/arbos.mexe .make/tools
$(run) evm-tests
evmlogs: evm-test-logs
@printf $(done)
evmdebug: arb_os/arbos.mexe .make/tools
$(run) evm-debug
replay: replayTests
@printf $(done)
coverage: always lcov-mini.info
@printf $(done)
benchmark: arb_os/arbos.mexe .make/tools
$(run) make-benchmarks
test: .make/test
cargo test --release
push: .make/push
@printf "\e[38;5;161;1mReady for push!\e[0;0m\n"
ci: .make/all replayTests lcov-mini.info
@printf "Made ci products\n"
clean:
@rm -f {builtin,stdlib,upgradetests,minitests,looptest}/*.mexe arb_os/{arbos,arbos-upgrade}.mexe
@rm -f minitests/generics/*.mexe
@rm -f arbos/{upgrade.json,contractTemplates.mini}
@rm -rf contracts/artifacts contracts/cache
@rm -f */*.cov lcov.info lcov-mini.info logs/* .make/*
# pattern rules
builtin/%.mexe: builtin/%.mini builtin/*.mini $(consts) .make/tools
$(compile) -c $(consts) $< -o $@ -t
stdlib/%.mexe: stdlib/%.mini stdlib/*.mini builtin/*.mini $(consts) .make/tools
$(compile) -c $(consts) $< -o $@ -t
stdlib2/%.mexe: stdlib2/%.mini stdlib2/*.mini builtin/*.mini $(consts) .make/tools
$(compile) -c $(consts) $< -o $@ -t
minitests/%.mexe: minitests/%.mini minitests/*.mini stdlib/*.mini builtin/*.mini $(consts) .make/tools
$(compile) -c $(consts) $< -o $@ -t
upgradetests/%.mexe: upgradetests/%.mini upgradetests/*.mini stdlib/*.mini builtin/*.mini $(consts) .make/tools
$(compile) -c $(consts) $< -o $@ -t
arb_os/arbos.mexe: arb_os/*.mini arb_os/bridge_arbos_versions.mini arb_os/contractTemplates.mini stdlib/*.mini builtin/*.mini $(consts) $(globals) .make/tools
$(compile) arb_os -o $@ -m
parameters.json: arb_os/constants.json .make/tools
$(run) make-parameters-list -c arb_os/constants.json > $<
replayTests: arb_os/arbos.mexe .make/tools
mkdir -p testlogs replayTests
$(run) make-test-logs > /dev/null
mv testlogs/* replayTests/
evm-test-logs: arb_os/arbos.mexe .make/tools
rm -rf evm-test-logs
mkdir -p evm-test-logs
$(run) evm-tests --savelogs
arb_os/contractTemplates.mini: .make/tools
$(run) make-templates
# Upgrade tests
upgradetests/upgrade1_new.mexe: upgradetests/upgrade1_new.mini $(consts) .make/tools
$(compile) -c $(consts) $< -o $@
looptest/upgrade2_new.mexe: looptest/upgrade2_new.mini looptest/*.mini looptest/upgrade2.toml .make/tools
$(compile) looptest/upgrade2_new.mini -c $(consts) -o $@
looptest/bridge2.mini upgradetests/impl2.mini &: looptest/upgrade2_base.mexe looptest/upgrade2_old.mexe looptest/upgrade2.toml .make/tools
$(upgrade) looptest/upgrade2_old.mexe $< looptest/bridge2.mini impl2 looptest/upgrade2.toml
looptest/upgrade2_base.mexe: looptest/upgrade2_new.mini .make/tools
$(compile) $< -c arb_os/constants.json -o looptest/upgrade2_base.mexe
looptest/upgrade2_old.mexe: looptest/upgrade2_old.mini stdlib/*.mini builtin/*.mini .make/tools
$(compile) -c $(consts) $< -o $@ -t
# ArbOS upgrade
arbos_source_all = $(wildcard arb_os/*.mini) $(consts) $(globals) stdlib/*.mini builtin/*.mini arb_os/contractTemplates.mini
arbos_source_no_bridge = $(filter-out arb_os/bridge_arbos_versions.mini, $(arbos_source_all))
arb_os/upgrade.json: arb_os/arbos-upgrade.mexe .make/tools
$(run) serialize-upgrade arb_os/arbos-upgrade.mexe > $@
arb_os/arbos-upgrade.mexe: arb_os/arbos-upgrade-base.mexe arb_os/bridge_arbos_versions.mini .make/tools
$(compile) arb_os -o $@ -m
arb_os/bridge_arbos_versions.mini: arb_os/arbos-upgrade-base.mexe arb_os/arbos_before.mexe arb_os/customize_arbos_bridge_versions.mini arb_os/upgrade.toml .make/tools
$(upgrade) arb_os/arbos_before.mexe $< $@ customize_arbos_bridge_versions arb_os/upgrade.toml
arb_os/arbos-upgrade-base.mexe: $(arbos_source_no_bridge) .make/tools
cp arb_os/dummy_version_bridge.mini arb_os/bridge_arbos_versions.mini
$(compile) arb_os -o $@ -m
# strategic rules to minimize dependency building
.make/tools: .make/solidity .make/compiler .make/install
@touch .make/tools
.make/test: arb_os/arbos.mexe $(test_mexes) arb_os/arbos-upgrade.mexe arb_os/upgrade.json
cargo test --release
@touch .make/test
.make/libs: $(libs_mexes)
cargo test --release -- test_arraytest test_if_else test_closures test_codeblocks test_basic test_codeload test_globaltest test_map test_kvstest test_fixedpoint test_error_system test_queuetest test_keccak test_pqtest test_storage_map test_expanding_int_array test_bytearray test_biguint test_rlp
exit 1
@touch .make/libs
.make/fmt: src/*.rs src/*/*.rs Cargo.* .make/install
cargo fmt
@touch .make/fmt
.make/push: .make/fmt arb_os/arbos.mexe
make $(MAKEFLAGS) compile_options="$(compile_options)" replayTests .make/test
@touch .make/push
.make/compiler: src/*.rs src/*/*.rs src/*.lalrpop Cargo.* .make/install
cargo build --release
@touch .make/compiler
.make/solidity: contracts/arbos/*/*.sol .make/install
yarn --cwd contracts build
@touch .make/solidity
.make/install:
mkdir -p .make
yarn --cwd contracts install
@touch .make/install
# CLI tooling
cov_files = $(wildcard coverage/*.cov)
cov_files_no_upgrade = $(filter-out coverage/test_upgrade_arbos_to_different_version.cov, $(cov_files))
lcov-mini.info: coverage/alltests.all ./coverage/mini-coverage.sh
./coverage/mini-coverage.sh $< > $@
coverage/alltests.all: coverage/avmcodebuilder.partial $(cov_files_no_upgrade) .make/test
cat $^ | sort -r | uniq | sort | uniq -f 1 | sort -k2,2 -k3,3n | grep -v test | grep -v Test > $@
coverage/avmcodebuilder.partial: coverage/test_upgrade_arbos_to_different_version.cov
grep avmcodebuilder $< > $@
coverage/test_upgrade_arbos_to_different_version.cov: .make/test
# Makefile settings
always: # use this to force other rules to always build
.DELETE_ON_ERROR: # causes a failure to delete its target