1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

debug option to track build events

This commit is contained in:
Andrew Gvozdev 2010-03-22 17:05:48 +00:00
parent 62139d3e3b
commit d1005fa487
7 changed files with 102 additions and 1 deletions

View file

@ -73,6 +73,9 @@ public class MakeBuilder extends ACBuilder {
*/ */
@Override @Override
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
if (DEBUG_EVENTS)
printEvent(kind, args);
boolean bPerformBuild = true; boolean bPerformBuild = true;
IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(args, MakeBuilder.BUILDER_ID); IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(args, MakeBuilder.BUILDER_ID);
if (!shouldBuild(kind, info)) { if (!shouldBuild(kind, info)) {
@ -102,6 +105,9 @@ public class MakeBuilder extends ACBuilder {
@Override @Override
protected void clean(IProgressMonitor monitor) throws CoreException { protected void clean(IProgressMonitor monitor) throws CoreException {
if (DEBUG_EVENTS)
printEvent(IncrementalProjectBuilder.CLEAN_BUILD, null);
final IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(getProject(), BUILDER_ID); final IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(getProject(), BUILDER_ID);
if (shouldBuild(CLEAN_BUILD, info)) { if (shouldBuild(CLEAN_BUILD, info)) {
IResourceRuleFactory ruleFactory= ResourcesPlugin.getWorkspace().getRuleFactory(); IResourceRuleFactory ruleFactory= ResourcesPlugin.getWorkspace().getRuleFactory();

View file

@ -47,6 +47,9 @@ public class ScannerConfigBuilder extends ACBuilder {
* @see IncrementalProjectBuilder#build * @see IncrementalProjectBuilder#build
*/ */
protected IProject [] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { protected IProject [] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
if (DEBUG_EVENTS)
printEvent(kind, args);
// If auto discovery is disabled, do nothing // If auto discovery is disabled, do nothing
// boolean autodiscoveryEnabled; // boolean autodiscoveryEnabled;
if(buildNewStyle(getProject(), monitor)) if(buildNewStyle(getProject(), monitor))

View file

@ -64,6 +64,9 @@ public class GNUMakefileChecker extends ACBuilder {
* @see IncrementalProjectBuilder#build * @see IncrementalProjectBuilder#build
*/ */
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
if (DEBUG_EVENTS)
printEvent(kind, args);
IResourceDelta delta = null; IResourceDelta delta = null;
// For non-full-build fetch the deltas // For non-full-build fetch the deltas

View file

@ -72,6 +72,9 @@ public class ScannerConfigBuilder extends ACBuilder {
*/ */
@Override @Override
protected IProject [] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { protected IProject [] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
if (DEBUG_EVENTS)
printEvent(kind, args);
// If auto discovery is disabled, do nothing // If auto discovery is disabled, do nothing
// boolean autodiscoveryEnabled; // boolean autodiscoveryEnabled;
// boolean autodiscoveryEnabled2; // boolean autodiscoveryEnabled2;

View file

@ -469,6 +469,9 @@ public class CommonBuilder extends ACBuilder {
*/ */
@Override @Override
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
if (DEBUG_EVENTS)
printEvent(kind, args);
fBuildSet.start(this); fBuildSet.start(this);
IProject project = getProject(); IProject project = getProject();
@ -1485,6 +1488,9 @@ public class CommonBuilder extends ACBuilder {
@Override @Override
protected void clean(IProgressMonitor monitor) throws CoreException { protected void clean(IProgressMonitor monitor) throws CoreException {
if (DEBUG_EVENTS)
printEvent(IncrementalProjectBuilder.CLEAN_BUILD, null);
IProject curProject = getProject(); IProject curProject = getProject();
if(!isCdtProjectCreated(curProject)) if(!isCdtProjectCreated(curProject))

View file

@ -56,6 +56,7 @@ import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor; import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
@ -403,6 +404,9 @@ public class GeneratedMakefileBuilder extends ACBuilder {
*/ */
@Override @Override
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
if (DEBUG_EVENTS)
printEvent(kind, args);
// We should always tell the build system what projects we reference // We should always tell the build system what projects we reference
referencedProjects = getProject().getReferencedProjects(); referencedProjects = getProject().getReferencedProjects();
@ -582,6 +586,9 @@ public class GeneratedMakefileBuilder extends ACBuilder {
*/ */
@Override @Override
protected void clean(IProgressMonitor monitor) throws CoreException { protected void clean(IProgressMonitor monitor) throws CoreException {
if (DEBUG_EVENTS)
printEvent(IncrementalProjectBuilder.CLEAN_BUILD, null);
referencedProjects = getProject().getReferencedProjects(); referencedProjects = getProject().getReferencedProjects();
outputTrace(getProject().getName(), "Clean build requested"); //$NON-NLS-1$ outputTrace(getProject().getName(), "Clean build requested"); //$NON-NLS-1$
IManagedBuildInfo info = getBuildInfo(); IManagedBuildInfo info = getBuildInfo();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2009 QNX Software Systems and others. * Copyright (c) 2000, 2010 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -12,14 +12,21 @@
package org.eclipse.cdt.core.resources; package org.eclipse.cdt.core.resources;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IMarkerGenerator; import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.core.ProblemMarkerInfo; import org.eclipse.cdt.core.ProblemMarkerInfo;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Preferences;
import org.eclipse.osgi.util.NLS; import org.eclipse.osgi.util.NLS;
@ -29,6 +36,9 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa
private static final String PREF_BUILD_CONFIGS_RESOURCE_CHANGES = "build.proj.ref.configs.enabled"; //$NON-NLS-1$ private static final String PREF_BUILD_CONFIGS_RESOURCE_CHANGES = "build.proj.ref.configs.enabled"; //$NON-NLS-1$
private static final Preferences prefs = CCorePlugin.getDefault().getPluginPreferences(); private static final Preferences prefs = CCorePlugin.getDefault().getPluginPreferences();
private static final String CONTENTS_CONFIGURATION_IDS = "org.eclipse.cdt.make.core.configurationIds"; //$NON-NLS-1$
/** @since 5.2 */ // set to true to print build events on the console in debug mode
protected static final boolean DEBUG_EVENTS = false;
/** /**
* Constructor for ACBuilder * Constructor for ACBuilder
*/ */
@ -139,4 +149,67 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa
prefs.setValue(PREF_BUILD_CONFIGS_RESOURCE_CHANGES, enable); prefs.setValue(PREF_BUILD_CONFIGS_RESOURCE_CHANGES, enable);
} }
@SuppressWarnings("nls")
private static String kindToString(int kind) {
return (kind==IncrementalProjectBuilder.AUTO_BUILD ? "AUTO_BUILD"
: kind==IncrementalProjectBuilder.CLEAN_BUILD ? "CLEAN_BUILD"
: kind==IncrementalProjectBuilder.FULL_BUILD ? "FULL_BUILD"
: kind==IncrementalProjectBuilder.INCREMENTAL_BUILD ? "INCREMENTAL_BUILD"
: "[unknown kind]")+"="+kind;
}
@SuppressWarnings("nls")
private String cfgIdToNames(String strIds) {
IProject project = getProject();
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project);
if (prjDesc==null)
return strIds;
if (strIds==null)
return "Active=" + prjDesc.getActiveConfiguration().getName();
String[] ids = strIds.split("\\|");
String names="";
for (String id : ids) {
ICConfigurationDescription cfgDesc = prjDesc.getConfigurationById(id);
String name;
if (cfgDesc!=null)
name = cfgDesc.getName();
else
name = id;
if (names.length()>0)
names=names+",";
names = names + name;
}
if (names.equals(""))
return strIds;
return names;
}
/**
* For debugging purpose only. Prints events on the debug console.
*
* @since 5.2
*/
@SuppressWarnings("nls")
protected void printEvent(int kind, Map<String, String> args) {
if (DEBUG_EVENTS) {
System.out.println("t"+Thread.currentThread().getId()+": "
+ kindToString(kind)
+ ", " + getProject()
+ (args!=null ? "[" + cfgIdToNames(args.get(CONTENTS_CONFIGURATION_IDS)) +"]" : "")
+ ", " + this.getClass().getSimpleName()
);
}
}
@Override
// This method is overridden with no purpose but to track events in debug mode
protected void clean(IProgressMonitor monitor) throws CoreException {
super.clean(monitor);
if (DEBUG_EVENTS)
printEvent(IncrementalProjectBuilder.CLEAN_BUILD, null);
}
} }