next up previous contents
Next: 6.2.5 Make Up: 6.2 Built-in tools Previous: 6.2.3 ML-Burg   Contents

6.2.4 Shell

The Shell tool can be used to specify arbitrary shell commands to be invoked on behalf of a given file. The name of the class is shell. There are no recognized file name suffixes. This means that in order to use the shell tool one must always specify the shell member class explicitly.

The rule for the shell class relies on tool parameters. The parameter list must be given in parentheses and follow the shell class specification.

Consider the following example:


  foo.pp : shell (target:foo.sml options:(shared)
                        /lib/cpp -P -Dbar=baz %s %t)

This member specification says that file foo.sml can be obtained from foo.pp by running it through the C preprocessor cpp. The fact that the target file is given as a tool parameter implies that the member itself is the source. The named parameter options lists the tool parameters to be used for that target. (In the example, the parentheses around shared are optional because it is the only element of the list.) The command line itself is given by the remaining non-keyword parameters. Here, a single %s is replaced by the source file name, and a single %t is replaced by the target file name; any other string beginning with % is shortened by its first character.

In the specification one can swap the positions of source and target (i.e., let the member name be the target) by using a source parameter:


  foo.sml : shell (source:foo.pp options:shared
                         /lib/cpp -P -Dbar=baz %s %t)

Exactly one of the source and target parameters must be specified; the other one is taken to be the member name itself. The target class can be given by writing a class parameter whose single sub-option must be the desired class name.

The usual distinction between native and standard filename syntax applies to any given source or target parameter.

For example, if one were working on a Win32 system and the target file is supposed to be in the root directory on volume D:, then one must use native syntax to write it. One way of doing this would be:


  "D:\\foo.sml" : shell (source : foo.pp options : shared
                               cpp -P -Dbar=baz %s %t)

As a result, foo.sml is interpreted using native syntax while foo.pp uses standard conventions (although in this case it does not make a difference). Had we used the target version from above, one would have to write:


  foo.pp : shell (target : "D:\\foo.sml" options : shared
                                 cpp -P -Dbar=baz %s %t)

The shell tool invokes its command whenever the target is outdated with respect to the source.


next up previous contents
Next: 6.2.5 Make Up: 6.2 Built-in tools Previous: 6.2.3 ML-Burg   Contents
Matthias Blume
2001-07-19