This repository has been archived by the owner on Jul 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
302 lines (226 loc) · 8.55 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
############################################################################
# You can define your own path to COQBIN by creating a file called
# "settings.sh" and placing the right definitions into it, e.g.
# COQBIN=/var/tmp/charguer/v8.4/bin/
#
# The same applies for the path to tlc, e.g.: TLC=~/tlc/trunk
#
# Note that TLC should have no leading slash, whereas COQBIN should have one.
# Note that if you rebind COQBIN you need to do the same in the TLC folder.
# Note that if you add a settings.sh file, you need to do "make clean" first.
# Default paths for TLC and COQBIN, etc are as follows:
COQBIN=
TLC=lib/tlc/src
# Define FAST to be non empty for compiling Coq proofs faster
FAST=
# Use bash as the default shell
SHELL=/bin/bash
LAMBDAS5=~/Documents/data/LambdaS5/tests/s5
SPIDERMONKEY=~/Mozilla/Central/Central/js/src/build_release/js
NODEJS=/usr/bin/nodejs
# Edit settings.sh to modify the default paths mentioned above
-include settings.sh
#######################################################
TLC_SRC=$(wildcard $(TLC)/*.v)
TLC_VO=$(TLC_SRC:.v=.vo)
#######################################################
COQINCLUDES=-I coq -I $(TLC)
COQC=$(COQBIN)coqc
COQDEP=$(COQBIN)coqdep
COQFLAGS=-dont-load-proofs
OCAMLBUILD=ocamlbuild
OCAMLBUILDFLAGS=-cflags "-w -20"
#######################################################
# MAIN SOURCE FILES
JS_SRC=\
coq/Shared.v \
coq/JsNumber.v \
coq/JsSyntax.v \
coq/JsSyntaxAux.v \
coq/JsSyntaxInfos.v \
coq/JsCommon.v \
coq/JsPreliminary.v \
coq/JsCommonAux.v \
coq/JsInit.v \
coq/JsInterpreterMonads.v \
coq/JsInterpreter.v \
coq/JsInterpreterExtraction.v \
coq/JsPrettyInterm.v \
coq/JsPrettyIntermAux.v \
coq/JsPrettyRules.v \
coq/JsCorrectness.v
JS_VO=$(JS_SRC:.v=.vo)
# List for files that can be compiled without proofs in FAST=1 mode.
ifneq ($(FAST),)
FAST_SRC=\
# coq/Shared.v \
coq/JsNumber.v \
coq/JsSyntax.v \
coq/JsSyntaxAux.v \
coq/JsSyntaxInfos.v \
coq/JsCommon.v \
coq/JsCommonAux.v \
coq/JsInit.v \
coq/JsPrettyInterm.v \
coq/JsPrettyIntermAux.v \
coq/JsPrettyRules.v
endif
FAST_VO=$(FAST_SRC:.v=.vo)
#######################################################
# MAIN TARGETS
default: coq interpreter tags
all: default interp/run_jsbisect
debug: OCAMLBUILDFLAGS+=-tag debug
debug: default interp/run_js.byte interp/prtest.cmo
report:
cd interp; bisect-report -I _build -html ../report ../bisect*.out
firefox report/index.html || open report/index.html
rm bisect*.out
tags: $(JS_SRC)
./gentags.sh
.PHONY: all default debug report init tlc lib \
local nofast
#######################################################
# EXTERNAL LIBRARIES: TLC and Flocq
init:
tools/git-hooks/install.sh .
git submodule update --init
-opam repo add coq-released https://coq.inria.fr/opam/released
opam pin -yn add JS_Parser "https://github.com/resource-reasoning/JS_Parser.git#v0.1.0"
opam pin -yn add coq-jscert .
opam install -y --deps-only coq-jscert
lib: tlc
tlc: $(TLC_VO)
#######################################################
# Coq Compilation Implicit Rules
%.v.d: %.v
$(COQDEP) $(COQINCLUDES) $< > $@
# If this rule fails for some reason, try `make clean_all && make`
%.vo: %.v
$(COQC) $(COQFLAGS) $(COQINCLUDES) $<
#######################################################
# FAST COMPILATION TOOL: coqj
# Compile coqj : converts a .v file into a shallow .v file (without proofs)
tools/coqj/coqj:
$(MAKE) -C tools/coqj coqj
# Fast compilation of files in $(FAST_SRC)
define FAST_RULE
$(1).vo: tools/coqj/coqj
@mkdir -p _shallow/$(dir $1)
tools/coqj/coqj $(1).v > _shallow/$(1).v
$(COQC) -dont-load-proofs -I coq -I $(TLC) _shallow/$(1).v
mv _shallow/$(1).vo $(1).vo
endef
$(foreach filebase,$(FAST_SRC:.v=),$(eval $(call FAST_RULE,$(filebase))))
# "make nofast" : Compilation mode to force the verification of all files
nofast: $(FAST_VO:.vo=_full.vo)
%_full.vo : %.v
echo $*
cp $*.v $*_full.v
$(COQC) -dont-load-proofs -I coq -I $(TLC) $*_full.v
rm $*_full.v
#######################################################
# JSCert Specific Rules
.PHONY: coq proof
coq: $(JS_VO)
ifeq (proof,$(MAKECMDGOALS))
$(JS_SRC): proof.patched
endif
proof.patched:
@echo -e "\e[1;41;5mWARNING! WARNING!\e[0m This command modifies files in coq/"
tools/runcheck.py patch
touch proof.patched
proof: COQFLAGS=
proof: proof.patched coq
rm -f proof.patched
# Interpreter extraction spits out lots of *.ml,mli files
# The option [-dont-load-proof] would extract all instance to an axiom! -- Martin.
coq/JsInterpreterExtraction.vo: coq/JsInterpreterExtraction.v
$(COQC) $(subst -dont-load-proofs,,$(COQFLAGS)) $(COQINCLUDES) $<
-mkdir -p interp/src/extract
-rm -f interp/src/extract/.patched
mv *.ml interp/src/extract
mv *.mli interp/src/extract
#######################################################
# JsRef Interpreter Rules
.PHONY: extract_interpreter interpreter
# ; forces rule to be run, generates everything under extract dir
interp/src/extract/%: coq/JsInterpreterExtraction.vo ;
# Insert more useful error messages into Interpreter
REFGETVALUE=$(shell cat interp/src/insert/ref_get_value)
REFGETVALUE2=$(shell cat interp/src/insert/ref_get_value2)
RUNOBJECTMETHOD=$(shell cat interp/src/insert/run_object_method)
RUNOBJECTHEAP=$(shell cat interp/src/insert/run_object_heap_set_extensible)
ENVGETIDENTIFIER=$(shell cat interp/src/insert/lexical_env_get_identifier_ref)
interp/src/extract/JsInterpreter.ml.patched: interp/src/extract/JsInterpreter.ml
@echo \# Inserting useful error messages into $<
@perl -i -pe 's|res_res \(run_error s Coq_native_error_ref\)|$(REFGETVALUE)|g' $<
@perl -i -pe 's/\(\*\* val run_object_heap_set_extensible :/$(RUNOBJECTMETHOD)/g' $<
@perl -i -pe 's/type runs_type =/$(RUNOBJECTHEAP)/g' $<
@perl -i -pe 's/ result_val s \(ref_create_value \(Coq_value_prim Coq_prim_undef\) x0 str\)/$(ENVGETIDENTIFIER)/g' $<
@perl -i -pe 's|\(\*\* val run_expr_get_value :|$(REFGETVALUE2)|g' $<
touch $@
# Sentinel file to check all interpreter source files have been patched
# Should depend on each individual file patched sentinel
# (Can also add rules to patch all files)
interp/src/extract/.patched: interp/src/extract/JsInterpreter.ml.patched
touch $@
extract_interpreter: interp/src/extract/.patched
# .ml executables may be placed in a number of locations, tell make where to search for them
vpath %.ml interp/src interp/top_level
# interp/_tags contains OCaml-specific build rules for all interpreter variants
interp/%.byte: extract_interpreter %.ml
cd interp && $(OCAMLBUILD) -use-ocamlfind $(OCAMLBUILDFLAGS) $(@F)
interp/%.native: extract_interpreter %.ml
cd interp && $(OCAMLBUILD) -use-ocamlfind $(OCAMLBUILDFLAGS) $(@F)
interp/%.cmo: %.ml
cd interp && $(OCAMLBUILD) -use-ocamlfind $(OCAMLBUILDFLAGS) $(@F)
.PRECIOUS: interp/%.native
interp/%: interp/%.native
ln -fs $(<F) $@
interpreter: interp/run_js interp/top
#######################################################
# JSRef Bisect Mode
interp/src/extract/JsInterpreterBisect.ml: interp/src/extract/JsInterpreter.ml extract_interpreter
perl -pe 's/ impossible/ (*BISECT-IGNORE*) impossible/g' $< > $@
interp/src/run_jsbisect.ml: interp/src/run_js.ml
perl -pe 's/JsInterpreter\./JsInterpreterBisect\./g' $< > $@
interp/run_jsbisect.native: interp/src/extract/JsInterpreterBisect.ml
# interp/run_jsbisect is an implicit rule
#######################################################
# Interpreter run helpers
.PHONY: run_tests run_tests_spidermonkey run_tests_lambdaS5 run_tests_nodejs
run_tests: interpreter
./runtests.py --no_parasite
run_tests_spidermonkey:
./runtests.py --spidermonkey --interp_path $(SPIDERMONKEY)
run_tests_lambdaS5:
./runtests.py --lambdaS5 --interp_path $(LAMBDAS5)
run_tests_nodejs:
./runtests.py --nodejs --interp_path $(NODEJS)
#######################################################
# CLEAN
.PHONY: clean clean_interp clean_all
clean_interp:
-rm -f coq/JsInterpreterExtraction.vo
-rm -rf interp/src/extract
-rm -f interp/run_js interp/top
-rm -f interp/run_jsbisect interp/src/run_jsbisect.ml
cd interp && $(OCAMLBUILD) -quiet -clean
clean: clean_interp
-rm -f coq/*.{vo,glob,d}
clean_all: clean
-rm -rf lib/flocq
find . -iname "*.vo" -exec rm {} \;
find . -iname "*.glob" -exec rm {} \;
find . -iname "*.d" -exec rm {} \;
#######################################################
# LOCAL: copy all tlc .vo files to the head folder
local:
@$(foreach file, $(TLC_VO), cp $(file) $(notdir $(file));)
#######################################################
#######################################################
ifeq ($(filter init clean% install%,$(MAKECMDGOALS)),)
-include $(JS_SRC:.v=.v.d)
-include $(TLC_SRC:.v=.v.d)
endif