[Bug 9031] set source roots at actual source root based on new cdt pref
authorChad Peckham <chad.peckham@nokia.com>
Wed, 20 May 2009 15:36:03 -0500
changeset 178 333b05116a29
parent 177 0bf059ef23f8
child 179 77bd4ab5f973
[Bug 9031] set source roots at actual source root based on new cdt pref
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/EpocEngineHelper.java
core/com.nokia.carbide.cpp/plugin_customization.ini
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/EpocEngineHelper.java	Wed May 20 13:59:07 2009 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/EpocEngineHelper.java	Wed May 20 15:36:03 2009 -0500
@@ -16,30 +16,72 @@
 */
 package com.nokia.carbide.cdt.builder;
 
-import java.io.*;
-import java.util.*;
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.eclipse.core.resources.IFile;
+import org.eclipse.cdt.core.CCorePlugin;
 import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.*;
+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.Path;
 
 import com.nokia.carbide.cdt.builder.builder.CarbideCPPBuilder;
-import com.nokia.carbide.cdt.builder.project.*;
-import com.nokia.carbide.cpp.epoc.engine.*;
-import com.nokia.carbide.cpp.epoc.engine.image.*;
-import com.nokia.carbide.cpp.epoc.engine.model.bldinf.*;
+import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration;
+import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo;
+import com.nokia.carbide.cdt.builder.project.ISISBuilderInfo;
+import com.nokia.carbide.cpp.epoc.engine.BldInfDataRunnableAdapter;
+import com.nokia.carbide.cpp.epoc.engine.BldInfViewRunnableAdapter;
+import com.nokia.carbide.cpp.epoc.engine.EpocEnginePlugin;
+import com.nokia.carbide.cpp.epoc.engine.ImageMakefileDataRunnableAdapter;
+import com.nokia.carbide.cpp.epoc.engine.MMPDataRunnableAdapter;
+import com.nokia.carbide.cpp.epoc.engine.MMPViewRunnableAdapter;
+import com.nokia.carbide.cpp.epoc.engine.PKGViewRunnableAdapter;
+import com.nokia.carbide.cpp.epoc.engine.image.IBitmapSource;
+import com.nokia.carbide.cpp.epoc.engine.image.IImageSource;
+import com.nokia.carbide.cpp.epoc.engine.image.IMultiImageSource;
+import com.nokia.carbide.cpp.epoc.engine.model.bldinf.IBldInfData;
+import com.nokia.carbide.cpp.epoc.engine.model.bldinf.IBldInfView;
+import com.nokia.carbide.cpp.epoc.engine.model.bldinf.IExport;
 import com.nokia.carbide.cpp.epoc.engine.model.bldinf.IExtension;
+import com.nokia.carbide.cpp.epoc.engine.model.bldinf.IMMPReference;
+import com.nokia.carbide.cpp.epoc.engine.model.bldinf.IMakMakeReference;
+import com.nokia.carbide.cpp.epoc.engine.model.bldinf.IMakefileReference;
 import com.nokia.carbide.cpp.epoc.engine.model.makefile.image.IImageMakefileData;
-import com.nokia.carbide.cpp.epoc.engine.model.mmp.*;
+import com.nokia.carbide.cpp.epoc.engine.model.mmp.EMMPLanguage;
+import com.nokia.carbide.cpp.epoc.engine.model.mmp.EMMPStatement;
+import com.nokia.carbide.cpp.epoc.engine.model.mmp.IMMPAIFInfo;
+import com.nokia.carbide.cpp.epoc.engine.model.mmp.IMMPBitmap;
+import com.nokia.carbide.cpp.epoc.engine.model.mmp.IMMPData;
+import com.nokia.carbide.cpp.epoc.engine.model.mmp.IMMPResource;
+import com.nokia.carbide.cpp.epoc.engine.model.mmp.IMMPView;
+import com.nokia.carbide.cpp.epoc.engine.model.mmp.IMMPViewConfiguration;
 import com.nokia.carbide.cpp.epoc.engine.preprocessor.AcceptedNodesViewFilter;
 import com.nokia.carbide.cpp.epoc.engine.preprocessor.AllNodesViewFilter;
 import com.nokia.carbide.cpp.internal.api.sdk.SymbianBuildContext;
 import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
