module Findlib:sig
..end
The Findlib module is the primary interface of the findlib library. It contains functions to look up packages, to interpret META files, and to determine the ancestors of packages.
This module must be initialized before it can be used: Call either
init
or init_manually
for this.
exception No_such_package of string * string
exception Package_loop of string
typeformal_pred =
[ `NegPred of string | `Pred of string ]
val init : ?env_ocamlpath:string ->
?env_ocamlfind_destdir:string ->
?env_ocamlfind_metadir:string ->
?env_ocamlfind_commands:string ->
?env_ocamlfind_ignore_dups_in:string ->
?env_camllib:string ->
?env_ldconf:string -> ?config:string -> ?toolchain:string -> unit -> unit
config
argument.
Furthermore, the environment variables OCAMLPATH, OCAMLFIND_DESTDIR,
OCAMLFIND_COMMANDS, and CAMLLIB are interpreted. By default, the function takes
the values found in the environment, but you can pass different values
using the env_*
arguments. By setting these values to empty strings
they are no longer considered.
The result of the initialization is determined as follows:destdir
of the
configuration file.metadir
of the configuration file, and otherwise
no such directory is used.
The special value "none"
turns this feature off.path
of the config fileocamlc
, ocamlopt
, ocamlcp
, ocamlmklib
and
ocamlmktop
are set, their contents specify the executables. Otherwise,
the obvious default values are chosen: "ocamlc"
for ocamlc
,
"ocamlopt"
for ocamlopt
, and so on.stdlib
, or if unset the built-in locationld.conf
file (configuring the dynamic loader) is the value of
the environment variable OCAMLFIND_LDCONF, or if unset or empty, the
value of the configuration variable ldconf
, or if unset the
built-in location.val init_manually : ?ocamlc_command:string ->
?ocamlopt_command:string ->
?ocamlcp_command:string ->
?ocamloptp_command:string ->
?ocamlmklib_command:string ->
?ocamlmktop_command:string ->
?ocamldep_command:string ->
?ocamlbrowser_command:string ->
?ocamldoc_command:string ->
?ignore_dups_in:string ->
?stdlib:string ->
?ldconf:string ->
install_dir:string ->
meta_dir:string -> search_path:string list -> unit -> unit
val default_location : unit -> string
val meta_directory : unit -> string
""
if no such directory is configured.val search_path : unit -> string list
val command : [ `ocamlbrowser
| `ocamlc
| `ocamlcp
| `ocamldep
| `ocamldoc
| `ocamlmklib
| `ocamlmktop
| `ocamlopt
| `ocamloptp ] -> string
val ocaml_stdlib : unit -> string
val ocaml_ldconf : unit -> string
ld.conf
val package_directory : string -> string
Raises No_such_package
if the package cannot be found.
val ignore_dups_in : unit -> string option
Some d
, duplicate packages below d
are ignored, and do not
produce warnings. (Only affects the generation of warnings.)val package_property : string list -> string -> string -> string
package_property predlist pkg propname
:
Looks up the property propname
of package pkg
under the assumption
that the predicates in predlist
are true.
Raises No_such_package
if the package, and Not_found
if the property
cannot be found.
EXAMPLES:
package_property [] "p" "requires":
get the value of the requires
clause of package p
package_property [ "mt"; "byte" ] "p" "archive":
get the value of the archive
property of package p
for multi-
threaded bytecode applications.val package_property_2 : string list -> string -> string -> string * formal_pred list
package_property_2 predlist pkg propname
: This returns two values
(v, preds)
. The first one, v
, is computed as in package_property
.
The other list, preds
, contains the predicates that actually had to
be set or not set in order to select the particular variable definition.val package_ancestors : string list -> string -> string list
package_ancestors predlist pkg:
Determines the direct ancestors of package pkg
under the assumption
that the predicates in predlist
are true, i.e. the names of the
packages required by pkg
.
The returned list is unsorted.
Raises No_such_package
if the package pkg
or one of its ancestors
could not be found.
val package_deep_ancestors : string list -> string list -> string list
package_deep_ancestors predlist pkglist:
determines the list of direct or indirect ancestors of the packages
named in pkglist
under the assumption that the predicates in predlist
are true.
The returned list is topologically sorted: The first element is the
deepest ancestor; the last element is one of pkglist
.
Raises No_such_package
if one of the packages in pkglist
or one of
the ancestors cannot be found. Raises Package_loop
if there is a
cyclic dependency.
val resolve_path : ?base:string -> ?explicit:bool -> string -> string
+name/path
can be used to refer to the subdirectory name
of the standard library directory; the continuation /path
is
optional. The notation @name/path
can be used to refer to
the directory of the package name
; the continuation /path
is optional. For these two notations, absolute paths are returned.
base
: When the function is applied on a relative path, the
base
path is prepended. Otherwise, the path is returned as
it is.explicit
: Changes the meaning of base
so that only paths
count as relative that include at least one slash.val list_packages : ?tab:int -> ?descr:bool -> Pervasives.out_channel -> unit
out_channel
.
tab
: The tabulator width, by default 20descr
: Whether package descriptions are printed. Default: falsetype
rectype =
| |
Record_core |
(* | The package is part of the executable core | *) |
| |
Record_load |
(* | The package has been dynamically loaded | *) |
val record_package : rectype -> string -> unit
val record_package_predicates : string list -> unit
record_package_predicates
replaces the set of predicates that was
installed beforehand.val recorded_packages : rectype -> string list
record_package
val is_recorded_package : string -> bool
val type_of_recorded_package : string -> rectype
Not_found
val recorded_predicates : unit -> string list
val reset_recordings : unit -> unit
Record_load
packages from the list of recordings.
This forces that the packages are loaded again.