mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 03:53:21 +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
|
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
|
# Reports path entry container activity
|
||||||
org.eclipse.cdt.managedbuilder.core/debug/pathEntry=false
|
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 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.ManagedBuildCPathEntryContainer;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildPathEntryContainerInitializer;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
@ -83,16 +85,26 @@ public class ManagedBuilderCorePlugin extends Plugin {
|
||||||
configurePluginDebugOptions();
|
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() {
|
private void configurePluginDebugOptions() {
|
||||||
if (isDebugging()) {
|
if (isDebugging()) {
|
||||||
String option = Platform.getDebugOption(PATH_ENTRY);
|
String pathInit = Platform.getDebugOption(PATH_ENTRY_INIT);
|
||||||
if (option != null) {
|
if (pathInit != null) {
|
||||||
ManagedBuildCPathEntryContainer.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
|
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
|
* @since 1.2
|
||||||
*/
|
*/
|
||||||
public class GeneratedMakefileBuilder extends ACBuilder {
|
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 {
|
public class ResourceDeltaVisitor implements IResourceDeltaVisitor {
|
||||||
private boolean buildNeeded = true;
|
|
||||||
private IManagedBuildInfo buildInfo;
|
private IManagedBuildInfo buildInfo;
|
||||||
|
private boolean buildNeeded = true;
|
||||||
private List reservedNames;
|
private List reservedNames;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,6 +101,10 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
private boolean isProjectFile(IResource resource) {
|
private boolean isProjectFile(IResource resource) {
|
||||||
return reservedNames.contains(resource.getName());
|
return reservedNames.contains(resource.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean shouldBuild() {
|
||||||
|
return buildNeeded;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||||
IResource resource = delta.getResource();
|
IResource resource = delta.getResource();
|
||||||
|
@ -146,9 +134,42 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean shouldBuild() {
|
// String constants
|
||||||
return buildNeeded;
|
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
|
// Get the build information
|
||||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
|
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
|
outputError(getProject().getName(), "Build information was not found"); //$NON-NLS-1$
|
||||||
return referencedProjects;
|
return referencedProjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
// So let's figure out why we got called
|
// So let's figure out why we got called
|
||||||
if (kind == CLEAN_BUILD) {
|
if (kind == CLEAN_BUILD) {
|
||||||
|
outputTrace(getProject().getName(), "Clean build requested"); //$NON-NLS-1$
|
||||||
cleanBuild(monitor, info);
|
cleanBuild(monitor, info);
|
||||||
}
|
}
|
||||||
else if (kind == FULL_BUILD || info.needsRebuild()) {
|
else if (kind == FULL_BUILD || info.needsRebuild()) {
|
||||||
|
outputTrace(getProject().getName(), "Full build needed/requested"); //$NON-NLS-1$
|
||||||
fullBuild(monitor, info);
|
fullBuild(monitor, info);
|
||||||
}
|
}
|
||||||
else if (kind == AUTO_BUILD && info.needsRebuild()) {
|
else if (kind == AUTO_BUILD && info.needsRebuild()) {
|
||||||
|
outputTrace(getProject().getName(), "Autobuild requested, full build needed"); //$NON-NLS-1$
|
||||||
fullBuild(monitor, info);
|
fullBuild(monitor, info);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -188,11 +213,13 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(info);
|
ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(info);
|
||||||
IResourceDelta delta = getDelta(getProject());
|
IResourceDelta delta = getDelta(getProject());
|
||||||
if (delta == null) {
|
if (delta == null) {
|
||||||
|
outputTrace(getProject().getName(), "Incremental build requested, full build needed"); //$NON-NLS-1$
|
||||||
fullBuild(monitor, info);
|
fullBuild(monitor, info);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
delta.accept(visitor);
|
delta.accept(visitor);
|
||||||
if (visitor.shouldBuild()) {
|
if (visitor.shouldBuild()) {
|
||||||
|
outputTrace(getProject().getName(), "Incremental build requested"); //$NON-NLS-1$
|
||||||
incrementalBuild(delta, info, monitor);
|
incrementalBuild(delta, info, monitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,6 +232,19 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
return referencedProjects;
|
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 monitor
|
||||||
* @param info
|
* @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
|
* @param monitor
|
||||||
*/
|
*/
|
||||||
|
@ -599,7 +626,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
epm.reportProblems();
|
epm.reportProblems();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CCorePlugin.log(e);
|
ManagedBuilderCorePlugin.log(e);
|
||||||
forgetLastBuiltState();
|
forgetLastBuiltState();
|
||||||
} finally {
|
} finally {
|
||||||
monitor.done();
|
monitor.done();
|
||||||
|
|
|
@ -64,11 +64,15 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
||||||
public static boolean VERBOSE = false;
|
public static boolean VERBOSE = false;
|
||||||
|
|
||||||
public static void outputTrace(String resourceName, String message) {
|
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) {
|
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() {
|
public IPathEntry[] getPathEntries() {
|
||||||
info = (ManagedBuildInfo) ManagedBuildManager.getBuildInfo(project);
|
info = (ManagedBuildInfo) ManagedBuildManager.getBuildInfo(project);
|
||||||
|
if (info == null) {
|
||||||
// Load the toolchain-spec'd collector
|
ManagedBuildCPathEntryContainer.outputError(project.getName(), "Build information is null"); //$NON-NLS-1$
|
||||||
|
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
|
||||||
|
}
|
||||||
defaultTarget = info.getDefaultTarget();
|
defaultTarget = info.getDefaultTarget();
|
||||||
if (defaultTarget == null) {
|
if (defaultTarget == null) {
|
||||||
// The build information has not been loaded yet
|
// 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()]);
|
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
|
||||||
}
|
}
|
||||||
ITarget parent = defaultTarget.getParent();
|
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$
|
ManagedBuildCPathEntryContainer.outputError(project.getName(), "Build information has not been loaded yet"); //$NON-NLS-1$
|
||||||
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
|
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if we can load a dynamic resolver
|
// See if we can load a dynamic resolver
|
||||||
String baseTargetId = parent.getId();
|
String baseTargetId = parent.getId();
|
||||||
IManagedScannerInfoCollector collector = ManagedBuildManager.getScannerInfoCollector(baseTargetId);
|
IManagedScannerInfoCollector collector = ManagedBuildManager.getScannerInfoCollector(baseTargetId);
|
||||||
|
|
|
@ -21,6 +21,9 @@ import org.eclipse.core.runtime.IPath;
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public class ManagedBuildPathEntryContainerInitializer extends PathEntryContainerInitializer {
|
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
|
* 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)
|
* @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 {
|
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);
|
CoreModel.getDefault().setPathEntryContainer(new ICProject[]{project}, new ManagedBuildCPathEntryContainer(project.getProject()), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue