1 Commits

Author SHA1 Message Date
cqc
420e350544 examples.ml lol that was hard 2023-03-05 15:50:18 -06:00
2 changed files with 88 additions and 60 deletions

146
dune
View File

@ -1,7 +1,8 @@
(env (env
(dev (flags (:standard -warn-error -A)) (dev (flags (:standard -warn-error -A))
(js_of_ocaml (flags :standard --no-inline --debug-info --target-env browser --disable shortvar) (js_of_ocaml (flags :standard)
(build_runtime_flags :standard --no-inline --debug-info) (build_runtime_flags :standard --no-inline --debug-info)
(compilation_mode whole_program)
(link_flags :standard)))) (link_flags :standard))))
(library (library
@ -35,33 +36,7 @@
uri uri
gg gg
lwd lwd
log_js log_js))
))
(executables
(names toplevel)
(modules toplevel ppx_graph)
(libraries
js_of_ocaml-compiler
js_of_ocaml-tyxml
js_of_ocaml-toplevel
lwt
js_of_ocaml-lwt
;; not used directly
graphics
js_of_ocaml.deriving
js_of_ocaml-lwt.graphics
js_of_ocaml-ppx.as-lib
ocp-indent.lib
react
reactiveData
str
log_js)
(flags
(:standard -rectypes -linkall))
(modes byte)
(preprocess
(pps js_of_ocaml-ppx)))
(rule (rule
(targets test_dynlink.cmo test_dynlink.cmi) (targets test_dynlink.cmo test_dynlink.cmi)
@ -73,6 +48,11 @@
(action (action
(run %{bin:js_of_ocaml} --pretty --toplevel %{dep:test_dynlink.cmo}))) (run %{bin:js_of_ocaml} --pretty --toplevel %{dep:test_dynlink.cmo})))
(rule
(targets embedded_fs.js)
(action
(run %{bin:jsoo_fs} -I . -o %{targets} %{dep:examples.ml} %{dep:test_dynlink.js})))
(rule (rule
(targets export.txt) (targets export.txt)
(deps (deps
@ -84,33 +64,36 @@
(package js_of_ocaml-toplevel)) (package js_of_ocaml-toplevel))
(action (action
(run (run
jsoo_listunits jsoo_listunits
-o -o
%{targets} %{targets}
stdlib stdlib
graphics graphics
str str
dynlink dynlink
js_of_ocaml-compiler.runtime js_of_ocaml-compiler.runtime
js_of_ocaml-lwt.graphics js_of_ocaml-lwt.graphics
js_of_ocaml-ppx.as-lib js_of_ocaml-ppx.as-lib
js_of_ocaml.deriving js_of_ocaml.deriving
lwt lwt
tyxml.functor tyxml.functor
tyxml.functor:html_types.cmi tyxml.functor:html_types.cmi
react react
reactiveData reactiveData
js_of_ocaml js_of_ocaml
js_of_ocaml-lwt js_of_ocaml-lwt
js_of_ocaml-tyxml js_of_ocaml-tyxml
js_of_ocaml-toplevel js_of_ocaml-toplevel
dynlink))) dynlink)))
(rule (executables
(targets toplevel.js) (names toplevel)
(action (modules toplevel ppx_graph)
(run (flags
%{bin:js_of_ocaml} (:standard -rectypes -linkall))
(modes js)
(js_of_ocaml
(flags
compile compile
--pretty --pretty
--Werror --Werror
@ -123,10 +106,55 @@
shortvar shortvar
+toplevel.js +toplevel.js
+dynlink.js +dynlink.js
%{dep:toplevel.bc} %{dep:embedded_fs.js}))
-o (preprocess
%{targets}))) (pps js_of_ocaml-ppx))
(libraries
js_of_ocaml-compiler
js_of_ocaml-tyxml
js_of_ocaml-toplevel
lwt
js_of_ocaml-lwt
;; not used directly
graphics
js_of_ocaml.deriving
js_of_ocaml-lwt.graphics
js_of_ocaml-ppx.as-lib
compiler-libs
compiler-libs.common
compiler-libs.bytecomp
js_of_ocaml-compiler.runtime
ocp-indent.lib
react
reactiveData
str
log_js)
)
; (rule
; (targets toplevel.js)
; (deps examples.ml)
; (action
; (run
; %{bin:js_of_ocaml}
; compile
; --pretty
; --Werror
; --target-env
; browser
; --extern-fs
; "--file=%{dep:examples.ml}"
; --export
; %{dep:export.txt}
; --toplevel
; --disable
; shortvar
; +toplevel.js
; +dynlink.js
; %{dep:toplevel.bc}
; -o
; %{targets})))
(alias (alias
(name default) (name default)
(deps toplevel.js index.html)) (deps toplevel.bc.js index.html toplevel.html))

View File

@ -167,7 +167,7 @@
document.getElementsByTagName("head")[0].appendChild(fileref); document.getElementsByTagName("head")[0].appendChild(fileref);
} }
load_script("_build/default/exported-unit.cmis.js"); load_script("_build/default/exported-unit.cmis.js");
load_script("_build/default/toplevel.js"); load_script("_build/default/toplevel.bc.js");
</script> </script>
</head> </head>