mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
bug 219337
This commit is contained in:
parent
44907e7056
commit
858e15d457
5 changed files with 62 additions and 52 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Intel Corporation and others.
|
||||
* Copyright (c) 2007, 2009 Intel Corporation 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
|
||||
|
@ -491,6 +491,22 @@ public class CommonBuilder extends ACBuilder {
|
|||
return des != null && !des.isCdtProjectCreating();
|
||||
}
|
||||
|
||||
private class MyBoolean {
|
||||
private boolean value;
|
||||
|
||||
public MyBoolean (boolean value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(boolean value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* @see IncrementalProjectBuilder#build
|
||||
*/
|
||||
|
@ -513,12 +529,12 @@ public class CommonBuilder extends ACBuilder {
|
|||
for (IConfiguration cfg : cfgs) {
|
||||
info.setDefaultConfiguration(cfg);
|
||||
IBuilder builders[] = ManagedBuilderCorePlugin.createBuilders(project, args);
|
||||
projects = build(kind, project, builders, true, monitor);
|
||||
projects = build(kind, project, builders, true, monitor, new MyBoolean(false));
|
||||
}
|
||||
info.setDefaultConfiguration(defCfg);
|
||||
} else {
|
||||
IBuilder builders[] = ManagedBuilderCorePlugin.createBuilders(project, args);
|
||||
projects = build(kind, project, builders, true, monitor);
|
||||
projects = build(kind, project, builders, true, monitor, new MyBoolean(false));
|
||||
}
|
||||
|
||||
if(VERBOSE)
|
||||
|
@ -527,7 +543,7 @@ public class CommonBuilder extends ACBuilder {
|
|||
return projects;
|
||||
}
|
||||
|
||||
protected IProject[] build(int kind, IProject project, IBuilder[] builders, boolean isForeground, IProgressMonitor monitor) throws CoreException{
|
||||
protected IProject[] build(int kind, IProject project, IBuilder[] builders, boolean isForeground, IProgressMonitor monitor, MyBoolean isBuild) throws CoreException{
|
||||
if(!isCdtProjectCreated(project))
|
||||
return project.getReferencedProjects();
|
||||
|
||||
|
@ -545,7 +561,7 @@ public class CommonBuilder extends ACBuilder {
|
|||
monitor.beginTask("", num + rcfgs.length); //$NON-NLS-1$
|
||||
|
||||
if(rcfgs.length != 0){
|
||||
Set<IProject> set = buildReferencedConfigs(rcfgs, new SubProgressMonitor(monitor, 1));// = getProjectsSet(cfgs);
|
||||
Set<IProject> set = buildReferencedConfigs(rcfgs, new SubProgressMonitor(monitor, 1), isBuild);// = getProjectsSet(cfgs);
|
||||
if(set.size() != 0){
|
||||
set.addAll(Arrays.asList(refProjects));
|
||||
refProjects = set.toArray(new IProject[set.size()]);
|
||||
|
@ -553,7 +569,23 @@ public class CommonBuilder extends ACBuilder {
|
|||
}
|
||||
|
||||
for(int i = 0; i < num; i++){
|
||||
build(kind, new CfgBuildInfo(builders[i], isForeground), new SubProgressMonitor(monitor, 1));
|
||||
//bug 219337
|
||||
if (kind == INCREMENTAL_BUILD || kind == AUTO_BUILD ) {
|
||||
if (buildConfigResourceChanges()) { //only build projects with project resource changes
|
||||
IResourceDelta delta = getDelta(project);
|
||||
if (delta != null && delta.getAffectedChildren().length > 0) { //project resource has changed within Eclipse, need to build this configuration
|
||||
isBuild.setValue(true);
|
||||
build(kind, new CfgBuildInfo(builders[i], isForeground), new SubProgressMonitor(monitor, 1));
|
||||
}
|
||||
else if (isBuild.getValue()) { //one of its dependencies have rebuilt, need to rebuild this configuration
|
||||
build(kind, new CfgBuildInfo(builders[i], isForeground), new SubProgressMonitor(monitor, 1));
|
||||
}
|
||||
} else { //the default behaviour: 'make' is invoked on all configurations and incremental build is handled by 'make'
|
||||
build(kind, new CfgBuildInfo(builders[i], isForeground), new SubProgressMonitor(monitor, 1));
|
||||
}
|
||||
} else { //FULL_BUILD or CLEAN
|
||||
build(kind, new CfgBuildInfo(builders[i], isForeground), new SubProgressMonitor(monitor, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -564,37 +596,25 @@ public class CommonBuilder extends ACBuilder {
|
|||
return refProjects;
|
||||
}
|
||||
|
||||
private Set<IProject> buildReferencedConfigs(IConfiguration[] cfgs, IProgressMonitor monitor){
|
||||
private Set<IProject> buildReferencedConfigs(IConfiguration[] cfgs, IProgressMonitor monitor, MyBoolean refConfigChanged){
|
||||
Set<IProject> projSet = getProjectsSet(cfgs);
|
||||
cfgs = filterConfigsToBuild(cfgs);
|
||||
MyBoolean nextConfigChanged = new MyBoolean(false);
|
||||
|
||||
if(cfgs.length != 0){
|
||||
monitor.beginTask(ManagedMakeMessages.getResourceString("CommonBuilder.22"), cfgs.length); //$NON-NLS-1$
|
||||
for(int i = 0; i < cfgs.length; i++){
|
||||
IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
|
||||
nextConfigChanged.setValue(false);
|
||||
try {
|
||||
IConfiguration cfg = cfgs[i];
|
||||
IBuilder builder = cfg.getEditableBuilder();
|
||||
// CfgBuildInfo bInfo = new CfgBuildInfo(builder, false);
|
||||
|
||||
//bug 219337
|
||||
if (buildRefConfig()){
|
||||
IProject currProject = cfg.getOwner().getProject(); //get the project of the current referenced configuration
|
||||
IBuilder[] builders = new IBuilder[]{builder};
|
||||
IConfiguration[] refConfigs = getReferencedConfigs(builders); //referenced configurations of the current project
|
||||
if (refConfigs.length <=0) { //if this is not a dependent project, then we don't build unless there's a change within the workspace
|
||||
IResourceDelta delta = getDelta(currProject);
|
||||
if (delta != null && delta.getAffectedChildren().length <= 0) { //do not build when there are no changes since last build
|
||||
projSet.addAll(Arrays.asList(currProject.getReferencedProjects()));
|
||||
return projSet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(VERBOSE)
|
||||
outputTrace(cfg.getOwner().getProject().getName(), ">>>>building reference cfg " + cfg.getName()); //$NON-NLS-1$
|
||||
|
||||
IProject[] projs = build(INCREMENTAL_BUILD, cfg.getOwner().getProject(), new IBuilder[]{builder}, false, subMonitor);
|
||||
IProject[] projs = build(INCREMENTAL_BUILD, cfg.getOwner().getProject(), new IBuilder[]{builder}, false, subMonitor, nextConfigChanged);
|
||||
|
||||
if(VERBOSE)
|
||||
outputTrace(cfg.getOwner().getProject().getName(), "<<<<done building reference cfg " + cfg.getName()); //$NON-NLS-1$
|
||||
|
@ -605,6 +625,7 @@ public class CommonBuilder extends ACBuilder {
|
|||
} finally {
|
||||
subMonitor.done();
|
||||
}
|
||||
refConfigChanged.setValue(refConfigChanged.getValue() || nextConfigChanged.getValue());
|
||||
}
|
||||
} else {
|
||||
monitor.done();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2008 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2009 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
|
||||
|
@ -25,7 +25,7 @@ import org.eclipse.core.runtime.Preferences;
|
|||
public abstract class ACBuilder extends IncrementalProjectBuilder implements IMarkerGenerator {
|
||||
|
||||
private static final String PREF_BUILD_ALL_CONFIGS = "build.all.configs.enabled"; //$NON-NLS-1$
|
||||
private static final String PREF_BUILD_REFERENCED_CONFIGS = "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();
|
||||
|
||||
/**
|
||||
|
@ -105,25 +105,25 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa
|
|||
}
|
||||
|
||||
/**
|
||||
* Preference for building referenced projects only when there are changes within Eclipse.
|
||||
* Dependent projects will be built regardless.
|
||||
* @return true if referenced projects will be build when changes within the project in Eclipse
|
||||
* Preference for building configurations only when there are resource changes within Eclipse or
|
||||
* when there are changes in its references.
|
||||
* @return true if configurations will be build when project resource changes within Eclipse
|
||||
* false otherwise
|
||||
* @since 5.1
|
||||
*/
|
||||
public static boolean buildRefConfig() {
|
||||
public static boolean buildConfigResourceChanges() {
|
||||
//bug 219337
|
||||
return prefs.getBoolean(PREF_BUILD_REFERENCED_CONFIGS);
|
||||
return prefs.getBoolean(PREF_BUILD_CONFIGS_RESOURCE_CHANGES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preference for building referenced projects only when there are changes within Eclipse.
|
||||
* Dependent projects will be built regardless.
|
||||
* Preference for building configurations only when there are resource changes within Eclipse or
|
||||
* when there are changes in its references.
|
||||
* @param enable
|
||||
* @since 5.1
|
||||
*/
|
||||
public static void setBuildRefConfig(boolean enable) {
|
||||
prefs.setValue(PREF_BUILD_REFERENCED_CONFIGS, enable);
|
||||
public static void setBuildConfigResourceChanges(boolean enable) {
|
||||
prefs.setValue(PREF_BUILD_CONFIGS_RESOURCE_CHANGES, enable);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2008 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 2009 IBM Corporation 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
|
||||
|
@ -136,7 +136,7 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
|
|||
gr2.setLayoutData(gd2);
|
||||
gr2.setLayout(new GridLayout());
|
||||
|
||||
boolean b2 = ACBuilder.buildRefConfig();
|
||||
boolean b2 = ACBuilder.buildConfigResourceChanges();
|
||||
|
||||
b3 = new Button(gr2, SWT.CHECK);
|
||||
b3.setText(PreferencesMessages.CPluginPreferencePage_7);
|
||||
|
@ -145,15 +145,6 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
|
|||
b3.setLayoutData(gd2);
|
||||
b3.setSelection(b2);
|
||||
|
||||
noteControl= createNoteComposite(
|
||||
JFaceResources.getDialogFont(),
|
||||
gr2,
|
||||
PreferencesMessages.CPluginPreferencePage_note,
|
||||
PreferencesMessages.CPluginPreferencePage_6);
|
||||
gd2 = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
|
||||
gd2.verticalIndent = GROUP_VINDENT;
|
||||
noteControl.setLayoutData(gd2);
|
||||
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns= 2;
|
||||
|
||||
|
@ -234,7 +225,7 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
|
|||
prefs.setDefault(PreferenceConstants.PREF_LINK_TO_EDITOR, false);
|
||||
prefs.setDefault(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE, false);
|
||||
ACBuilder.setAllConfigBuild(false);
|
||||
ACBuilder.setBuildRefConfig(false);
|
||||
ACBuilder.setBuildConfigResourceChanges(false);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -247,7 +238,7 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
|
|||
// tell the Core Plugin about this preference
|
||||
CCorePlugin.getDefault().setStructuralParseMode(useStructuralParseMode());
|
||||
ACBuilder.setAllConfigBuild(b2.getSelection());
|
||||
ACBuilder.setBuildRefConfig(b3.getSelection());
|
||||
ACBuilder.setBuildConfigResourceChanges(b3.getSelection());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -255,7 +246,7 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
|
|||
protected void performDefaults() {
|
||||
super.performDefaults();
|
||||
ACBuilder.setAllConfigBuild(false);
|
||||
ACBuilder.setBuildRefConfig(false);
|
||||
ACBuilder.setBuildConfigResourceChanges(false);
|
||||
b1.setSelection(true);
|
||||
b2.setSelection(false);
|
||||
b3.setSelection(false);
|
||||
|
|
|
@ -296,7 +296,6 @@ public final class PreferencesMessages extends NLS {
|
|||
public static String CPluginPreferencePage_3;
|
||||
public static String CPluginPreferencePage_4;
|
||||
public static String CPluginPreferencePage_5;
|
||||
public static String CPluginPreferencePage_6;
|
||||
public static String CPluginPreferencePage_7;
|
||||
public static String CPluginPreferencePage_caption;
|
||||
public static String CPluginPreferencePage_cdtDialogs_group;
|
||||
|
|
|
@ -333,9 +333,8 @@ CPluginPreferencePage_1=Commands 'Build project', 'Build All', 'Build Working Se
|
|||
CPluginPreferencePage_2=Build a&ctive configuration in each project
|
||||
CPluginPreferencePage_3=Build a&ll configurations in each project
|
||||
CPluginPreferencePage_4=This feature is applicable only to projects that support separate configurations.
|
||||
CPluginPreferencePage_5=Building project dependencies
|
||||
CPluginPreferencePage_6=Projects with dependencies will still be build regardless
|
||||
CPluginPreferencePage_7=Build referenced projects only when there are Eclipse qresource changes within the projects
|
||||
CPluginPreferencePage_5=Building project configurations
|
||||
CPluginPreferencePage_7=Build configurations only when there are Eclipse resource changes within the project and its references
|
||||
CPluginPreferencePage_caption= General settings for C/C++ Development:
|
||||
CPluginPreferencePage_cdtDialogs_group=CDT Dialogs
|
||||
CPluginPreferencePage_clear_button=Clear
|
||||
|
|
Loading…
Add table
Reference in a new issue