1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-02 22:05:44 +02:00

Bug #194026 : Add "Build All Configurations" preference option

This commit is contained in:
Oleg Krasilnikov 2008-03-20 16:41:09 +00:00
parent 01a5281372
commit 4ef0990365
7 changed files with 184 additions and 84 deletions

View file

@ -59,8 +59,6 @@ public class ScannerConfigBuilder extends ACBuilder {
public final static String BUILDER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".ScannerConfigBuilder"; //$NON-NLS-1$ public final static String BUILDER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".ScannerConfigBuilder"; //$NON-NLS-1$
private static final boolean BUILD_ALL_CONFIGS = false;
public ScannerConfigBuilder() { public ScannerConfigBuilder() {
super(); super();
} }
@ -78,7 +76,7 @@ public class ScannerConfigBuilder extends ACBuilder {
if(bInfo != null){ if(bInfo != null){
IConfiguration cfgs[] = bInfo.getManagedProject().getConfigurations(); IConfiguration cfgs[] = bInfo.getManagedProject().getConfigurations();
if(cfgs.length != 0){ if(cfgs.length != 0){
if(!BUILD_ALL_CONFIGS){ if(!needAllConfigBuild()){
ICProjectDescription des = CoreModel.getDefault().getProjectDescription(getProject(), false); ICProjectDescription des = CoreModel.getDefault().getProjectDescription(getProject(), false);
IConfiguration cfg = null; IConfiguration cfg = null;
if(des != null){ if(des != null){

View file

@ -502,8 +502,21 @@ public class CommonBuilder extends ACBuilder {
if(VERBOSE) if(VERBOSE)
outputTrace(project.getName(), ">>build requested, type = " + kind); //$NON-NLS-1$ outputTrace(project.getName(), ">>build requested, type = " + kind); //$NON-NLS-1$
IBuilder builders[] = ManagedBuilderCorePlugin.createBuilders(project, args); IProject[] projects = null;
IProject[] projects = build(kind, project, builders, true, monitor); if (needAllConfigBuild()) {
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
IConfiguration[] cfgs = info.getManagedProject().getConfigurations();
IConfiguration defCfg = info.getDefaultConfiguration();
for (IConfiguration cfg : cfgs) {
info.setDefaultConfiguration(cfg);
IBuilder builders[] = ManagedBuilderCorePlugin.createBuilders(project, args);
projects = build(kind, project, builders, true, monitor);
}
info.setDefaultConfiguration(defCfg);
} else {
IBuilder builders[] = ManagedBuilderCorePlugin.createBuilders(project, args);
projects = build(kind, project, builders, true, monitor);
}
if(VERBOSE) if(VERBOSE)
outputTrace(project.getName(), "<<done build requested, type = " + kind); //$NON-NLS-1$ outputTrace(project.getName(), "<<done build requested, type = " + kind); //$NON-NLS-1$
@ -524,15 +537,15 @@ public class CommonBuilder extends ACBuilder {
if(status.getSeverity() != IStatus.OK) if(status.getSeverity() != IStatus.OK)
throw new CoreException(status); throw new CoreException(status);
IConfiguration cfgs[] = getReferencedConfigs(builders); IConfiguration rcfgs[] = getReferencedConfigs(builders);
monitor.beginTask("", num + cfgs.length); //$NON-NLS-1$ monitor.beginTask("", num + rcfgs.length); //$NON-NLS-1$
if(cfgs.length != 0){ if(rcfgs.length != 0){
Set set = buildReferencedConfigs(cfgs, new SubProgressMonitor(monitor, 1));// = getProjectsSet(cfgs); Set<IProject> set = buildReferencedConfigs(rcfgs, new SubProgressMonitor(monitor, 1));// = getProjectsSet(cfgs);
if(set.size() != 0){ if(set.size() != 0){
set.addAll(Arrays.asList(refProjects)); set.addAll(Arrays.asList(refProjects));
refProjects = (IProject[])set.toArray(new IProject[set.size()]); refProjects = set.toArray(new IProject[set.size()]);
} }
} }
@ -548,8 +561,8 @@ public class CommonBuilder extends ACBuilder {
return project.getReferencedProjects(); return project.getReferencedProjects();
} }
private Set buildReferencedConfigs(IConfiguration[] cfgs, IProgressMonitor monitor){ private Set<IProject> buildReferencedConfigs(IConfiguration[] cfgs, IProgressMonitor monitor){
Set projSet = getProjectsSet(cfgs); Set<IProject> projSet = getProjectsSet(cfgs);
cfgs = filterConfigsToBuild(cfgs); cfgs = filterConfigsToBuild(cfgs);
if(cfgs.length != 0){ if(cfgs.length != 0){
@ -610,7 +623,7 @@ public class CommonBuilder extends ACBuilder {
} }
private IConfiguration[] getReferencedConfigs(IBuilder[] builders){ private IConfiguration[] getReferencedConfigs(IBuilder[] builders){
Set set = new HashSet(); Set<IConfiguration> set = new HashSet<IConfiguration>();
for(int i = 0; i < builders.length; i++){ for(int i = 0; i < builders.length; i++){
IConfiguration cfg = builders[i].getParent().getParent(); IConfiguration cfg = builders[i].getParent().getParent();
IConfiguration refs[] = ManagedBuildManager.getReferencedConfigurations(cfg); IConfiguration refs[] = ManagedBuildManager.getReferencedConfigurations(cfg);
@ -618,14 +631,14 @@ public class CommonBuilder extends ACBuilder {
set.add(refs[k]); set.add(refs[k]);
} }
} }
return (IConfiguration[]) set.toArray(new Configuration[set.size()]); return set.toArray(new Configuration[set.size()]);
} }
private Set getProjectsSet(IConfiguration[] cfgs){ private Set<IProject> getProjectsSet(IConfiguration[] cfgs){
if(cfgs.length == 0) if(cfgs.length == 0)
return new HashSet(0); return new HashSet<IProject>(0);
Set set = new HashSet(); Set<IProject> set = new HashSet<IProject>();
for(int i = 0; i < cfgs.length; i++){ for(int i = 0; i < cfgs.length; i++){
set.add(cfgs[i].getOwner().getProject()); set.add(cfgs[i].getOwner().getProject());
} }
@ -759,7 +772,6 @@ public class CommonBuilder extends ACBuilder {
// } // }
if (status.isBuild()) { if (status.isBuild()) {
// IManagedBuilderMakefileGenerator makeGen = null;
IConfiguration cfg = bInfo.getConfiguration(); IConfiguration cfg = bInfo.getConfiguration();
if(!builder.isCustomBuilder()){ if(!builder.isCustomBuilder()){

View file

@ -417,80 +417,87 @@ public class GeneratedMakefileBuilder extends ACBuilder {
return referencedProjects; return referencedProjects;
} }
IConfiguration cfg = info.getDefaultConfiguration(); IConfiguration[] cfgs = null;
if (needAllConfigBuild()) {
updateOtherConfigs(cfg, kind); cfgs = info.getManagedProject().getConfigurations();
} else {
if(((Configuration)cfg).isInternalBuilderEnabled()){ cfgs = new IConfiguration[] {info.getDefaultConfiguration() };
invokeInternalBuilder(cfg, kind != FULL_BUILD, ((Configuration)cfg).getInternalBuilderIgnoreErr(), monitor);
// Scrub the build info the project
info.setRebuildState(false);
return referencedProjects;
} }
// Create a makefile generator for the build for (IConfiguration cfg : cfgs) {
IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration()); updateOtherConfigs(cfg, kind);
generator.initialize(getProject(), info, monitor);
//perform necessary cleaning and build type calculation if(((Configuration)cfg).isInternalBuilderEnabled()){
if(cfg.needsFullRebuild()){ invokeInternalBuilder(cfg, kind != FULL_BUILD, ((Configuration)cfg).getInternalBuilderIgnoreErr(), monitor);
//configuration rebuild state is set to true,
//full rebuild is needed in any case
//clean first, then make a full build
outputTrace(getProject().getName(), "config rebuild state is set to true, making a full rebuild"); //$NON-NLS-1$
clean(new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN));
fullBuild(info, generator, monitor);
} else {
boolean fullBuildNeeded = info.needsRebuild();
IBuildDescription des = null;
IResourceDelta delta = kind == FULL_BUILD ? null : getDelta(getProject()); // Scrub the build info the project
if(delta == null) info.setRebuildState(false);
fullBuildNeeded = true; return referencedProjects;
if(cfg.needsRebuild() || delta != null){ }
//use a build desacription model to calculate the resources to be cleaned
//only in case there are some changes to the project sources or build information
try{
int flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.DEPFILES | BuildDescriptionManager.DEPS;
if(delta != null)
flags |= BuildDescriptionManager.REMOVED;
outputTrace(getProject().getName(), "using a build description.."); //$NON-NLS-1$ // Create a makefile generator for the build
IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration());
generator.initialize(getProject(), info, monitor);
des = BuildDescriptionManager.createBuildDescription(info.getDefaultConfiguration(), getDelta(getProject()), flags); //perform necessary cleaning and build type calculation
if(cfg.needsFullRebuild()){
//configuration rebuild state is set to true,
//full rebuild is needed in any case
//clean first, then make a full build
outputTrace(getProject().getName(), "config rebuild state is set to true, making a full rebuild"); //$NON-NLS-1$
clean(new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN));
fullBuild(info, generator, monitor);
} else {
boolean fullBuildNeeded = info.needsRebuild();
IBuildDescription des = null;
BuildDescriptionManager.cleanGeneratedRebuildResources(des); IResourceDelta delta = kind == FULL_BUILD ? null : getDelta(getProject());
} catch (Throwable e){ if(delta == null)
//TODO: log error fullBuildNeeded = true;
outputError(getProject().getName(), "error occured while build description calculation: " + e.getLocalizedMessage()); //$NON-NLS-1$ if(cfg.needsRebuild() || delta != null){
//in case an error occured, make it behave in the old stile: //use a build desacription model to calculate the resources to be cleaned
if(info.needsRebuild()){ //only in case there are some changes to the project sources or build information
//make a full clean if an info needs a rebuild try{
clean(new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN)); int flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.DEPFILES | BuildDescriptionManager.DEPS;
fullBuildNeeded = true; if(delta != null)
} flags |= BuildDescriptionManager.REMOVED;
else if(delta != null && !fullBuildNeeded){
// Create a delta visitor to detect the build type outputTrace(getProject().getName(), "using a build description.."); //$NON-NLS-1$
ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(info);
delta.accept(visitor); des = BuildDescriptionManager.createBuildDescription(info.getDefaultConfiguration(), getDelta(getProject()), flags);
if (visitor.shouldBuildFull()) {
BuildDescriptionManager.cleanGeneratedRebuildResources(des);
} catch (Throwable e){
//TODO: log error
outputError(getProject().getName(), "error occured while build description calculation: " + e.getLocalizedMessage()); //$NON-NLS-1$
//in case an error occured, make it behave in the old stile:
if(info.needsRebuild()){
//make a full clean if an info needs a rebuild
clean(new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN)); clean(new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN));
fullBuildNeeded = true; fullBuildNeeded = true;
} }
else if(delta != null && !fullBuildNeeded){
// Create a delta visitor to detect the build type
ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(info);
delta.accept(visitor);
if (visitor.shouldBuildFull()) {
clean(new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN));
fullBuildNeeded = true;
}
}
} }
} }
}
if(fullBuildNeeded){ if(fullBuildNeeded){
outputTrace(getProject().getName(), "performing a full build"); //$NON-NLS-1$ outputTrace(getProject().getName(), "performing a full build"); //$NON-NLS-1$
fullBuild(info, generator, monitor); fullBuild(info, generator, monitor);
} else { } else {
outputTrace(getProject().getName(), "performing an incremental build"); //$NON-NLS-1$ outputTrace(getProject().getName(), "performing an incremental build"); //$NON-NLS-1$
incrementalBuild(delta, info, generator, monitor); incrementalBuild(delta, info, generator, monitor);
}
} }
} }
/* /*
// So let's figure out why we got called // So let's figure out why we got called
if (kind == FULL_BUILD) { if (kind == FULL_BUILD) {
outputTrace(getProject().getName(), "Full build needed/requested"); //$NON-NLS-1$ outputTrace(getProject().getName(), "Full build needed/requested"); //$NON-NLS-1$
@ -544,7 +551,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
} }
} }
} }
*/ */
// Scrub the build info the project // Scrub the build info the project
info.setRebuildState(false); info.setRebuildState(false);
// Ask build mechanism to compute deltas for project dependencies next time // Ask build mechanism to compute deltas for project dependencies next time

View file

@ -19,9 +19,13 @@ import org.eclipse.core.resources.IMarker;
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.Preferences;
public abstract class ACBuilder extends IncrementalProjectBuilder implements IMarkerGenerator { public abstract class ACBuilder extends IncrementalProjectBuilder implements IMarkerGenerator {
private static final String PREF_BUILD_ALL_CONFIGS = "build.all.configs.enabled";
private static final Preferences prefs = CCorePlugin.getDefault().getPluginPreferences();
/** /**
* Constructor for ACBuilder * Constructor for ACBuilder
*/ */
@ -90,4 +94,13 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa
} }
return IMarker.SEVERITY_ERROR; return IMarker.SEVERITY_ERROR;
} }
public static boolean needAllConfigBuild() {
return prefs.getBoolean(PREF_BUILD_ALL_CONFIGS);
}
public static void setAllConfigBuild(boolean enable) {
prefs.setValue(PREF_BUILD_ALL_CONFIGS, enable);
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others. * Copyright (c) 2000, 2008 IBM Corporation 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
@ -18,13 +18,17 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.PreferenceConstants;
@ -37,6 +41,9 @@ import org.eclipse.cdt.internal.ui.util.PixelConverter;
public class CPluginPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { public class CPluginPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
private static final String USE_STRUCTURAL_PARSE_MODE_LABEL= PreferencesMessages.CPluginPreferencePage_structuralParseMode_label; 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;
public CPluginPreferencePage() { public CPluginPreferencePage() {
super(GRID); super(GRID);
@ -71,6 +78,48 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan= 1; gd.horizontalSpan= 1;
noteControl.setLayoutData(gd); noteControl.setLayoutData(gd);
// Build either default cfg or all.
Group gr = new Group(parent, SWT.NONE);
gr.setText(PreferencesMessages.CPluginPreferencePage_0);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalIndent = GROUP_VINDENT;
gr.setLayoutData(gd);
gr.setLayout(new GridLayout());
Label l1 = new Label(gr, SWT.NONE);
l1.setText(PreferencesMessages.CPluginPreferencePage_1);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalIndent = GROUP_VINDENT;
l1.setLayoutData(gd);
boolean b = ACBuilder.needAllConfigBuild();
b1 = new Button(gr, SWT.RADIO);
b1.setText(PreferencesMessages.CPluginPreferencePage_2);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalIndent = GROUP_VINDENT;
gd.horizontalIndent = GROUP_HINDENT;
b1.setLayoutData(gd);
b1.setSelection(!b);
b2 = new Button(gr, SWT.RADIO);
b2.setText(PreferencesMessages.CPluginPreferencePage_3);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalIndent = GROUP_HINDENT;
b2.setLayoutData(gd);
b2.setSelection(b);
noteControl= createNoteComposite(
JFaceResources.getDialogFont(),
gr,
PreferencesMessages.CPluginPreferencePage_note,
PreferencesMessages.CPluginPreferencePage_4);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.verticalIndent = GROUP_VINDENT;
noteControl.setLayoutData(gd);
} }
protected void addFiller(Composite composite) { protected void addFiller(Composite composite) {
@ -94,6 +143,9 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE); return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE);
} }
public static void setBuildAllMode3(boolean enable) {
}
/** /**
* @see IWorkbenchPreferencePage#init * @see IWorkbenchPreferencePage#init
*/ */
@ -106,6 +158,7 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
public static void initDefaults(IPreferenceStore prefs) { public static void initDefaults(IPreferenceStore prefs) {
prefs.setDefault(PreferenceConstants.PREF_LINK_TO_EDITOR, false); prefs.setDefault(PreferenceConstants.PREF_LINK_TO_EDITOR, false);
prefs.setDefault(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE, false); prefs.setDefault(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE, false);
ACBuilder.setAllConfigBuild(false);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -116,7 +169,14 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
return false; return false;
// tell the Core Plugin about this preference // tell the Core Plugin about this preference
CCorePlugin.getDefault().setStructuralParseMode(useStructuralParseMode()); CCorePlugin.getDefault().setStructuralParseMode(useStructuralParseMode());
ACBuilder.setAllConfigBuild(b2.getSelection());
return true; return true;
} }
protected void performDefaults() {
super.performDefaults();
ACBuilder.setAllConfigBuild(false);
b1.setSelection(true);
b2.setSelection(false);
}
} }

View file

@ -287,6 +287,11 @@ public final class PreferencesMessages extends NLS {
public static String FileLanguagesPropertyPage_missingLanguage; public static String FileLanguagesPropertyPage_missingLanguage;
public static String FileLanguagesPropertyPage_mappingTableTitle; public static String FileLanguagesPropertyPage_mappingTableTitle;
public static String CPluginPreferencePage_0;
public static String CPluginPreferencePage_1;
public static String CPluginPreferencePage_2;
public static String CPluginPreferencePage_3;
public static String CPluginPreferencePage_4;
public static String CPluginPreferencePage_caption; public static String CPluginPreferencePage_caption;
public static String CPluginPreferencePage_structuralParseMode_label; public static String CPluginPreferencePage_structuralParseMode_label;
public static String CPluginPreferencePage_note; public static String CPluginPreferencePage_note;

View file

@ -325,6 +325,11 @@ FileLanguagesPropertyPage_mappingTableTitle = Language mappings for this file
ProposalFilterPreferencesUtil_defaultFilterName=<Default Filter> ProposalFilterPreferencesUtil_defaultFilterName=<Default Filter>
# C/C++ Preferences # C/C++ Preferences
CPluginPreferencePage_0=Build scope
CPluginPreferencePage_1=Functions 'Build project', 'Build All', 'Build Working Set' should...
CPluginPreferencePage_2=build ACTIVE CONFIGURATION in each project
CPluginPreferencePage_3=build ALL CONFIGURATIONS in each project
CPluginPreferencePage_4=This feature is applicable only to projects which support separate configurations.
CPluginPreferencePage_caption= General settings for C/C++ Development: CPluginPreferencePage_caption= General settings for C/C++ Development:
CPluginPreferencePage_structuralParseMode_label= Follow unindexed header files when producing the outline view CPluginPreferencePage_structuralParseMode_label= Follow unindexed header files when producing the outline view
CPluginPreferencePage_note= Note: CPluginPreferencePage_note= Note: