1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +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$
private static final boolean BUILD_ALL_CONFIGS = false;
public ScannerConfigBuilder() {
super();
}
@ -78,7 +76,7 @@ public class ScannerConfigBuilder extends ACBuilder {
if(bInfo != null){
IConfiguration cfgs[] = bInfo.getManagedProject().getConfigurations();
if(cfgs.length != 0){
if(!BUILD_ALL_CONFIGS){
if(!needAllConfigBuild()){
ICProjectDescription des = CoreModel.getDefault().getProjectDescription(getProject(), false);
IConfiguration cfg = null;
if(des != null){

View file

@ -502,9 +502,22 @@ public class CommonBuilder extends ACBuilder {
if(VERBOSE)
outputTrace(project.getName(), ">>build requested, type = " + kind); //$NON-NLS-1$
IBuilder builders[] = ManagedBuilderCorePlugin.createBuilders(project, args);
IProject[] projects = build(kind, project, builders, true, monitor);
IProject[] projects = null;
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)
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)
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){
Set set = buildReferencedConfigs(cfgs, new SubProgressMonitor(monitor, 1));// = getProjectsSet(cfgs);
if(rcfgs.length != 0){
Set<IProject> set = buildReferencedConfigs(rcfgs, new SubProgressMonitor(monitor, 1));// = getProjectsSet(cfgs);
if(set.size() != 0){
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();
}
private Set buildReferencedConfigs(IConfiguration[] cfgs, IProgressMonitor monitor){
Set projSet = getProjectsSet(cfgs);
private Set<IProject> buildReferencedConfigs(IConfiguration[] cfgs, IProgressMonitor monitor){
Set<IProject> projSet = getProjectsSet(cfgs);
cfgs = filterConfigsToBuild(cfgs);
if(cfgs.length != 0){
@ -610,7 +623,7 @@ public class CommonBuilder extends ACBuilder {
}
private IConfiguration[] getReferencedConfigs(IBuilder[] builders){
Set set = new HashSet();
Set<IConfiguration> set = new HashSet<IConfiguration>();
for(int i = 0; i < builders.length; i++){
IConfiguration cfg = builders[i].getParent().getParent();
IConfiguration refs[] = ManagedBuildManager.getReferencedConfigurations(cfg);
@ -618,14 +631,14 @@ public class CommonBuilder extends ACBuilder {
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)
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++){
set.add(cfgs[i].getOwner().getProject());
}
@ -759,7 +772,6 @@ public class CommonBuilder extends ACBuilder {
// }
if (status.isBuild()) {
// IManagedBuilderMakefileGenerator makeGen = null;
IConfiguration cfg = bInfo.getConfiguration();
if(!builder.isCustomBuilder()){

View file

@ -417,80 +417,87 @@ public class GeneratedMakefileBuilder extends ACBuilder {
return referencedProjects;
}
IConfiguration cfg = info.getDefaultConfiguration();
updateOtherConfigs(cfg, kind);
if(((Configuration)cfg).isInternalBuilderEnabled()){
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
IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration());
generator.initialize(getProject(), info, monitor);
//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);
IConfiguration[] cfgs = null;
if (needAllConfigBuild()) {
cfgs = info.getManagedProject().getConfigurations();
} else {
boolean fullBuildNeeded = info.needsRebuild();
IBuildDescription des = null;
IResourceDelta delta = kind == FULL_BUILD ? null : getDelta(getProject());
if(delta == null)
fullBuildNeeded = true;
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;
cfgs = new IConfiguration[] {info.getDefaultConfiguration() };
}
for (IConfiguration cfg : cfgs) {
updateOtherConfigs(cfg, kind);
outputTrace(getProject().getName(), "using a build description.."); //$NON-NLS-1$
if(((Configuration)cfg).isInternalBuilderEnabled()){
invokeInternalBuilder(cfg, kind != FULL_BUILD, ((Configuration)cfg).getInternalBuilderIgnoreErr(), monitor);
des = BuildDescriptionManager.createBuildDescription(info.getDefaultConfiguration(), getDelta(getProject()), flags);
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));
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()) {
// Scrub the build info the project
info.setRebuildState(false);
return referencedProjects;
}
// Create a makefile generator for the build
IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration());
generator.initialize(getProject(), info, monitor);
//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;
IResourceDelta delta = kind == FULL_BUILD ? null : getDelta(getProject());
if(delta == null)
fullBuildNeeded = true;
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$
des = BuildDescriptionManager.createBuildDescription(info.getDefaultConfiguration(), getDelta(getProject()), flags);
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));
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){
outputTrace(getProject().getName(), "performing a full build"); //$NON-NLS-1$
fullBuild(info, generator, monitor);
} else {
outputTrace(getProject().getName(), "performing an incremental build"); //$NON-NLS-1$
incrementalBuild(delta, info, generator, monitor);
if(fullBuildNeeded){
outputTrace(getProject().getName(), "performing a full build"); //$NON-NLS-1$
fullBuild(info, generator, monitor);
} else {
outputTrace(getProject().getName(), "performing an incremental build"); //$NON-NLS-1$
incrementalBuild(delta, info, generator, monitor);
}
}
}
/*
/*
// So let's figure out why we got called
if (kind == FULL_BUILD) {
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
info.setRebuildState(false);
// 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.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
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";
private static final Preferences prefs = CCorePlugin.getDefault().getPluginPreferences();
/**
* Constructor for ACBuilder
*/
@ -90,4 +94,13 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa
}
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
* are made available under the terms of the Eclipse Public License v1.0
* 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.swt.SWT;
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.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.cdt.ui.CUIPlugin;
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 {
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() {
super(GRID);
@ -71,6 +78,48 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan= 1;
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) {
@ -94,6 +143,9 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE);
}
public static void setBuildAllMode3(boolean enable) {
}
/**
* @see IWorkbenchPreferencePage#init
*/
@ -106,6 +158,7 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
public static void initDefaults(IPreferenceStore prefs) {
prefs.setDefault(PreferenceConstants.PREF_LINK_TO_EDITOR, false);
prefs.setDefault(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE, false);
ACBuilder.setAllConfigBuild(false);
}
/* (non-Javadoc)
@ -116,7 +169,14 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
return false;
// tell the Core Plugin about this preference
CCorePlugin.getDefault().setStructuralParseMode(useStructuralParseMode());
ACBuilder.setAllConfigBuild(b2.getSelection());
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_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_structuralParseMode_label;
public static String CPluginPreferencePage_note;

View file

@ -325,6 +325,11 @@ FileLanguagesPropertyPage_mappingTableTitle = Language mappings for this file
ProposalFilterPreferencesUtil_defaultFilterName=<Default Filter>
# 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_structuralParseMode_label= Follow unindexed header files when producing the outline view
CPluginPreferencePage_note= Note: