[yocto] [eclipse][PATCH 4/4] plugins/cmake: Add cmake error message to error dialog

Timo Mueller mail at timomueller.eu
Thu May 22 02:58:22 PDT 2014


From: Timo Mueller <timo.mueller at bmw-carit.de>

In case cmake reported an error during project configuration the
resulting error dialog showed a generic 'build failed' message. The
specific error message which can help the user find the problem was
hidden in cmake console.

Along with logging the cmake error to the configure console it is now also
captured and added to the error dialog.

[BUGFIX #6313]

Signed-off-by: Timo Mueller <timo.mueller at bmw-carit.de>
---
 .../yocto/cmake/managedbuilder/YoctoCMakeMessages.properties  |  2 +-
 .../yocto/cmake/managedbuilder/job/ExecuteConfigureJob.java   | 11 +++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/YoctoCMakeMessages.properties b/plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/YoctoCMakeMessages.properties
index 55773ac..651ace5 100644
--- a/plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/YoctoCMakeMessages.properties
+++ b/plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/YoctoCMakeMessages.properties
@@ -15,7 +15,7 @@ ExecuteConfigureJob.consoleName=Configure using CMake [{0}]
 ExecuteConfigureJob.buildingMakefile=Building Makefile
 ExecuteConfigureJob.warning.aborted=Build of project has been aborted
 ExecuteConfigureJob.error.couldNotStart=Build of project could not be started
-ExecuteConfigureJob.error.buildFailed=Build of project failed
+ExecuteConfigureJob.error.buildFailed=Build of project failed with the following error:\n{0}
 ExecuteConfigureJob.cmakeWarning.dialogTitle=Unable to run command "cmake"
 ExecuteConfigureJob.cmakeWarning.dialogMessage=Please make sure that cmake is installed properly on this machine.
 
diff --git a/plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/job/ExecuteConfigureJob.java b/plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/job/ExecuteConfigureJob.java
index f90a2d7..84e8c62 100644
--- a/plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/job/ExecuteConfigureJob.java
+++ b/plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/job/ExecuteConfigureJob.java
@@ -10,6 +10,7 @@
  *******************************************************************************/
 package org.yocto.cmake.managedbuilder.job;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Arrays;
@@ -124,10 +125,11 @@ public class ExecuteConfigureJob extends Job {
 		IOConsoleOutputStream cos =
 				ConsoleUtility.getConsoleOutput(YoctoCMakeMessages.getFormattedString("ExecuteConfigureJob.consoleName", //$NON-NLS-1$
 						project.getName()));
+		ByteArrayOutputStream ces = new ByteArrayOutputStream();
 		monitor.worked(1);
 
 		try {
-			return buildProject(monitor, cos);
+			return buildProject(monitor, cos, ces);
 		} catch (IOException e) {
 			if(e.getMessage().startsWith("Cannot run program \"cmake\"")) { //$NON-NLS-1$
 				Display.getDefault().asyncExec(new Runnable() {
@@ -158,16 +160,17 @@ public class ExecuteConfigureJob extends Job {
 	}
 
 	private IStatus buildProject(IProgressMonitor monitor,
-			OutputStream cos) throws IOException, InterruptedException {
+			OutputStream stdout, OutputStream stderr) throws IOException, InterruptedException {
 		monitor.subTask(
 				YoctoCMakeMessages.getString("ExecuteConfigureJob.buildingMakefile")); //$NON-NLS-1$
-		configureProcess.start(cos);
+		configureProcess.start(stdout, stderr);
 		int exitValue = configureProcess.waitForResultAndStop();
 		monitor.worked(15);
 
 		if (exitValue != 0) {
 			return new Status(Status.ERROR, Activator.PLUGIN_ID,
-					YoctoCMakeMessages.getString("ExecuteConfigureJob.error.buildFailed") + " " + exitValue); //$NON-NLS-1$ //$NON-NLS-2$
+					YoctoCMakeMessages.getFormattedString("ExecuteConfigureJob.error.buildFailed", //$NON-NLS-1$
+															stderr.toString().trim()));
 		}
 
 		return Status.OK_STATUS;
-- 
1.9.0




More information about the yocto mailing list