1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

Bug #201612 : CDT does not use the first configuration in xml as default

This commit is contained in:
Oleg Krasilnikov 2007-09-07 13:27:52 +00:00
parent c3b99a4faf
commit aca075d50b
4 changed files with 104 additions and 4 deletions

View file

@ -15,6 +15,7 @@ import java.util.Set;
import java.util.TreeSet;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
@ -360,10 +361,16 @@ public class CDTConfigWizardPage extends WizardPage {
Set x = new TreeSet();
Set y = new TreeSet();
for (int i=0; i<n; i++) {
if (tcs[i] == null) // --- NO TOOLCHAIN ---
continue; // has no custom pages.
x.add(tcs[i]);
try { // Any element may be null. Do nothing in this case.
y.add(tcs[i].getParent().getProjectType().getId());
} catch (NullPointerException e) {}
IConfiguration cfg = tcs[i].getParent();
if (cfg == null)
continue;
IProjectType pt = cfg.getProjectType();
if (pt != null)
y.add(pt.getId());
}
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.TOOLCHAIN, x);
if (ptIsNull) {

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.managedbuilder.ui.wizards;
import java.util.ArrayList;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.ui.newui.UIMessages;
@ -52,6 +53,13 @@ public class CfgHolder {
return (cfg.isSupported());
}
/**
* Checks whether names are unique
*
* @param its
* @return
*/
public static boolean hasDoubles(CfgHolder[] its) {
for (int i=0; i<its.length; i++) {
String s = its[i].name;
@ -64,6 +72,13 @@ public class CfgHolder {
return false;
}
/**
* Creates array of holders on a basis
* of configurations array.
*
* @param cfgs
* @return
*/
public static CfgHolder[] cfgs2items(IConfiguration[] cfgs) {
CfgHolder[] its = new CfgHolder[cfgs.length];
for (int i=0; i<cfgs.length; i++) {
@ -72,6 +87,15 @@ public class CfgHolder {
return its;
}
/**
* Makes configuration's names unique.
* Adds either version number or toolchain name.
* If it does not help, simply adds index.
*
* @param its - list of items.
* @return the same list with unique names.
*/
public static CfgHolder[] unique(CfgHolder[] its) {
// if names are not unique, add version name
if (hasDoubles(its)) {
@ -106,6 +130,65 @@ public class CfgHolder {
return its;
}
/**
* Returns corresponding project type
* obtained either from configuration
* (if any) or from toolchain.
*
* @return projectType
*/
public IProjectType getProjectType() {
if (cfg != null)
return cfg.getProjectType();
if (tc != null && tc.getParent() != null)
return tc.getParent().getProjectType();
return null;
}
/**
* Reorders selected configurations in "physical" order.
* Although toolchains are displayed in alphabetical
* order in Wizard, it's required to create corresponding
* configurations in the same order as they are listed
* in xml file, inside of single project type.
*
* @param its - items in initial order.
* @return - items in "physical" order.
*/
public static CfgHolder[] reorder(CfgHolder[] its) {
ArrayList ls = new ArrayList(its.length);
boolean found = true;
while (found) {
found = false;
for (int i=0; i<its.length; i++) {
if (its[i] == null)
continue;
found = true;
IProjectType pt = its[i].getProjectType();
if (pt == null) {
ls.add(its[i]);
its[i] = null;
continue;
}
IConfiguration[] cfs = pt.getConfigurations();
for (int j=0; j<cfs.length; j++) {
for (int k=0; k<its.length; k++) {
if (its[k] == null)
continue;
if (cfs[j].equals(its[k].getTcCfg())) {
ls.add(its[k]);
its[k] = null;
}
}
}
}
}
return (CfgHolder[])ls.toArray(new CfgHolder[ls.size()]);
}
/*
* Note that null configurations are ignored !
*/
@ -115,6 +198,14 @@ public class CfgHolder {
if (its[i].cfg != null) lst.add(its[i].cfg);
return (IConfiguration[])lst.toArray(new IConfiguration[lst.size()]);
}
public IConfiguration getTcCfg() {
if (tc != null)
return tc.getParent();
return null;
}
public Object getConfiguration() { return cfg; }
public String getName() { return name; }
public Object getToolChain() { return tc; }

View file

@ -419,6 +419,7 @@ public class MBSWizardHandler extends CWizardHandler {
info.setManagedProject(mProj);
cfgs = CfgHolder.unique(cfgs);
cfgs = CfgHolder.reorder(cfgs);
ICConfigurationDescription cfgDebug = null;
ICConfigurationDescription cfgFirst = null;

View file

@ -56,7 +56,8 @@ public class STDWizardHandler extends MBSWizardHandler {
info.setManagedProject(mProj);
cfgs = CfgHolder.unique(fConfigPage.getCfgItems(defaults));
cfgs = CfgHolder.reorder(cfgs);
for (int i=0; i<cfgs.length; i++) {
String s = (cfgs[i].getToolChain() == null) ? "0" : ((ToolChain)(cfgs[i].getToolChain())).getId(); //$NON-NLS-1$
Configuration cfg = new Configuration(mProj, (ToolChain)cfgs[i].getToolChain(), ManagedBuildManager.calculateChildId(s, null), cfgs[i].getName());