Module B0_jsoo

js_of_ocaml B0 file support

Metadata

type comp_mode = [
| `Separate
| `Whole
]

The type for js_of_ocaml compilation either whole program compilation mode for runtime efficiency and minimality or `Separate for build time efficiency.

comp are options added to the js_of_ocaml compile subcommand.

val comp_mode : comp_mode B0_meta.key

mode is the js_of_ocaml compilation mode.

FIXME this should likely be a store key.

source_map is the source map option.

val tag : unit B0_meta.key

tag indicates the entity is related to js_of_ocaml.

val toplevel : bool B0_meta.key

toplevel should be true to embed toplevel support in the js executable.

link are options added to the js_of_ocaml link subcommand.

val assets_root : B00_std.Fpath.t B0_meta.key

assets_root indicates the path w.r.t. to which assets are are B00_std.Fpath.rerooted. Assets that are not prefixed by assets_root are simply copied at the toplevel of the build dir.

val meta : ?meta:B0_meta.t -> ?assets_root:B00_std.Fpath.t -> ?comp:B00_std.Cmd.t -> ?comp_mode:comp_mode -> ?link:B00_std.Cmd.t -> ?requires:B00_ocaml.Lib.Name.t list -> ?source_map:B00_jsoo.source_map -> ?toplevel:bool -> unit -> B0_meta.t

meta creates a base metadata dictionary for compiling with js_of_ocaml. See the corresponding keys above. FIXME defaults.

Build units

val exe : ?wrap:(B0_unit.proc -> B0_unit.proc) -> ?doc:string -> ?meta:B0_meta.t -> ?action:B0_unit.action -> ?name:string -> string -> srcs:B0_srcs.sels -> B0_unit.t

exe n is a JavaScript "executable" file named n.

  • doc is the unit doc string.
  • meta is the initial metadata.
  • requires are the OCaml libraries required to compile the JavaScript.
  • name is the name of the unit (defaults to n with . replaced by -).
  • srcs are the executable sources. All files with extension .ml, .mli and .js are considered for compiling and linked in the JavaScript file.
  • wrap allows to extend the build procedure you must call the given build procedure. TODO maybe remove once we have good Build fragments.
val web : ?wrap:(B0_unit.proc -> B0_unit.proc) -> ?doc:string -> ?meta:B0_meta.t -> ?action:B0_unit.action -> ?name:string -> string -> srcs:B0_srcs.sels -> B0_unit.t

web n is an HTML page named n (without the .html extension FIXME review that).

  • doc is the unit doc string.
  • meta is the initial metadata.
  • requires are the OCaml libraries required to compile the JavaScript.
  • name is the name of the unit (defaults to n).
  • srcs are the executable sources. All files with extension .ml, .mli and .js are considered for compiling and linking the executable. The files B00_fexts.www in srcs minus .js files are copied over the build directory. If these files are can be rerooted to the build dir according to assets_dir they are copied as such otherwise they are copied assets_dir FIXME. A competing idea was to have a notion of root induced by B0_srcs selection. See the commented stuff there. This is likely something that will play better with generated assets. It's also sligthly borderline with deployements.
  • wrap allows to extend the build procedure you must call the given build procedure. TODO maybe remove once we have good Build fragments.

TODO document. The js file is n.js, if there's no .html source in the srcs a minimal HTML file is generated in which n.js is linked as a script and any css file in srcs as a stylesheet.

Build fragments

See TODO.

val copy_assets : B00.Memo.t -> B00_fexts.map -> exts:B00_fexts.t -> assets_root:B00_std.Fpath.t option -> dst:B00_std.Fpath.t -> B00_std.Fpath.Set.t

copy_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 B00_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.