mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
1. Fix NPE in the New Project Wizard
2. Fix to [Bug 189125] [New project model] Stroage modules don't get copied 3. Fix to build path settings
This commit is contained in:
parent
6653aa0f0d
commit
a032fbd206
9 changed files with 87 additions and 23 deletions
|
@ -1693,41 +1693,65 @@ public class Builder extends BuildObject implements IBuilder, IMatchKeyProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBuildPathAttribute(){
|
public String getBuildPathAttribute(){
|
||||||
|
return getBuildPathAttribute(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBuildPathAttribute(boolean querySuperClass){
|
||||||
if(buildPath == null){
|
if(buildPath == null){
|
||||||
if(superClass != null){
|
if(querySuperClass && superClass != null){
|
||||||
return ((Builder)superClass).getBuildPathAttribute();
|
return ((Builder)superClass).getBuildPathAttribute(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buildPath;
|
return buildPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBuildPath(String path){
|
public void setBuildPath(String path){
|
||||||
|
setBuildPathAttribute(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBuildPathAttribute(String path){
|
||||||
buildPath = path;
|
buildPath = path;
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBuildPath(){
|
public String getBuildPath(){
|
||||||
|
if(isManagedBuildOn())
|
||||||
|
return getDefaultBuildPath();
|
||||||
|
|
||||||
String path = getBuildPathAttribute();
|
String path = getBuildPathAttribute();
|
||||||
if(path == null){
|
if(path == null){
|
||||||
boolean initBuildPathVar = false;
|
path = getDefaultBuildPath();
|
||||||
Configuration cfg = (Configuration)getConfguration();
|
// if(isManagedBuildOn() && !isExtensionElement()) {
|
||||||
if(cfg != null && !cfg.isPreference()){
|
// buildPath = path;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultBuildPath(){
|
||||||
|
Configuration cfg = (Configuration)getConfguration();
|
||||||
|
String path = null;
|
||||||
|
if(cfg != null){
|
||||||
|
if(isManagedBuildOn()){
|
||||||
|
path = cfg.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isExtensionElement() && !cfg.isPreference()){
|
||||||
IProject project = cfg.getOwner().getProject();
|
IProject project = cfg.getOwner().getProject();
|
||||||
IPath projPath = project.getFullPath();
|
IPath buildPath = project.getFullPath();
|
||||||
if(isManagedBuildOn()){
|
|
||||||
path = projPath.append(cfg.getName()).toString();
|
|
||||||
initBuildPathVar = !isExtensionBuilder;
|
|
||||||
} else {
|
|
||||||
path = projPath.toString();
|
|
||||||
}
|
|
||||||
IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager();
|
IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager();
|
||||||
|
if(path != null)
|
||||||
|
buildPath = buildPath.append(path);
|
||||||
|
|
||||||
|
path = buildPath.toString();
|
||||||
path = mngr.generateVariableExpression("workspace_loc", path); //$NON-NLS-1$
|
path = mngr.generateVariableExpression("workspace_loc", path); //$NON-NLS-1$
|
||||||
if(initBuildPathVar)
|
|
||||||
buildPath = path;
|
|
||||||
} else {
|
|
||||||
path = ""; //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(path == null){
|
||||||
|
path = ""; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
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.managedbuilder.core.ManagedBuilderCorePlugin;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.core.Builder;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory;
|
import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
|
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.ISettingsChangeListener;
|
import org.eclipse.cdt.managedbuilder.internal.core.ISettingsChangeListener;
|
||||||
|
@ -106,6 +107,11 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
|
||||||
rootElement.setAttribute(VERSION_ATTRIBUTE, ManagedBuildManager.getVersion().toString());
|
rootElement.setAttribute(VERSION_ATTRIBUTE, ManagedBuildManager.getVersion().toString());
|
||||||
ICStorageElement cfgElemen = rootElement.createChild(IConfiguration.CONFIGURATION_ELEMENT_NAME);
|
ICStorageElement cfgElemen = rootElement.createChild(IConfiguration.CONFIGURATION_ELEMENT_NAME);
|
||||||
Configuration cfg = (Configuration)appliedCfg.getConfiguration();
|
Configuration cfg = (Configuration)appliedCfg.getConfiguration();
|
||||||
|
Builder b = (Builder)cfg.getEditableBuilder();
|
||||||
|
if(b != null && b.isManagedBuildOn() && b.getBuildPathAttribute(false) == null){
|
||||||
|
String bPath = b.getDefaultBuildPath();
|
||||||
|
b.setBuildPathAttribute(bPath);
|
||||||
|
}
|
||||||
// cfg.setConfigurationDescription(des);
|
// cfg.setConfigurationDescription(des);
|
||||||
// ManagedBuildManager.performValueHandlerEvent(cfg, IManagedOptionValueHandler.EVENT_APPLY);
|
// ManagedBuildManager.performValueHandlerEvent(cfg, IManagedOptionValueHandler.EVENT_APPLY);
|
||||||
cfg.serialize(cfgElemen);
|
cfg.serialize(cfgElemen);
|
||||||
|
|
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
|
||||||
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IBuilder;
|
import org.eclipse.cdt.managedbuilder.core.IBuilder;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.core.Builder;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
|
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
|
||||||
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
|
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
|
||||||
import org.eclipse.cdt.ui.newui.TriButton;
|
import org.eclipse.cdt.ui.newui.TriButton;
|
||||||
|
@ -296,7 +297,7 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
|
||||||
b2.setParallelizationNum(b1.getParallelizationNum());
|
b2.setParallelizationNum(b1.getParallelizationNum());
|
||||||
if (b2.canKeepEnvironmentVariablesInBuildfile())
|
if (b2.canKeepEnvironmentVariablesInBuildfile())
|
||||||
b2.setKeepEnvironmentVariablesInBuildfile(b1.keepEnvironmentVariablesInBuildfile());
|
b2.setKeepEnvironmentVariablesInBuildfile(b1.keepEnvironmentVariablesInBuildfile());
|
||||||
b2.setBuildPath(null);
|
((Builder)b2).setBuildPath(((Builder)b1).getBuildPathAttribute());
|
||||||
|
|
||||||
b2.setAutoBuildEnable((b1.isAutoBuildEnable()));
|
b2.setAutoBuildEnable((b1.isAutoBuildEnable()));
|
||||||
b2.setBuildAttribute(IBuilder.BUILD_TARGET_AUTO, (b1.getBuildAttribute(IBuilder.BUILD_TARGET_AUTO, EMPTY_STR)));
|
b2.setBuildAttribute(IBuilder.BUILD_TARGET_AUTO, (b1.getBuildAttribute(IBuilder.BUILD_TARGET_AUTO, EMPTY_STR)));
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class MBSWizardHandler extends CWizardHandler {
|
||||||
private IWizardPage startingPage;
|
private IWizardPage startingPage;
|
||||||
// private EntryDescriptor entryDescriptor = null;
|
// private EntryDescriptor entryDescriptor = null;
|
||||||
private EntryInfo entryInfo;
|
private EntryInfo entryInfo;
|
||||||
private CfgHolder[] cfgs = null;
|
protected CfgHolder[] cfgs = null;
|
||||||
|
|
||||||
protected static final class EntryInfo {
|
protected static final class EntryInfo {
|
||||||
private SortedMap tcs;
|
private SortedMap tcs;
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class STDWizardHandler extends MBSWizardHandler {
|
||||||
ManagedProject mProj = new ManagedProject(des);
|
ManagedProject mProj = new ManagedProject(des);
|
||||||
info.setManagedProject(mProj);
|
info.setManagedProject(mProj);
|
||||||
|
|
||||||
CfgHolder[] cfgs = fConfigPage.getCfgItems(defaults);
|
cfgs = fConfigPage.getCfgItems(defaults);
|
||||||
|
|
||||||
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$
|
||||||
|
|
|
@ -87,8 +87,8 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
|
||||||
ICStorageElement child = el.createChild(EL_NAME);
|
ICStorageElement child = el.createChild(EL_NAME);
|
||||||
child.setAttribute(ATTR2, ATTR2_VALUE);
|
child.setAttribute(ATTR2, ATTR2_VALUE);
|
||||||
|
|
||||||
final String newCfgId1 = CDataUtil.genId(null);
|
final String newCfgId1 = "cfg1.id";//CDataUtil.genId(null);
|
||||||
final String newCfgId2 = CDataUtil.genId(null);
|
// final String newCfgId2 = CDataUtil.genId(null);
|
||||||
|
|
||||||
ICConfigurationDescription cfg1 = des.createConfiguration(newCfgId1, newCfgId1 + ".name", baseCfg);
|
ICConfigurationDescription cfg1 = des.createConfiguration(newCfgId1, newCfgId1 + ".name", baseCfg);
|
||||||
assertEquals(newCfgId1, cfg1.getId());
|
assertEquals(newCfgId1, cfg1.getId());
|
||||||
|
@ -102,6 +102,26 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
|
||||||
|
|
||||||
mngr.setProjectDescription(p3, des);
|
mngr.setProjectDescription(p3, des);
|
||||||
|
|
||||||
|
des = mngr.getProjectDescription(p3, false);
|
||||||
|
cfg1 = des.getConfigurationById(newCfgId1);
|
||||||
|
el = cfg1.getStorage(STORAGE_ID, false);
|
||||||
|
assertNotNull(el);
|
||||||
|
assertEquals(ATTR_VALUE, el.getAttribute(ATTR));
|
||||||
|
assertEquals(1, el.getChildren().length);
|
||||||
|
child = el.getChildren()[0];
|
||||||
|
assertEquals(EL_NAME, child.getName());
|
||||||
|
assertEquals(ATTR2_VALUE, child.getAttribute(ATTR2));
|
||||||
|
|
||||||
|
des = mngr.getProjectDescription(p3, true);
|
||||||
|
cfg1 = des.getConfigurationById(newCfgId1);
|
||||||
|
el = cfg1.getStorage(STORAGE_ID, false);
|
||||||
|
assertNotNull(el);
|
||||||
|
assertEquals(ATTR_VALUE, el.getAttribute(ATTR));
|
||||||
|
assertEquals(1, el.getChildren().length);
|
||||||
|
child = el.getChildren()[0];
|
||||||
|
assertEquals(EL_NAME, child.getName());
|
||||||
|
assertEquals(ATTR2_VALUE, child.getAttribute(ATTR2));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove_prefix_testSetInvalidCreatingDescription() throws Exception {
|
public void remove_prefix_testSetInvalidCreatingDescription() throws Exception {
|
||||||
|
|
|
@ -93,13 +93,14 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC
|
||||||
|
|
||||||
CConfigurationSpecSettings baseSettings = ((CConfigurationDescription)base).getSpecSettings();
|
CConfigurationSpecSettings baseSettings = ((CConfigurationDescription)base).getSpecSettings();
|
||||||
InternalXmlStorageElement baseRootEl = (InternalXmlStorageElement)baseSettings.getRootStorageElement();
|
InternalXmlStorageElement baseRootEl = (InternalXmlStorageElement)baseSettings.getRootStorageElement();
|
||||||
InternalXmlStorageElement newRootEl = CProjectDescriptionManager.getInstance().copyElement(baseRootEl, false);
|
InternalXmlStorageElement newRootEl = CProjectDescriptionManager.getInstance().copyConfigurationElement(baseRootEl, id, false);
|
||||||
ICStorageElement parentEl = baseRootEl.getParent();
|
ICStorageElement parentEl = baseRootEl.getParent();
|
||||||
parentEl.importChild(newRootEl);
|
newRootEl = (InternalXmlStorageElement)parentEl.importChild(newRootEl);
|
||||||
|
|
||||||
fCfgSpecSettings = new CConfigurationSpecSettings(this, baseSettings, newRootEl);
|
fCfgSpecSettings = new CConfigurationSpecSettings(this, baseSettings, newRootEl);
|
||||||
fCfgSpecSettings.setId(id);
|
fCfgSpecSettings.setId(id);
|
||||||
fCfgSpecSettings.setName(name);
|
fCfgSpecSettings.setName(name);
|
||||||
|
fCfgSpecSettings.serializeId();
|
||||||
CConfigurationData baseData = ((IInternalCCfgInfo)base).getConfigurationData(false);
|
CConfigurationData baseData = ((IInternalCCfgInfo)base).getConfigurationData(false);
|
||||||
if(baseData instanceof CConfigurationDescriptionCache){
|
if(baseData instanceof CConfigurationDescriptionCache){
|
||||||
baseData = ((CConfigurationDescriptionCache)baseData).getConfigurationData();
|
baseData = ((CConfigurationDescriptionCache)baseData).getConfigurationData();
|
||||||
|
|
|
@ -329,6 +329,12 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
|
||||||
fIsModified = true;
|
fIsModified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void serializeId() throws CoreException {
|
||||||
|
fId = fCfg.getId();
|
||||||
|
ICStorageElement settings = getSettingsStorageElement();
|
||||||
|
settings.setAttribute(ID, fId);
|
||||||
|
}
|
||||||
|
|
||||||
void serialize() throws CoreException {
|
void serialize() throws CoreException {
|
||||||
fId = fCfg.getId();
|
fId = fCfg.getId();
|
||||||
|
|
|
@ -2807,6 +2807,12 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InternalXmlStorageElement copyConfigurationElement(InternalXmlStorageElement el, String newId, boolean readOnly) throws CoreException {
|
||||||
|
el = copyElement(el, readOnly);
|
||||||
|
el.setAttribute(CConfigurationSpecSettings.ID, newId);
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
InternalXmlStorageElement copyElement(InternalXmlStorageElement el, boolean readOnly) throws CoreException {
|
InternalXmlStorageElement copyElement(InternalXmlStorageElement el, boolean readOnly) throws CoreException {
|
||||||
// try {
|
// try {
|
||||||
// DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
// DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
|
|
Loading…
Add table
Reference in a new issue