merged Tims changes
authorfturovic <frank.turovich@nokia.com>
Tue, 30 Jun 2009 13:04:25 -0500
changeset 328 31403302c38e
parent 327 653e5573ae3c (current diff)
parent 323 d40e42540f1f (diff)
child 329 6f5ea15e52ff
child 331 b79bdacb7335
merged Tims changes
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/builder/CarbideCommandLauncher.java	Tue Jun 30 12:44:21 2009 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/builder/builder/CarbideCommandLauncher.java	Tue Jun 30 13:04:25 2009 -0500
@@ -16,29 +16,20 @@
 */
 package com.nokia.carbide.cdt.builder.builder;
 
-import java.io.IOException;
-import java.util.Properties;
+import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin;
 
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.CommandLauncher;
-import org.eclipse.cdt.core.ConsoleOutputStream;
-import org.eclipse.cdt.core.ErrorParserManager;
-import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.cdt.core.ProblemMarkerInfo;
+import org.eclipse.cdt.core.*;
 import org.eclipse.cdt.core.model.ICModelMarker;
 import org.eclipse.cdt.core.resources.IConsole;
 import org.eclipse.cdt.ui.CUIPlugin;
 import org.eclipse.cdt.utils.spawner.EnvironmentReader;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.internal.resources.MarkerInfo;
+import org.eclipse.core.internal.resources.Workspace;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
 
