Module Assemblage.Bin

module Bin: sig .. end
Binary executable part.

Defines a program executable's build products by gathering a set of unit parts.



Metadata


type kind = [ `C | `OCaml | `OCaml_toplevel ] 
The type for kinds of binaries.
val pp_kind : Format.formatter -> kind -> unit
pp_kind ppf k prints an unspecified representation of k on ppf.
val kind : [< `Bin ] Assemblage.part -> kind
kind p is p's kind.
val byte : [< `Bin ] Assemblage.part -> bool
byte p is true if p can compile to OCaml byte code.
val native : [< `Bin ] Assemblage.part -> bool
native p is true if p can compile to native code.
val js : [< `Bin ] Assemblage.part -> bool
js p is true if p can compile to JavaScript code.
val ocaml : [< Assemblage.part_kind ] Assemblage.part ->
[< Assemblage.part_kind > `Bin ] Assemblage.part option
ocaml p is Some p iff p is an `OCaml binary.
val ocaml_toplevel : [< Assemblage.part_kind ] Assemblage.part ->
[< Assemblage.part_kind > `Bin ] Assemblage.part option
ocaml_toplevel p is Some p iff p is an `OCaml_toplevel binary.
val c : [< Assemblage.part_kind ] Assemblage.part ->
[< Assemblage.part_kind > `Bin ] Assemblage.part option
c p is Some p iff p is an `C binary.

Binaries


val v : ?usage:Assemblage.Part.usage ->
?exists:bool Assemblage.Conf.value ->
?args:Assemblage.Args.t ->
?byte:bool ->
?native:bool ->
?js:bool ->
string ->
kind ->
[< `Lib | `Pkg | `Unit ] Assemblage.part list ->
[< Assemblage.part_kind > `Bin ] Assemblage.part
v ?byte ?native ?js name kind needs is a binary named name of the given kind. needs has the compilation units us that define the binary, they are integrated. The package and libraries that are in needs are added to us needs and used at link time.

The binary's ability to compile to different targets is specified by the arguments ?byte, ?native and ?js whose defaults respectively depend on kind as follows.

Whether the outputs associated to a compilation target are concretly build depends on the configuration keys Assemblage.Conf.ocaml_byte, Assemblage.Conf.ocaml_native, Assemblage.Conf.ocaml_js and Assemblage.Conf.c_js.
val to_cmd : ?ext:Assemblage.Path.ext ->
[< `Bin ] Assemblage.part -> Assemblage.Acmd.cmd Assemblage.Conf.value
to_cmd ext bin is an action command for using the part's binary. ext specifies the binary to use if there are multiple of them; default favors native code over byte code if available and as per configuration.

Warning. When you use the resulting command in actions make sure to specify it as an input product of the action using Assemblage.Bin.to_cmd_path otherwise the binary may not exist when the action is executed. Also make sure to use the command in configurations in which bin exists, see Assemblage.Bin.exists. For simple use cases Assemblage.Run.with_bin and Assemblage.Run.bin will take care of these details.

val to_cmd_path : ?abs:bool ->
?ext:Assemblage.Path.ext ->
[< `Bin ] Assemblage.part -> Assemblage.Path.t Assemblage.Conf.value
to_cmd_path ext bin is to_cmd ext bin as a path. If abs is true (default to false) returns an absolute path.
val exists : ?ext:Assemblage.Path.ext ->
[< `Bin ] Assemblage.part -> bool Assemblage.Conf.value
exists ?ext bin is true if the to_cmd bin command exists.

Binaries as product generators


val gen : ?usage:Assemblage.Part.usage ->
?exists:bool Assemblage.Conf.value ->
?args:Assemblage.Args.t ->
?dir:Assemblage.Path.t Assemblage.Conf.value ->
?name:string ->
?ext:Assemblage.Path.ext ->
?stdin:Assemblage.Path.t Assemblage.Conf.value ->
?stdout:Assemblage.Path.t Assemblage.Conf.value ->
?stderr:Assemblage.Path.t Assemblage.Conf.value ->
[< `Bin ] Assemblage.Part.t ->
string list Assemblage.Conf.value ->
[< Assemblage.part_kind > `Base ] Assemblage.Part.t
gen ext bin args is a part that uses Assemblage.Bin.to_cmd to generate a product on stdout.

FIXME This API is a proof of concept, it was quickly derived from Assemblage.Run.bin, it's not designed. We need to devise sensitive things with dir and relative to what we express paths. Also want to specify the action's outputs explicitely. See the gen-quine example.