Module Compilers


module Compilers: Libs.Compilers
Invoke the OCamlc compilers, documentation generator...

This module defines a simple layer for invoking the stand-alone elements of the toolchain (ocamlc, ocamlopt, ocamlfind, ocamldoc, ocamlrun, ocaml).

Note Before calling any of the functions of this module, you need to initialize Findlib by calling either Packages.init or Packages.init_manually.


type command 
Abstraction of a command, i.e. the instructions necessary to run one of the tools of the toolchain.
val string_of_command : command -> string
Format a command as a string, fit for use with Sys.command
val command_for_exec : command -> string * string array
Format a command as a string and an array of arguments, fit for use with Unix.exec.

Options

If this is the first time you attempt to invoke theh tools, you should probably disregard these options for now.

type package_option = [ `dllpath_all
| `dllpath_pkg of string
| `dontlink of string
| `ignore_error
| `linkpkg
| `package of string
| `passopt of string list
| `ppopt of string list
| `predicates of string list
| `syntax of string
| `verbose ]
Package options, understood by ocamlfind.

These options serve essentially for automatically resolving dependencies between packages.

type warning = [ `comments of bool
| `deprecated of bool
| `fragile_match of bool
| `misc of bool
| `non_unit of bool
| `omitted_labels of bool
| `other_unused_var of bool
| `overridden_field of bool
| `overridden_methods of bool
| `partial_applications of bool
| `partial_match of bool
| `unused_match of bool
| `unused_var of bool ]
type compiler_option = [ `I of string list
| `c
| `cc of string
| `cclib of string list
| `ccopt of string list
| `config
| `custom
| `debug
| `dinstr
| `dlambda
| `dllib of string
| `dllpath of string
| `dparsetree
| `drawlambda
| `dtypes
| `file of string
| `for_pack of string
| `g
| `i
| `impl of string
| `include_dir of string list
| `intf of string
| `intf_suffix of string
| `labels
| `library
| `linkall
| `make_runtime
| `noassert
| `noautolink
| `nolabels
| `nopervasives
| `nostdlib
| `o of string
| `output of string
| `output_obj
| `pack
| `pp of string
| `principal
| `rectypes
| `thread
| `unsafe
| `use_prims of string
| `use_runtime of string
| `v
| `verbose
| `version
| `vmthread
| `warn_error of warning list
| `warnings of warning list
| `where ]
Compiler options, understood directly by ocamlc or ocamlopt.
type interpreter_option = [ `I of string list
| `dinstr
| `dlambda
| `dparsetree
| `drawlambda
| `file of string
| `init of string
| `labels
| `noassert
| `nolabels
| `noprompt
| `nostdlib
| `principal
| `rectypes
| `unsafe
| `version
| `warn_error of warning list
| `warnings of warning list ]
val all_warnings : warning list

Compilers

val ocamlc : ?batteries:bool ->
?package:package_option list ->
?options:compiler_option list ->
string list -> command
Invoke the ocamlc compiler, to produce bytecode modules and executables.

ocamlc l returns a command which may be used to run the ocamlc compiler to compile files l.

batteries : Use the standard library (true by default).
package : An optional list of package options.
options : An optional list of compiler options.

Note that it is possible to specify that a file some_file must be compiled either by making sure that some_file appears in l or by making sure that `file some_file appears in options. Either manners of adding a file are equivalent, with files mentioned in options being compiled before files mentioned in l.

For more informations about the ocamlc compiler, see the manual of OCaml.

val ocamlopt : ?batteries:bool ->
?package:package_option list ->
?options:compiler_option list ->
string list -> command
Invoke the ocamlopt compiler, to produce native optimized modules and executables.

ocamlopt l returns a command which may be used to run the ocamlopt compiler to compile files l.

batteries : Use the standard library (true by default).
package : An optional list of package options.
options : An optional list of compiler options.

Note that it is possible to specify that a file some_file must be compiled either by making sure that some_file appears in l or by making sure that `file some_file appears in options. Either manners of adding a file are equivalent, with files mentioned in options being compiled before files mentioned in l.

For more informations about the ocamlopt compiler, the manual of OCaml.

val ocaml : ?batteries:bool ->
?options:interpreter_option list ->
string list -> command
Invoke the ocaml interpreter, to execute files without a compilation phase.

ocaml l returns a command which may be used to run the ocaml interpreter to execute files l.

batteries : Use the standard library (true by default).
options : An optional list of compiler options.

For more informations about the ocaml interpreter, the manual of OCaml.