1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 01:35:39 +02:00

1. Fix to [Bug 175836] project build macro no longer resolved in the new project model

2. [Bug 175581] Includes path entry not filled out with envVarBuildPath: project suppliers now working
3. Option event handling fixes
4. Other bug-fixes
This commit is contained in:
Mikhail Sennikovsky 2007-02-28 17:49:25 +00:00
parent 91a194dc33
commit d6885590f9
8 changed files with 104 additions and 30 deletions

View file

@ -44,6 +44,7 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.settings.model.util.XmlStorageElement;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyManager;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentBuildPathsChangeListener;
@ -1884,7 +1885,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
Node node = nodes.item(0);
// Create the internal representation of the project's MBS information
buildInfo = new ManagedBuildInfo(project, (Element)node, fileVersion);
buildInfo = new ManagedBuildInfo(project, new XmlStorageElement((Element)node), true, fileVersion);
if (fileVersion != null) {
// buildInfo.setVersion(fileVersion);
PluginVersionIdentifier version = new PluginVersionIdentifier(fileVersion);

View file

@ -27,6 +27,7 @@ import org.eclipse.cdt.core.model.IPathEntryContainer;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.core.settings.model.WriteAccessException;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
@ -123,16 +124,18 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @param element
* @param managedBuildRevision
*/
public ManagedBuildInfo(IResource owner, Element element, String managedBuildRevision) {
public ManagedBuildInfo(IResource owner, ICStorageElement element, boolean loadConfigs, String managedBuildRevision) {
this(owner);
// Recreate the managed build project element and its children
NodeList projNodes = element.getElementsByTagName(IManagedProject.MANAGED_PROJECT_ELEMENT_NAME);
ICStorageElement projNodes[] = element.getChildren();
// TODO: There should only be 1?
for (int projIndex = projNodes.getLength() - 1; projIndex >= 0; --projIndex) {
ManagedProject proj = new ManagedProject(this, (Element)projNodes.item(projIndex), managedBuildRevision);
if (!proj.resolveReferences())
proj.setValid(false);
for (int projIndex = projNodes.length - 1; projIndex >= 0; --projIndex) {
if(IManagedProject.MANAGED_PROJECT_ELEMENT_NAME.equals(projNodes[projIndex].getName())){
ManagedProject proj = new ManagedProject(this, projNodes[projIndex], loadConfigs, managedBuildRevision);
if (!proj.resolveReferences())
proj.setValid(false);
}
}
// Switch the rebuild off since this is an existing project

View file

@ -124,7 +124,7 @@ public class ManagedProject extends BuildObject implements IManagedProject, IBui
* @param element
* @param managedBuildRevision the fileVersion of Managed Build System
*/
public ManagedProject(ManagedBuildInfo buildInfo, Element element, String managedBuildRevision) {
public ManagedProject(ManagedBuildInfo buildInfo, ICStorageElement element, boolean loadConfigs, String managedBuildRevision) {
this(buildInfo.getOwner());
setManagedBuildRevision(managedBuildRevision);
@ -133,24 +133,25 @@ public class ManagedProject extends BuildObject implements IManagedProject, IBui
if (loadFromProject(element)) {
// check for migration support.
boolean isSupportAvailable = projectType.checkForMigrationSupport();
boolean isSupportAvailable = projectType != null ? projectType.checkForMigrationSupport() : true;
if (isSupportAvailable == false) {
setValid(false);
}
// Load children
NodeList configElements = element.getChildNodes();
for (int i = 0; i < configElements.getLength(); ++i) {
Node configElement = configElements.item(i);
if (configElement.getNodeName().equals(IConfiguration.CONFIGURATION_ELEMENT_NAME)) {
ICStorageElement el = new XmlStorageElement((Element)configElement);
Configuration config = new Configuration(this, el, 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);
}*/
if(loadConfigs){
// Load children
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 {
setValid(false);
@ -170,13 +171,13 @@ public class ManagedProject extends BuildObject implements IManagedProject, IBui
*
* @param element An XML element containing the project information
*/
protected boolean loadFromProject(Element element) {
protected boolean loadFromProject(ICStorageElement element) {
// id
setId(element.getAttribute(IBuildObject.ID));
// name
if (element.hasAttribute(IBuildObject.NAME)) {
if (element.getAttribute(IBuildObject.NAME) != null) {
setName(element.getAttribute(IBuildObject.NAME));
}
@ -196,6 +197,21 @@ public class ManagedProject extends BuildObject implements IManagedProject, IBui
return true;
}
public void serializeProjectInfo(ICStorageElement element) {
element.setAttribute(IBuildObject.ID, id);
if (name != null) {
element.setAttribute(IBuildObject.NAME, name);
}
if (projectType != null) {
element.setAttribute(PROJECTTYPE, projectType.getId());
}
// I am clean now
isDirty = false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedProject#serialize()
*/

View file

@ -21,6 +21,7 @@ import java.util.Set;
import org.eclipse.cdt.core.model.ILanguageDescriptor;
import org.eclipse.cdt.core.model.LanguageManager;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider;
@ -29,6 +30,7 @@ import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
@ -38,6 +40,7 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.ISettingsChangeListener;
import org.eclipse.cdt.managedbuilder.internal.core.InputType;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
import org.eclipse.cdt.managedbuilder.internal.core.NotificationManager;
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
@ -70,6 +73,7 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
ICStorageElement cfgElemen = rootElement.createChild(IConfiguration.CONFIGURATION_ELEMENT_NAME);
Configuration cfg = (Configuration)appliedCfg.getConfiguration();
cfg.setConfigurationDescription(des);
ManagedBuildManager.performValueHandlerEvent(cfg, IManagedOptionValueHandler.EVENT_APPLY);
cfg.serialize(cfgElemen);
return appliedCfg;
@ -96,10 +100,21 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
IManagedBuildInfo info = getBuildInfo(des);
ManagedProject mProj = (ManagedProject)info.getManagedProject();
mProj.applyConfiguration((Configuration)appliedCfg.getConfiguration());
writeManagedProjectInfo(des.getProjectDescription(), mProj);
info.setValid(true);
return appliedCfg;
}
private static void writeManagedProjectInfo(ICProjectDescription des,
ManagedProject mProj) throws CoreException {
ICStorageElement rootElement = des.getStorage(BUILD_SYSTEM_DATA_MODULE_NAME, true);
rootElement.clear();
rootElement.setAttribute(VERSION_ATTRIBUTE, ManagedBuildManager.getVersion().toString());
ICStorageElement mProjElem = rootElement.createChild(IManagedProject.MANAGED_PROJECT_ELEMENT_NAME);
mProj.serializeProjectInfo(mProjElem);
}
protected CConfigurationData createPreferences(
ICConfigurationDescription des, CConfigurationData base)
@ -149,9 +164,34 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
private IManagedProject getManagedProject(ICConfigurationDescription des, IManagedBuildInfo info){
IManagedProject mProj = info.getManagedProject();
if(mProj == null){
mProj = new ManagedProject(des.getProjectDescription());
mProj = createManagedProject(info, des.getProjectDescription());
}
return mProj;
}
private IManagedProject createManagedProject(IManagedBuildInfo info, ICProjectDescription des){
IManagedProject mProj = null;
try {
ICStorageElement rootElem = des.getStorage(BUILD_SYSTEM_DATA_MODULE_NAME, false);
if(rootElem != null){
String version = rootElem.getAttribute(VERSION_ATTRIBUTE);
ICStorageElement children[] = rootElem.getChildren();
for(int i = 0; i < children.length; i++){
if(IManagedProject.MANAGED_PROJECT_ELEMENT_NAME.equals(children[i].getName())){
mProj = new ManagedProject((ManagedBuildInfo)info, children[i], false, version);
break;
}
}
}
} catch (CoreException e) {
mProj = null;
}
if(mProj == null){
mProj = new ManagedProject(des);
info.setManagedProject(mProj);
}
return mProj;
}
@ -164,6 +204,7 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
for(int i = 0; i < children.length; i++){
if(IConfiguration.CONFIGURATION_ELEMENT_NAME.equals(children[i].getName())){
cfg = new Configuration(mProj, children[i], version, isPreference);
ManagedBuildManager.performValueHandlerEvent(cfg, IManagedOptionValueHandler.EVENT_OPEN);
break;
}
}
@ -353,6 +394,7 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
public void removeConfiguration(ICConfigurationDescription des,
CConfigurationData data) {
IConfiguration cfg = ((BuildConfigurationData)data).getConfiguration();
ManagedBuildManager.performValueHandlerEvent(cfg, IManagedOptionValueHandler.EVENT_CLOSE);
IManagedBuildInfo info = getBuildInfo(des);
IManagedProject mProj = info.getManagedProject();
mProj.removeConfiguration(cfg.getId());

View file

@ -106,6 +106,7 @@ public class ProjectConverter implements ICProjectConverter {
Configuration cfg = ConfigurationDataProvider.getClearPreference(des.getId());
cfg.applyToManagedProject(mProj);
cfg.setConfigurationDescription(des);
des.setConfigurationData(ManagedBuildManager.CFG_DATA_PROVIDER_ID, cfg.getConfigurationData());
}
@ -278,7 +279,8 @@ public class ProjectConverter implements ICProjectConverter {
cfg = (Configuration)cfgs[i];
data = cfg.getConfigurationData();
try {
newDes.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
ICConfigurationDescription cfgDes = newDes.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
cfg.setConfigurationDescription(cfgDes);
} catch (WriteAccessException e) {
ManagedBuilderCorePlugin.log(e);
} catch (CoreException e) {

View file

@ -93,7 +93,7 @@ public class ExternalExtensionEnvironmentSupplier implements
}
else if (context instanceof IManagedProject) {
IManagedProject project = (IManagedProject)context;
IProjectEnvironmentVariableSupplier supplier = null;//project.getProjectType().getEnvironmentVariableSupplier();
IProjectEnvironmentVariableSupplier supplier = project.getProjectType() != null ? project.getProjectType().getEnvironmentVariableSupplier() : null;
if(supplier == null)
return null;
variables = supplier.getVariables(project,fProvider);

View file

@ -93,6 +93,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
*/
public CProjectDescription(CProjectDescription base, boolean saving, ICStorageElement el) {
fActiveCfgId = base.fActiveCfgId;
fIndexCfgId = base.fIndexCfgId;
fProject = base.fProject;
fRootStorageElement = el;
fIsReadOnly = saving;
@ -359,13 +360,22 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
if(fIndexCfg == null){
String id = getIndexConfigurationId();
fIndexCfg = getConfigurationById(id);
if(fIndexCfg == null){
fIndexCfg = getActiveConfiguration();
if(fIndexCfg != null){
fIndexCfgId = fIndexCfg.getId();
} else {
fIndexCfgId = null;
}
}
}
return fIndexCfg;
}
private String getIndexConfigurationId(){
if(fIndexCfgId == null)
if(fIndexCfgId == null){
fIndexCfgId = getActiveConfigurationId();
}
return fIndexCfgId;
}

View file

@ -52,14 +52,14 @@ public class EnvVarOperationProcessor {
String delimiter = added.getDelimiter();
return new EnvirinmentVariable(name,
performAppend(initial.getValue(),added.getValue(),delimiter),
// IBuildEnvironmentVariable.ENVVAR_APPEND,
IEnvironmentVariable.ENVVAR_APPEND,
delimiter);
}
case IEnvironmentVariable.ENVVAR_PREPEND:{
String delimiter = added.getDelimiter();
return new EnvirinmentVariable(name,
performPrepend(initial.getValue(),added.getValue(),delimiter),
// IBuildEnvironmentVariable.ENVVAR_PREPEND,
IEnvironmentVariable.ENVVAR_PREPEND,
delimiter);
}
case IEnvironmentVariable.ENVVAR_REPLACE: