package b0
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=e9aa779e66c08fc763019f16d4706f465d16c05d6400b58fbd0313317ef33ddea51952e2b058db28e65f7ddb7012f328c8bf02d8f1da17bb543348541a2587f0
doc/b0.kit/B0_jsoo/index.html
Module B0_jsooSource
js_of_ocaml support.
Tool
tool is the js_of_ocaml executable.
Build units
Metadata
assets_root indicates the path with respect to which page assets are are B0_std.Fpath.rerooted. Assets that are not prefixed by assets_root are simply copied at the toplevel of the build dir.
The type for js_of_ocaml compilation either whole program compilation mode for runtime efficiency and minimality or `Separate for build time efficiency.
compilaton_mode is the js_of_ocaml compilation mode. Defaults to `Whole.
FIXME this should likely be a store key or something similar to the way we handle built code for OCaml.
compile are options added to the js_of_ocaml compile subcommand. Defaults to B0_std.Cmd.empty.
The type for specifying source maps desires.
FIXME Like compilation_mode this should possibly be associated the build.
source_map is the source map option. Defaults to Some `File.
tag indicates the entity is related to js_of_ocaml.
toplevel should be true to embed toplevel support in the js executable.
link_opts are options added to the js_of_ocaml link subcommand.
JavaScript file
val exe :
?wrap:(B0_unit.build_proc -> B0_unit.build_proc) ->
?doc:string ->
?meta:B0_meta.t ->
?assets_root:B0_std.Fpath.t ->
?requires:B0_ocaml.Libname.t list ->
?public:bool ->
?name:string ->
string ->
srcs:B0_srcs.sels ->
B0_unit.texe exename is a JavaScript "executable" file named exename.
docis the unit doc string.requiresare the OCaml libraries required to compile the JavaScript. Added to the unit meta asB0_ocaml.requires.metais added to thepublicis the visibility status. Added to the unit meta asB0_meta.public's meta.nameis the name of the unit (defaults tonamewith.replaced by-).srcsare the executable sources. All files with extension.ml,.mliand.jsare considered for compiling and linked in the JavaScript file.wrapallows to extend the build procedure you must call the given build procedure.
HTML page
val html_page :
?wrap:(B0_unit.build_proc -> B0_unit.build_proc) ->
?doc:string ->
?meta:B0_meta.t ->
?assets_root:B0_std.Fpath.t ->
?requires:B0_ocaml.Libname.t list ->
?name:string ->
?js_file:string ->
string ->
srcs:B0_srcs.sels ->
B0_unit.thtml_page ?js_file page constructs in the unit directory an HTML file named page.html, a JavaScript file named js_file (defaults to page.js) and copies over (or generates) B0_file_exts.www files of srcs as follows:
page.html, if a file exists with that name insrcs, this file is used. Otherwise a minimal HTML document linkingpagename.jsand.cssassets is generated.js_fileis compiled by considering all files with extension.ml,.mliand.jsand linked against required librariesrequires.The files
B0_file_exts.wwwinsrcsminus.jsfiles are copied over to the unit directory. If these files can be rerooted to the build directory according toassets_rootthey are copied in a hierarchy otherwise they are copied at the root of the directoryFIXME. Make that comprehensible.
FIXME. A competing idea was to have a notion of root induced by
B0_srcsselection. See the commented stuff there. This is likely something that will play better with generated assets. It's also sligthly borderline with deployements.
The other arguments are as follows:
docis the unit doc string.metais the initial metadata.requiresare the OCaml libraries required to compile the JavaScript.nameis the name of the unit (defaults topagename).jsnameis the basename of the JavaScript file, defaults topagename.srcsare the sources to lookup, see above.wrapallows to extend the build procedure you must call the given build procedure. TODO maybe remove once we have good Build fragments.
Build fragments
See TODO.
val compile :
B0_memo.t ->
opts:B0_std.Cmd.t ->
source_map:source_map ->
jss:B0_std.Fpath.t list ->
byte:B0_std.Fpath.t ->
o:B0_std.Fpath.t ->
unitcompile m ~source_map ~jss ~byte ~o compiles the JavaScript files jss and byte code object or executable byte to the JavaScript file o.
val link :
B0_memo.t ->
opts:B0_std.Cmd.t ->
source_map:source_map ->
jss:B0_std.Fpath.t list ->
o:B0_std.Fpath.t ->
unitlink m ~opts ~jss ~o links the JavaScript files jss to o with options opts.
val build_runtime :
B0_memo.t ->
opts:B0_std.Cmd.t ->
jss:B0_std.Fpath.t list ->
o:B0_std.Fpath.t ->
unitbuild_runtime m ~jss o writes a standalone runtime with JavaScript files jss to o.
val copy_assets :
B0_memo.t ->
B0_file_exts.map ->
exts:B0_file_exts.t ->
assets_root:B0_std.Fpath.t option ->
dst:B0_std.Fpath.t ->
B0_std.Fpath.Set.tcopy_assets m srcs ~exts ~assets_root ~dst copies srcs with extensions in exts to dst. If assets_root is specified indicates the path w.r.t. which assets are B0_std.Fpath.rerooted. Assets that are not prefixed by assets_root are simply copied at the toplevel of dst.
FIXME. Not a good idea to ready them inside. But all this needs a good review.
val write_page :
?lang:string ->
?generator:string ->
?styles:string list ->
?scripts:string list ->
?title:string ->
B0_memo.t ->
o:B0_std.Fpath.t ->
unitwrite_page m ~title ~o writes to file o a full HTML document whose body contains only a B0_html.El.noscript element that entices the user, in english, to enable JavaScript. title defaults to the basename of o without its extension, for the other arguments and more information see B0_html.El.basic_page.