The primary findlib interface
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.
First arg is the package name not found, second arg contains additional info for the user
A package is required by itself. The arg is the name of the package
Initializes the library from the configuration file and the environment.
By default the
function reads the file specified at compile time, but you can also
pass a different file name in the 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.This is an alternate way to initialize the library directly. Environment variables and configuration files are ignored.
Get the default installation directory for packages
Get the META installation directory for packages.
Returns ""
if no such directory is configured.
Get the search path for packages
Get the name/path of the executable
Get the directory of the standard library
Get the file name of ld.conf
Get the absolute path of the directory where the given package is stored.
Raises No_such_package
if the package cannot be found.
If Some d
, duplicate packages below d
are ignored, and do not
produce warnings. (Only affects the generation of warnings.)
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.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.
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.
Resolves findlib notation in filename paths. The notation
+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
path is prepended. Otherwise, the path is returned as
it is.
base
so that only paths
count as relative that include at least one slash.
Prints the list of available packages to the out_channel
.