/* Not visualized: Compile Contiki immediately */
if (getIdentifier() == null) {
throw new MoteTypeCreationException("No identifier");
}
final MessageList compilationOutput = new MessageList();
if (getCompileCommands() != null) {
/* Handle multiple compilation commands one by one */
String[] arr = getCompileCommands().split("\n");
for (String cmd: arr) {
if (cmd.trim().isEmpty()) {
continue;
}
try {
CompileContiki.compile(
cmd,
null,
null /* Do not observe output firmware file */,
getContikiSourceFile().getParentFile(),
null,
null,
compilationOutput,
true
);
} catch (Exception e) {
MoteTypeCreationException newException =
new MoteTypeCreationException("Mote type creation failed: " + e.getMessage());
newException = (MoteTypeCreationException) newException.initCause(e);
newException.setCompilationOutput(compilationOutput);
/* Print last 10 compilation errors to console */
MessageContainer[] messages = compilationOutput.getMessages();
for (int i=messages.length-10; i < messages.length; i++) {
if (i < 0) {
continue;
}
logger.fatal(">> " + messages[i]);