| |||
| Home > ARM Project Manager > Build step patterns > Specifying input and output patterns in a build step pattern | |||
A build step pattern uses simple pattern expressions to describe:
the inputs to which it can be applied
the outputs it generates
the command-line options that are used to generate those outputs.
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.
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.
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:
<path><slash|/><file>.c
supplied with the string
myfile.c
sets the variables to the following values:
path = "" slash = "" file = "myfile"
and the same input pattern element supplied with the string:
c:\projdir\myproj\myfile.c
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 \.
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:
<""|-I>""
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:
<"c:\projdir\myproj"|-I>"c:\projdir\myproj"
resulting in a final value of:
"-Ic:\projdir\myproj".
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:
<file>.o
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>.