mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for PR 80185 - output message to console when there are no source files to build,
This commit is contained in:
parent
00b506b69e
commit
3950ab52ae
2 changed files with 76 additions and 10 deletions
|
@ -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$
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue