next up previous contents
Next: 4.2 The autoloader Up: 4.1 Structure CM Previous: 4.1.10 Support for stand-alone   Contents


4.1.11 Finding all sources

The CM.sources function can be used to find the names of all source files that a given library depends on. It returns the names of all files involved with the exception of skeleton files and binfiles (see Section 10). Stable libraries are represented by their library file; their description file or consitutent members are not listed.

Normally, the function reports actual file names as used for accessing the file system. For (stable) library files this behavior can be inconvenient because these names depend on architecture and operating system. For this reason, CM.sources accepts an optional pair of strings that then will be used in place of the architecture- and OS-specific part of these names.


  val sources :
    { arch: string, os: string } option ->
    string ->
    { file: string, class: string, derived: bool } list option

In case there was some error analyzing the specified library or group, CM.sources returns NONE. Otherwise the result is a list of records, each carrying a file name, the corresponding class, and information about whether or not the source was created by some tool.

Examples:

generating ``make'' dependencies:
To generate dependency information usable by Unix' make command, one would be interested in all files that were not derived by some tool application. Moreover, one would probably like to use shell variables instead of concrete architecture- and OS-names:

  Option.map (List.filter (not o #derived))
    (CM.sources (SOME { arch = "$ARCH", os = "$OPSYS" })
         "foo.cm");
A call of CM.sources similar to the one shown here is used by the auxiliary script ml-makedepend (see Section 14.2).
finding all noweb sources:
To find all noweb sources (see Section 6.2.6), e.g., to be able to run the document preparation program noweave on them, one can simply look for entries of the noweb class. Here, one would probably want to include derived sources:

  Option.map (List.filter (fn x => #class x = "noweb"))
    (CM.sources NONE "foo.cm");


next up previous contents
Next: 4.2 The autoloader Up: 4.1 Structure CM Previous: 4.1.10 Support for stand-alone   Contents
Matthias Blume
2001-07-19