-import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin;
+import java.io.IOException;
+import java.util.*;
 
 /**
  * A utility class to handle windows process execution. This utility class handles all the execution, 
@@ -46,6 +37,53 @@
  */
 public class CarbideCommandLauncher extends CommandLauncher implements IMarkerGenerator {
 
+	public class MarkerCacheElement {
+		private int line;
+		private int severity;
+		private String message;
+		
+		public MarkerCacheElement(IMarker marker) throws CoreException {
+			line = marker.getAttribute(IMarker.LINE_NUMBER, -1);
+			severity = ((Integer) marker.getAttribute(IMarker.SEVERITY)).intValue();
+			message = (String) marker.getAttribute(IMarker.MESSAGE);
+		}
+
+		public MarkerCacheElement(ProblemMarkerInfo problemMarkerInfo) {
+			line = problemMarkerInfo.lineNumber;
+			severity = mapMarkerSeverity(problemMarkerInfo.severity);
+			message = problemMarkerInfo.description;
+		}
+
+		@Override
+		public int hashCode() {
+			final int prime = 31; 
+			int result = 1;
+			result = prime * result + line;
+			result = prime * result + severity;
+			result = prime * result
+					+ ((message == null) ? 0 : message.hashCode());
+			return result;
+		}
+
+		@Override
+		public boolean equals(Object obj) {
+			if (!(obj instanceof MarkerCacheElement))
+				return false;
+			MarkerCacheElement other = (MarkerCacheElement) obj;
+			if (line != other.line)
+				return false;
+			if (severity != other.severity)
+				return false;
+			if (message == null) {
+				if (other.message != null)
+					return false;
+			} 
+			else if (!message.equals(other.message))
+				return false;
+			return true;
+		}
+	}
+
 	protected IProgressMonitor monitor;
 	protected IConsole console;
 	protected ErrorParserManager stdoutStream;
@@ -56,6 +94,8 @@
 	protected IProject project;
 	protected String[] errorParserIds;
 	protected IMarkerGenerator markerGen;
+	private Map<IResource, Set<MarkerCacheElement>> markerCache;
+	private long markerCreationTime;
 	
 	/**
 	 * Location of tool execution
@@ -212,6 +252,8 @@
 	 * @return 0 (zero) on success. returns the actual tool return status
 	 */
 	public int executeCommand(IPath command, String[] args, String[] env, IPath workingDir){
+		markerCache = null;
+		markerCreationTime = System.currentTimeMillis();
 		int exitValue = -1;
 		String errMsg;
 		try {
@@ -299,35 +341,27 @@
     }
 
 	public void addMarker(ProblemMarkerInfo problemMarkerInfo) {
-
+		if (markerCache == null)
+			markerCache = new HashMap<IResource, Set<MarkerCacheElement>>();
+		
 		try {
 			IResource markerResource = problemMarkerInfo.file ;
 			if (markerResource == null)  {
 				markerResource = stdoutStream.getProject();
 			}
-			IMarker[] cur = markerResource.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_ONE);
-
-			/*
-			 * Try to find matching markers and don't put in duplicates
-			 */
-			if ((cur != null) && (cur.length > 0)) {
-				for (int i = 0; i < cur.length; i++) {
-					int line = cur[i].getAttribute(IMarker.LINE_NUMBER, -1);
-					int sev = ((Integer) cur[i].getAttribute(IMarker.SEVERITY)).intValue();
-					String mesg = (String) cur[i].getAttribute(IMarker.MESSAGE);
-					if (line == problemMarkerInfo.lineNumber && sev == mapMarkerSeverity(problemMarkerInfo.severity) && mesg.equals(problemMarkerInfo.description)) {
-						return;
-					}
+			
+			Set<MarkerCacheElement> cacheElements = markerCache.get(markerResource);
+			if (cacheElements == null) {
+				cacheElements = new HashSet<MarkerCacheElement>();
+				markerCache.put(markerResource, cacheElements);
+				IMarker[] cur = markerResource.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_ONE);
+				for (IMarker marker : cur) {
+					cacheElements.add(new MarkerCacheElement(marker));
 				}
 			}
-
-			// need to pause briefly between marker creations so the creation timestamps
-			// are unique and sorting the problems view by creation time works properly.
-			try {
-				Thread.sleep(20);
-			} catch (InterruptedException e1) {
-				e1.printStackTrace();
-			}
+			
+			if (!cacheElements.add(new MarkerCacheElement(problemMarkerInfo)))
+				return;
 
 			IMarker marker = markerResource.createMarker(ICModelMarker.C_MODEL_PROBLEM_MARKER);
 			marker.setAttribute(IMarker.MESSAGE, problemMarkerInfo.description);
@@ -356,6 +390,7 @@
 				}
 				marker.setAttribute(ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION, absolutePath.toOSString());
 			}
+			setUniqueCreationTime(marker);
 		}
 		catch (CoreException e) {
 			CCorePlugin.log(e.getStatus());
@@ -363,6 +398,16 @@
 
 	}
 	
+	private void setUniqueCreationTime(IMarker marker) {
+		// This is using internal platform APIs to avoid putting a delay into every marker creation
+		// to ensure each marker gets a unique creation time (for sorting in the problems view).
+		// The total delay could be significant when there are many problem markers
+		IResource resource = marker.getResource();
+		Workspace workspace = (Workspace) resource.getWorkspace();
+		MarkerInfo markerInfo = workspace.getMarkerManager().findMarkerInfo(resource, marker.getId());
+		markerInfo.setCreationTime(markerCreationTime++);
+	}
+
 	int mapMarkerSeverity(int severity) {
 
 		switch (severity) {
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/CarbideCPPBuilderUIHelpIds.java	Tue Jun 30 12:44:21 2009 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/CarbideCPPBuilderUIHelpIds.java	Tue Jun 30 13:04:25 2009 -0500
@@ -32,4 +32,5 @@
 	public static final String CARBIDE_BUILDER_SIS_DIALOG = CarbideBuilderPlugin.PLUGIN_ID + ".builder_sis_dialog"; //$NON-NLS-1$
 	public static final String CARBIDE_BUILDER_MMP_CHANGED_ACTION_DIALOG = CarbideBuilderPlugin.PLUGIN_ID + ".builder_mmp_changed_action_dialog"; //$NON-NLS-1$
 	public static final String CARBIDE_BUILDER_MMP_SELECTION_DIALOG = CarbideBuilderPlugin.PLUGIN_ID + ".builder_mmp_selection_dialog"; //$NON-NLS-1$
+	public static final String CARBIDE_BUILDER_TRACK_DEPENDENCIES_QUERY_DIALOG = CarbideBuilderPlugin.PLUGIN_ID + ".dependency_tracking_dialog"; //$NON-NLS-1$
 }
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/TrackDependenciesQueryDialog.java	Tue Jun 30 12:44:21 2009 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/TrackDependenciesQueryDialog.java	Tue Jun 30 13:04:25 2009 -0500
@@ -25,6 +25,7 @@
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.*;
+import org.eclipse.ui.PlatformUI;
 
 import com.nokia.carbide.cdt.builder.BuilderPreferenceConstants;
 import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin;
@@ -57,6 +58,7 @@
 	public TrackDependenciesQueryDialog(Shell shell, ICarbideProjectInfo cpi) {
 		super(shell);
 		this.cpi = cpi;
+		setShellStyle(getShellStyle() | SWT.RESIZE);
 	}
 
 	/**
@@ -113,6 +115,7 @@
 	 */
 	protected void configureShell(Shell shell) {
 		super.configureShell(shell);
+		PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, CarbideCPPBuilderUIHelpIds.CARBIDE_BUILDER_TRACK_DEPENDENCIES_QUERY_DIALOG);
 		shell.setText("Project rebuild notification"); //$NON-NLS-1$
 	}
 
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/messages.properties	Tue Jun 30 12:44:21 2009 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/messages.properties	Tue Jun 30 13:04:25 2009 -0500
@@ -200,7 +200,7 @@
 TrackDependenciesQueryDialog.0=This project was previously built from the command-line.  Carbide can manage the makefile dependencies in this project for faster incremental builds, but a full rebuild wil be required.
 TrackDependenciesQueryDialog.1=Improve Carbide build times (forces a rebuild)
 TrackDependenciesQueryDialog.2=Carbide will make dependency file for each source file and update makefiles accordingly.
-TrackDependenciesQueryDialog.3=Don't do anything (slower builds from Carbide)
+TrackDependenciesQueryDialog.3=Do not update dependencies (slower builds from Carbide, no rebuild)
 TrackDependenciesQueryDialog.4=Source dependencies will be managed as they currently exist in abld-generated makefiles.
 TrackDependenciesQueryDialog.5=Don't ask me again for any project
 TrackDependenciesQueryDialog.6=Carbide will not try to override dependency tracking for projects that are built with abld first.
--- a/core/com.nokia.carbide.cpp.doc.user/html/concepts/dependency_tracking.htm	Tue Jun 30 12:44:21 2009 -0500
+++ b/core/com.nokia.carbide.cpp.doc.user/html/concepts/dependency_tracking.htm	Tue Jun 30 13:04:25 2009 -0500
@@ -1,22 +1,31 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta name="LASTUPDATED" content="06/17/05 11:09:43" />
-<title>Dependency Tracking</title>
-<link rel="StyleSheet" href="../../book.css" type="text/css"/>
-</head>
-<body bgcolor="#FFFFFF">
-<h2>Dependency Tracking</h2>
-<p> blah blah blah</p>
-<p align="center">&nbsp;</p>
-<p align="left" class="figure">Figure 1 -Dependency Tracking dialog</p>
-<h5>Related references <b></b></h5>
-<ul>
-  <li>???</li>
-</ul>
-<div id="footer">Copyright &copy; 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. <br>License: <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a></div>
-
-</body>
-</html>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<meta http-equiv="Content-Style-Type" content="text/css" />
+<meta name="LASTUPDATED" content="06/17/05 11:09:43" />
+<title>Dependency Tracking</title>
+<link rel="StyleSheet" href="../../book.css" type="text/css"/>
+<style type="text/css">
+<!--
+.style1 {font-family: "Courier New", Courier, mono}
+-->
+</style>
+</head>
+<body bgcolor="#FFFFFF">
+<h2>Dependency Tracking</h2>
+<p> This section only applies to the SBSv1 (abld) build system. If you are using the Raptor (SBSv2) build system Carbide does not perform any build system modifications to optimize dependency tracking.</p>
+<p>Carbide has made some performance improvements over command-line builds when performing incremental builds. Once a project has been built, many users will invoke 'abld build' on their project, not knowing that their makefiles will be regenerated each time, taking a large performance hit. Although a command-line user can invoke 'abld target' to improve incremental build performance, Carbide invokes each build stage independently for a full incremental build (including the 'abld makefile' stage). In order to get around this performance hit from the IDE, Carbide manages the source and resource dependencies in separate <span class="style1">.d</span> (dependency) files generated under the build system. Then Carbide  makes a small modification to each component's (MMP) makefile under the <span class="style1">\epoc32\build</span>\ directory by including the generated .d files as dependency includes. This performance modification  makes incremental builds faster from Carbide.</p>
+<p>Normally,  you do not need to know the details dependency management unless you first build from the command-line and then try to build their project from the IDE. When this happens, Carbide will prompt you with the following dialog when you initiate a build from the IDE.</p>
+<p align="center"><img src="images/deps_track_query.png" width="483" height="203"></p>
+<p align="left" class="figure">Figure 1 -Dependency Tracking dialog</p>
+<p>If you plan to continue building in Carbide it is recommended you choose the option to <strong>Improve Carbide build times</strong>. However, be cautious of this as Carbide will remove all the object code and build everything from scratch. If you do choose the option <strong>Do not update dependencies</strong>, then Carbide will disable the option to manage dependencies under the <strong>Carbide Project Settings</strong>, <strong>SBSv1</strong> tab. </p>
+<h5>Related references <b></b></h5>
+<ul>
+  <li><a href="../reference/build_properties/pane_project_settings.htm">Carbide Project Settings</a></li>
+  <li><a href="../reference/wnd_build_prefs.htm">Carbide Global Build Settings</a> </li>
+</ul>
+<div id="footer">Copyright &copy; 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. <br>License: <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a></div>
+
+</body>
+</html>
Binary file core/com.nokia.carbide.cpp.doc.user/html/concepts/images/deps_track_query.png has changed
--- a/core/com.nokia.carbide.cpp.doc.user/html/context_help/carbide_ide_dialogs_help.xml	Tue Jun 30 12:44:21 2009 -0500
+++ b/core/com.nokia.carbide.cpp.doc.user/html/context_help/carbide_ide_dialogs_help.xml	Tue Jun 30 13:04:25 2009 -0500
@@ -76,10 +76,8 @@
 	<!-- Dependency Tracking (added v2.1) -->
 	<context id="dependency_tracking_dialog" >
 		<description>Managing makefile dependencies</description>
-		<topic label="Dependency Tracking"	   		href="html/concepts/dependency_tracking.htm" />
+		<topic label="Dependency Tracking"		href="html/concepts/dependency_tracking.htm" />
 	</context>
-
-	
 	
 <!-- =============================================================================== -->
 <!-- PLUGIN: com.nokia.carbide.cdt.rombuilder                                        -->
--- a/core/com.nokia.carbide.cpp.doc.user/html/reference/wnd_build_prefs.htm	Tue Jun 30 12:44:21 2009 -0500
+++ b/core/com.nokia.carbide.cpp.doc.user/html/reference/wnd_build_prefs.htm	Tue Jun 30 13:04:25 2009 -0500
@@ -90,6 +90,10 @@
       </ul>
     </td>
   </tr>
+  <tr>
+    <td><strong>Do not offer to track dependencies for projects build on command-line </strong></td>
+    <td>If you build a project from the command-line (with 'abld build') and then import the project into Carbide and attempt to build, Carbide will prompt you if you would like Carbide to manage source dependencies for you. Enabling this option insures Carbide will not ask you to manage dependencies (they will be done as normally done via 'abld build' command).</td>
+  </tr>
 </table>
 <p align="left">&nbsp;</p>
 <p align="center"><img src="images/carbide_proj_settings_sbsv2.png" alt="sbsv2 tab" width="420" height="283"></p>