<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <link rel="Start" href="index.html"> <link rel="previous" href="Findlib.html"> <link rel="next" href="Fl_metascanner.html"> <link rel="Up" href="index.html"> <link title="Index of types" rel=Appendix href="index_types.html"> <link title="Index of exceptions" rel=Appendix href="index_exceptions.html"> <link title="Index of values" rel=Appendix href="index_values.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="Findlib" rel="Chapter" href="Findlib.html"> <link title="Fl_package_base" rel="Chapter" href="Fl_package_base.html"> <link title="Fl_metascanner" rel="Chapter" href="Fl_metascanner.html"> <link title="Topfind" rel="Chapter" href="Topfind.html"><link title="The package graph" rel="Section" href="#1_Thepackagegraph"> <link title="Parsing META files" rel="Section" href="#1_ParsingMETAfiles"> <title>The Findlib Library : Fl_package_base</title> </head> <body> <div class="navbar"><a href="Findlib.html">Previous</a> <a href="index.html">Up</a> <a href="Fl_metascanner.html">Next</a> </div> <center><h1>Module <a href="type_Fl_package_base.html">Fl_package_base</a></h1></center> <br> <pre><span class="keyword">module</span> Fl_package_base: <code class="code">sig</code> <a href="Fl_package_base.html">..</a> <code class="code">end</code></pre>Direct access to the package graph and package files<br> <hr width="100%"> <br><code><span class="keyword">type</span> <a name="TYPEpackage"></a><code class="type"></code>package = {</code><table class="typetable"> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>package_name : <code class="type">string</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The fully qualified package name, i.e. for subpackages the names of the containing packages are prepended and the name components are separated by '.'</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>package_dir : <code class="type">string</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The directory where to lookup package files</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>package_defs : <code class="type"><a href="Fl_metascanner.html#TYPEpkg_definition">Fl_metascanner.pkg_definition</a> list</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The definitions in the META file</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr></table> } <div class="info"> The definition of a package<br> </div> <pre><span class="keyword">val</span> <a name="VALinit"></a>init : <code class="type">string list -> string -> string option -> unit</code></pre><div class="info"> This function must be called before <code class="code">Fl_package_base</code> can be used. The first string corresponds to the <code class="code">OCAMLPATH</code> setting, the second string is the location of the standard library. <p> This function is called by <a href="Findlib.html#VALinit"><code class="code">Findlib.init</code></a> and <a href="Findlib.html#VALinit_manually"><code class="code">Findlib.init_manually</code></a>, so it is already sufficient to initialize the <code class="code">Findlib</code> module.<br> </div> <br> <a name="1_Thepackagegraph"></a> <h1>The package graph</h1><br> <br> The functions in this section operate on a representation of the package graph in memory. The graph is usually only partially available, as only packages are loaded that are queried for.<br> <pre><span class="keyword">exception</span> <a name="EXCEPTIONNo_such_package"></a>No_such_package <span class="keyword">of</span> <code class="type">string * string</code></pre> <div class="info"> First arg is the package name not found, second arg contains additional info for the user. - This is the same exception as in <code class="code">Findlib</code>.<br> </div> <pre><span class="keyword">exception</span> <a name="EXCEPTIONPackage_loop"></a>Package_loop <span class="keyword">of</span> <code class="type">string</code></pre> <div class="info"> A package is required by itself. The arg is the name of the package. - This is the same exception as in <code class="code">Findlib</code>.<br> </div> <pre><span class="keyword">val</span> <a name="VALquery"></a>query : <code class="type">string -> <a href="Fl_package_base.html#TYPEpackage">package</a></code></pre><div class="info"> Returns the <code class="code">package</code> definition for the fully-qualified package name, or raises <code class="code">No_such_package</code>. It is allowed to query for subpackages. <p> This function loads package definitions into the graph kept in memory.<br> </div> <pre><span class="keyword">val</span> <a name="VALrequires"></a>requires : <code class="type">preds:string list -> string -> string list</code></pre><div class="info"> Analyzes the direct requirements of the package whose name is passed as second argument under the assumption that the predicates <code class="code">preds</code> hold. The function returns the names of the required packages. It is checked whether these packages exist. <p> If there is the "mt" predicate, missing dependencies on "threads" are silently added. <p> The function may raise <code class="code">No_such_package</code> or <code class="code">Package_loop</code>. <p> This function loads package definitions into the graph kept in memory.<br> </div> <pre><span class="keyword">val</span> <a name="VALrequires_deeply"></a>requires_deeply : <code class="type">preds:string list -> string list -> string list</code></pre><div class="info"> Analyzes the direct or indirect requirements of the packages whose names are passed as second argument under the assumption that the predicates <code class="code">preds</code> hold. The function returns the names of the required packages. It is checked whether these packages exist. <p> If there is the "mt" predicate, missing dependencies on "threads" are silently added. <p> The function may raise <code class="code">No_such_package</code> or <code class="code">Package_loop</code>. <p> This function loads package definitions into the graph kept in memory.<br> </div> <pre><span class="keyword">val</span> <a name="VALpackage_conflict_report"></a>package_conflict_report : <code class="type">?identify_dir:(string -> 'a) -> unit -> unit</code></pre><div class="info"> Checks whether there are several META files for the same main packages. Complaints are printed to stderr. <p> Only packages in the loaded part of the package graph are checked (i.e. packages for which there was a query). <p> It is recommended to pass the ~identify_dir function whose task it is to return a unique value for every existing directory. For example, <pre><code class="code"> fun d -> let s = Unix.stat d in (s.Unix.st_dev, s.Unix.st_ino) </code></pre> could be an implementation for this function. The default is the identity (and not this nice implementation to avoid dependencies on the Unix module).<br> </div> <pre><span class="keyword">val</span> <a name="VALmodule_conflict_report"></a>module_conflict_report : <code class="type">?identify_dir:(string -> 'a) -> string list -> unit</code></pre><div class="info"> Checks whether there are cmi files for the same modules. The directories passed as first argument are checked. (Note: Neither the '+' nor the '@' notation are recognized.) Complaints about double cmi files are printed to stderr. <p> <br> </div> <div class="param_info"><code class="code">identify_dir</code> : See <code class="code">package_conflict_report</code>.</div> <pre><span class="keyword">val</span> <a name="VALload_base"></a>load_base : <code class="type">unit -> unit</code></pre><div class="info"> Ensures that the complete package graph is loaded into memory. This is a time-consuming operation. Warnings may be printed to stderr.<br> </div> <pre><span class="keyword">val</span> <a name="VALlist_packages"></a>list_packages : <code class="type">unit -> string list</code></pre><div class="info"> Ensures that the complete package graph is loaded into memory (like <code class="code">load_base</code>), and returns the (unsorted) list of all packages.<br> </div> <pre><span class="keyword">val</span> <a name="VALpackage_users"></a>package_users : <code class="type">preds:string list -> string list -> string list</code></pre><div class="info"> Ensures that the complete package graph is loaded into memory (like <code class="code">load_base</code>), and determines the packages using one of the packages passed as second argument. The <code class="code">preds</code> are assumed for the evaluation of the <code class="code">requires</code> directives. The returned list is sorted in ascending order. <p> If there is the "mt" predicate, missing dependencies on "threads" are silently added. <p> Raises <code class="code">No_such_package</code> if one of the passed packages cannot be found.<br> </div> <br> <a name="1_ParsingMETAfiles"></a> <h1>Parsing META files</h1><br> <br> The functions in this section access directly files and directories. The package graph is unknown.<br> <pre><span class="keyword">val</span> <a name="VALpackages_in_meta_file"></a>packages_in_meta_file : <code class="type">?directory_required:bool -><br> name:string -><br> dir:string -> meta_file:string -> unit -> <a href="Fl_package_base.html#TYPEpackage">package</a> list</code></pre><div class="info"> Parses the META file whose name is <code class="code">meta_file</code>. In <code class="code">name</code>, the name of the main package must be passed. <code class="code">dir</code> is the directory associated with the package by default (i.e. before it is overriden by the "directory" directive). <p> Returns the package records found in this file. The "directory" directive is already applied. <p> <br> </div> <div class="param_info"><code class="code">directory_required</code> : If true, it is checked whether there is a "directory" directive in the main package. If this directive is missing, the function will fail.</div> <pre><span class="keyword">val</span> <a name="VALpackage_definitions"></a>package_definitions : <code class="type">search_path:string list -> string -> string list</code></pre><div class="info"> Return all META files defining this package that occur in the directories mentioned in <code class="code">search_path</code>. The package name must be fully-qualified. For simplicity, however, only the name of the main package is taken into account (so it is a good idea to call this function only for main packages).<br> </div> </body></html>