This repository has been archived by the owner on Sep 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathMakefile
189 lines (157 loc) · 5.4 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
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# User-level configuration
include Makefile.config
# Contains the list of all the Coq modules
include Makefile.coq_modules
#
CP=cp
FILES = $(addprefix compiler/core/,$(MODULES:%=%.v))
## Compiler
all:
@$(MAKE) prepare
@$(MAKE) MAKEFLAGS= ergo
# Stdlib
%.ctoj: %.cto
./scripts/cto2ctoj.js parse $<
compiler/lib/resources.ml: compiler/stdlib/concerto.ctoj \
compiler/stdlib/stdlib.ergo \
compiler/stdlib/etime.ergo \
compiler/stdlib/template.ergo \
runtimes/javascript/ergo-runtime.js
echo '(* generated ocaml file *)' > compiler/lib/resources.ml
(for i in concerto; do \
echo "let $$i = {xxx|"; \
cat compiler/stdlib/$$i.ctoj; \
echo "|xxx}"; \
done) >> compiler/lib/resources.ml
(for i in stdlib etime template; do \
echo "let $$i = {xxx|"; \
cat compiler/stdlib/$$i.ergo; \
echo "|xxx}"; \
done) >> compiler/lib/resources.ml
(for i in runtime; do \
echo "let ergo_$$i = {xxx|"; \
cat ./runtimes/javascript/ergo-$$i.js; \
echo "|xxx}"; \
done) >> compiler/lib/resources.ml
(echo `date "+let builddate = {xxx|%b %d, %Y|xxx}"`) >> compiler/lib/resources.ml
# Configure
runtimes/javascript/ergo-runtime.js: runtimes/javascript/ergo-runtime-core.js \
runtimes/javascript/ergo-runtime-tostring.js \
runtimes/javascript/ergo-runtime-date-time.js \
runtimes/javascript/ergo-runtime-log.js \
runtimes/javascript/ergo-runtime-math.js \
runtimes/javascript/ergo-runtime-uri.js
$(MAKE) -C ./runtimes/javascript
./compiler/lib/js_runtime.ml: ./runtimes/javascript/ergo_runtime.ml
cp ./runtimes/javascript/ergo_runtime.ml ./compiler/lib/js_runtime.ml
./compiler/lib/static_config.ml:
echo "(* This file is generated *)" > ./compiler/lib/static_config.ml
echo "let ergo_home = \"$(CURDIR)\"" >> ./compiler/lib/static_config.ml
prepare: ./compiler/lib/static_config.ml compiler/lib/resources.ml Makefile.coq
$(MAKE) -C ./runtimes/javascript
configure:
@echo "[Ergo] "
@echo "[Ergo] Configuring Build"
@echo "[Ergo] "
npm install
@$(MAKE) prepare
# Regenerate the npm directory
ergo:
@$(MAKE) ergo-mechanization
@$(MAKE) MAKEFLAGS= ergo-ocaml-extraction
@$(MAKE) MAKEFLAGS= ergo-js-extraction
ergo-mechanization: _CoqProject Makefile.coq
@echo "[Ergo] "
@echo "[Ergo] Compiling Coq Mechanization"
@echo "[Ergo] "
@$(MAKE) -f Makefile.coq
ergo-ocaml-extraction:
@echo "[Ergo] "
@echo "[Ergo] Extracting Ergo Compiler to OCaml"
@echo "[Ergo] "
@$(MAKE) -C compiler/extraction
dune build @install
ergo-js-extraction:
@echo "[Ergo] "
@echo "[Ergo] Extracting Ergo Compiler to JavaScript"
@echo "[Ergo] "
@$(MAKE) -C compiler/libjs
## Documentation
documentation:
$(MAKE) -C compiler/core documentation
## Testing
test:
lerna run test
## Cleanup
clean-mechanization: Makefile.coq
- @$(MAKE) -f Makefile.coq clean
cleanall-mechanization:
- @$(MAKE) -f Makefile.coq cleanall
- @rm -f ./compiler/lib/js_runtime.ml ./compiler/lib/static_config.ml compiler/lib/resources.ml
- @rm -f Makefile.coq
- @rm -f Makefile.coq.conf
- @rm -f _CoqProject
- @find compiler/core \( -name '*.vo' -or -name '*.v.d' -or -name '*.glob' -or -name '*.aux' \) -print0 | xargs -0 rm -f
clean-ocaml-extraction:
- @$(MAKE) -C compiler/extraction clean
cleanall-ocaml-extraction:
- @$(MAKE) -C compiler/extraction cleanall
- dune clean
clean-js-extraction:
- @$(MAKE) -C compiler/libjs clean
cleanall-js-extraction:
- @$(MAKE) -C compiler/libjs cleanall
clean-npm:
cleanall-npm: clean-npm
- @node ./scripts/external/cleanExternalModels.js
- @rm -f ergo*.tgz
- @rm -rf node_modules
- @rm -rf .nyc_output
- @rm -rf coverage
- @rm -rf log
- @rm -f lerna-debug.log
clean: Makefile.coq
- @$(MAKE) clean-npm
- @$(MAKE) clean-ocaml-extraction
- @$(MAKE) clean-js-extraction
- @$(MAKE) -C packages/ergo-compiler clean
- @$(MAKE) -C packages/ergo-engine clean
- @$(MAKE) -C packages/ergo-cli clean
- @$(MAKE) -C runtimes/javascript clean
cleanall: Makefile.coq
@echo "[Ergo] "
@echo "[Ergo] Cleaning up"
@echo "[Ergo] "
- @$(MAKE) cleanall-npm
- @$(MAKE) cleanall-ocaml-extraction
- @$(MAKE) cleanall-mechanization
- @$(MAKE) -C packages/ergo-compiler cleanall
- @$(MAKE) -C packages/ergo-engine cleanall
- @$(MAKE) -C packages/ergo-cli cleanall
- @$(MAKE) -C runtimes/javascript cleanall
##
_CoqProject: Makefile.config
@echo "[Ergo] "
@echo "[Ergo] Setting up Coq"
@echo "[Ergo] "
ifneq ($(QCERT),)
(echo "-R compiler/core ErgoSpec -R $(QCERT)/compiler/core Qcert";) > _CoqProject
else
(echo "-R compiler/core ErgoSpec";) > _CoqProject
endif
Makefile.coq: _CoqProject Makefile $(FILES)
coq_makefile -f _CoqProject $(FILES) -o Makefile.coq
.PHONY: all clean documentation npm ergo