From 3ca4a76b93bc6eeb24b4688f1a12c4ec97ae21ca Mon Sep 17 00:00:00 2001 From: Mikhail Sennikovsky Date: Fri, 12 May 2006 19:46:24 +0000 Subject: [PATCH] 1. About.html update for the managed builder plug-ins 2. Enhanced error handling for Internal Builder invokation 3. The message is displayed now when the Internal Builder has nothing to build --- .../about.html | 32 ++-- .../about.html | 32 ++-- .../buildmodel/DescriptionBuilder.java | 53 ++++-- .../core/GeneratedMakefileBuilder.java | 155 ++++++++++-------- .../internal/core/PluginResources.properties | 1 + .../about.html | 32 ++-- .../about.html | 32 ++-- .../about.html | 32 ++-- 8 files changed, 215 insertions(+), 154 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/about.html b/build/org.eclipse.cdt.managedbuilder.core.tests/about.html index 04f07e6858e..9c7ba0a57bc 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/about.html +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/about.html @@ -1,22 +1,24 @@ - - - -About - - + + +About +

About This Content

-

June 17, 2005

+

May 2, 2006

License

-

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

+

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

-

If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content.

+

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

- - \ No newline at end of file + \ No newline at end of file diff --git a/build/org.eclipse.cdt.managedbuilder.core/about.html b/build/org.eclipse.cdt.managedbuilder.core/about.html index 04f07e6858e..9c7ba0a57bc 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/about.html +++ b/build/org.eclipse.cdt.managedbuilder.core/about.html @@ -1,22 +1,24 @@ - - - -About - - + + +About +

About This Content

-

June 17, 2005

+

May 2, 2006

License

-

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

+

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

-

If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content.

+

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

