Skip to content

Commit

Permalink
Align Js_runtime build and Assemblyscript_runtime build.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkel committed May 10, 2021
1 parent c1b5c27 commit 9969786
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 77 deletions.
26 changes: 2 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,11 @@ cleanmost-qcert-compiler:

## Configure

runtimes/javascript/qcert_runtime.ml:
$(MAKE) -C runtimes/javascript

compiler/lib/js_runtime.ml: runtimes/javascript/qcert_runtime.ml
cp runtimes/javascript/qcert_runtime.ml compiler/lib/js_runtime.ml

compiler/lib/static_config.ml:
echo "(* This file is generated *)" > compiler/lib/static_config.ml
echo "let qcert_home = \"$(CURDIR)\"" >> compiler/lib/static_config.ml

prepare: compiler/lib/js_runtime.ml compiler/lib/static_config.ml Makefile.coq
prepare: compiler/lib/static_config.ml Makefile.coq

configure:
@echo "[Q*cert] "
Expand All @@ -134,8 +128,6 @@ configure:
clean-configure:

cleanall-configure:
$(MAKE) -C runtimes/javascript cleanall
rm -rf compiler/lib/js_runtime.ml
rm -rf compiler/lib/static_config.ml
rm -f compiler/.merlin compiler/*/.merlin

Expand Down Expand Up @@ -243,22 +235,13 @@ qcert-runtimes:
@echo "[Q*cert] "
@echo "[Q*cert] Building runtimes"
@echo "[Q*cert] "
ifneq ($(JAVASCRIPT),)
@$(MAKE) javascript-runtime
endif
ifneq ($(JAVA),)
@$(MAKE) java-runtime
endif
ifneq ($(SPARK),)
@$(MAKE) spark2-runtime
endif

javascript-runtime:
@echo "[Q*cert] "
@echo "[Q*cert] JavaScript runtime"
@echo "[Q*cert] "
@$(MAKE) -C runtimes/javascript

java-runtime:
@echo "[Q*cert] "
@echo "[Q*cert] Java runtime"
Expand All @@ -272,14 +255,12 @@ spark2-runtime:
@$(MAKE) -C runtimes/spark2

clean-runtimes:
- @$(MAKE) -C runtimes/javascript clean
- @$(MAKE) -C runtimes/java clean
- @$(MAKE) -C runtimes/spark2 clean
- @rm -rf bin/lib
- @rm -f bin/javaRunner.jar

cleanall-runtimes:
- @$(MAKE) -C runtimes/javascript cleanall
- @$(MAKE) -C runtimes/java cleanall
- @$(MAKE) -C runtimes/spark2 cleanall
- @rm -rf bin/lib
Expand Down Expand Up @@ -337,10 +318,7 @@ demo:
bin/qcertJS.js:
@$(MAKE) qcert-javascript

runtimes/javascript/qcert-runtime.js:
@$(MAKE) javascript-runtime

qcert-demo: bin/qcertJS.js runtimes/javascript/qcert-runtime.js
qcert-demo: bin/qcertJS.js
@echo "[Q*cert] "
@echo "[Q*cert] Compiling Web Demo in TypeScript"
@echo "[Q*cert] "
Expand Down
5 changes: 3 additions & 2 deletions compiler/dune
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
(library
(name qcert_lib)
(public_name coq-qcert)
(libraries base64 uri calendar wasm coq-qcert.assemblyscript)
)
(libraries base64 uri calendar wasm
coq-qcert.runtime.assemblyscript
coq-qcert.runtime.js))

(copy_files util/*.{ml,mli})
(copy_files wasm/*.{ml,mli})
Expand Down
2 changes: 1 addition & 1 deletion compiler/wasm/wasm_backend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ end = struct
open ImpEJson
module Encoding = Wasm_binary_ejson.Make(ImpEJson)

let runtime = Lazy.force Assemblyscript.Runtime.wasm_ast
let runtime = Lazy.force Assemblyscript_runtime.wasm_ast

let ejson_of_cejson = function
| Coq_cejnull -> Coq_ejnull
Expand Down
11 changes: 0 additions & 11 deletions runtimes/assemblyscript/assemblyscript.ml

This file was deleted.

9 changes: 9 additions & 0 deletions runtimes/assemblyscript/assemblyscript_runtime.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
let string = Stringified.runtime

let wasm_ast =
lazy (
let open Wasm in
let m = Decode.decode "runtime.wasm" string in
let () = Valid.check_module m in
m
)
4 changes: 2 additions & 2 deletions runtimes/assemblyscript/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(library
(name assemblyscript)
(public_name coq-qcert.assemblyscript)
(name assemblyscript_runtime)
(public_name coq-qcert.runtime.assemblyscript)
(libraries wasm))

(rule ; not evaluated for package release (-p flag)
Expand Down
2 changes: 1 addition & 1 deletion runtimes/assemblyscript/test_ml/dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(tests
(names force_wasm_ast)
(libraries coq-qcert.assemblyscript))
(libraries coq-qcert.runtime.assemblyscript))
2 changes: 1 addition & 1 deletion runtimes/assemblyscript/test_ml/force_wasm_ast.ml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let _ = Lazy.force Assemblyscript.Runtime.wasm_ast
let _ = Lazy.force Assemblyscript_runtime.wasm_ast
1 change: 0 additions & 1 deletion runtimes/javascript/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
qcert-runtime.js
qcert_runtime.ml
34 changes: 0 additions & 34 deletions runtimes/javascript/Makefile

This file was deleted.

33 changes: 33 additions & 0 deletions runtimes/javascript/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
(library
(name js_runtime)
(public_name coq-qcert.runtime.js))

(rule ; We promote to source dir because this file is also used from nodejs.
(target qcert-runtime.js)
(mode promote)
(deps
qcert-runtime-core.js
qcert-runtime-tostring.js
qcert-runtime-sql-date.js
qcert-runtime-uri.js)
(action
(with-stdout-to
qcert-runtime.js
(progn (echo "/* include: qcert-runtime-core.js */\n\n")
(cat qcert-runtime-core.js)
(echo "/* include: qcert-runtime-tostring.js */\n\n")
(cat qcert-runtime-tostring.js)
(echo "/* include: qcert-runtime-sql-date.js */\n\n")
(cat qcert-runtime-sql-date.js)
(echo "/* include: qcert-runtime-uri */\n\n")
(cat qcert-runtime-uri.js)))))

(rule
(target js_runtime.ml)
(deps qcert-runtime.js)
(action
(with-stdout-to
js_runtime.ml
(progn (echo "let runtime = {|\n")
(cat qcert-runtime.js)
(echo "|}\n")))))

0 comments on commit 9969786

Please # to comment.