print compilation errors to console
This commit is contained in:
parent
37fa4da899
commit
83e97ecfba
1 changed files with 21 additions and 16 deletions
|
@ -26,7 +26,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: MspMoteType.java,v 1.8 2008/09/18 14:14:58 fros4943 Exp $
|
* $Id: MspMoteType.java,v 1.9 2008/09/20 08:05:07 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.mspmote;
|
package se.sics.cooja.mspmote;
|
||||||
|
@ -237,6 +237,16 @@ public abstract class MspMoteType implements MoteType {
|
||||||
newException = (MoteTypeCreationException) newException.initCause(e);
|
newException = (MoteTypeCreationException) newException.initCause(e);
|
||||||
newException.setCompilationOutput(compilationOutput);
|
newException.setCompilationOutput(compilationOutput);
|
||||||
|
|
||||||
|
if (compilationOutput != null) {
|
||||||
|
try { Thread.sleep(500); } catch (InterruptedException ignore) { }
|
||||||
|
ListModel tmp = compilationOutput.getModel();
|
||||||
|
for (int i=tmp.getSize()-5; i < tmp.getSize(); i++) {
|
||||||
|
if (i < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
logger.fatal(">> " + tmp.getElementAt(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
logger.fatal("Compilation error: " + e.getMessage());
|
logger.fatal("Compilation error: " + e.getMessage());
|
||||||
throw newException;
|
throw newException;
|
||||||
}
|
}
|
||||||
|
@ -456,10 +466,8 @@ public abstract class MspMoteType implements MoteType {
|
||||||
final BufferedReader processError = new BufferedReader(
|
final BufferedReader processError = new BufferedReader(
|
||||||
new InputStreamReader(compileProcess.getErrorStream()));
|
new InputStreamReader(compileProcess.getErrorStream()));
|
||||||
|
|
||||||
final PrintStream listNormal = compilationOutput
|
final PrintStream listNormal = compilationOutput.getInputStream(MessageList.NORMAL);
|
||||||
.getInputStream(MessageList.NORMAL);
|
final PrintStream listError = compilationOutput.getInputStream(MessageList.ERROR);
|
||||||
final PrintStream listError = compilationOutput
|
|
||||||
.getInputStream(MessageList.ERROR);
|
|
||||||
|
|
||||||
final File ELFFile = new File(parentDirectory, filenameNoExtension + firmwareFileExtension);
|
final File ELFFile = new File(parentDirectory, filenameNoExtension + firmwareFileExtension);
|
||||||
if (ELFFile.exists()) {
|
if (ELFFile.exists()) {
|
||||||
|
@ -476,13 +484,11 @@ public abstract class MspMoteType implements MoteType {
|
||||||
|
|
||||||
Thread readInput = new Thread(new Runnable() {
|
Thread readInput = new Thread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
String readLine;
|
|
||||||
try {
|
try {
|
||||||
|
String readLine;
|
||||||
while ((readLine = processNormal.readLine()) != null) {
|
while ((readLine = processNormal.readLine()) != null) {
|
||||||
if (listNormal != null && readLine != null) {
|
|
||||||
listNormal.println(readLine);
|
listNormal.println(readLine);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Error while reading from process");
|
logger.warn("Error while reading from process");
|
||||||
}
|
}
|
||||||
|
@ -491,13 +497,11 @@ public abstract class MspMoteType implements MoteType {
|
||||||
|
|
||||||
Thread readError = new Thread(new Runnable() {
|
Thread readError = new Thread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
String readLine;
|
|
||||||
try {
|
try {
|
||||||
|
String readLine;
|
||||||
while ((readLine = processError.readLine()) != null) {
|
while ((readLine = processError.readLine()) != null) {
|
||||||
if (listError != null && readLine != null) {
|
|
||||||
listError.println(readLine);
|
listError.println(readLine);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Error while reading from process");
|
logger.warn("Error while reading from process");
|
||||||
}
|
}
|
||||||
|
@ -513,6 +517,7 @@ public abstract class MspMoteType implements MoteType {
|
||||||
try {
|
try {
|
||||||
compileProcess.waitFor();
|
compileProcess.waitFor();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
listError.println(e.getMessage());
|
||||||
syncException.setCompilationOutput(new MessageList());
|
syncException.setCompilationOutput(new MessageList());
|
||||||
syncException.fillInStackTrace();
|
syncException.fillInStackTrace();
|
||||||
return;
|
return;
|
||||||
|
@ -520,8 +525,7 @@ public abstract class MspMoteType implements MoteType {
|
||||||
|
|
||||||
/* Check return value */
|
/* Check return value */
|
||||||
if (compileProcess.exitValue() != 0) {
|
if (compileProcess.exitValue() != 0) {
|
||||||
listError.println("Process returned error code "
|
listError.println("Process returned error code " + compileProcess.exitValue());
|
||||||
+ compileProcess.exitValue());
|
|
||||||
if (failAction != null) {
|
if (failAction != null) {
|
||||||
failAction.actionPerformed(null);
|
failAction.actionPerformed(null);
|
||||||
}
|
}
|
||||||
|
@ -563,9 +567,10 @@ public abstract class MspMoteType implements MoteType {
|
||||||
"Compilation error: " + e.getMessage()).initCause(e);
|
"Compilation error: " + e.getMessage()).initCause(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Detect error manually */
|
||||||
if (syncException.hasCompilationOutput()) {
|
if (syncException.hasCompilationOutput()) {
|
||||||
throw (MoteTypeCreationException) new MoteTypeCreationException(
|
throw (MoteTypeCreationException) new MoteTypeCreationException(
|
||||||
"Compilation error").initCause(syncException);
|
"Bad return value").initCause(syncException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue