Merge commit
authorEd Swartz <ed.swartz@nokia.com>
Wed, 15 Sep 2010 14:53:50 -0500
changeset 2016 e77c83f0c75a
parent 2015 d1f4910518d1 (diff)
parent 2011 445b096b330f (current diff)
child 2017 3155bf88e8d1
Merge commit
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/BuildConfigurationData.java	Wed Sep 15 14:45:18 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/BuildConfigurationData.java	Wed Sep 15 14:53:50 2010 -0500
@@ -316,7 +316,7 @@
 		try {
 			ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(project);
 			if (projDes != null) {
-				ICConfigurationDescription configDes = projDes.getConfigurationById(((CarbideBuildConfiguration)carbideBuildConfig).getBuildContext().getConfigurationID());
+				ICConfigurationDescription configDes = projDes.getConfigurationById(carbideBuildConfig.getBuildContext().getConfigurationID());
 				if (configDes != null) {
 					ICStorageElement storage = configDes.getStorage(CONFIG_DATA_CACHE, false);
 					if (storage != null) {
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideBuildManager.java	Wed Sep 15 14:45:18 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideBuildManager.java	Wed Sep 15 14:53:50 2010 -0500
@@ -338,12 +338,14 @@
 		Set<IPath> pathList = new HashSet<IPath>();
 		for (ICarbideBuildConfiguration config : cpi.getBuildConfigurations()) {
 
+			// Bug 12078:  I see no reason for this in C3 -- it always happens on startup and obviates the cache
+			/*
 			// force a rebuild of the CarbideLanguageData cache
 			// TODO PERFORMANCE EJS: why??? We end up forcing a cache rebuild even when you just switch configurations...
 			CLanguageData languageData = null;
 			ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(config.getCarbideProject().getProject());
 			if (projDes != null) {
-				ICConfigurationDescription configDes = projDes.getConfigurationById(config.getDisplayString());
+				ICConfigurationDescription configDes = projDes.getConfigurationById(config.getBuildContext().getConfigurationID());
 				if (configDes != null) {
 					CConfigurationData configData = configDes.getConfigurationData();
 					if (configData != null && configData instanceof BuildConfigurationData) {
@@ -360,7 +362,8 @@
 					}
 				}
 			}
-
+			 */
+			
 			EpocEngineHelper.addIncludedFilesFromBldInf(cpi, config, cpi.getAbsoluteBldInfPath(), pathList);
 
 			
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java	Wed Sep 15 14:45:18 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java	Wed Sep 15 14:53:50 2010 -0500
@@ -36,10 +36,16 @@
 import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.WorkspaceJob;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.content.IContentType;
 import org.eclipse.core.runtime.content.IContentTypeManager;
 import org.eclipse.core.runtime.content.IContentTypeSettings;
@@ -140,7 +146,24 @@
 		}
 		
 		if (cacheBuilt) {
-			persistCache();
+			// Bug 12078: persisting the cache requires setting the project 
+			// description, or else it gets thrown away (!).
+			// But we must save the cache in a workspace job because this code
+			// is usually called when the project description is being read for 
+			// the first time (thus saving just throws an exception).
+			WorkspaceJob job = new WorkspaceJob("Saving Carbide indexer cache for " + carbideBuildConfig.getDisplayString()) {
+
+				@Override
+				public IStatus runInWorkspace(IProgressMonitor monitor)
+						throws CoreException {
+					persistCache(monitor);
+					
+					return Status.OK_STATUS;
+				}
+				
+			};
+			job.setRule(ResourcesPlugin.getWorkspace().getRoot());
+			job.schedule();
 		}
 
 		switch(kind) {
@@ -333,13 +356,13 @@
 		cacheTimestamp = System.currentTimeMillis();
 	}
 
-	private void persistCache() {
+	private void persistCache(IProgressMonitor monitor) {
 		// persist the cache between IDE launches.
 		try {
 			final IProject project = carbideBuildConfig.getCarbideProject().getProject();
 			ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(project);
 			if (projDes != null) {
-				ICConfigurationDescription configDes = projDes.getConfigurationById(carbideBuildConfig.getDisplayString());
+				ICConfigurationDescription configDes = projDes.getConfigurationById(carbideBuildConfig.getBuildContext().getConfigurationID());
 				if (configDes != null) {
 					String includesCacheValue = "";
 					for (ICLanguageSettingEntry inc : includeEntries) {
@@ -370,6 +393,8 @@
 						filesCacheValue += file.getAbsolutePath() + ENTRY_DELIMTER;
 					}
 					storage.setAttribute(FILES_CACHE, filesCacheValue);
+					
+					CoreModel.getDefault().setProjectDescription(project, projDes, true, monitor);
 				}
 			}
 		} catch (CoreException e) {
@@ -386,7 +411,7 @@
 		try {
 			ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(project);
 			if (projDes != null) {
-				ICConfigurationDescription configDes = projDes.getConfigurationById(carbideBuildConfig.getDisplayString());
+				ICConfigurationDescription configDes = projDes.getConfigurationById(carbideBuildConfig.getBuildContext().getConfigurationID());
 				if (configDes != null) {
 					ICStorageElement storage = configDes.getStorage(CONFIG_DATA_CACHE, false);
 					if (storage != null) {