5.7.7 External execute
External commands, e.g. compilers, can be executed using the
External template:
external 'javac ' id '.java' execute
Again, all
output between external and execute keywords goes to building up the command to
be executed. For example, the command above would run a Java compiler on a .java
file named after the current object, e.g. ‘javac Stopwatch.java’.
Commands are executed immediately they are encountered, and the generator
continues executing without waiting for the command to return.
To block generator execution during the external command,
substitute the final execute command
with an executeBlocking command,
i.e.
external 'javac ' id '.java' executeBlocking
Note
that executeBlocking can only work for
programs, i.e. something that exists as an executable (e.g. .exe, .com or .bat
on Windows); execute also works with
URLs, documents, and internal DOS commands such as
mkdir. To use
executeBlocking for non-programs, you
can make a command that invokes the platform’s command processor or a
script like metarun. E.g. the following
would work in Windows:
external 'start "" cmd /x /c mkdir NEW' executeBlocking
A
useful resource for command processors, batch files and shell scripts is
www.ss64.com.