diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java index da03a84236d..88e7542d4e3 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Intel Corporation and others. + * Copyright (c) 2007, 2008 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 @@ -7,6 +7,7 @@ * * Contributors: * Intel Corporation - Initial API and implementation + * IBM Corporation *******************************************************************************/ package org.eclipse.cdt.managedbuilder.internal.core; @@ -559,7 +560,7 @@ public class CommonBuilder extends ACBuilder { updateOtherConfigs(info, builders, kind); monitor.done(); - return project.getReferencedProjects(); + return refProjects; } private Set buildReferencedConfigs(IConfiguration[] cfgs, IProgressMonitor monitor){ @@ -574,6 +575,21 @@ public class CommonBuilder extends ACBuilder { 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$ diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ACBuilder.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ACBuilder.java index 9fa866b32ae..2ac46ffa7c6 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ACBuilder.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ACBuilder.java @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * IBM Corporation *******************************************************************************/ package org.eclipse.cdt.core.resources; @@ -24,6 +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 Preferences prefs = CCorePlugin.getDefault().getPluginPreferences(); /** @@ -102,4 +104,26 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa prefs.setValue(PREF_BUILD_ALL_CONFIGS, enable); } + /** + * 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 + * false otherwise + * @since 5.1 + */ + public static boolean buildRefConfig() { + //bug 219337 + return prefs.getBoolean(PREF_BUILD_REFERENCED_CONFIGS); + } + + /** + * Preference for building referenced projects only when there are changes within Eclipse. + * Dependent projects will be built regardless. + * @param enable + * @since 5.1 + */ + public static void setBuildRefConfig(boolean enable) { + prefs.setValue(PREF_BUILD_REFERENCED_CONFIGS, enable); + } + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java index e6b4d5a7a75..29b72ab58db 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java @@ -45,7 +45,7 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements private static final String USE_STRUCTURAL_PARSE_MODE_LABEL= PreferencesMessages.CPluginPreferencePage_structuralParseMode_label; private static final int GROUP_VINDENT = 5; private static final int GROUP_HINDENT = 20; - private Button b1, b2; + private Button b1, b2, b3; public CPluginPreferencePage() { super(GRID); @@ -123,7 +123,31 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements gd.verticalIndent = GROUP_VINDENT; noteControl.setLayoutData(gd); + // Building project dependencies + Group gr2 = new Group(parent, SWT.NONE); + gr2.setText(PreferencesMessages.CPluginPreferencePage_5); + GridData gd2 = new GridData(GridData.FILL_HORIZONTAL); + gd2.verticalIndent = GROUP_VINDENT; + gr2.setLayoutData(gd2); + gr2.setLayout(new GridLayout()); + + boolean b2 = ACBuilder.buildRefConfig(); + b3 = new Button(gr2, SWT.CHECK); + b3.setText(PreferencesMessages.CPluginPreferencePage_7); + gd2 = new GridData(GridData.FILL_HORIZONTAL); + gd2.verticalIndent = GROUP_VINDENT; + 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); } @Override protected Composite createNoteComposite(Font font, Composite composite, @@ -177,6 +201,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); } /* (non-Javadoc) @@ -189,6 +214,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()); return true; } @@ -196,7 +222,9 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements protected void performDefaults() { super.performDefaults(); ACBuilder.setAllConfigBuild(false); + ACBuilder.setBuildRefConfig(false); b1.setSelection(true); b2.setSelection(false); + b3.setSelection(false); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java index 0401e4a99ed..56398c741a2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java @@ -294,6 +294,9 @@ public final class PreferencesMessages extends NLS { public static String CPluginPreferencePage_2; 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_structuralParseMode_label; public static String CPluginPreferencePage_note; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties index 5b166eda776..ec1e8400f64 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties @@ -332,11 +332,16 @@ 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_caption= General settings for C/C++ Development: CPluginPreferencePage_structuralParseMode_label= &Follow unindexed header files when producing the outline view CPluginPreferencePage_note= Note: CPluginPreferencePage_performanceHint= Enabling this preference may have negative impact on performance. + + PropertyAndPreferencePage_useworkspacesettings_change=Configure Workspace Settings... PropertyAndPreferencePage_showprojectspecificsettings_label=Configure Project Specific Settings... PropertyAndPreferencePage_useprojectsettings_label=Enable pr&oject specific settings