next up previous contents
Next: 4.1.11 Finding all sources Up: 4.1 Structure CM Previous: 4.1.9 Plug-ins   Contents


4.1.10 Support for stand-alone programs

CM can be used to build stand-alone programs. In fact SML/NJ itself--including CM--is an example of this. (The interactive system cannot rely on an existing compilation manager when starting up.)

A stand-alone program is constructed by the runtime system from existing binfiles or members of existing stable libraries. CM must prepare those binfiles or libraries together with a list that describes them to the runtime system.


  val mk_standalone : bool option ->
                      { project: string, wrapper: string, target: string } ->
                      string list option

Here, project and wrapper name description files and target is the name of a heap image--with or without the usual implicit heap image suffix; see the description of SMLofNJ.exportFn from the (SML/NJ-specific extension of the) Basis Library [RG99].

A call of mk_standalone triggers the following three-stage procedure:

  1. Depending on the optional boolean argument, project is subjected to the equivalent of either CM.recomp or CM.stabilize. NONE means CM.recomp, and (SOME $r$) means CM.stabilize $r$. There are tree ways of how to continue from here:
    1. If recompilation of project failed, then a result of NONE will be returned immediately.
    2. If everything was up-to-date (i.e, if no ML source had to be compiled and all these sources were older than the existing target), then a result of SOME [] will be returned.
    3. Otherwise execution proceeds to the next stage.
  2. The wrapper library named by wrapper is being recompiled (using the equivalent of CM.recomp). If this fails, NONE is returned. Otherwise execution proceeds to the next stage.
  3. CM.mk_standalone constructs a topologically sorted list $l$ of strings that, when written to a file, can be passed to the runtime system in order to perform stand-alone linkage of the program given by wrapper. The final result is SOME $l$.

The idea is that project names the library that actually implements the main program while wrapper names an auxiliary wrapper library responsible for issuing a call of SMLofNJ.exportFn (generating target) on behalf of project.

The programmer should normally never have a need to invoke CM.mk_standalone directly. Instead, this function is used by an auxiliary script called ml-build (see Section 14.1).


next up previous contents
Next: 4.1.11 Finding all sources Up: 4.1 Structure CM Previous: 4.1.9 Plug-ins   Contents
Matthias Blume
2001-07-19