- - \ No newline at end of file + \ No newline at end of file diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/DescriptionBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/DescriptionBuilder.java index 1c8a8fa267d..178263ce5b8 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/DescriptionBuilder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/DescriptionBuilder.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.managedbuilder.internal.buildmodel; +import java.io.IOException; import java.io.OutputStream; import java.util.HashMap; import java.util.Map; @@ -18,6 +19,7 @@ import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager; import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription; import org.eclipse.cdt.managedbuilder.buildmodel.IBuildStep; import org.eclipse.cdt.managedbuilder.buildmodel.IStepVisitor; +import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -36,6 +38,11 @@ import org.eclipse.core.runtime.SubProgressMonitor; * */ public class DescriptionBuilder implements IBuildModelBuilder { + private static final String BUILDER_MSG_HEADER = "InternalBuilder.msg.header"; //$NON-NLS-1$ + private static final String BUILDER_NOTHING_TODO = "InternalBuilder.nothing.todo"; //$NON-NLS-1$ + private static final String LINE_SEPARATOR = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ + + private IBuildDescription fDes; private IPath fCWD; private boolean fBuildIncrementaly; @@ -133,21 +140,34 @@ public class DescriptionBuilder implements IBuildModelBuilder { public int build(OutputStream out, OutputStream err, IProgressMonitor monitor){ + int num = getNumCommands(); + int status = STATUS_OK; + //TODO: should we specify some task name here? - monitor.beginTask("", getNumCommands()); //$NON-NLS-1$ + monitor.beginTask("", num > 0 ? num : 1); //$NON-NLS-1$ monitor.subTask(""); //$NON-NLS-1$ - - BuildStepVisitor visitor = new BuildStepVisitor(out, err, monitor); - try { - BuildDescriptionManager.accept(visitor, - fDes, true); - } catch (CoreException e) { - return STATUS_ERROR_LAUNCH; + + if(num > 0){ + BuildStepVisitor visitor = new BuildStepVisitor(out, err, monitor); + try { + BuildDescriptionManager.accept(visitor, + fDes, true); + } catch (CoreException e) { + status = STATUS_ERROR_LAUNCH; + } + + if(status == STATUS_OK) + status = visitor.fStatus; + } else { + printMessage( + ManagedMakeMessages.getFormattedString(BUILDER_NOTHING_TODO, + fDes.getConfiguration().getOwner().getName()), + out); } - + monitor.done(); - - return visitor.fStatus; + + return status; } public int getNumCommands() { @@ -175,4 +195,15 @@ public class DescriptionBuilder implements IBuildModelBuilder { return b; } + protected void printMessage(String msg, OutputStream os){ + if (os != null) { + msg = ManagedMakeMessages.getFormattedString(BUILDER_MSG_HEADER, msg) + LINE_SEPARATOR; + try { + os.write(msg.getBytes()); + os.flush(); + } catch (IOException e) { + // ignore; + } + } + } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java index 8abf172ffc8..3ba2b3f361e 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java @@ -1205,6 +1205,9 @@ public class GeneratedMakefileBuilder extends ACBuilder { monitor.beginTask("", 1000); //$NON-NLS-1$ monitor.subTask(ManagedMakeMessages.getFormattedString(MAKE, msgs)); + ConsoleOutputStream consoleOutStream = null; + IConsole console = null; + OutputStream epmOutputStream = null; try { int flags = 0; IResourceDelta delta = null; @@ -1220,9 +1223,9 @@ public class GeneratedMakefileBuilder extends ACBuilder { // Get a build console for the project StringBuffer buf = new StringBuffer(); - IConsole console = CCorePlugin.getDefault().getConsole(); + console = CCorePlugin.getDefault().getConsole(); console.start(currentProject); - ConsoleOutputStream consoleOutStream = console.getOutputStream(); + consoleOutStream = console.getOutputStream(); String[] consoleHeader = new String[3]; if(buildIncrementaly) consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC); @@ -1246,80 +1249,96 @@ public class GeneratedMakefileBuilder extends ACBuilder { } consoleOutStream.write(buf.toString().getBytes()); consoleOutStream.flush(); + + if(builder.getNumCommands() > 0) { + // Remove all markers for this project + removeAllMarkers(currentProject); - // Remove all markers for this project - removeAllMarkers(currentProject); - - // Hook up an error parser manager - String[] errorParsers = cfg.getErrorParserList(); - ErrorParserManager epm = new ErrorParserManager(getProject(), des.getDefaultBuildDirLocation(), this, errorParsers); - epm.setOutputStream(consoleOutStream); - // This variable is necessary to ensure that the EPM stream stay open - // until we explicitly close it. See bug#123302. - OutputStream epmOutputStream = epm.getOutputStream(); - - int status = builder.build(epmOutputStream, epmOutputStream, new SubProgressMonitor(monitor, 1000)); - - //no refresh is needed since the builder now performs - //a refresh automatically after each build step -/* monitor.subTask(ManagedMakeMessages - .getResourceString(REFRESH)); - try { - currentProject.refreshLocal( - IResource.DEPTH_INFINITE, null); - } catch (CoreException e) { + // Hook up an error parser manager + String[] errorParsers = cfg.getErrorParserList(); + ErrorParserManager epm = new ErrorParserManager(getProject(), des.getDefaultBuildDirLocation(), this, errorParsers); + epm.setOutputStream(consoleOutStream); + // This variable is necessary to ensure that the EPM stream stay open + // until we explicitly close it. See bug#123302. + epmOutputStream = epm.getOutputStream(); + + int status = builder.build(epmOutputStream, epmOutputStream, new SubProgressMonitor(monitor, 1000)); + + // Report either the success or failure of our mission + buf = new StringBuffer(); + + switch(status){ + case IBuildModelBuilder.STATUS_OK: + buf.append(ManagedMakeMessages + .getFormattedString(BUILD_FINISHED, + currentProject.getName())); + break; + case IBuildModelBuilder.STATUS_CANCELLED: + buf.append(ManagedMakeMessages + .getResourceString(BUILD_CANCELLED)); + break; + case IBuildModelBuilder.STATUS_ERROR_BUILD: + String msg = resumeOnErr ? + ManagedMakeMessages.getResourceString(BUILD_FINISHED_WITH_ERRS) : + ManagedMakeMessages.getResourceString(BUILD_STOPPED_ERR); + buf.append(msg); + break; + case IBuildModelBuilder.STATUS_ERROR_LAUNCH: + default: + buf.append(ManagedMakeMessages + .getResourceString(BUILD_FAILED_ERR)); + break; + } + buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$ + + // Write message on the console + consoleOutStream.write(buf.toString().getBytes()); + consoleOutStream.flush(); + epmOutputStream.close(); + epmOutputStream = null; + // Generate any error markers that the build has discovered monitor.subTask(ManagedMakeMessages - .getResourceString(REFRESH_ERROR)); + .getResourceString(MARKERS)); + addBuilderMarkers(epm); + epm.reportProblems(); + } else { + buf = new StringBuffer(); + buf.append(ManagedMakeMessages.getFormattedString(NOTHING_BUILT, getProject().getName())); + buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$ + consoleOutStream.write(buf.toString().getBytes()); + consoleOutStream.flush(); } -*/ - // Report either the success or failure of our mission - buf = new StringBuffer(); - - switch(status){ - case IBuildModelBuilder.STATUS_OK: - buf.append(ManagedMakeMessages - .getFormattedString(BUILD_FINISHED, - currentProject.getName())); - break; - case IBuildModelBuilder.STATUS_CANCELLED: - buf.append(ManagedMakeMessages - .getResourceString(BUILD_CANCELLED)); - break; - case IBuildModelBuilder.STATUS_ERROR_BUILD: - String msg = resumeOnErr ? - ManagedMakeMessages.getResourceString(BUILD_FINISHED_WITH_ERRS) : - ManagedMakeMessages.getResourceString(BUILD_STOPPED_ERR); - buf.append(msg); - break; - case IBuildModelBuilder.STATUS_ERROR_LAUNCH: - default: - buf.append(ManagedMakeMessages - .getResourceString(BUILD_FAILED_ERR)); - break; - } - buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$ - // Write message on the console - consoleOutStream.write(buf.toString().getBytes()); - consoleOutStream.flush(); - epmOutputStream.close(); - - // Generate any error markers that the build has discovered - monitor.subTask(ManagedMakeMessages - .getResourceString(MARKERS)); - addBuilderMarkers(epm); - epm.reportProblems(); - consoleOutStream.close(); } catch (Exception e) { - StringBuffer buf = new StringBuffer(); - String errorDesc = ManagedMakeMessages - .getResourceString(BUILD_ERROR); - buf.append(errorDesc); - buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$ - buf.append("(").append(e.getLocalizedMessage()).append(")"); //$NON-NLS-1$ //$NON-NLS-2$ + if(consoleOutStream != null){ + StringBuffer buf = new StringBuffer(); + String errorDesc = ManagedMakeMessages + .getResourceString(BUILD_ERROR); + buf.append(errorDesc); + buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$ + buf.append("(").append(e.getLocalizedMessage()).append(")"); //$NON-NLS-1$ //$NON-NLS-2$ + buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$ + try { + consoleOutStream.write(buf.toString().getBytes()); + consoleOutStream.flush(); + } catch (IOException e1) { + } + } forgetLastBuiltState(); } finally { + if(epmOutputStream != null){ + try { + epmOutputStream.close(); + } catch (IOException e) { + } + } + if(consoleOutStream != null){ + try { + consoleOutStream.close(); + } catch (IOException e) { + } + } getGenerationProblems().clear(); monitor.done(); } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties index dfcf3119a00..ccc5bcd0bb2 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties @@ -128,6 +128,7 @@ ManagedBuilderCorePlugin.resourceChangeHandlingInitializationJob=Initializing Re #Internal Builder messages InternalBuilder.msg.header=Internal Builder: {0} +InternalBuilder.nothing.todo=Nothing to be done for project {0} CleanFilesAction.cleanFiles=Clean File(s) CleanFilesAction.cleanSelectedFiles=Clean the selected file(s). CleanFilesAction.cleaningFiles=Cleaning files diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/about.html b/build/org.eclipse.cdt.managedbuilder.gnu.ui/about.html index 04f07e6858e..9c7ba0a57bc 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/about.html +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/about.html @@ -1,22 +1,24 @@ - - - -About - - + + +About +

About This Content

-

June 17, 2005

+

May 2, 2006

License

-

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

+

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

-

If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content.

+

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

- - \ No newline at end of file + \ No newline at end of file diff --git a/build/org.eclipse.cdt.managedbuilder.ui.tests/about.html b/build/org.eclipse.cdt.managedbuilder.ui.tests/about.html index 04f07e6858e..9c7ba0a57bc 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui.tests/about.html +++ b/build/org.eclipse.cdt.managedbuilder.ui.tests/about.html @@ -1,22 +1,24 @@ - - - -About - - + + +About +

About This Content

-

June 17, 2005

+

May 2, 2006

License

-

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

+

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

-

If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content.

+

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

- - \ No newline at end of file + \ No newline at end of file diff --git a/build/org.eclipse.cdt.managedbuilder.ui/about.html b/build/org.eclipse.cdt.managedbuilder.ui/about.html index 04f07e6858e..9c7ba0a57bc 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/about.html +++ b/build/org.eclipse.cdt.managedbuilder.ui/about.html @@ -1,22 +1,24 @@ - - - -About - - + + +About +

About This Content

-

June 17, 2005

+

May 2, 2006

License

-

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

+

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

-

If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content.

+

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

- - \ No newline at end of file + \ No newline at end of file