diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java index af6ca83cd34..9316f98e621 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java @@ -636,7 +636,7 @@ public class CommonBuilder extends ACBuilder { IConfiguration cfg = builder.getParent().getParent(); boolean isParallel = builder.getParallelizationNum() != 0; - boolean buildIncrementaly = true; +// boolean buildIncrementaly = true; boolean resumeOnErr = !builder.isStopOnError(); // Get the project and make sure there's a monitor to cancel the build @@ -654,13 +654,15 @@ public class CommonBuilder extends ACBuilder { OutputStream epmOutputStream = null; try { int flags = 0; - IResourceDelta delta = null; + IResourceDelta delta = getDelta(currentProject); - if(buildIncrementaly){ + if(delta != null){ flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.REMOVED | BuildDescriptionManager.DEPS; - delta = getDelta(currentProject); +// delta = getDelta(currentProject); } + boolean buildIncrementaly = delta != null; + IBuildDescription des = BuildDescriptionManager.createBuildDescription(cfg, delta, flags); DescriptionBuilder dBuilder = null; diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java index 30220c21fab..fcd936a199f 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java @@ -84,7 +84,9 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem } public CConfigurationData applyConfiguration( - ICConfigurationDescription des, CConfigurationData base) + ICConfigurationDescription des, + ICConfigurationDescription baseDescription, + CConfigurationData base) throws CoreException { if(des.isPreferenceConfiguration()) return applyPreferences(des, base); @@ -115,7 +117,9 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem public CConfigurationData createConfiguration( - ICConfigurationDescription des, CConfigurationData base, boolean clone) + ICConfigurationDescription des, + ICConfigurationDescription baseDescription, + CConfigurationData base, boolean clone) throws CoreException { if(des.isPreferenceConfiguration()) return createPreferences(des, base); diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryStorage.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryStorage.java index 169e71e5a5c..459670c11fb 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryStorage.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/EntryStorage.java @@ -189,6 +189,9 @@ public class EntryStorage { if(size > 0){ for(int j = 0; j < size; j++){ String value = (String)list.get(j); + if(value.indexOf('"') == 0 && value.lastIndexOf('"') == value.length() - 1 && value.length() != 1){ + value = value.substring(1, value.length() - 1); + } ICLanguageSettingEntry entry = createEntry(discoveredEntryFromString(value), false, false); EntryInfo discoveredInfo = fDiscoveredEntries.getEntryInfo(entry); if(discoveredInfo != null){ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ExternalExtensionMacroSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ExternalExtensionMacroSupplier.java index bbaa5c9f0c8..46ed2d72717 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ExternalExtensionMacroSupplier.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ExternalExtensionMacroSupplier.java @@ -149,7 +149,7 @@ public class ExternalExtensionMacroSupplier implements ICdtVariableSupplier{ case IBuildMacroProvider.CONTEXT_PROJECT: if (contextData instanceof IManagedProject) { IManagedProject project = (IManagedProject)contextData; - IProjectBuildMacroSupplier supplier = project.getProjectType().getBuildMacroSupplier(); + IProjectBuildMacroSupplier supplier = project.getProjectType() != null ? project.getProjectType().getBuildMacroSupplier() : null; if(supplier == null) return null; return supplier.getMacro(macroName,project,new ExtensionMacroProvider(contextType, contextData)); @@ -187,7 +187,7 @@ public class ExternalExtensionMacroSupplier implements ICdtVariableSupplier{ case IBuildMacroProvider.CONTEXT_PROJECT: if (contextData instanceof IManagedProject) { IManagedProject project = (IManagedProject)contextData; - IProjectBuildMacroSupplier supplier = project.getProjectType().getBuildMacroSupplier(); + IProjectBuildMacroSupplier supplier = project.getProjectType() != null ? project.getProjectType().getBuildMacroSupplier() : null; if(supplier != null) macros = supplier.getMacros(project,new ExtensionMacroProvider(contextType, contextData)); } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/CPropertyVarsTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/CPropertyVarsTab.java index d613f9fd0f6..4d6bbe88e07 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/CPropertyVarsTab.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/CPropertyVarsTab.java @@ -452,7 +452,7 @@ public class CPropertyVarsTab extends AbstractCPropertyTab { } private boolean isUserVar(ICdtVariable v) { - return mgr.isUserVariable(v, cfgd); + return cfgd != null ? mgr.isUserVariable(v, cfgd) : vars.contains(v); } /* check whether variable is dynamic */ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationDataProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationDataProvider.java index 432698a0f25..4dc9d8031bc 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationDataProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CConfigurationDataProvider.java @@ -40,7 +40,9 @@ public abstract class CConfigurationDataProvider { * @return * @throws CoreException */ - public abstract CConfigurationData createConfiguration(ICConfigurationDescription des, CConfigurationData base, boolean clone) throws CoreException; + public abstract CConfigurationData createConfiguration(ICConfigurationDescription des, + ICConfigurationDescription baseDescription, + CConfigurationData baseData, boolean clone) throws CoreException; /** * called to notify the provider that the configuration is removed @@ -60,5 +62,7 @@ public abstract class CConfigurationDataProvider { * @return * @throws CoreException */ - public abstract CConfigurationData applyConfiguration(ICConfigurationDescription des, CConfigurationData base) throws CoreException; + public abstract CConfigurationData applyConfiguration(ICConfigurationDescription des, + ICConfigurationDescription baseDescription, + CConfigurationData baseData) throws CoreException; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java index 7dc11664bf4..41a266b5366 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java @@ -21,6 +21,9 @@ import java.util.Map; import java.util.Set; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.cdtvariables.CdtVariableException; +import org.eclipse.cdt.core.cdtvariables.ICdtVariable; +import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModelUtil; @@ -54,7 +57,11 @@ import org.eclipse.cdt.core.settings.model.extension.CFileData; import org.eclipse.cdt.core.settings.model.extension.CFolderData; import org.eclipse.cdt.core.settings.model.extension.CLanguageData; import org.eclipse.cdt.core.settings.model.extension.CResourceData; +import org.eclipse.cdt.internal.core.CdtVarPathEntryVariableManager; import org.eclipse.cdt.internal.core.CharOperation; +import org.eclipse.cdt.internal.core.cdtvariables.CoreVariableSubstitutor; +import org.eclipse.cdt.internal.core.cdtvariables.DefaultVariableContextInfo; +import org.eclipse.cdt.internal.core.cdtvariables.ICoreVariableContextInfo; import org.eclipse.cdt.internal.core.model.APathEntry; import org.eclipse.cdt.internal.core.model.CModelStatus; import org.eclipse.cdt.internal.core.model.PathEntry; @@ -62,6 +69,7 @@ import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescriptionCac import org.eclipse.cdt.internal.core.settings.model.CExternalSetting; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo; +import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; @@ -112,6 +120,24 @@ public class PathEntryTranslator { private Map fResourceMap = new HashMap(); private IWorkspaceRoot fRoot = ResourcesPlugin.getWorkspace().getRoot(); + + private static class VarSubstitutor extends CoreVariableSubstitutor { + ICConfigurationDescription fCfg; + ICdtVariableManager fMngr = CCorePlugin.getDefault().getCdtVariableManager(); + + public VarSubstitutor(ICConfigurationDescription cfg) { + super(new DefaultVariableContextInfo(ICoreVariableContextInfo.CONTEXT_CONFIGURATION, cfg), "", " "); //$NON-NLS-1$ //$NON-NLS-2$ + fCfg = cfg; + } + + protected ResolvedMacro resolveMacro(ICdtVariable macro) + throws CdtVariableException { + if(!CdtVarPathEntryVariableManager.isPathEntryVariable(macro, fCfg, fMngr)) + return super.resolveMacro(macro); + return new ResolvedMacro(macro.getName(), CdtVariableResolver.createVariableReference(macro.getName())); + } + } + public static final class ReferenceSettingsInfo{ private IPath[] fRefProjPaths; private ICExternalSetting[] fExtSettings; @@ -390,7 +416,7 @@ public class PathEntryTranslator { } if(path != null){ - return new CLibraryFileEntry(path, flags); + return new CLibraryFileEntry(value.getName(), flags); } break; } @@ -407,7 +433,7 @@ public class PathEntryTranslator { } if(path != null){ - return new CIncludePathEntry(path, flags); + return new CIncludePathEntry(value.getName(), flags); } break; } @@ -431,7 +457,7 @@ public class PathEntryTranslator { } if(path != null){ - return new CIncludeFileEntry(path, flags); + return new CIncludeFileEntry(value.getName(), flags); } break; } @@ -444,7 +470,7 @@ public class PathEntryTranslator { } if(path != null){ - return new CMacroFileEntry(path, flags); + return new CMacroFileEntry(value.getName(), flags); } break; } @@ -563,6 +589,9 @@ public class PathEntryTranslator { basePath = mngr.resolvePath(basePath); valuePath = mngr.resolvePath(valuePath); + + fName = unresolvedBase.append(unresolvedValue).toString(); + fValue = fName; if (!basePath.isEmpty()) { IPath loc = basePath; @@ -580,8 +609,6 @@ public class PathEntryTranslator { } } fLocation = loc.append(valuePath); - fName = unresolvedBase.append(unresolvedValue).toString(); - fValue = fName; // fName = fValuePath.toString(); // fValue = fValuePath.toString(); break; @@ -604,11 +631,12 @@ public class PathEntryTranslator { fResourceInfo = rcInfo; // fFullPath = fResourceInfo.fRc.getFullPath(); // fLocation = fResourceInfo.fRc.getLocation(); + break; } } - } else { - fLocation = valuePath; } + + fLocation = valuePath; }while(false); } } @@ -722,27 +750,30 @@ public class PathEntryTranslator { private Set fFiltersSet; private boolean fIsExported; private IProject fProject; + private ICConfigurationDescription fCfg; - PathEntryComposer(String projName, IProject project){ - this(new Path(projName).makeAbsolute(), project); + PathEntryComposer(String projName, IProject project, ICConfigurationDescription cfg){ + this(new Path(projName).makeAbsolute(), project, cfg); } - PathEntryComposer(IPath path, IProject project){ + PathEntryComposer(IPath path, IProject project, ICConfigurationDescription cfg){ fPath = toProjectPath(path); fProject = project; + fCfg = cfg; } private static IPath toProjectPath(IPath path){ if(path.segmentCount() > 1) path = new Path(path.segment(0)); - + return path.makeAbsolute(); } - PathEntryComposer(ICExclusionPatternPathEntry entry, IProject project){ + PathEntryComposer(ICExclusionPatternPathEntry entry, IProject project, ICConfigurationDescription cfg){ fPath = new Path(entry.getValue()); fLangEntry = entry; fProject = project; + fCfg = cfg; IPath[] exclusions = entry.getExclusionPatterns(); if(exclusions.length != 0){ fFiltersSet = new HashSet(exclusions.length); @@ -750,11 +781,12 @@ public class PathEntryTranslator { } } - PathEntryComposer(IPath path, ICLanguageSettingEntry entry, boolean exported, IProject project){ + PathEntryComposer(IPath path, ICLanguageSettingEntry entry, boolean exported, IProject project, ICConfigurationDescription cfg){ fPath = path; fLangEntry = entry; fIsExported = exported; fProject = project; + fCfg = cfg; } public void addFilter(IPath path){ @@ -778,32 +810,48 @@ public class PathEntryTranslator { return new IPath[0]; } - private IPath[] getEntryPath(ICSettingEntry entry){ - return valueToEntryPath(entry.getName(), (entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0); + private IPath[] getEntryPath(ICSettingEntry entry, ICConfigurationDescription cfg){ + return valueToEntryPath(entry.getName(), (entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0, cfg); } - private IPath[] valueToEntryPath(String value, boolean isWsp){ - IPath path = new Path(value); + private IPath[] valueToEntryPath(String value, boolean isWsp, ICConfigurationDescription cfg){ + String pathVarValue = resolveKeepingPathEntryFars(value, cfg); + String resolvedValue = resolveAll(value, cfg); + IPath resolvedPath = new Path(resolvedValue); + IPath pathVarPath = new Path(pathVarValue); IPath result[] = new IPath[2]; if(isWsp){ - if(!path.isAbsolute()){ + if(!resolvedPath.isAbsolute()){ result[0] = fProject.getFullPath().makeRelative(); - result[1] = path; - path = fProject.getFullPath().append(path); + result[1] = pathVarPath; +// path = fProject.getFullPath().append(path); } else { - if(path.segmentCount() != 0){ - result[0] = new Path(path.segment(0)); - result[1] = path.removeFirstSegments(1).makeRelative(); + if(resolvedPath.segmentCount() != 0){ + String projName = resolvedPath.segment(0); + IPath valuePath = resolvedPath.removeFirstSegments(1).makeRelative(); + if(pathVarPath.segmentCount() != 0){ + String resolvedProjName = projName; + String varProjName = pathVarPath.segment(0); + IPath resolvedProjPath = CCorePlugin.getDefault().getPathEntryVariableManager().resolvePath(new Path(varProjName)); + if(resolvedProjPath.segmentCount() == 1 && resolvedProjName.equals(resolvedProjPath.segment(0))){ + projName = varProjName; + valuePath = pathVarPath.removeFirstSegments(1).makeRelative(); + } + } + + + result[0] = new Path(projName); + result[1] = valuePath; } } // path = path.makeRelative(); } else { - if(!path.isAbsolute()){ + if(!resolvedPath.isAbsolute()){ IPath location = fProject.getLocation(); if(location != null) - path = location.append(path); + pathVarPath = location.append(pathVarPath); } - result[1] = path; + result[1] = pathVarPath; } return result; @@ -813,24 +861,24 @@ public class PathEntryTranslator { if(fLangEntry != null){ switch(fLangEntry.getKind()){ case ICLanguageSettingEntry.INCLUDE_FILE:{ - IPath paths[] = getEntryPath(fLangEntry); + IPath paths[] = getEntryPath(fLangEntry, fCfg); return CoreModel.newIncludeFileEntry(fPath, null, paths[0], paths[1], getExclusionPatterns(), fIsExported); } case ICLanguageSettingEntry.INCLUDE_PATH:{ - IPath paths[] = getEntryPath(fLangEntry); + IPath paths[] = getEntryPath(fLangEntry, fCfg); ICIncludePathEntry ipe = (ICIncludePathEntry)fLangEntry; return CoreModel.newIncludeEntry(fPath, paths[0], paths[1], !ipe.isLocal(), getExclusionPatterns(), fIsExported); } case ICLanguageSettingEntry.MACRO: return CoreModel.newMacroEntry(fPath, fLangEntry.getName(), fLangEntry.getValue(), getExclusionPatterns(), fIsExported); case ICLanguageSettingEntry.MACRO_FILE:{ - IPath paths[] = getEntryPath(fLangEntry); + IPath paths[] = getEntryPath(fLangEntry, fCfg); return CoreModel.newMacroFileEntry(fPath, paths[0], null, paths[1], getExclusionPatterns(), fIsExported); } case ICLanguageSettingEntry.LIBRARY_PATH: return null; case ICLanguageSettingEntry.LIBRARY_FILE:{ - IPath paths[] = getEntryPath(fLangEntry); + IPath paths[] = getEntryPath(fLangEntry, fCfg); return CoreModel.newLibraryEntry(fPath, paths[0], paths[1], null, null, null, fIsExported); } case ICLanguageSettingEntry.OUTPUT_PATH: @@ -847,29 +895,52 @@ public class PathEntryTranslator { } } + private static String resolveAll(String value, ICConfigurationDescription cfg){ + try { + return CCorePlugin.getDefault().getCdtVariableManager().resolveValue(value, "", " ", cfg); + } catch (CdtVariableException e) { + CCorePlugin.log(e); + } + return value; + } + + private static String resolveKeepingPathEntryFars(String value, ICConfigurationDescription cfg){ + try { + VarSubstitutor substitutor = new VarSubstitutor(cfg); + + return CdtVariableResolver.resolveToString(value, substitutor); + } catch (CdtVariableException e) { + CCorePlugin.log(e); + } + return value; + } + public static class PathEntryCollector { private PathSettingsContainer fStorage; private KindBasedStore fStore; private LinkedHashMap fRefProjMap; private IProject fProject; + private ICConfigurationDescription fCfg; - private PathEntryCollector(IProject project){ + private PathEntryCollector(IProject project, ICConfigurationDescription cfg){ fStorage = PathSettingsContainer.createRootContainer(); fStorage.setValue(this); fStore = new KindBasedStore(false); + fCfg = cfg; fProject = project; } - private PathEntryCollector(PathSettingsContainer container, KindBasedStore store, IProject project){ + private PathEntryCollector(PathSettingsContainer container, KindBasedStore store, IProject project, ICConfigurationDescription cfg){ fStorage = container; fStore = store; + fCfg = cfg; fProject = project; } public void setSourceOutputEntries(int kind, ICExclusionPatternPathEntry entries[]){ Map map = getEntriesMap(kind, true); for(int i = 0; i < entries.length; i++){ - map.put(entries[i], new PathEntryComposer(entries[i], fProject)); + map.put(entries[i], new PathEntryComposer(entries[i], fProject, fCfg)); } } @@ -879,7 +950,7 @@ public class PathEntryTranslator { else { fRefProjMap = new LinkedHashMap(); for(int i = 0; i < paths.length; i++){ - PathEntryComposer cs = new PathEntryComposer(paths[i], fProject); + PathEntryComposer cs = new PathEntryComposer(paths[i], fProject, fCfg); IPath path = cs.getPath(); fRefProjMap.put(path, cs); } @@ -906,7 +977,7 @@ public class PathEntryTranslator { info[i].setInfo((LinkedHashMap)map.clone()); } } - PathEntryCollector newCr = new PathEntryCollector(newContainer, cloneStore, fProject); + PathEntryCollector newCr = new PathEntryCollector(newContainer, cloneStore, fProject, fCfg); newContainer.setValue(newCr); return newCr; } @@ -944,7 +1015,7 @@ public class PathEntryTranslator { continue; ICLanguageSettingEntry entry = entries[i]; - map.put(entry, new PathEntryComposer(fullPath, entry, exportedEntries.contains(entry), fProject)); + map.put(entry, new PathEntryComposer(fullPath, entry, exportedEntries.contains(entry), fProject, fCfg)); } } } @@ -2157,13 +2228,13 @@ public class PathEntryTranslator { CConfigurationData data = des instanceof CConfigurationDescriptionCache ? (CConfigurationData)des : ((IInternalCCfgInfo)des).getConfigurationData(false); - ReferenceSettingsInfo info = new ReferenceSettingsInfo(des); + ReferenceSettingsInfo refInfo = new ReferenceSettingsInfo(des); - return collectEntries(project, data, info); - } - - public static PathEntryCollector collectEntries(IProject project, CConfigurationData data, ReferenceSettingsInfo refInfo){ - final PathEntryCollector cr = new PathEntryCollector(project); +// return collectEntries(project, data, info); +// } +// +// public static PathEntryCollector collectEntries(IProject project, CConfigurationData data, ReferenceSettingsInfo refInfo){ + final PathEntryCollector cr = new PathEntryCollector(project, des); PathSettingsContainer rcDatas = createRcDataHolder(data); IPath srcPaths[] = data.getSourcePaths(); ICSourceEntry sEntries[] = calculateSourceEntriesFromPaths(project, rcDatas, srcPaths); @@ -2250,8 +2321,9 @@ public class PathEntryTranslator { return false; } - public static IPathEntry[] getPathEntries(IProject project, CConfigurationData data, ReferenceSettingsInfo refInfo, int flags){ - PathEntryCollector cr = collectEntries(project, data, refInfo); +// public static IPathEntry[] getPathEntries(IProject project, CConfigurationData data, ReferenceSettingsInfo refInfo, int flags){ + public static IPathEntry[] getPathEntries(IProject project, ICConfigurationDescription cfg, int flags){ + PathEntryCollector cr = collectEntries(project, cfg); return cr.getEntries(flags); } // diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java index 7a7ea0e0c5e..54051602880 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescription.java @@ -41,7 +41,6 @@ import org.eclipse.cdt.core.settings.model.extension.CFolderData; import org.eclipse.cdt.core.settings.model.extension.CLanguageData; import org.eclipse.cdt.core.settings.model.extension.CResourceData; import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData; -import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData; import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -99,7 +98,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC if(baseData instanceof CConfigurationDescriptionCache){ baseData = ((CConfigurationDescriptionCache)baseData).getConfigurationData(); } - setData(CProjectDescriptionManager.getInstance().createData(this, baseData, false)); + setData(CProjectDescriptionManager.getInstance().createData(this, base, baseData, false)); } /* @@ -138,8 +137,9 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC void doWritable() throws CoreException{ CConfigurationData data = getConfigurationData(false); if(data instanceof CConfigurationDescriptionCache){ - data = ((CConfigurationDescriptionCache)data).getConfigurationData(); - setData(CProjectDescriptionManager.getInstance().createData(this, data, true)); + CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)data; + data = cache.getConfigurationData(); + setData(CProjectDescriptionManager.getInstance().createData(this, cache, data, true)); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java index 4bb68c1869a..7f1c7f30ebd 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationDescriptionCache.java @@ -89,7 +89,7 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData fInitializing = false; } - CConfigurationDescriptionCache(CConfigurationData base, CConfigurationSpecSettings settingsBase, CProjectDescription parent, ICStorageElement rootEl, boolean saving) throws CoreException { + CConfigurationDescriptionCache(ICConfigurationDescription baseDescription, CConfigurationData base, CConfigurationSpecSettings settingsBase, CProjectDescription parent, ICStorageElement rootEl, boolean saving) throws CoreException { super(base.getId(), base.getName(), null); fInitializing = true; fParent = parent; @@ -97,9 +97,10 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData if(base instanceof CConfigurationDescriptionCache){ fData = ((CConfigurationDescriptionCache)base).getConfigurationData(); - fData = CProjectDescriptionManager.getInstance().applyData(this, fData); + fData = CProjectDescriptionManager.getInstance().applyData(this, baseDescription, fData); } else { - base = CProjectDescriptionManager.getInstance().applyData(this, base); + fData = base; + base = CProjectDescriptionManager.getInstance().applyData(this, baseDescription, base); fData = base; } fDataLoadded = true; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java index 6e14cc8453a..96537f67bb9 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java @@ -108,7 +108,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon if(baseData instanceof CConfigurationDescriptionCache){ baseData = ((CConfigurationDescriptionCache)baseData).getConfigurationData(); } - CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(baseData, cfgDes.getSpecSettings(), this, null, saving); + CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache((ICConfigurationDescription)cfgDes, baseData, cfgDes.getSpecSettings(), this, null, saving); configurationCreated(cache); } else { CConfigurationData baseData = cfgDes.getConfigurationData(false); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java index ccccc4c423b..4d882037057 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java @@ -149,6 +149,7 @@ public class CProjectDescriptionManager { private static final String DEFAULT_CFG_NAME = "Configuration"; //$NON-NLS-1$ private static final QualifiedName SCANNER_INFO_PROVIDER_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, "scannerInfoProvider"); //$NON-NLS-1$ + private static final QualifiedName LOAD_FLAG = new QualifiedName(CCorePlugin.PLUGIN_ID, "descriptionLoadded"); //$NON-NLS-1$ private class CompositeSafeRunnable implements ISafeRunnable { private List fRunnables = new ArrayList(); @@ -376,7 +377,7 @@ public class CProjectDescriptionManager { } if(des != null){ - if(setLoaddedDescription(project, des, false)){ + if(setLoaddedDescriptionOnLoad(project, des)){ if(eDes != null) saveConversion(project, eDes, (CProjectDescription)des, new NullProgressMonitor()); @@ -414,6 +415,18 @@ public class CProjectDescriptionManager { return des; } + private synchronized boolean setLoaddedDescriptionOnLoad(IProject project, ICProjectDescription des){ + des.setSessionProperty(LOAD_FLAG, Boolean.TRUE); + ICProjectDescription oldDes = getLoaddedDescription(project); + + setLoaddedDescription(project, des, true); + + if(oldDes == null) + return true; + + return oldDes.getSessionProperty(LOAD_FLAG) == null; + } + private CProjectDescriptionEvent createLoaddedEvent(ICProjectDescription des){ return new CProjectDescriptionEvent(CProjectDescriptionEvent.LOADDED, null, @@ -1304,9 +1317,9 @@ public class CProjectDescriptionManager { return provider.loadConfiguration(des); } - CConfigurationData applyData(ICConfigurationDescription des, CConfigurationData base) throws CoreException { + CConfigurationData applyData(ICConfigurationDescription des, ICConfigurationDescription baseDescription, CConfigurationData base) throws CoreException { CConfigurationDataProvider provider = getProvider(des); - return provider.applyConfiguration(des, base); + return provider.applyConfiguration(des, baseDescription, base); } void removeData(ICConfigurationDescription des, CConfigurationData data) throws CoreException{ @@ -1314,9 +1327,9 @@ public class CProjectDescriptionManager { provider.removeConfiguration(des, data); } - CConfigurationData createData(ICConfigurationDescription des, CConfigurationData base, boolean clone) throws CoreException{ + CConfigurationData createData(ICConfigurationDescription des, ICConfigurationDescription baseDescription, CConfigurationData base, boolean clone) throws CoreException{ CConfigurationDataProvider provider = getProvider(des); - return provider.createConfiguration(des, base, clone); + return provider.createConfiguration(des, baseDescription, base, clone); } private CConfigurationDataProvider getProvider(ICConfigurationDescription des) throws CoreException{ @@ -2583,7 +2596,7 @@ public class CProjectDescriptionManager { rootParent.removeChild(rootEl); ICStorageElement baseRootEl = settings.getRootStorageElement(); rootEl = rootParent.importChild(baseRootEl); - CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(baseData, cfgDes.getSpecSettings(), null, rootEl, true); + CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(des, baseData, cfgDes.getSpecSettings(), null, rootEl, true); return cache; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DefaultConfigurationDataProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DefaultConfigurationDataProvider.java index e273d99e2e8..b2155ea4a42 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DefaultConfigurationDataProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DefaultConfigurationDataProvider.java @@ -20,14 +20,18 @@ public class DefaultConfigurationDataProvider extends CConfigurationDataProvider { public CConfigurationData applyConfiguration( - ICConfigurationDescription des, CConfigurationData base) + ICConfigurationDescription des, + ICConfigurationDescription baseDescription, + CConfigurationData base) throws CoreException { //TODO: implement load/store return base; } public CConfigurationData createConfiguration( - ICConfigurationDescription des, CConfigurationData base, + ICConfigurationDescription des, + ICConfigurationDescription baseDescription, + CConfigurationData base, boolean clone) throws CoreException { //TODO: implement load/store CDefaultConfigurationData data = new CDefaultConfigurationData(des.getId(), des.getName(), base, null, clone); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/PathEntryConfigurationDataProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/PathEntryConfigurationDataProvider.java index eb543c22690..683560e85d9 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/PathEntryConfigurationDataProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/PathEntryConfigurationDataProvider.java @@ -12,9 +12,7 @@ package org.eclipse.cdt.internal.core.settings.model; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.List; -import java.util.Map; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.IPathEntry; @@ -220,7 +218,9 @@ public class PathEntryConfigurationDataProvider extends } public CConfigurationData applyConfiguration( - ICConfigurationDescription des, CConfigurationData base) + ICConfigurationDescription des, + ICConfigurationDescription baseDescription, + CConfigurationData base) throws CoreException { //TODO: check external/reference info here as well. if(!fFactory.isModified(base)) @@ -229,8 +229,8 @@ public class PathEntryConfigurationDataProvider extends IProject project = des.getProjectDescription().getProject(); - ReferenceSettingsInfo refInfo = new ReferenceSettingsInfo(des); - IPathEntry entries[] = PathEntryTranslator.getPathEntries(project, base, refInfo, PathEntryTranslator.INCLUDE_USER); +// ReferenceSettingsInfo refInfo = new ReferenceSettingsInfo(des); + IPathEntry entries[] = PathEntryTranslator.getPathEntries(project, baseDescription, PathEntryTranslator.INCLUDE_USER); CModelManager manager = CModelManager.getDefault(); ICProject cproject = manager.create(project); IPathEntry[] curRawEntries = PathEntryManager.getDefault().getRawPathEntries(cproject); @@ -249,7 +249,9 @@ public class PathEntryConfigurationDataProvider extends } public CConfigurationData createConfiguration( - ICConfigurationDescription des, CConfigurationData base, + ICConfigurationDescription des, + ICConfigurationDescription baseDescription, + CConfigurationData base, boolean clone) throws CoreException { CfgData copy = new CfgData(des.getId(), des.getName(), base, clone); copy.setModified(false); diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CdtVarPathEntryVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CdtVarPathEntryVariableManager.java index 86de6e94b83..8268b089a0e 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CdtVarPathEntryVariableManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CdtVarPathEntryVariableManager.java @@ -19,9 +19,11 @@ import java.util.Set; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.cdtvariables.CdtVariableException; import org.eclipse.cdt.core.cdtvariables.ICdtVariable; +import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager; import org.eclipse.cdt.core.resources.IPathEntryVariableChangeListener; import org.eclipse.cdt.core.resources.IPathEntryVariableManager; import org.eclipse.cdt.core.resources.PathEntryVariableChangeEvent; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.internal.core.cdtvariables.ICdtVariableChangeListener; import org.eclipse.cdt.internal.core.cdtvariables.ICoreVariableContextInfo; import org.eclipse.cdt.internal.core.cdtvariables.UserDefinedVariableSupplier; @@ -129,6 +131,23 @@ public class CdtVarPathEntryVariableManager implements return null; } + public static boolean isPathEntryVariable(ICdtVariable var, ICConfigurationDescription cfg){ + return isPathEntryVariable(var, cfg, CCorePlugin.getDefault().getCdtVariableManager()); + } + + public static boolean isPathEntryVariable(ICdtVariable var, ICConfigurationDescription cfg, ICdtVariableManager mngr){ + if(mngr.isUserVariable(var, cfg)) + return false; + + if(!mngr.isUserVariable(var, null)) + return false; + + if(getVariablePath(var) == null) + return false; + + return true; + } + public String[] getVariableNames() { ICdtVariable[] vars = fUserVarSupplier.getMacros(ICoreVariableContextInfo.CONTEXT_WORKSPACE, null); ArrayList list = new ArrayList(); diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/BuildSystemVariableSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/BuildSystemVariableSupplier.java index ab3bd5b8c2a..47def4d8277 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/BuildSystemVariableSupplier.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/BuildSystemVariableSupplier.java @@ -17,7 +17,16 @@ import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo; import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableManager; public class BuildSystemVariableSupplier extends CoreMacroSupplierBase { - + private static BuildSystemVariableSupplier fInstance; + private BuildSystemVariableSupplier(){ + } + + public static BuildSystemVariableSupplier getInstance(){ + if(fInstance == null){ + fInstance = new BuildSystemVariableSupplier(); + } + return fInstance; + } private class ExtensionMacroProvider extends CdtVariableManager{ private IVariableContextInfo fStartInfo; private int fContextType; diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtVariableManager.java index fef7ea7dac7..8f67278196a 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtVariableManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtVariableManager.java @@ -31,6 +31,7 @@ public class CdtVariableManager implements ICdtVariableManager { static private CdtVariableManager fDefault; public static UserDefinedVariableSupplier fUserDefinedMacroSupplier = UserDefinedVariableSupplier.getInstance(); + public static BuildSystemVariableSupplier fBuildSystemVariableSupplier = BuildSystemVariableSupplier.getInstance(); public static EnvironmentVariableSupplier fEnvironmentMacroSupplier = EnvironmentVariableSupplier.getInstance(); public static CdtMacroSupplier fCdtMacroSupplier = CdtMacroSupplier.getInstance(); public static EclipseVariablesVariableSupplier fEclipseVariablesMacroSupplier = EclipseVariablesVariableSupplier.getInstance(); @@ -199,6 +200,12 @@ public class CdtVariableManager implements ICdtVariableManager { public boolean isUserVariable(ICdtVariable variable, ICConfigurationDescription cfg) { - return variable instanceof StorableCdtVariable; + if(!(variable instanceof StorableCdtVariable)) + return false; + + if(cfg != null) + return UserDefinedVariableSupplier.getInstance().containsVariable(ICoreVariableContextInfo.CONTEXT_CONFIGURATION, cfg, variable); + + return UserDefinedVariableSupplier.getInstance().containsVariable(ICoreVariableContextInfo.CONTEXT_WORKSPACE, null, variable); } } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/DefaultVariableContextInfo.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/DefaultVariableContextInfo.java index 4309ee4068e..61f02f18f56 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/DefaultVariableContextInfo.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/DefaultVariableContextInfo.java @@ -44,6 +44,7 @@ public class DefaultVariableContextInfo implements ICoreVariableContextInfo { if(data instanceof ICConfigurationDescription){ return new ICdtVariableSupplier[]{ CdtVariableManager.fUserDefinedMacroSupplier, + CdtVariableManager.fBuildSystemVariableSupplier, CdtVariableManager.fEnvironmentMacroSupplier, CdtVariableManager.fCdtMacroSupplier }; diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/StorableCdtVariables.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/StorableCdtVariables.java index bdf269243d4..8c79a4f2beb 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/StorableCdtVariables.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/StorableCdtVariables.java @@ -18,6 +18,7 @@ import java.util.Map; import org.eclipse.cdt.core.cdtvariables.CdtVariableException; import org.eclipse.cdt.core.cdtvariables.ICdtVariable; import org.eclipse.cdt.core.settings.model.ICStorageElement; +import org.eclipse.cdt.internal.core.cdtvariables.UserDefinedVariableSupplier.VarKey; import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory; import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver; @@ -375,4 +376,16 @@ public class StorableCdtVariables { } return false; } + + public boolean contains(ICdtVariable var){ + ICdtVariable curVar = getMacro(var.getName()); + if(curVar == null) + return false; + + if(new VarKey(curVar, false).equals(new VarKey(var, false))) + return true; + + return false; + + } } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/UserDefinedVariableSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/UserDefinedVariableSupplier.java index decee3d318c..15e5c5fc7e7 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/UserDefinedVariableSupplier.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/UserDefinedVariableSupplier.java @@ -268,7 +268,7 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase { } } - private static class VarKey { + static class VarKey { private ICdtVariable fVar; private boolean fNameOnly; @@ -484,7 +484,7 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase { StorableCdtVariables macros = loadNewStileWorkspaceMacros(); //now load PathEntry Variables from preferences - + loadPathEntryVariables(macros); return macros; } @@ -672,4 +672,15 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase { } } + public boolean containsVariable(int context, Object data, ICdtVariable var){ + ICdtVariable varContained = getMacro(var.getName(), context, data); + if(varContained == null) + return false; + + if(new VarKey(varContained, false).equals(new VarKey(var, false))) + return true; + + return false; + } + }