mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 17:35:35 +02:00
Added extra debug logging
This commit is contained in:
parent
dc9f25b601
commit
905660166d
5 changed files with 103 additions and 44 deletions
|
@ -1,4 +1,10 @@
|
|||
org.eclipse.cdt.managedbuilder.core/debug=true
|
||||
|
||||
# Reports path entry container initialization
|
||||
org.eclipse.cdt.managedbuilder.core/debug/pathEntryInit=false
|
||||
|
||||
# Reports path entry container activity
|
||||
org.eclipse.cdt.managedbuilder.core/debug/pathEntry=false
|
||||
|
||||
# Reports builder activity
|
||||
org.eclipse.cdt.managedbuilder.core/debug/builder=false
|
||||
|
|
|
@ -13,7 +13,9 @@ package org.eclipse.cdt.managedbuilder.core;
|
|||
|
||||
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;
|
||||
|
@ -83,16 +85,26 @@ public class ManagedBuilderCorePlugin extends Plugin {
|
|||
configurePluginDebugOptions();
|
||||
}
|
||||
|
||||
private static final String PATH_ENTRY = getUniqueIdentifier() + "/debug/pathEntry"; //$NON-NLS-1$
|
||||
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$
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void configurePluginDebugOptions() {
|
||||
if (isDebugging()) {
|
||||
String option = Platform.getDebugOption(PATH_ENTRY);
|
||||
if (option != null) {
|
||||
ManagedBuildCPathEntryContainer.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
|
||||
String pathInit = Platform.getDebugOption(PATH_ENTRY_INIT);
|
||||
if (pathInit != null) {
|
||||
ManagedBuildPathEntryContainerInitializer.VERBOSE = pathInit.equalsIgnoreCase("true") ; //$NON-NLS-1$
|
||||
}
|
||||
String pathCalc = Platform.getDebugOption(PATH_ENTRY);
|
||||
if (pathCalc != null) {
|
||||
ManagedBuildCPathEntryContainer.VERBOSE = pathCalc.equalsIgnoreCase("true") ; //$NON-NLS-1$
|
||||
}
|
||||
String builder = Platform.getDebugOption(BUILDER);
|
||||
if (builder != null) {
|
||||
GeneratedMakefileBuilder.VERBOSE = builder.equalsIgnoreCase("true") ; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,29 +60,13 @@ import org.eclipse.core.runtime.SubProgressMonitor;
|
|||
* @since 1.2
|
||||
*/
|
||||
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 REFRESH_ERROR = BUILD_ERROR + ".refresh"; //$NON-NLS-1$
|
||||
private static final String BUILD_FINISHED = MESSAGE + ".finished"; //$NON-NLS-1$
|
||||
private static final String NOTHING_BUILT = MESSAGE + ".no.build"; //$NON-NLS-1$
|
||||
private static final String MAKE = MESSAGE + ".make"; //$NON-NLS-1$
|
||||
private static final String REFRESH = MESSAGE + ".updating"; //$NON-NLS-1$
|
||||
private static final String MARKERS = MESSAGE + ".creating.markers"; //$NON-NLS-1$
|
||||
private static final String CONSOLE_HEADER = MESSAGE + ".console.header"; //$NON-NLS-1$
|
||||
private static final String TYPE_CLEAN = "ManagedMakeBuilder.type.clean"; //$NON-NLS-1$
|
||||
private static final String TYPE_FULL = "ManagedMakeBuilder.type.full"; //$NON-NLS-1$
|
||||
private static final String TYPE_INC = "ManagedMakeBuider.type.incremental"; //$NON-NLS-1$
|
||||
|
||||
// Local variables
|
||||
protected List resourcesToBuild;
|
||||
protected List ruleList;
|
||||
protected IManagedBuilderMakefileGenerator generator;
|
||||
protected IProject[] referencedProjects;
|
||||
|
||||
/**
|
||||
* @since 1.2
|
||||
*/
|
||||
public class ResourceDeltaVisitor implements IResourceDeltaVisitor {
|
||||
private boolean buildNeeded = true;
|
||||
private IManagedBuildInfo buildInfo;
|
||||
private boolean buildNeeded = true;
|
||||
private List reservedNames;
|
||||
|
||||
/**
|
||||
|
@ -117,6 +101,10 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
private boolean isProjectFile(IResource resource) {
|
||||
return reservedNames.contains(resource.getName());
|
||||
}
|
||||
|
||||
public boolean shouldBuild() {
|
||||
return buildNeeded;
|
||||
}
|
||||
|
||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||
IResource resource = delta.getResource();
|
||||
|
@ -146,9 +134,42 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean shouldBuild() {
|
||||
return buildNeeded;
|
||||
// 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 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 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 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$
|
||||
private static final String TYPE_CLEAN = "ManagedMakeBuilder.type.clean"; //$NON-NLS-1$
|
||||
private static final String TYPE_FULL = "ManagedMakeBuilder.type.full"; //$NON-NLS-1$
|
||||
private static final String TYPE_INC = "ManagedMakeBuider.type.incremental"; //$NON-NLS-1$
|
||||
public static boolean VERBOSE = false;
|
||||
|
||||
// Local variables
|
||||
protected IManagedBuilderMakefileGenerator generator;
|
||||
protected IProject[] referencedProjects;
|
||||
protected List resourcesToBuild;
|
||||
protected List ruleList;
|
||||
|
||||
public static void outputTrace(String resourceName, String message) {
|
||||
if (VERBOSE) {
|
||||
System.out.println(TRACE_HEADER + resourceName + TRACE_FOOTER + message + NEWLINE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void outputError(String resourceName, String message) {
|
||||
if (VERBOSE) {
|
||||
System.err.println(ERROR_HEADER + resourceName + TRACE_FOOTER + message + NEWLINE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,17 +191,21 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
// Get the build information
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
|
||||
if (info == null) {
|
||||
outputError(getProject().getName(), "Build information was not found"); //$NON-NLS-1$
|
||||
return referencedProjects;
|
||||
}
|
||||
|
||||
// So let's figure out why we got called
|
||||
if (kind == CLEAN_BUILD) {
|
||||
outputTrace(getProject().getName(), "Clean build requested"); //$NON-NLS-1$
|
||||
cleanBuild(monitor, info);
|
||||
}
|
||||
else if (kind == FULL_BUILD || info.needsRebuild()) {
|
||||
outputTrace(getProject().getName(), "Full build needed/requested"); //$NON-NLS-1$
|
||||
fullBuild(monitor, info);
|
||||
}
|
||||
else if (kind == AUTO_BUILD && info.needsRebuild()) {
|
||||
outputTrace(getProject().getName(), "Autobuild requested, full build needed"); //$NON-NLS-1$
|
||||
fullBuild(monitor, info);
|
||||
}
|
||||
else {
|
||||
|
@ -188,11 +213,13 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(info);
|
||||
IResourceDelta delta = getDelta(getProject());
|
||||
if (delta == null) {
|
||||
outputTrace(getProject().getName(), "Incremental build requested, full build needed"); //$NON-NLS-1$
|
||||
fullBuild(monitor, info);
|
||||
}
|
||||
else {
|
||||
delta.accept(visitor);
|
||||
if (visitor.shouldBuild()) {
|
||||
outputTrace(getProject().getName(), "Incremental build requested"); //$NON-NLS-1$
|
||||
incrementalBuild(delta, info, monitor);
|
||||
}
|
||||
}
|
||||
|
@ -205,6 +232,19 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
return referencedProjects;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check whether the build has been canceled. Cancellation requests
|
||||
* propagated to the caller by throwing <code>OperationCanceledException</code>.
|
||||
*
|
||||
* @see org.eclipse.core.runtime.OperationCanceledException#OperationCanceledException()
|
||||
*/
|
||||
public void checkCancel(IProgressMonitor monitor) {
|
||||
if (monitor != null && monitor.isCanceled()) {
|
||||
throw new OperationCanceledException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param monitor
|
||||
* @param info
|
||||
|
@ -227,19 +267,6 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check whether the build has been canceled. Cancellation requests
|
||||
* propagated to the caller by throwing <code>OperationCanceledException</code>.
|
||||
*
|
||||
* @see org.eclipse.core.runtime.OperationCanceledException#OperationCanceledException()
|
||||
*/
|
||||
public void checkCancel(IProgressMonitor monitor) {
|
||||
if (monitor != null && monitor.isCanceled()) {
|
||||
throw new OperationCanceledException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param monitor
|
||||
*/
|
||||
|
@ -599,7 +626,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
epm.reportProblems();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CCorePlugin.log(e);
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
forgetLastBuiltState();
|
||||
} finally {
|
||||
monitor.done();
|
||||
|
|
|
@ -64,11 +64,15 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
|||
public static boolean VERBOSE = false;
|
||||
|
||||
public static void outputTrace(String resourceName, String message) {
|
||||
System.out.println(TRACE_HEADER + resourceName + TRACE_FOOTER + message + NEWLINE);
|
||||
if (VERBOSE) {
|
||||
System.out.println(TRACE_HEADER + resourceName + TRACE_FOOTER + message + NEWLINE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void outputError(String resourceName, String message) {
|
||||
System.err.println(ERROR_HEADER + resourceName + TRACE_FOOTER + message + NEWLINE);
|
||||
if (VERBOSE) {
|
||||
System.err.println(ERROR_HEADER + resourceName + TRACE_FOOTER + message + NEWLINE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -191,11 +195,14 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
|||
*/
|
||||
public IPathEntry[] getPathEntries() {
|
||||
info = (ManagedBuildInfo) ManagedBuildManager.getBuildInfo(project);
|
||||
|
||||
// Load the toolchain-spec'd collector
|
||||
if (info == null) {
|
||||
ManagedBuildCPathEntryContainer.outputError(project.getName(), "Build information is null"); //$NON-NLS-1$
|
||||
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
|
||||
}
|
||||
defaultTarget = info.getDefaultTarget();
|
||||
if (defaultTarget == null) {
|
||||
// The build information has not been loaded yet
|
||||
ManagedBuildCPathEntryContainer.outputError(project.getName(), "Build information has not been loaded yet"); //$NON-NLS-1$
|
||||
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
|
||||
}
|
||||
ITarget parent = defaultTarget.getParent();
|
||||
|
@ -204,6 +211,7 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
|||
ManagedBuildCPathEntryContainer.outputError(project.getName(), "Build information has not been loaded yet"); //$NON-NLS-1$
|
||||
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
|
||||
}
|
||||
|
||||
// See if we can load a dynamic resolver
|
||||
String baseTargetId = parent.getId();
|
||||
IManagedScannerInfoCollector collector = ManagedBuildManager.getScannerInfoCollector(baseTargetId);
|
||||
|
|
|
@ -21,6 +21,9 @@ import org.eclipse.core.runtime.IPath;
|
|||
* @since 2.0
|
||||
*/
|
||||
public class ManagedBuildPathEntryContainerInitializer extends PathEntryContainerInitializer {
|
||||
private static final String TRACE_FOOTER = "]: "; //$NON-NLS-1$
|
||||
private static final String TRACE_HEADER = "PathEntryContainerInitializer trace ["; //$NON-NLS-1$
|
||||
public static boolean VERBOSE = false;
|
||||
|
||||
/**
|
||||
* Need a zero-argument constructor to allow the system to create
|
||||
|
@ -34,6 +37,9 @@ public class ManagedBuildPathEntryContainerInitializer extends PathEntryContaine
|
|||
* @see org.eclipse.cdt.core.model.PathEntryContainerInitializer#initialize(org.eclipse.core.runtime.IPath, org.eclipse.cdt.core.model.ICProject)
|
||||
*/
|
||||
public void initialize(IPath containerPath, ICProject project) throws CoreException {
|
||||
if (VERBOSE) {
|
||||
System.out.println(TRACE_HEADER + project.getProject().getName() + TRACE_FOOTER + "Initializing path entry container");
|
||||
}
|
||||
CoreModel.getDefault().setPathEntryContainer(new ICProject[]{project}, new ManagedBuildCPathEntryContainer(project.getProject()), null);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue