mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Bug #201612 : CDT does not use the first configuration in xml as default
This commit is contained in:
parent
c3b99a4faf
commit
aca075d50b
4 changed files with 104 additions and 4 deletions
|
@ -15,6 +15,7 @@ import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
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.IProjectType;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
@ -360,10 +361,16 @@ public class CDTConfigWizardPage extends WizardPage {
|
||||||
Set x = new TreeSet();
|
Set x = new TreeSet();
|
||||||
Set y = new TreeSet();
|
Set y = new TreeSet();
|
||||||
for (int i=0; i<n; i++) {
|
for (int i=0; i<n; i++) {
|
||||||
|
if (tcs[i] == null) // --- NO TOOLCHAIN ---
|
||||||
|
continue; // has no custom pages.
|
||||||
x.add(tcs[i]);
|
x.add(tcs[i]);
|
||||||
try { // Any element may be null. Do nothing in this case.
|
|
||||||
y.add(tcs[i].getParent().getProjectType().getId());
|
IConfiguration cfg = tcs[i].getParent();
|
||||||
} catch (NullPointerException e) {}
|
if (cfg == null)
|
||||||
|
continue;
|
||||||
|
IProjectType pt = cfg.getProjectType();
|
||||||
|
if (pt != null)
|
||||||
|
y.add(pt.getId());
|
||||||
}
|
}
|
||||||
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.TOOLCHAIN, x);
|
MBSCustomPageManager.addPageProperty(MBSCustomPageManager.PAGE_ID, MBSCustomPageManager.TOOLCHAIN, x);
|
||||||
if (ptIsNull) {
|
if (ptIsNull) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.managedbuilder.ui.wizards;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
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.IToolChain;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.ui.newui.UIMessages;
|
import org.eclipse.cdt.ui.newui.UIMessages;
|
||||||
|
@ -52,6 +53,13 @@ public class CfgHolder {
|
||||||
return (cfg.isSupported());
|
return (cfg.isSupported());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether names are unique
|
||||||
|
*
|
||||||
|
* @param its
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
|
||||||
public static boolean hasDoubles(CfgHolder[] its) {
|
public static boolean hasDoubles(CfgHolder[] its) {
|
||||||
for (int i=0; i<its.length; i++) {
|
for (int i=0; i<its.length; i++) {
|
||||||
String s = its[i].name;
|
String s = its[i].name;
|
||||||
|
@ -64,6 +72,13 @@ public class CfgHolder {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates array of holders on a basis
|
||||||
|
* of configurations array.
|
||||||
|
*
|
||||||
|
* @param cfgs
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static CfgHolder[] cfgs2items(IConfiguration[] cfgs) {
|
public static CfgHolder[] cfgs2items(IConfiguration[] cfgs) {
|
||||||
CfgHolder[] its = new CfgHolder[cfgs.length];
|
CfgHolder[] its = new CfgHolder[cfgs.length];
|
||||||
for (int i=0; i<cfgs.length; i++) {
|
for (int i=0; i<cfgs.length; i++) {
|
||||||
|
@ -72,6 +87,15 @@ public class CfgHolder {
|
||||||
return its;
|
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) {
|
public static CfgHolder[] unique(CfgHolder[] its) {
|
||||||
// if names are not unique, add version name
|
// if names are not unique, add version name
|
||||||
if (hasDoubles(its)) {
|
if (hasDoubles(its)) {
|
||||||
|
@ -106,6 +130,65 @@ public class CfgHolder {
|
||||||
return its;
|
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 !
|
* Note that null configurations are ignored !
|
||||||
*/
|
*/
|
||||||
|
@ -115,6 +198,14 @@ public class CfgHolder {
|
||||||
if (its[i].cfg != null) lst.add(its[i].cfg);
|
if (its[i].cfg != null) lst.add(its[i].cfg);
|
||||||
return (IConfiguration[])lst.toArray(new IConfiguration[lst.size()]);
|
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 Object getConfiguration() { return cfg; }
|
||||||
public String getName() { return name; }
|
public String getName() { return name; }
|
||||||
public Object getToolChain() { return tc; }
|
public Object getToolChain() { return tc; }
|
||||||
|
|
|
@ -419,6 +419,7 @@ public class MBSWizardHandler extends CWizardHandler {
|
||||||
info.setManagedProject(mProj);
|
info.setManagedProject(mProj);
|
||||||
|
|
||||||
cfgs = CfgHolder.unique(cfgs);
|
cfgs = CfgHolder.unique(cfgs);
|
||||||
|
cfgs = CfgHolder.reorder(cfgs);
|
||||||
|
|
||||||
ICConfigurationDescription cfgDebug = null;
|
ICConfigurationDescription cfgDebug = null;
|
||||||
ICConfigurationDescription cfgFirst = null;
|
ICConfigurationDescription cfgFirst = null;
|
||||||
|
|
|
@ -56,7 +56,8 @@ public class STDWizardHandler extends MBSWizardHandler {
|
||||||
info.setManagedProject(mProj);
|
info.setManagedProject(mProj);
|
||||||
|
|
||||||
cfgs = CfgHolder.unique(fConfigPage.getCfgItems(defaults));
|
cfgs = CfgHolder.unique(fConfigPage.getCfgItems(defaults));
|
||||||
|
cfgs = CfgHolder.reorder(cfgs);
|
||||||
|
|
||||||
for (int i=0; i<cfgs.length; i++) {
|
for (int i=0; i<cfgs.length; i++) {
|
||||||
String s = (cfgs[i].getToolChain() == null) ? "0" : ((ToolChain)(cfgs[i].getToolChain())).getId(); //$NON-NLS-1$
|
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());
|
Configuration cfg = new Configuration(mProj, (ToolChain)cfgs[i].getToolChain(), ManagedBuildManager.calculateChildId(s, null), cfgs[i].getName());
|
||||||
|
|
Loading…
Add table
Reference in a new issue