2.9.1. Specifying input and output patterns in a build step pattern

A build step pattern uses simple pattern expressions to describe:

When you add a file to a project, APM searches for an input pattern expression to match the filename. If a match is found, the pattern variables used in the input pattern become defined and are used to generate output filenames. When the project is built, the same pattern variables are used to generate command-lines for the tools invoked by the build step pattern.

Input pattern expressions

An input pattern can contain three kinds of pattern element:


written as <name>, that matches any sequence of characters not containing the next literal.


written as is, that matches only itself.

Conditional literal

written as <name|literal> that either:

  • matches and <name> takes on the value of the literal

  • fails to match and <name> takes on the value "" (null).

Patterns match from right to left, and / in a pattern matches / or \ in the filename.

For example, the input pattern element:


supplied with the string


sets the variables to the following values:

path = ""
slash = ""
file = "myfile"

and the same input pattern element supplied with the string:


sets the variables to the following values:

path = "c:\projdir\myproj"
slash = "\"
file = "myfile"


An input pattern element <path>\<file>.c does not recognize the string myfile.c because the string does not contain the specified literal \.

Output and command-line pattern expressions

An output or command-line pattern can use a mixture of pattern variables, conditional literals and literals. The variables are those matched in the input pattern expressions or defined within the project.

For example, the output pattern element <path|-I><path> consists of the pattern variable and conditional literal -I (defined only if the pattern variable <path> is non-empty) followed by the pattern variable <path> value.

When given with the filename myfile.c this expression resolves to "" (a null string). When given with the fully qualified filename -I c:\projdir\myproj\myfile.c the expression resolves to -Ic:\projdir\myproj because in the first case the input pattern variable <path> is set to "", so the output pattern element <path|-I><path> becomes:


which produces:


resulting in a final value of:


In the case of the fully qualified filename, the input pattern variable <path> is set to "c:\projdir\myproj", so the output pattern element <path|-I><path> becomes:


resulting in a final value of:


Outputs and command-lines can refer to variables not used in an input pattern. A typical example is:

<tool> -o <file>.o ... <TOOLFLAGS> ...

If the variable <TOOLFLAGS> is defined within the project, its value is used, otherwise it is ignored.

A more typical output expression is:


A command-line expression might be {path|<path|-I><path>} denoting the set of values accumulated from the expression discussed above.


The first variable on a command-line is treated differently. Its default value is its name. APM insists that the name of a tool must be a variable. So, if you want to call armcc, you must enter <armcc>.

Copyright © 1997, 1998 ARM Limited. All rights reserved.ARM DUI 0040D