-import com.nokia.carbide.internal.api.cpp.epoc.engine.model.pkg.*;
-import com.nokia.cpp.internal.api.utils.core.*;
+import com.nokia.carbide.internal.api.cpp.epoc.engine.model.pkg.EPKGLanguage;
+import com.nokia.carbide.internal.api.cpp.epoc.engine.model.pkg.IPKGEmbeddedSISFile;
+import com.nokia.carbide.internal.api.cpp.epoc.engine.model.pkg.IPKGInstallFile;
+import com.nokia.carbide.internal.api.cpp.epoc.engine.model.pkg.IPKGView;
+import com.nokia.carbide.internal.api.cpp.epoc.engine.model.pkg.PKGModelHelper;
+import com.nokia.cpp.internal.api.utils.core.CommonPathFinder;
+import com.nokia.cpp.internal.api.utils.core.FileUtils;
+import com.nokia.cpp.internal.api.utils.core.Logging;
 
 public class EpocEngineHelper {
 
@@ -1313,6 +1355,7 @@
 	 */
 	public static List<IPath> getSourceRootsForProject(final ICarbideProjectInfo info) {
 		final List<IPath> sourceRoots = new ArrayList<IPath>();
+		final boolean showSourceRootsAtTopOfProject = CCorePlugin.showSourceRootsAtTopOfProject();
 
 		IMMPReference[] mmps = (IMMPReference[])EpocEnginePlugin.runWithBldInfData(info.getWorkspaceRelativeBldInfPath(),
 			new DefaultViewConfiguration(info),
@@ -1345,9 +1388,13 @@
 							IPath fullPath = helper.convertMMPToWorkspace(EMMPPathContext.SOURCEPATH, path);
 							if (fullPath != null) {
 								// add the absolute workspace path to the folder directly under the project.
-								// ideally we'd be more precise but then CDT creates a C folder named Foo\Bar,
-								// rather than just expanding Foo and then seeing bar a C source folder.
-								topLevelSourcePaths.add(fullPath.uptoSegment(2).makeAbsolute());
+								if (showSourceRootsAtTopOfProject) {
+									// ideally we'd be more precise but then CDT creates a C folder named Foo\Bar,
+									// rather than just expanding Foo and then seeing bar a C source folder.
+									topLevelSourcePaths.add(fullPath.uptoSegment(2).makeAbsolute());
+								}
+								else // ideal
+									topLevelSourcePaths.add(fullPath.makeAbsolute());
 							}
 						}
 
@@ -1356,9 +1403,13 @@
 							IPath fullPath = helper.convertMMPToWorkspace(EMMPPathContext.SOURCEPATH, path);
 							if (fullPath != null) {
 								// add the absolute workspace path to the folder directly under the project.
-								// ideally we'd be more precise but then CDT creates a C folder named Foo\Bar,
-								// rather than just expanding Foo and then seeing bar a C source folder.
-								topLevelSourcePaths.add(fullPath.uptoSegment(2).makeAbsolute());
+								if (showSourceRootsAtTopOfProject) {
+									// ideally we'd be more precise but then CDT creates a C folder named Foo\Bar,
+									// rather than just expanding Foo and then seeing bar a C source folder.
+									topLevelSourcePaths.add(fullPath.uptoSegment(2).makeAbsolute());
+								}
+								else // ideal
+									topLevelSourcePaths.add(fullPath.makeAbsolute());
 							}
 						}
 
@@ -1366,7 +1417,13 @@
 							IPath fullPath = helper.convertMMPToWorkspace(EMMPPathContext.USERINCLUDE, path);
 							if (fullPath != null) {
 								// add the absolute workspace path to the folder directly under the project.
-								topLevelSourcePaths.add(fullPath.uptoSegment(2).makeAbsolute());
+								if (showSourceRootsAtTopOfProject) {
+									// ideally we'd be more precise but then CDT creates a C folder named Foo\Bar,
+									// rather than just expanding Foo and then seeing bar a C source folder.
+									topLevelSourcePaths.add(fullPath.uptoSegment(2).makeAbsolute());
+								}
+								else // ideal
+									topLevelSourcePaths.add(fullPath.makeAbsolute());
 							}
 						}
 						
@@ -1374,7 +1431,13 @@
 							IPath fullPath = helper.convertMMPToWorkspace(EMMPPathContext.SYSTEMINCLUDE, path);
 							if (fullPath != null) {
 								// add the absolute workspace path to the folder directly under the project.
-								topLevelSourcePaths.add(fullPath.uptoSegment(2).makeAbsolute());
+								if (showSourceRootsAtTopOfProject) {
+									// ideally we'd be more precise but then CDT creates a C folder named Foo\Bar,
+									// rather than just expanding Foo and then seeing bar a C source folder.
+									topLevelSourcePaths.add(fullPath.uptoSegment(2).makeAbsolute());
+								}
+								else // ideal
+									topLevelSourcePaths.add(fullPath.makeAbsolute());
 							}
 						}
 						
--- a/core/com.nokia.carbide.cpp/plugin_customization.ini	Wed May 20 13:59:07 2009 -0500
+++ b/core/com.nokia.carbide.cpp/plugin_customization.ini	Wed May 20 15:36:03 2009 -0500
@@ -248,6 +248,9 @@
 # turn off showing source files from binaries, maybe not be needed in CDT 5.0
 org.eclipse.cdt.core/org.eclipse.cdt.core.showSourceFilesInBinaries=false
 
+# turn off showing source roots at top level of projects
+org.eclipse.cdt.core/org.eclipse.cdt.core.showSourceRootsAtTopLevelOfProject=false
+
 # map C sources and headers to C++
 org.eclipse.cdt.core/org.eclipse.cdt.core.workspaceLanguageMappings=<?xml version\="1.0" encoding\="UTF-8"?><workspace-mappings><content-type-mapping content-type\="org.eclipse.cdt.core.cHeader" language\="org.eclipse.cdt.core.g++"/><content-type-mapping content-type\="org.eclipse.cdt.core.cSource" language\="org.eclipse.cdt.core.g++"/></workspace-mappings>