From 3950ab52aec3e3a967e2a41980a809afdef253ab Mon Sep 17 00:00:00 2001 From: Leo Treggiari Date: Fri, 27 May 2005 03:45:56 +0000 Subject: [PATCH] Fix for PR 80185 - output message to console when there are no source files to build, --- .../core/GeneratedMakefileBuilder.java | 65 ++++++++++++++++++- .../makegen/gnu/GnuMakefileGenerator.java | 21 +++--- 2 files changed, 76 insertions(+), 10 deletions(-) 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 dfee8dee5de..4db8ee8ebb6 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 @@ -264,6 +264,46 @@ public class GeneratedMakefileBuilder extends ACBuilder { } } + /* (non-javadoc) + * Emits a message to the console indicating that there were no source files to build + * @param buildType + * @param status + * @param configName + */ + private void emitNoSourceMessage(int buildType, IStatus status, String configName) throws CoreException { + try { + StringBuffer buf = new StringBuffer(); + IConsole console = CCorePlugin.getDefault().getConsole(); + console.start(getProject()); + ConsoleOutputStream consoleOutStream = console.getOutputStream(); + // Report a successful clean + String[] consoleHeader = new String[3]; + if (buildType == FULL_BUILD) { + consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_FULL); + } else if (buildType == INCREMENTAL_BUILD) { + consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC); + } else { + consoleHeader[0] = new String(); + outputError(getProject().getName(), "The given build type is not supported in this context"); //$NON-NLS-1$ + } + consoleHeader[1] = configName; + consoleHeader[2] = getProject().getName(); + buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ + buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader)); + buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ + buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ + buf.append(status.getMessage()); + buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$ + consoleOutStream.write(buf.toString().getBytes()); + consoleOutStream.flush(); + consoleOutStream.close(); + } catch (CoreException e) { + // Throw the exception back to the builder + throw e; + } catch (IOException io) { // Ignore console failures... + } + } + /* (non-Javadoc) * @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor) */ @@ -395,8 +435,9 @@ public class GeneratedMakefileBuilder extends ACBuilder { } /* (non-Javadoc) - * @param monitor * @param info + * @param generator + * @param monitor */ protected void cleanBuild(IManagedBuildInfo info, IManagedBuilderMakefileGenerator generator, IProgressMonitor monitor) { // Make sure that there is a top level directory and a set of makefiles @@ -418,6 +459,8 @@ public class GeneratedMakefileBuilder extends ACBuilder { } /* (non-Javadoc) + * @param info + * @param generator * @param monitor */ protected void fullBuild(IManagedBuildInfo info, IManagedBuilderMakefileGenerator generator, IProgressMonitor monitor) throws CoreException { @@ -439,6 +482,15 @@ public class GeneratedMakefileBuilder extends ACBuilder { // One possibility is that there is nothing to build IStatus status = kids[index]; if (status.getCode() == IManagedBuilderMakefileGenerator.NO_SOURCE_FOLDERS) { + // Inform the user, via the console, that there is nothing to build + // either because there are no buildable sources files or all potentially + // buildable files have been excluded from build + try { + emitNoSourceMessage(FULL_BUILD, status, info.getConfigurationName()); + } catch (CoreException e) { + // Throw the exception back to the builder + throw e; + } // Dude, we're done return; } else { @@ -550,6 +602,15 @@ public class GeneratedMakefileBuilder extends ACBuilder { // One possibility is that there is nothing to build IStatus status = kids[index]; if (status.getCode() == IManagedBuilderMakefileGenerator.NO_SOURCE_FOLDERS) { + // Inform the user, via the console, that there is nothing to build + // either because there are no buildable sources files or all potentially + // buildable files have been excluded from build + try { + emitNoSourceMessage(INCREMENTAL_BUILD, status, info.getConfigurationName()); + } catch (CoreException e) { + // Throw the exception back to the builder + throw e; + } // Dude, we're done return; } else { @@ -691,7 +752,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { //resolve the build macros in environment variables try{ envList.add(variables[i].getName() + "=" + macroProvier.resolveValue(variables[i].getValue(),""," ",IBuildMacroProvider.CONTEXT_CONFIGURATION,cfg)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - }catch(BuildMacroException e){ + } catch(BuildMacroException e) { envList.add(variables[i].getName() + "=" + variables[i].getValue()); //$NON-NLS-1$ } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java index 9942b2a5b2c..f3f555bba6a 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java @@ -204,12 +204,17 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { if (proxy.getType() == IResource.FILE) { // Check extension to see if build model should build this file IResource resource = proxy.requestResource(); - String ext = resource.getFileExtension(); + String ext = resource.getFileExtension(); if (info.buildsFileType(ext)) { + // If this file resource is a generated resource, then it is uninteresting if (!generator.isGeneratedResource(resource)) { - generator.appendBuildSubdirectory(resource); + // If this file resource is excluded from build, then it is uninteresting + IResourceConfiguration resConfig = config.getResourceConfiguration(resource.getFullPath().toString()); + if ((resConfig == null) || (!(resConfig.isExcluded()))) { + generator.appendBuildSubdirectory(resource); + } } - } + } return false; } @@ -432,13 +437,13 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { status = new MultiStatus( ManagedBuilderCorePlugin.getUniqueIdentifier(), IStatus.INFO, - info, + new String(), null); status.add(new Status ( IStatus.INFO, ManagedBuilderCorePlugin.getUniqueIdentifier(), NO_SOURCE_FOLDERS, - new String(), + info, null)); return status; } @@ -632,20 +637,20 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { // See if the user has cancelled the build checkCancel(); - // Populate the makefile if any source files have been found in the project + // Populate the makefile if any buildable source files have been found in the project if (getSubdirList().isEmpty()) { String info = ManagedMakeMessages.getFormattedString("MakefileGenerator.warning.no.source", project.getName()); //$NON-NLS-1$ updateMonitor(info); status = new MultiStatus( ManagedBuilderCorePlugin.getUniqueIdentifier(), IStatus.INFO, - info, + new String(), null); status.add(new Status ( IStatus.INFO, ManagedBuilderCorePlugin.getUniqueIdentifier(), NO_SOURCE_FOLDERS, - new String(), + info, null)); return status; }