command

Description

Execute a command with arguments. This is used inside a compilerstaticlibrarylinkerdynamiclibrarylinker or loadablemodulelinker task. On a windows platform the command is executed directy, on all other platforms the command is started using sh -c '<command+commandline>'. This makes it more scriptlike and the commandline parsing will work as expected (expanding *, proper grouping of arguments, etc).

The arguemtns given as nested elements are not separated as arguments formally. They are just evaluated and added as text to the total command line. The command line parsing is left to the command interpreter (except under windows).

Note: The working directory in which the commands will be executed depends on the launching task. It will be the output directory or the directory in which the target file is to be placed. This behaviour is intended as a help because some tools can't specify an output directory for multiple object files.

Parameters

Attribute Description Required
file This is the actual command to execute.  Specify either the full path, or rely on the command to be in the PATH environment variable.
Yes.

Parameters specified as nested elements

arg

Add constant arguments to the command line.

value

Add the value of an attribute from the launching task (compile, linklib or linkexe) to the command line.

switch

Use a switch-tag to add different arguments depending on the value of an attribute from the laumching task.

arglist

Add a list supplied by the launching task to the command line.

Examples

<command file="g++">
<arglist name="srcfiles"/>
</command>
This will run the command "g++" found on the PATH with the sourcefiles from the launching task (a compile task).
<command file="ar">
<arg value="rvs"/>
<value attribute="output" prefix="lib" suffix=".a "/>
<arglist name="objfiles"/>
</command>
This is an example which uses three kind of argument-tags when putting together the commandline nescessairy to run the command ar (on the PATH).

The actual arguments are not formal arguments, this means that the following commands are all eqvivalent:
<ommand file="cl.exe">
<arg value="/nologo"/>
<arg value="/EHsc"/>
<arglist name="srcfiles"/>
</command>

<ommand file="cl.exe">
<arg value="/nologo /EHsc"/>
<arglist name="srcfiles"/>
</command>

<ommand file="cl.exe /nologo /EHsc">
<arglist name="srcfiles"/>
</command>
The last example which really exploits the fact that arguments are reparsed upon execution might be useful sometimes when just one simple command is needed for housekeeping functions:
<ommand file="mv *.o x86"/>