|
Packit |
b513ef |
(* $Id$
|
|
Packit |
b513ef |
* ----------------------------------------------------------------------
|
|
Packit |
b513ef |
*
|
|
Packit |
b513ef |
*)
|
|
Packit |
b513ef |
|
|
Packit |
b513ef |
(** Load packages from toploops and scripts
|
|
Packit |
b513ef |
*
|
|
Packit |
b513ef |
* The [Topfind] module is part of the [findlib] package. The module
|
|
Packit |
b513ef |
* depends on the presence of a toploop. When building a toploop, it is
|
|
Packit |
b513ef |
* automatically linked in if "findlib" is linked in, e.g.
|
|
Packit |
b513ef |
* {[
|
|
Packit |
b513ef |
* ocamlfind ocamlmktop ...options... -package findlib -linkpkg
|
|
Packit |
b513ef |
* ]}
|
|
Packit |
b513ef |
*
|
|
Packit |
b513ef |
* When the platform supports DLLs, another possibility to get a toploop
|
|
Packit |
b513ef |
* with findlib directives is to load the file "topfind" (normally installed
|
|
Packit |
b513ef |
* in the standard library directory):
|
|
Packit |
b513ef |
* {[
|
|
Packit |
b513ef |
* $ ocaml
|
|
Packit |
b513ef |
* Objective Caml version 3.04
|
|
Packit |
b513ef |
* # #use "topfind";;
|
|
Packit |
b513ef |
* Findlib has been successfully loaded. Additional directives:
|
|
Packit |
b513ef |
* #require "package";; to load a package
|
|
Packit |
b513ef |
* #list;; to list the available packages
|
|
Packit |
b513ef |
* #camlp4o;; to load camlp4 (standard syntax)
|
|
Packit |
b513ef |
* #camlp4r;; to load camlp4 (revised syntax)
|
|
Packit |
b513ef |
* Topfind.reset();; to force that packages will be reloaded
|
|
Packit |
b513ef |
* ~ : unit = ()
|
|
Packit |
b513ef |
* # _
|
|
Packit |
b513ef |
* ]}
|
|
Packit |
b513ef |
*
|
|
Packit |
b513ef |
* This works even in scripts (but the startup message is suppressed in this
|
|
Packit |
b513ef |
* case).
|
|
Packit |
b513ef |
*
|
|
Packit |
b513ef |
* The module is not thread-safe; if used in a multi-threaded script, all
|
|
Packit |
b513ef |
* packgage loading must have happened before the first thread forks.
|
|
Packit |
b513ef |
*
|
|
Packit |
b513ef |
* The Topfind module contains some functions simplifying package loading
|
|
Packit |
b513ef |
* in scripts. Most important, there is a new directive [#require] for
|
|
Packit |
b513ef |
* the same purpose (see below).
|
|
Packit |
b513ef |
*
|
|
Packit |
b513ef |
* The [Topfind] module needs some initialization, in particular the
|
|
Packit |
b513ef |
* [predicates] variable needs to be
|
|
Packit |
b513ef |
* set, and the packages already compiled into the toploop needs to be
|
|
Packit |
b513ef |
* declared by the [don't_load]
|
|
Packit |
b513ef |
* function. If the toploop has been built by [ocamlfind],
|
|
Packit |
b513ef |
* the necessary initialization is
|
|
Packit |
b513ef |
* automatically compiled in.
|
|
Packit |
b513ef |
*)
|
|
Packit |
b513ef |
|
|
Packit |
b513ef |
(** {1 Directives}
|
|
Packit |
b513ef |
*
|
|
Packit |
b513ef |
* This module also defines the following directives for the toploop:
|
|
Packit |
b513ef |
*
|
|
Packit |
b513ef |
* - [#require "<package>"]
|
|
Packit |
b513ef |
* loads the package (and if necessary the prerequisites of the package)
|
|
Packit |
b513ef |
* - [#camlp4o]
|
|
Packit |
b513ef |
* loads camlp4 and selects standard syntax
|
|
Packit |
b513ef |
* - [#camlp4r]
|
|
Packit |
b513ef |
* loads camlp4 and selects revised syntax
|
|
Packit |
b513ef |
* - [#list]
|
|
Packit |
b513ef |
* lists the available packages (calls external command "ocamlfind")
|
|
Packit |
b513ef |
* - [#thread]
|
|
Packit |
b513ef |
* enables multi-threading if possible
|
|
Packit |
b513ef |
* - [#predicates "p1,p2,..."]
|
|
Packit |
b513ef |
* adds these predicates
|
|
Packit |
b513ef |
*)
|
|
Packit |
b513ef |
|
|
Packit |
b513ef |
(** {1 Functions and variables} *)
|
|
Packit |
b513ef |
|
|
Packit |
b513ef |
val predicates : string list ref
|
|
Packit |
b513ef |
(** The list of predicates used for package loading *)
|
|
Packit |
b513ef |
|
|
Packit |
b513ef |
val add_predicates : string list -> unit
|
|
Packit |
b513ef |
(** Adds predicates to the list of predicates *)
|
|
Packit |
b513ef |
|
|
Packit |
b513ef |
val syntax : string -> unit
|
|
Packit |
b513ef |
(** Emulates the [-syntax] option *)
|
|
Packit |
b513ef |
|
|
Packit |
b513ef |
val standard_syntax : unit -> unit
|
|
Packit |
b513ef |
(** Adds predicates that select the standard syntax. Same as
|
|
Packit |
b513ef |
* [syntax "camlp4o"]
|
|
Packit |
b513ef |
*)
|
|
Packit |
b513ef |
|
|
Packit |
b513ef |
val revised_syntax : unit -> unit
|
|
Packit |
b513ef |
(** Adds predicates that select the revised syntax. Same as
|
|
Packit |
b513ef |
* [syntax "camlp4r"]
|
|
Packit |
b513ef |
*)
|
|
Packit |
b513ef |
|
|
Packit |
b513ef |
val don't_load : string list -> unit
|
|
Packit |
b513ef |
(** The packages named in pkglist are added to the list of packages which
|
|
Packit |
b513ef |
* are already loaded.
|
|
Packit |
b513ef |
*)
|
|
Packit |
b513ef |
|
|
Packit |
b513ef |
val don't_load_deeply : string list -> unit
|
|
Packit |
b513ef |
(** The packages named in pkglist and all direct and indirect ancestors
|
|
Packit |
b513ef |
* are added to the list of packages which are already loaded.
|
|
Packit |
b513ef |
*)
|
|
Packit |
b513ef |
|
|
Packit |
b513ef |
val load : string list -> unit
|
|
Packit |
b513ef |
(** The packages from the passed package list are loaded, from left to
|
|
Packit |
b513ef |
* right, but packages that have already been loaded are left out.
|
|
Packit |
b513ef |
*)
|
|
Packit |
b513ef |
|
|
Packit |
b513ef |
val load_deeply : string list -> unit
|
|
Packit |
b513ef |
(** The packages from the passed package list and all direct or indirect
|
|
Packit |
b513ef |
* ancestors are loaded in topological order. Packages that have already
|
|
Packit |
b513ef |
* been loaded are left out.
|
|
Packit |
b513ef |
*)
|
|
Packit |
b513ef |
|
|
Packit |
b513ef |
val reset : unit -> unit
|
|
Packit |
b513ef |
(** All entries in the list of loaded packages that have been added by
|
|
Packit |
b513ef |
* [load] or [load_deeply] functions are removed from this list. This
|
|
Packit |
b513ef |
* means that if you execute the same [load] or [load_deeply] functions
|
|
Packit |
b513ef |
* again, the packages will be reloaded.
|
|
Packit |
b513ef |
*)
|
|
Packit |
b513ef |
|
|
Packit |
b513ef |
val announce : unit -> unit
|
|
Packit |
b513ef |
(** Output the startup message *)
|
|
Packit |
b513ef |
|
|
Packit |
b513ef |
val log : (string -> unit) ref
|
|
Packit |
b513ef |
(** Function used to log messages from this module. *)
|