mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for [Bug 194566] User defined Macro(in cdt v3.0 managed project)was lost when imported into CDT 4.0
This commit is contained in:
parent
7396f52e19
commit
c3b99a4faf
6 changed files with 75 additions and 27 deletions
|
@ -139,7 +139,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
|
|||
|
||||
//property name for holding the rebuild state
|
||||
private static final String REBUILD_STATE = "rebuildState"; //$NON-NLS-1$
|
||||
|
||||
|
||||
//The resource delta passed to the builder is not always up-to-date
|
||||
//for the given configuration because between two builds of the same configuration
|
||||
//any number of other configuration builds may occur
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.Map;
|
|||
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICStorageElement;
|
||||
import org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables;
|
||||
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
|
||||
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
|
@ -55,7 +56,7 @@ public class ManagedProject extends BuildObject implements IManagedProject, IBui
|
|||
//holds the user-defined macros
|
||||
// private StorableMacros userDefinedMacros;
|
||||
//holds user-defined environment
|
||||
private StorableEnvironment userDefinedEnvironment;
|
||||
// private StorableEnvironment userDefinedEnvironment;
|
||||
|
||||
private BuildObjectProperties buildProperties;
|
||||
|
||||
|
@ -138,18 +139,24 @@ public class ManagedProject extends BuildObject implements IManagedProject, IBui
|
|||
|
||||
if(loadConfigs){
|
||||
// Load children
|
||||
StorableCdtVariables vars = null;
|
||||
ICStorageElement configElements[] = element.getChildren();
|
||||
for (int i = 0; i < configElements.length; ++i) {
|
||||
ICStorageElement configElement = configElements[i];
|
||||
if (configElement.getName().equals(IConfiguration.CONFIGURATION_ELEMENT_NAME)) {
|
||||
Configuration config = new Configuration(this, configElement, managedBuildRevision, false);
|
||||
}/*else if (configElement.getNodeName().equals(StorableMacros.MACROS_ELEMENT_NAME)) {
|
||||
//load user-defined macros
|
||||
ICStorageElement el = new XmlStorageElement((Element)configElement);
|
||||
userDefinedMacros = new StorableMacros(el);
|
||||
}*/
|
||||
} else if (configElement.getName().equals("macros")) { //$NON-NLS-1$
|
||||
vars = new StorableCdtVariables(configElement, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(vars != null){
|
||||
for(Iterator iter = getConfigurationMap().values().iterator(); iter.hasNext(); ){
|
||||
Configuration cfg = (Configuration)iter.next();
|
||||
((ToolChain)cfg.getToolChain()).addProjectVariables(vars);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setValid(false);
|
||||
|
@ -484,8 +491,8 @@ public class ManagedProject extends BuildObject implements IManagedProject, IBui
|
|||
// return true;
|
||||
|
||||
//check whether the project - specific environment is dirty
|
||||
if(userDefinedEnvironment != null && userDefinedEnvironment.isDirty())
|
||||
return true;
|
||||
// if(userDefinedEnvironment != null && userDefinedEnvironment.isDirty())
|
||||
// return true;
|
||||
|
||||
|
||||
// Otherwise see if any configurations need saving
|
||||
|
@ -555,13 +562,13 @@ public class ManagedProject extends BuildObject implements IManagedProject, IBui
|
|||
return userDefinedMacros;
|
||||
}
|
||||
*/
|
||||
public StorableEnvironment getUserDefinedEnvironmet(){
|
||||
return userDefinedEnvironment;
|
||||
}
|
||||
|
||||
public void setUserDefinedEnvironmet(StorableEnvironment env){
|
||||
userDefinedEnvironment = env;
|
||||
}
|
||||
// public StorableEnvironment getUserDefinedEnvironmet(){
|
||||
// return userDefinedEnvironment;
|
||||
// }
|
||||
//
|
||||
// public void setUserDefinedEnvironmet(StorableEnvironment env){
|
||||
// userDefinedEnvironment = env;
|
||||
// }
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.internal.core.BuildObject#updateManagedBuildRevision(java.lang.String)
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManage
|
|||
import org.eclipse.cdt.core.settings.model.ICStorageElement;
|
||||
import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
|
||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||
import org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables;
|
||||
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
|
||||
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
|
@ -102,8 +103,9 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
|
|||
private boolean isExtensionToolChain = false;
|
||||
private boolean isDirty = false;
|
||||
private boolean resolved = resolvedDefault;
|
||||
//holds the user-defined macros
|
||||
// private StorableMacros userDefinedMacros;
|
||||
|
||||
//used for loadding pre-4.0 projects only
|
||||
private StorableCdtVariables userDefinedMacros;
|
||||
//holds user-defined macros
|
||||
// private StorableEnvironment userDefinedEnvironment;
|
||||
|
||||
|
@ -270,11 +272,10 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
|
|||
// TODO: report error
|
||||
}
|
||||
builder = new Builder(this, configElement, managedBuildRevision);
|
||||
}/*else if (configElement.getName().equals(StorableMacros.MACROS_ELEMENT_NAME)) {
|
||||
} else if (configElement.getName().equals("macros")) { //$NON-NLS-1$
|
||||
//load user-defined macros
|
||||
userDefinedMacros = new StorableMacros(configElement);
|
||||
|
||||
}*/
|
||||
userDefinedMacros = new StorableCdtVariables(configElement, false);
|
||||
}
|
||||
}
|
||||
|
||||
String rebuild = PropertyManager.getInstance().getProperty(this, REBUILD_STATE);
|
||||
|
@ -361,6 +362,8 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
|
|||
|
||||
discoveredInfo = toolChain.discoveredInfo;
|
||||
|
||||
userDefinedMacros = toolChain.userDefinedMacros;
|
||||
|
||||
// Clone the children in superclass
|
||||
boolean copyIds = toolChain.getId().equals(id);
|
||||
super.copyChildren(toolChain);
|
||||
|
@ -2752,4 +2755,21 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
|
|||
private String translateUnusedIdSetToString(Set set){
|
||||
return CDataUtil.arrayToString(set.toArray(), ";"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
void addProjectVariables(StorableCdtVariables vars){
|
||||
if(vars != null && !vars.isEmpty()){
|
||||
StorableCdtVariables cfgVars = new StorableCdtVariables(vars, false);
|
||||
if(userDefinedMacros != null){
|
||||
cfgVars.createMacros(userDefinedMacros.getMacros());
|
||||
}
|
||||
|
||||
userDefinedMacros = cfgVars;
|
||||
}
|
||||
}
|
||||
|
||||
public StorableCdtVariables getResetOldStyleProjectVariables(){
|
||||
StorableCdtVariables vars = userDefinedMacros;
|
||||
userDefinedMacros = null;
|
||||
return vars;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Set;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.ICDescriptor;
|
||||
import org.eclipse.cdt.core.ICDescriptorOperation;
|
||||
import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
|
||||
|
@ -33,6 +34,9 @@ import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
|
|||
import org.eclipse.cdt.core.settings.model.extension.ICProjectConverter;
|
||||
import org.eclipse.cdt.core.settings.model.util.PathEntryTranslator;
|
||||
import org.eclipse.cdt.core.settings.model.util.PathEntryTranslator.ReferenceSettingsInfo;
|
||||
import org.eclipse.cdt.internal.core.cdtvariables.ICoreVariableContextInfo;
|
||||
import org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables;
|
||||
import org.eclipse.cdt.internal.core.cdtvariables.UserDefinedVariableSupplier;
|
||||
import org.eclipse.cdt.make.core.IMakeTarget;
|
||||
import org.eclipse.cdt.make.core.IMakeTargetManager;
|
||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||
|
@ -585,7 +589,9 @@ public class ProjectConverter implements ICProjectConverter {
|
|||
if(cfgs.length != 0){
|
||||
Configuration cfg;
|
||||
CConfigurationData data;
|
||||
|
||||
|
||||
UserDefinedVariableSupplier usrSupplier = UserDefinedVariableSupplier.getInstance();
|
||||
|
||||
for(int i = 0; i < cfgs.length; i++){
|
||||
cfg = (Configuration)cfgs[i];
|
||||
data = cfg.getConfigurationData();
|
||||
|
@ -594,8 +600,17 @@ public class ProjectConverter implements ICProjectConverter {
|
|||
if(cfg.getConfigurationDescription() != null) {
|
||||
//copy cfg to avoid raise conditions
|
||||
cfg = ConfigurationDataProvider.copyCfg(cfg, cfgDes);
|
||||
cfgDes.setConfigurationData(ManagedBuildManager.CFG_DATA_PROVIDER_ID, cfg.getConfigurationData());
|
||||
}
|
||||
cfg.setConfigurationDescription(cfgDes);
|
||||
|
||||
StorableCdtVariables vars = ((ToolChain)cfg.getToolChain()).getResetOldStyleProjectVariables();
|
||||
if(vars != null){
|
||||
ICdtVariable vs[] = vars.getMacros();
|
||||
for(int k = 0; k < vs.length; k++){
|
||||
usrSupplier.createMacro(vs[k], ICoreVariableContextInfo.CONTEXT_CONFIGURATION, cfgDes);
|
||||
}
|
||||
}
|
||||
// } catch (WriteAccessException e) {
|
||||
// ManagedBuilderCorePlugin.log(e);
|
||||
// } catch (CoreException e) {
|
||||
|
|
|
@ -376,7 +376,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC
|
|||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
public void setConfigurationData(String buildSystemId, CConfigurationData data) throws WriteAccessException {
|
||||
String oldId = getId();
|
||||
setData(data);
|
||||
|
@ -385,8 +385,8 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC
|
|||
}
|
||||
try {
|
||||
CConfigurationSpecSettings settings = getSpecSettings();
|
||||
settings.setId(getId());
|
||||
settings.setName(getName());
|
||||
settings.setId(data.getId());
|
||||
settings.setName(data.getName());
|
||||
settings.setBuildSystemId(buildSystemId);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
|
|
|
@ -97,11 +97,17 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
|
|||
}
|
||||
|
||||
public static UserDefinedVariableSupplier getInstance(){
|
||||
if(fInstance == null)
|
||||
fInstance = getInstanceSynch();
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
private static UserDefinedVariableSupplier getInstanceSynch(){
|
||||
if(fInstance == null)
|
||||
fInstance = new UserDefinedVariableSupplier();
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.macros.IBuildMacroSupplier#getMacro(java.lang.String, int, java.lang.Object)
|
||||
|
|
Loading…
Add table
Reference in a new issue