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:
parent
62139d3e3b
commit
d1005fa487
7 changed files with 102 additions and 1 deletions
|
@ -73,6 +73,9 @@ public class MakeBuilder extends ACBuilder {
|
|||
*/
|
||||
@Override
|
||||
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
|
||||
if (DEBUG_EVENTS)
|
||||
printEvent(kind, args);
|
||||
|
||||
boolean bPerformBuild = true;
|
||||
IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(args, MakeBuilder.BUILDER_ID);
|
||||
if (!shouldBuild(kind, info)) {
|
||||
|
@ -102,6 +105,9 @@ public class MakeBuilder extends ACBuilder {
|
|||
|
||||
@Override
|
||||
protected void clean(IProgressMonitor monitor) throws CoreException {
|
||||
if (DEBUG_EVENTS)
|
||||
printEvent(IncrementalProjectBuilder.CLEAN_BUILD, null);
|
||||
|
||||
final IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(getProject(), BUILDER_ID);
|
||||
if (shouldBuild(CLEAN_BUILD, info)) {
|
||||
IResourceRuleFactory ruleFactory= ResourcesPlugin.getWorkspace().getRuleFactory();
|
||||
|
|
|
@ -47,6 +47,9 @@ public class ScannerConfigBuilder extends ACBuilder {
|
|||
* @see IncrementalProjectBuilder#build
|
||||
*/
|
||||
protected IProject [] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
|
||||
if (DEBUG_EVENTS)
|
||||
printEvent(kind, args);
|
||||
|
||||
// If auto discovery is disabled, do nothing
|
||||
// boolean autodiscoveryEnabled;
|
||||
if(buildNewStyle(getProject(), monitor))
|
||||
|
|
|
@ -64,6 +64,9 @@ public class GNUMakefileChecker extends ACBuilder {
|
|||
* @see IncrementalProjectBuilder#build
|
||||
*/
|
||||
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
|
||||
if (DEBUG_EVENTS)
|
||||
printEvent(kind, args);
|
||||
|
||||
IResourceDelta delta = null;
|
||||
|
||||
// For non-full-build fetch the deltas
|
||||
|
|
|
@ -72,6 +72,9 @@ public class ScannerConfigBuilder extends ACBuilder {
|
|||
*/
|
||||
@Override
|
||||
protected IProject [] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
|
||||
if (DEBUG_EVENTS)
|
||||
printEvent(kind, args);
|
||||
|
||||
// If auto discovery is disabled, do nothing
|
||||
// boolean autodiscoveryEnabled;
|
||||
// boolean autodiscoveryEnabled2;
|
||||
|
|
|
@ -469,6 +469,9 @@ public class CommonBuilder extends ACBuilder {
|
|||
*/
|
||||
@Override
|
||||
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
|
||||
if (DEBUG_EVENTS)
|
||||
printEvent(kind, args);
|
||||
|
||||
fBuildSet.start(this);
|
||||
|
||||
IProject project = getProject();
|
||||
|
@ -1485,6 +1488,9 @@ public class CommonBuilder extends ACBuilder {
|
|||
|
||||
@Override
|
||||
protected void clean(IProgressMonitor monitor) throws CoreException {
|
||||
if (DEBUG_EVENTS)
|
||||
printEvent(IncrementalProjectBuilder.CLEAN_BUILD, null);
|
||||
|
||||
IProject curProject = getProject();
|
||||
|
||||
if(!isCdtProjectCreated(curProject))
|
||||
|
|
|
@ -56,6 +56,7 @@ import org.eclipse.core.resources.IResourceDelta;
|
|||
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
@ -403,6 +404,9 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
*/
|
||||
@Override
|
||||
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
|
||||
referencedProjects = getProject().getReferencedProjects();
|
||||
|
||||
|
@ -582,6 +586,9 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
*/
|
||||
@Override
|
||||
protected void clean(IProgressMonitor monitor) throws CoreException {
|
||||
if (DEBUG_EVENTS)
|
||||
printEvent(IncrementalProjectBuilder.CLEAN_BUILD, null);
|
||||
|
||||
referencedProjects = getProject().getReferencedProjects();
|
||||
outputTrace(getProject().getName(), "Clean build requested"); //$NON-NLS-1$
|
||||
IManagedBuildInfo info = getBuildInfo();
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -12,14 +12,21 @@
|
|||
package org.eclipse.cdt.core.resources;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.IMarkerGenerator;
|
||||
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.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Preferences;
|
||||
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 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
|
||||
*/
|
||||
|
@ -139,4 +149,67 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue