mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 17:35:35 +02:00
Fix for 65148 -- Cannot build after cancel build of Managed Project
This commit is contained in:
parent
c7fd6b490a
commit
29ab091666
10 changed files with 251 additions and 127 deletions
|
@ -37,9 +37,9 @@ public interface IManagedBuildInfo {
|
|||
|
||||
|
||||
/**
|
||||
* Answers the file extension for the receivers build goal.
|
||||
* Answers the file extension for the receivers build goal without a separator.
|
||||
*
|
||||
* @return
|
||||
* @return the extension or an empty string if none is defined
|
||||
*/
|
||||
public String getBuildArtifactExtension();
|
||||
|
||||
|
@ -163,7 +163,7 @@ public interface IManagedBuildInfo {
|
|||
* the extension '.a', so the final goal would be 'libfoo.a'
|
||||
*
|
||||
* @param extension
|
||||
* @return
|
||||
* @return the prefix or an empty string
|
||||
*/
|
||||
public String getOutputPrefix(String outputExtension);
|
||||
|
||||
|
|
|
@ -11,17 +11,11 @@ package org.eclipse.cdt.managedbuilder.core;
|
|||
* IBM Rational Software - Initial API and implementation
|
||||
* **********************************************************************/
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.GeneratedMakefileBuilder;
|
||||
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
|
||||
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildPathEntryContainerInitializer;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
|
||||
|
@ -63,21 +57,6 @@ public class ManagedBuilderCorePlugin extends Plugin {
|
|||
return plugin;
|
||||
}
|
||||
|
||||
public static void log(Throwable e) {
|
||||
if (e instanceof InvocationTargetException)
|
||||
e = ((InvocationTargetException) e).getTargetException();
|
||||
IStatus status = null;
|
||||
if (e instanceof CoreException)
|
||||
status = ((CoreException) e).getStatus();
|
||||
else
|
||||
status = new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.OK, e.getMessage(), e);
|
||||
log(status);
|
||||
}
|
||||
|
||||
public static void log(IStatus status) {
|
||||
ResourcesPlugin.getPlugin().getLog().log(status);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
|
@ -90,7 +69,7 @@ public class ManagedBuilderCorePlugin extends Plugin {
|
|||
private static final String PATH_ENTRY = ManagedBuilderCorePlugin.getUniqueIdentifier() + "/debug/pathEntry"; //$NON-NLS-1$
|
||||
private static final String PATH_ENTRY_INIT = ManagedBuilderCorePlugin.getUniqueIdentifier() + "/debug/pathEntryInit"; //$NON-NLS-1$
|
||||
private static final String BUILDER = ManagedBuilderCorePlugin.getUniqueIdentifier() + "/debug/builder"; //$NON-NLS-1$
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -36,7 +36,9 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
|||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -70,6 +72,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
* @since 1.2
|
||||
*/
|
||||
public class ResourceDeltaVisitor implements IResourceDeltaVisitor {
|
||||
private String buildGoalName;
|
||||
private IManagedBuildInfo buildInfo;
|
||||
private boolean buildNeeded = true;
|
||||
private List reservedNames;
|
||||
|
@ -79,6 +82,12 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
*/
|
||||
public ResourceDeltaVisitor(IManagedBuildInfo info) {
|
||||
buildInfo = info;
|
||||
String ext = buildInfo.getBuildArtifactExtension();
|
||||
if (ext.length() > 0) {
|
||||
buildGoalName = buildInfo.getOutputPrefix(ext) + buildInfo.getBuildArtifactName() + "." + ext; //$NON-NLS-1$
|
||||
} else {
|
||||
buildGoalName = buildInfo.getBuildArtifactName();
|
||||
}
|
||||
reservedNames = Arrays.asList(new String[]{".cdtbuild", ".cdtproject", ".project"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
|
||||
|
@ -118,20 +127,28 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
IResourceDelta[] kids = delta.getAffectedChildren();
|
||||
for (int index = kids.length - 1; index >= 0; --index) {
|
||||
IResource changedResource = kids[index].getResource();
|
||||
String ext = changedResource.getFileExtension();
|
||||
// There are some things we don't care about
|
||||
if (resource.isDerived()) {
|
||||
buildNeeded = false;
|
||||
} else if (isGeneratedResource(changedResource)) {
|
||||
buildNeeded = false;
|
||||
} else if (buildInfo.buildsFileType(ext) || buildInfo.isHeaderFile(ext)) {
|
||||
// We do care and there is no point checking anythings else
|
||||
buildNeeded = true;
|
||||
break;
|
||||
} else if (isProjectFile(changedResource)) {
|
||||
buildNeeded = false;
|
||||
if (changedResource instanceof IFolder) {
|
||||
return true;
|
||||
} else {
|
||||
buildNeeded = true;
|
||||
String name = changedResource.getName();
|
||||
String ext = changedResource.getFileExtension();
|
||||
// There are some things we don't care about and some we do
|
||||
if (name.equals(buildGoalName)) {
|
||||
buildNeeded = true;
|
||||
break;
|
||||
} else if (resource.isDerived()) {
|
||||
buildNeeded |= false;
|
||||
} else if (isGeneratedResource(changedResource)) {
|
||||
buildNeeded |= false;
|
||||
} else if (buildInfo.buildsFileType(ext) || buildInfo.isHeaderFile(ext)) {
|
||||
// We do care and there is no point checking anythings else
|
||||
buildNeeded = true;
|
||||
break;
|
||||
} else if (isProjectFile(changedResource)) {
|
||||
buildNeeded |= false;
|
||||
} else {
|
||||
buildNeeded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -142,16 +159,15 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
}
|
||||
|
||||
// String constants
|
||||
private static final String MESSAGE = "ManagedMakeBuilder.message"; //$NON-NLS-1$
|
||||
private static final String BUILD_ERROR = MESSAGE + ".error"; //$NON-NLS-1$
|
||||
private static final String BUILD_FINISHED = MESSAGE + ".finished"; //$NON-NLS-1$
|
||||
private static final String CONSOLE_HEADER = MESSAGE + ".console.header"; //$NON-NLS-1$
|
||||
private static final String BUILD_ERROR = "ManagedMakeBuilder.message.error"; //$NON-NLS-1$
|
||||
private static final String BUILD_FINISHED = "ManagedMakeBuilder.message.finished"; //$NON-NLS-1$
|
||||
private static final String CONSOLE_HEADER = "ManagedMakeBuilder.message.console.header"; //$NON-NLS-1$
|
||||
private static final String ERROR_HEADER = "GeneratedmakefileBuilder error ["; //$NON-NLS-1$
|
||||
private static final String MAKE = MESSAGE + ".make"; //$NON-NLS-1$
|
||||
private static final String MARKERS = MESSAGE + ".creating.markers"; //$NON-NLS-1$
|
||||
private static final String MAKE = "ManagedMakeBuilder.message.make"; //$NON-NLS-1$
|
||||
private static final String MARKERS = "ManagedMakeBuilder.message.creating.markers"; //$NON-NLS-1$
|
||||
private static final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$
|
||||
private static final String NOTHING_BUILT = MESSAGE + ".no.build"; //$NON-NLS-1$
|
||||
private static final String REFRESH = MESSAGE + ".updating"; //$NON-NLS-1$
|
||||
private static final String NOTHING_BUILT = "ManagedMakeBuilder.message.no.build"; //$NON-NLS-1$
|
||||
private static final String REFRESH = "ManagedMakeBuilder.message.updating"; //$NON-NLS-1$
|
||||
private static final String REFRESH_ERROR = BUILD_ERROR + ".refresh"; //$NON-NLS-1$
|
||||
private static final String TRACE_FOOTER = "]: "; //$NON-NLS-1$
|
||||
private static final String TRACE_HEADER = "GeneratedmakefileBuilder trace ["; //$NON-NLS-1$
|
||||
|
@ -161,13 +177,12 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
public static boolean VERBOSE = false;
|
||||
|
||||
// Local variables
|
||||
private IConsole console;
|
||||
protected Vector generationProblems;
|
||||
protected IManagedBuilderMakefileGenerator generator;
|
||||
protected IProject[] referencedProjects;
|
||||
protected List resourcesToBuild;
|
||||
protected List ruleList;
|
||||
private IConsole console;
|
||||
|
||||
|
||||
public static void outputTrace(String resourceName, String message) {
|
||||
if (VERBOSE) {
|
||||
System.out.println(TRACE_HEADER + resourceName + TRACE_FOOTER + message + NEWLINE);
|
||||
|
@ -208,8 +223,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
|
||||
// We should always tell the build system what projects we reference
|
||||
referencedProjects = getProject().getReferencedProjects();
|
||||
checkCancel(monitor);
|
||||
|
||||
|
||||
// Get the build information
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
|
||||
if (info == null) {
|
||||
|
@ -217,14 +231,19 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
return referencedProjects;
|
||||
}
|
||||
|
||||
// Create a makefile generator for the build
|
||||
String targetID = info.getDefaultTarget().getParent().getId();
|
||||
IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getMakefileGenerator(targetID);
|
||||
generator.initialize(getProject(), info, monitor);
|
||||
|
||||
// So let's figure out why we got called
|
||||
if (kind == FULL_BUILD || info.needsRebuild()) {
|
||||
outputTrace(getProject().getName(), "Full build needed/requested"); //$NON-NLS-1$
|
||||
fullBuild(monitor, info);
|
||||
fullBuild(info, generator, monitor);
|
||||
}
|
||||
else if (kind == AUTO_BUILD && info.needsRebuild()) {
|
||||
outputTrace(getProject().getName(), "Autobuild requested, full build needed"); //$NON-NLS-1$
|
||||
fullBuild(monitor, info);
|
||||
fullBuild(info, generator, monitor);
|
||||
}
|
||||
else {
|
||||
// Create a delta visitor to make sure we should be rebuilding
|
||||
|
@ -232,25 +251,22 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
IResourceDelta delta = getDelta(getProject());
|
||||
if (delta == null) {
|
||||
outputTrace(getProject().getName(), "Incremental build requested, full build needed"); //$NON-NLS-1$
|
||||
fullBuild(monitor, info);
|
||||
fullBuild(info, generator, monitor);
|
||||
}
|
||||
else {
|
||||
delta.accept(visitor);
|
||||
if (visitor.shouldBuild()) {
|
||||
outputTrace(getProject().getName(), "Incremental build requested"); //$NON-NLS-1$
|
||||
incrementalBuild(delta, info, monitor);
|
||||
incrementalBuild(delta, info, generator, monitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Scrub the build info the project
|
||||
info.setRebuildState(false);
|
||||
|
||||
// Ask build mechanism to compute deltas for project dependencies next time
|
||||
return referencedProjects;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check whether the build has been canceled. Cancellation requests
|
||||
* propagated to the caller by throwing <code>OperationCanceledException</code>.
|
||||
|
@ -259,6 +275,8 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
*/
|
||||
public void checkCancel(IProgressMonitor monitor) {
|
||||
if (monitor != null && monitor.isCanceled()) {
|
||||
outputTrace(getProject().getName(), "Build cancelled"); //$NON-NLS-1$
|
||||
forgetLastBuiltState();
|
||||
throw new OperationCanceledException();
|
||||
}
|
||||
}
|
||||
|
@ -274,79 +292,108 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
outputError(getProject().getName(), "Build information was not found"); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
cleanBuild(monitor, info);
|
||||
IPath buildDirPath = getProject().getLocation().append(info.getConfigurationName());
|
||||
IWorkspace workspace = CCorePlugin.getWorkspace();
|
||||
IContainer buildDir = workspace.getRoot().getContainerForLocation(buildDirPath);
|
||||
if (buildDir == null || !buildDir.isAccessible()){
|
||||
outputError(buildDir.getName(), "Could not delete the build directory"); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
String status;
|
||||
try {
|
||||
// try the brute force approach first
|
||||
status = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.clean.deleting.output", buildDir.getName()); //$NON-NLS-1$
|
||||
monitor.subTask(status);
|
||||
workspace.delete(new IResource[]{buildDir}, true, monitor);
|
||||
} catch (CoreException e) {
|
||||
// Create a makefile generator for the build
|
||||
status = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.clean.build.clean", buildDir.getName()); //$NON-NLS-1$
|
||||
monitor.subTask(status);
|
||||
String targetID = info.getDefaultTarget().getParent().getId();
|
||||
IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getMakefileGenerator(targetID);
|
||||
generator.initialize(getProject(), info, monitor);
|
||||
cleanBuild(info, generator, monitor);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @param monitor
|
||||
* @param info
|
||||
*/
|
||||
protected void cleanBuild(IProgressMonitor monitor, IManagedBuildInfo info) {
|
||||
protected void cleanBuild(IManagedBuildInfo info, IManagedBuilderMakefileGenerator generator, IProgressMonitor monitor) {
|
||||
// Make sure that there is a top level directory and a set of makefiles
|
||||
String targetID = info.getDefaultTarget().getParent().getId();
|
||||
generator = ManagedBuildManager.getMakefileGenerator(targetID);
|
||||
IPath buildDir = getProject().getLocation().append(info.getConfigurationName());
|
||||
IPath makefilePath = buildDir.append(generator.getMakefileName());
|
||||
IPath buildDir = generator.getBuildWorkingDir();
|
||||
if (buildDir == null) {
|
||||
buildDir = new Path(info.getConfigurationName());
|
||||
}
|
||||
IPath makefilePath = getProject().getLocation().append(buildDir.append(generator.getMakefileName()));
|
||||
IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot();
|
||||
IFile makefile = root.getFileForLocation(makefilePath);
|
||||
|
||||
if (buildDir != null && makefile != null && makefile.exists()) {
|
||||
if (buildDir != null && makefile != null && makefile.isAccessible()) {
|
||||
// invoke make with the clean argument
|
||||
String statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.starting", getProject().getName()); //$NON-NLS-1$
|
||||
monitor.subTask(statusMsg);
|
||||
checkCancel(monitor);
|
||||
invokeMake(CLEAN_BUILD, buildDir, info, monitor);
|
||||
invokeMake(CLEAN_BUILD, buildDir, info, generator, monitor);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @param monitor
|
||||
*/
|
||||
protected void fullBuild(IProgressMonitor monitor, IManagedBuildInfo info) throws CoreException {
|
||||
protected void fullBuild(IManagedBuildInfo info, IManagedBuilderMakefileGenerator generator, IProgressMonitor monitor) throws CoreException {
|
||||
// Always need one of these bad boys
|
||||
if (monitor == null) {
|
||||
monitor = new NullProgressMonitor();
|
||||
}
|
||||
|
||||
// Regenerate the makefiles for this project
|
||||
checkCancel(monitor);
|
||||
String statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.rebuild.makefiles", getProject().getName()); //$NON-NLS-1$
|
||||
monitor.subTask(statusMsg);
|
||||
checkCancel(monitor);
|
||||
String targetID = info.getDefaultTarget().getParent().getId();
|
||||
generator = ManagedBuildManager.getMakefileGenerator(targetID);
|
||||
generator.initialize(getProject(), info, monitor);
|
||||
MultiStatus result = generator.regenerateMakefiles();
|
||||
if (result.getCode() != IStatus.OK) {
|
||||
getGenerationProblems().addAll(Arrays.asList(result.getChildren()));
|
||||
if (result.getCode() == IStatus.WARNING || result.getCode() == IStatus.INFO) {
|
||||
IStatus[] kids = result.getChildren();
|
||||
for (int index = 0; index < kids.length; ++index) {
|
||||
// One possibility is that there is nothing to build
|
||||
IStatus status = kids[index];
|
||||
if (status.getCode() == IManagedBuilderMakefileGenerator.NO_SOURCE_FOLDERS) {
|
||||
// Dude, we're done
|
||||
return;
|
||||
} else {
|
||||
// Stick this in the list of stuff to warn the user about
|
||||
getGenerationProblems().add(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
monitor.worked(1);
|
||||
|
||||
// Now call make
|
||||
checkCancel(monitor);
|
||||
statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.starting", getProject().getName()); //$NON-NLS-1$
|
||||
monitor.subTask(statusMsg);
|
||||
checkCancel(monitor);
|
||||
IPath topBuildDir = generator.getBuildWorkingDir();
|
||||
if (topBuildDir != null) {
|
||||
invokeMake(FULL_BUILD, topBuildDir, info, monitor);
|
||||
invokeMake(FULL_BUILD, topBuildDir, info, generator, monitor);
|
||||
} else {
|
||||
statusMsg = ManagedMakeMessages.getFormattedString(NOTHING_BUILT, getProject().getName()); //$NON-NLS-1$
|
||||
monitor.subTask(statusMsg);
|
||||
return;
|
||||
}
|
||||
monitor.worked(1);
|
||||
|
||||
// Now regenerate the dependencies
|
||||
checkCancel(monitor);
|
||||
statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.regen.deps", getProject().getName()); //$NON-NLS-1$
|
||||
monitor.subTask(statusMsg);
|
||||
checkCancel(monitor);
|
||||
try {
|
||||
generator.regenerateDependencies(false);
|
||||
} catch (CoreException e) {
|
||||
// Throw the exception back to the builder
|
||||
throw e;
|
||||
}
|
||||
monitor.worked(1);
|
||||
|
||||
// Say bye bye
|
||||
statusMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, getProject().getName()); //$NON-NLS-1$
|
||||
|
@ -452,51 +499,55 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
* @param monitor
|
||||
* @throws CoreException
|
||||
*/
|
||||
protected void incrementalBuild(IResourceDelta delta, IManagedBuildInfo info, IProgressMonitor monitor) throws CoreException {
|
||||
protected void incrementalBuild(IResourceDelta delta, IManagedBuildInfo info, IManagedBuilderMakefileGenerator generator, IProgressMonitor monitor) throws CoreException {
|
||||
// Need to report status to the user
|
||||
if (monitor == null) {
|
||||
monitor = new NullProgressMonitor();
|
||||
}
|
||||
|
||||
// Ask the makefile generator to generate any makefiles needed to build delta
|
||||
checkCancel(monitor);
|
||||
String statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.update.makefiles", getProject().getName()); //$NON-NLS-1$
|
||||
monitor.subTask(statusMsg);
|
||||
checkCancel(monitor);
|
||||
String targetID = info.getDefaultTarget().getParent().getId();
|
||||
generator = ManagedBuildManager.getMakefileGenerator(targetID);
|
||||
generator.initialize(getProject(), info, monitor);
|
||||
MultiStatus result = generator.generateMakefiles(delta);
|
||||
if (result.getCode() != IStatus.OK) {
|
||||
getGenerationProblems().addAll(Arrays.asList(result.getChildren()));
|
||||
if (result.getCode() == IStatus.WARNING || result.getCode() == IStatus.INFO) {
|
||||
IStatus[] kids = result.getChildren();
|
||||
for (int index = 0; index < kids.length; ++index) {
|
||||
// One possibility is that there is nothing to build
|
||||
IStatus status = kids[index];
|
||||
if (status.getCode() == IManagedBuilderMakefileGenerator.NO_SOURCE_FOLDERS) {
|
||||
// Dude, we're done
|
||||
return;
|
||||
} else {
|
||||
// Stick this in the list of stuff to warn the user about
|
||||
getGenerationProblems().add(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
monitor.worked(1);
|
||||
|
||||
// Run the build
|
||||
checkCancel(monitor);
|
||||
statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.starting", getProject().getName()); //$NON-NLS-1$
|
||||
monitor.subTask(statusMsg);
|
||||
checkCancel(monitor);
|
||||
IPath buildDir = new Path(info.getConfigurationName());
|
||||
if (buildDir != null) {
|
||||
invokeMake(INCREMENTAL_BUILD, buildDir, info, monitor);
|
||||
invokeMake(INCREMENTAL_BUILD, buildDir, info, generator, monitor);
|
||||
} else {
|
||||
statusMsg = ManagedMakeMessages.getFormattedString(NOTHING_BUILT, getProject().getName()); //$NON-NLS-1$
|
||||
monitor.subTask(statusMsg);
|
||||
return;
|
||||
}
|
||||
monitor.worked(1);
|
||||
|
||||
// Generate the dependencies for all changes
|
||||
checkCancel(monitor);
|
||||
statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.updating.deps", getProject().getName()); //$NON-NLS-1$
|
||||
monitor.subTask(statusMsg);
|
||||
checkCancel(monitor);
|
||||
try {
|
||||
generator.generateDependencies();
|
||||
} catch (CoreException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
throw e;
|
||||
}
|
||||
monitor.worked(1);
|
||||
|
||||
|
||||
// Say bye bye
|
||||
statusMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, getProject().getName()); //$NON-NLS-1$
|
||||
monitor.subTask(statusMsg);
|
||||
|
@ -508,7 +559,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
* @param info
|
||||
* @param monitor
|
||||
*/
|
||||
protected void invokeMake(int buildType, IPath buildDir, IManagedBuildInfo info, IProgressMonitor monitor) {
|
||||
protected void invokeMake(int buildType, IPath buildDir, IManagedBuildInfo info, IManagedBuilderMakefileGenerator generator, IProgressMonitor monitor) {
|
||||
// Get the project and make sure there's a monitor to cancel the build
|
||||
IProject currentProject = getProject();
|
||||
if (monitor == null) {
|
||||
|
@ -537,7 +588,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
String[] msgs = new String[2];
|
||||
msgs[0] = makeCommand.toString();
|
||||
msgs[1] = currentProject.getName();
|
||||
monitor.beginTask(ManagedMakeMessages.getFormattedString(MAKE, msgs), IProgressMonitor.UNKNOWN);
|
||||
monitor.subTask(ManagedMakeMessages.getFormattedString(MAKE, msgs));
|
||||
|
||||
// Get a build console for the project
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
@ -660,16 +711,15 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
stdout.close();
|
||||
stderr.close();
|
||||
|
||||
// Generate any error markers that the build has discovered
|
||||
monitor.subTask(ManagedMakeMessages.getResourceString(MARKERS));
|
||||
addBuilderMarkers(epm);
|
||||
epm.reportProblems();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
forgetLastBuiltState();
|
||||
} finally {
|
||||
getGenerationProblems().clear();
|
||||
monitor.done();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -684,8 +734,14 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
return console;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Removes the IMarkers for the project specified in the argument if the
|
||||
* project exists, and is open.
|
||||
*
|
||||
* @param project
|
||||
*/
|
||||
private void removeAllMarkers(IProject project) {
|
||||
if (project == null || !project.exists()) return;
|
||||
if (project == null || !project.isAccessible()) return;
|
||||
|
||||
// Clear out the problem markers
|
||||
IWorkspace workspace = project.getWorkspace();
|
||||
|
@ -693,14 +749,15 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
try {
|
||||
markers = project.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
|
||||
} catch (CoreException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
// Handled just about every case in the sanity check
|
||||
return;
|
||||
}
|
||||
if (markers != null) {
|
||||
try {
|
||||
workspace.deleteMarkers(markers);
|
||||
} catch (CoreException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
// The only situation that might cause this is some sort of resource change event
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -349,7 +349,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
}
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -719,7 +718,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
IPathEntryContainer container = new ManagedBuildCPathEntryContainer(getOwner().getProject());
|
||||
CoreModel.getDefault().setPathEntryContainer(new ICProject[]{cProject}, container, new NullProgressMonitor());
|
||||
} catch (CModelException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -889,9 +887,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
// See if there is anything to be done
|
||||
IConfiguration oldDefault = getDefaultConfiguration(target);
|
||||
if (defaultTarget == null || !configuration.equals(oldDefault)) {
|
||||
// Make sure it is the default
|
||||
// Make sure the containing target is also the default target
|
||||
setDefaultTarget(target);
|
||||
// Make the argument the
|
||||
// Make the argument the default configuration
|
||||
getDefaultConfigMap().put(target.getId(), configuration);
|
||||
// Save it
|
||||
persistDefaultConfigurations();
|
||||
|
|
|
@ -24,6 +24,8 @@ ManagedMakeBuilder.message.no.build = Nothing to build for {0}
|
|||
ManagedMakeBuilder.message.error = Build error
|
||||
ManagedMakeBuilder.message.error.refresh = Error refreshing project
|
||||
ManagedMakeBuilder.message.finished = Build complete for project {0}
|
||||
ManagedMakeBuilder.message.clean.deleting.output=Removing build artifacts from {0}
|
||||
ManagedMakeBuilder.message.clean.build.clean=Trying a make clean in {0}
|
||||
ManagedMakeBuilder.type.clean = Clean-only build
|
||||
ManagedMakeBuilder.type.full = Full rebuild
|
||||
ManagedMakeBuider.type.incremental = Incremental build
|
||||
|
@ -43,6 +45,10 @@ MakefileGenerator.message.start.file=Building file:
|
|||
MakefileGenerator.message.finish.file=Finished building:
|
||||
MakefileGenerator.message.start.build=Building target:
|
||||
MakefileGenerator.message.finish.build=Finished building target:
|
||||
MakefileGenerator.message.adding.source.folder=Adding folder {0} to sources
|
||||
MakefileGenerator.message.gen.source.makefile=Generating makefile for source folder {0}
|
||||
MakefileGenerator.message.calc.delta=Calculating the delta for project {0}
|
||||
MakefileGenerator.message.finding.sources=Finding source files in project {0}
|
||||
MakefileGenerator.comment.module.list = Every subdirectory with source files must be described here
|
||||
MakefileGenerator.comment.source.list = All of the sources participating in the build are defined here
|
||||
MakefileGenerator.comment.build.rule = Each subdirectory must supply rules for building sources it contributes
|
||||
|
@ -54,4 +60,7 @@ MakefileGenerator.error.spaces=Cannot generate makefile for folder with spaces i
|
|||
MakefileGenerator.warning.no.source=Nothing to build for project {0}
|
||||
|
||||
ManagedBuildInfo.message.job.init = Initializing path container for {0}
|
||||
ManagedBuildInfo.message.init.ok = Initializing path container succeeded for {0}
|
||||
ManagedBuildInfo.message.init.ok = Initializing path container succeeded for {0}
|
||||
|
||||
# Default GNU Makefile Generator messages
|
||||
GnuMakefileGenerator.message.postproc.dep.file=Verifying contents of dependency file {0}
|
|
@ -24,7 +24,6 @@ import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
|||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.IToolReference;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
@ -196,7 +195,7 @@ public class ToolReference implements IToolReference {
|
|||
break;
|
||||
}
|
||||
} catch (BuildException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
// Likely a mismatch between the value and option type
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.managedbuilder.makegen;
|
|||
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceDelta;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
@ -93,6 +94,13 @@ public interface IManagedBuilderMakefileGenerator {
|
|||
*/
|
||||
public void initialize(IProject project, IManagedBuildInfo info, IProgressMonitor monitor);
|
||||
|
||||
/**
|
||||
* Answers <code>true</code> if the argument is a resource created by the generator
|
||||
* @param resource
|
||||
* @return
|
||||
*/
|
||||
public boolean isGeneratedResource(IResource resource);
|
||||
|
||||
/**
|
||||
* @param force
|
||||
* @throws CoreException
|
||||
|
|
|
@ -472,6 +472,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
Iterator iter = getSubdirList().listIterator();
|
||||
while (iter.hasNext()) {
|
||||
IContainer container = (IContainer) iter.next();
|
||||
updateMonitor(ManagedMakeMessages.getFormattedString("MakefileGenerator.message.adding.source.folder", container.getFullPath().toString())); //$NON-NLS-1$
|
||||
// Check the special case where the module is the project root
|
||||
if (container.getFullPath() == project.getFullPath()) {
|
||||
buffer.append(DOT + WHITESPACE + LINEBREAK);
|
||||
|
@ -565,7 +566,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
|
||||
/*
|
||||
* Write out the target rule as:
|
||||
* targ_<prefix><target>.<extension>: $(OBJS) <refd_project_1 ... refd_project_n>
|
||||
* <targ_prefix><target>.<extension>: $(OBJS) <refd_project_1 ... refd_project_n>
|
||||
* @echo 'Building target: $@'
|
||||
* $(BUILD_TOOL) $(FLAGS) $(OUTPUT_FLAG)$@ $(OBJS) $(USER_OBJS) $(LIB_DEPS)
|
||||
* @echo 'Finished building: $@'
|
||||
|
@ -682,7 +683,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/* (non-Javadoc)
|
||||
* Check whether the build has been cancelled. Cancellation requests
|
||||
* propagated to the caller by throwing <code>OperationCanceledException</code>.
|
||||
*
|
||||
|
@ -861,6 +862,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
IFile depFile = root.getFile(file.getFullPath());
|
||||
if (depFile == null) continue;
|
||||
try {
|
||||
updateMonitor(ManagedMakeMessages.getFormattedString("GnuMakefileGenerator.message.postproc.dep.file", depFile.getName())); //$NON-NLS-1$
|
||||
populateDummyTargets(depFile, false);
|
||||
} catch (CoreException e) {
|
||||
throw e;
|
||||
|
@ -888,18 +890,43 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
return regenerateMakefiles();
|
||||
}
|
||||
|
||||
// Make sure the build directory is available
|
||||
topBuildDir = createDirectory(info.getConfigurationName());
|
||||
checkCancel();
|
||||
|
||||
// Return value
|
||||
MultiStatus status;
|
||||
|
||||
// Visit the resources in the delta and compile a list of subdirectories to regenerate
|
||||
updateMonitor(ManagedMakeMessages.getFormattedString("MakefileGenerator.message.calc.delta", project.getName())); //$NON-NLS-1$
|
||||
ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(this, info);
|
||||
delta.accept(visitor);
|
||||
checkCancel();
|
||||
|
||||
// Get all the subdirectories participating in the build
|
||||
updateMonitor(ManagedMakeMessages.getFormattedString("MakefileGenerator.message.finding.sources", project.getName())); //$NON-NLS-1$
|
||||
ResourceProxyVisitor resourceVisitor = new ResourceProxyVisitor(this, info);
|
||||
project.accept(resourceVisitor, IResource.NONE);
|
||||
checkCancel();
|
||||
|
||||
// Make sure there is something to build
|
||||
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,
|
||||
null);
|
||||
status.add(new Status (
|
||||
IStatus.INFO,
|
||||
ManagedBuilderCorePlugin.getUniqueIdentifier(),
|
||||
NO_SOURCE_FOLDERS,
|
||||
new String(),
|
||||
null));
|
||||
return status;
|
||||
}
|
||||
|
||||
// Make sure the build directory is available
|
||||
topBuildDir = createDirectory(info.getConfigurationName());
|
||||
checkCancel();
|
||||
|
||||
IPath srcsFilePath = topBuildDir.addTrailingSeparator().append(SRCSFILE_NAME);
|
||||
IFile srcsFileHandle = createFile(srcsFilePath);
|
||||
populateSourcesMakefile(srcsFileHandle);
|
||||
|
@ -943,7 +970,6 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
}
|
||||
|
||||
// How did we do
|
||||
MultiStatus status;
|
||||
if (!getInvalidDirList().isEmpty()) {
|
||||
status = new MultiStatus (
|
||||
ManagedBuilderCorePlugin.getUniqueIdentifier(),
|
||||
|
@ -977,7 +1003,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
public IPath getBuildWorkingDir() {
|
||||
if (topBuildDir != null) {
|
||||
return topBuildDir.removeFirstSegments(1);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1144,11 +1170,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Answers <code>true</code> if the argument is found in a generated container
|
||||
* @param resource
|
||||
* @return boolean
|
||||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator#isGeneratedResource(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
protected boolean isGeneratedResource(IResource resource) {
|
||||
public boolean isGeneratedResource(IResource resource) {
|
||||
// Is this a generated directory ...
|
||||
IPath path = resource.getProjectRelativePath();
|
||||
String[] configNames = info.getConfigurationNames();
|
||||
|
@ -1340,7 +1364,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
}
|
||||
|
||||
IPath moduleOutputPath = buildRoot.append(moduleRelativePath);
|
||||
|
||||
updateMonitor(ManagedMakeMessages.getFormattedString("MakefileGenerator.message.gen.source.makefile", moduleOutputPath.toString())); //$NON-NLS-1$
|
||||
|
||||
// Now create the directory
|
||||
IPath moduleOutputDir = createDirectory(moduleOutputPath.toString());
|
||||
|
||||
|
@ -1513,8 +1538,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
// The path to search for the dependency makefile
|
||||
IPath relDepFilePath = topBuildDir.append(new Path((String)iter.next()));
|
||||
IFile depFile = root.getFile(relDepFilePath);
|
||||
if (depFile == null || !depFile.exists()) continue;
|
||||
if (depFile == null || !depFile.isAccessible()) continue;
|
||||
try {
|
||||
updateMonitor(ManagedMakeMessages.getFormattedString("GnuMakefileGenerator.message.postproc.dep.file", depFile.getName())); //$NON-NLS-1$
|
||||
populateDummyTargets(depFile, true);
|
||||
} catch (CoreException e) {
|
||||
throw e;
|
||||
|
@ -1529,6 +1555,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator#regenerateMakefiles()
|
||||
*/
|
||||
public MultiStatus regenerateMakefiles() throws CoreException {
|
||||
MultiStatus status;
|
||||
// Visit the resources in the project
|
||||
ResourceProxyVisitor visitor = new ResourceProxyVisitor(this, info);
|
||||
project.accept(visitor, IResource.NONE);
|
||||
|
@ -1538,7 +1565,20 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
|
||||
// Populate the makefile if any source files have been found in the project
|
||||
if (getSubdirList().isEmpty()) {
|
||||
monitor.subTask(ManagedMakeMessages.getFormattedString("MakefileGenerator.warning.no.source", project.getName())); //$NON-NLS-1$
|
||||
String info = ManagedMakeMessages.getFormattedString("MakefileGenerator.warning.no.source", project.getName()); //$NON-NLS-1$
|
||||
updateMonitor(info);
|
||||
status = new MultiStatus(
|
||||
ManagedBuilderCorePlugin.getUniqueIdentifier(),
|
||||
IStatus.INFO,
|
||||
info,
|
||||
null);
|
||||
status.add(new Status (
|
||||
IStatus.INFO,
|
||||
ManagedBuilderCorePlugin.getUniqueIdentifier(),
|
||||
NO_SOURCE_FOLDERS,
|
||||
new String(),
|
||||
null));
|
||||
return status;
|
||||
}
|
||||
|
||||
// Create the top-level directory for the build output
|
||||
|
@ -1578,7 +1618,6 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
checkCancel();
|
||||
|
||||
// How did we do
|
||||
MultiStatus status;
|
||||
if (!getInvalidDirList().isEmpty()) {
|
||||
status = new MultiStatus (
|
||||
ManagedBuilderCorePlugin.getUniqueIdentifier(),
|
||||
|
@ -1605,4 +1644,14 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
return status;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @param msg
|
||||
*/
|
||||
protected void updateMonitor(String msg) {
|
||||
if (monitor!= null && !monitor.isCanceled()) {
|
||||
monitor.subTask(msg);
|
||||
monitor.worked(1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -130,8 +130,12 @@ Option.Posix.Linker.Defname=DEF file name (-Wl,--output-def=)
|
|||
|
||||
Option.Posix.Archiver.Flags=Archiver flags
|
||||
|
||||
Option.Gnu.Assembler.Flags=Assembler flags
|
||||
Option.Gnu.Assembler.warn.suppress=Suppress warnings (-W)
|
||||
Option.Gnu.Assembler.version=Announce version (-v)
|
||||
|
||||
# Platform specific option names
|
||||
Option.Windows.Windres.OutputFormat = Output format
|
||||
Option.Windows.Windres.OutputFormat.Coff = coff (--output-format coff)
|
||||
v = rc (--output-format rc)
|
||||
Option.Windows.Windres.OutputFormat.RC = rc (--output-format rc)
|
||||
Option.Windows.Windres.OutputFormat.Res = res (--output-format res)
|
|
@ -438,7 +438,7 @@
|
|||
name="%Option.Posix.UndefSym"
|
||||
id="gnu.windres.option.preprocessor.undefined.symbols"/>
|
||||
</tool-->
|
||||
<!--tool
|
||||
<tool
|
||||
command="as"
|
||||
sources="s,S"
|
||||
outputs="o"
|
||||
|
@ -452,13 +452,33 @@
|
|||
id="gnu.asm.category.general">
|
||||
</optionCategory>
|
||||
<option
|
||||
name="%Option.Posix.Assembler.Flags"
|
||||
name="%Option.Gnu.Assembler.Flags"
|
||||
category="gnu.asm.category.general"
|
||||
valueType="string"
|
||||
id="gnu.both.asm.option.flags">
|
||||
</option>
|
||||
|
||||
<tool/-->
|
||||
<option
|
||||
command="-I"
|
||||
valueType="includePath"
|
||||
category="gnu.asm.category.general"
|
||||
browseType="directory"
|
||||
name="%Option.Posix.InclPaths"
|
||||
id="gnu.both.asm.option.include.paths"/>
|
||||
<option
|
||||
command="-W"
|
||||
defaultValue="false"
|
||||
valueType="boolean"
|
||||
category="gnu.asm.category.general"
|
||||
name="%Option.Gnu.Assembler.warn.suppress"
|
||||
id="gnu.both.asm.option.warnings.nowarn"/>
|
||||
<option
|
||||
command="-v"
|
||||
defaultValue="false"
|
||||
valueType="boolean"
|
||||
category="gnu.asm.category.general"
|
||||
name="%Option.Gnu.Assembler.version"
|
||||
id="gnu.both.asm.option.version"/>
|
||||
</tool>
|
||||
<target
|
||||
name="%TargetName.gnu"
|
||||
id="cdt.managedbuild.target.gnu"
|
||||
|
@ -933,6 +953,7 @@
|
|||
valueType="boolean">
|
||||
</option>
|
||||
</tool>
|
||||
<toolReference id="cdt.managedbuild.tool.gnu.assembler"/>
|
||||
</target>
|
||||
<target
|
||||
isAbstract="false"
|
||||
|
|
Loading…
Add table
Reference in a new issue