Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Evoy2004-06-04 16:17:57 -0400
committerSean Evoy2004-06-04 16:17:57 -0400
commit5f5b6bc0d76595e4b92f22fb99ae2c6a05ae6e12 (patch)
tree6bd9dc441cbe88b070d3feee11fef631aa79a897 /build/org.eclipse.cdt.managedbuilder.core
parenta9c11b6167779f2553ed7cf04a4f200ec69eef2e (diff)
downloadorg.eclipse.cdt-5f5b6bc0d76595e4b92f22fb99ae2c6a05ae6e12.tar.gz
org.eclipse.cdt-5f5b6bc0d76595e4b92f22fb99ae2c6a05ae6e12.tar.xz
org.eclipse.cdt-5f5b6bc0d76595e4b92f22fb99ae2c6a05ae6e12.zip
Fix fog bug 64952 -- Indexer being called when it doesn't need to run
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.core')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/.options4
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/plugin.xml6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java155
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java25
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java114
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java2
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java103
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildPathEntryContainerInitializer.java40
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java10
9 files changed, 288 insertions, 171 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/.options b/build/org.eclipse.cdt.managedbuilder.core/.options
new file mode 100644
index 00000000000..ee072d7ffb0
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/.options
@@ -0,0 +1,4 @@
+org.eclipse.cdt.managedbuilder.core/debug=true
+
+# Reports path entry container activity
+org.eclipse.cdt.managedbuilder.core/debug/pathEntry=false
diff --git a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
index a2685df62b7..2f75590e532 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
@@ -67,5 +67,11 @@
id="org.eclipse.cdt.managedbuilder.core.genmakebuilder">
</builder>
</extension>
+ <extension
+ point="org.eclipse.cdt.core.PathEntryContainerInitializer">
+ <pathEntryContainerInitializer
+ class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildPathEntryContainerInitializer"
+ id="org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER"/>
+ </extension>
</plugin>
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java
index 4954341762e..59644eb61c9 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java
@@ -15,6 +15,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -35,6 +36,8 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.eclipse.cdt.core.AbstractCExtension;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
@@ -54,9 +57,12 @@ import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier;
import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.Status;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -345,16 +351,19 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
ListIterator iter = listeners.listIterator();
while (iter.hasNext()) {
- ((IScannerInfoChangeListener)iter.next()).changeNotification(resource, (IScannerInfo)getBuildInfo(resource, false));
+ ((IScannerInfoChangeListener)iter.next()).changeNotification(resource, (IScannerInfo)getBuildInfo(resource));
}
}
/**
- * @param newProject
+ * Adds the version of the managed build system to the project
+ * specified in the argument.
+ *
+ * @param newProject the project to version
*/
public static void setNewProjectVersion(IProject newProject) {
// Get the build info for the argument
- ManagedBuildInfo info = findBuildInfo(newProject, false);
+ ManagedBuildInfo info = findBuildInfo(newProject);
info.setVersion(buildInfoVersion.toString());
}
@@ -570,7 +579,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
return parentTarget;
if (resource instanceof IProject) {
- // Must be an extension target (why?)
+ // Must be an extension target
if (owner != null)
throw new BuildException(ManagedMakeMessages.getResourceString("ManagedBuildManager.error.owner_not_null")); //$NON-NLS-1$
} else {
@@ -585,6 +594,54 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
return new Target(resource, parentTarget);
}
+ /**
+ * @param resource
+ * @return
+ */
+ public static IStatus initBuildInfoContainer(IResource resource) {
+ ManagedBuildInfo buildInfo = null;
+
+ // Get the build info associated with this project for this session
+ try {
+ buildInfo = findBuildInfo(resource.getProject());
+ initBuildInfoContainer(buildInfo);
+ } catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
+ return new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ -1,
+ e.getLocalizedMessage(),
+ e);
+ }
+ return new Status(IStatus.OK,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ IStatus.OK,
+ ManagedMakeMessages.getFormattedString("ManagedBuildInfo.message.init.ok", resource.getName()), //$NON-NLS-1$
+ null);
+ }
+
+ /* (non-Javadoc)
+ * Private helper method to intialize the path entry container once and
+ * only once when the build info is first loaded or created.
+ *
+ * @param info
+ * @throws CoreException
+ */
+ private static void initBuildInfoContainer(ManagedBuildInfo info) throws CoreException {
+ // Now associate the path entry container with the project
+ ICProject cProject = info.getCProject();
+ // This does not block the workspace or trigger delta events
+ IPathEntry[] entries = cProject.getRawPathEntries();
+ // Make sure the container for this project is in the path entries
+ List newEntries = new ArrayList(Arrays.asList(entries));
+ if (!newEntries.contains(ManagedBuildInfo.containerEntry)) {
+ // In this case we should trigger an init and deltas
+ newEntries.add(ManagedBuildInfo.containerEntry);
+ cProject.setRawPathEntries((IPathEntry[])newEntries.toArray(new IPathEntry[newEntries.size()]), new NullProgressMonitor());
+ info.setContainerCreated(true);
+ }
+ }
+
private static boolean isVersionCompatible(IExtension extension) {
// We can ignore the qualifier
PluginVersionIdentifier version = null;
@@ -619,6 +676,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
if (!file.exists())
return null;
+ // So there is a project file, load the information there
try {
InputStream stream = file.getContents();
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
@@ -655,9 +713,9 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
project.setSessionProperty(buildInfoProperty, buildInfo);
}
} catch (Exception e) {
+ ManagedBuilderCorePlugin.log(e);
buildInfo = null;
}
-
return buildInfo;
}
@@ -735,6 +793,36 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
}
+ /**
+ * Creates a new build information object and associates it with the
+ * resource in the argument. Note that the information contains no
+ * build target or configuation information. It is the respoinsibility
+ * of the caller to populate it. It is also important to note that the
+ * caller is responsible for associating an IPathEntryContainer with the
+ * build information after it has been populated.
+ * <p>
+ * The typical sequence of calls to add a new build information object to
+ * a managed build project is
+ * <p><pre>
+ * ManagedBuildManager.createBuildInfo(project);
+ * &#047;&#047; Do whatever initialization you need here
+ * ManagedBuildManager.createTarget(project);
+ * ManagedBuildManager.initBuildInfoContainer(project);
+ *
+ * @param resource The resource the build information is associated with
+ */
+ public static void createBuildInfo(IResource resource) {
+ ManagedBuildInfo buildInfo = new ManagedBuildInfo(resource);
+ try {
+ // Associate the build info with the project for the duration of the session
+ resource.setSessionProperty(buildInfoProperty, buildInfo);
+ } catch (CoreException e) {
+ // There is no point in keeping the info around if it isn't associated with the project
+ ManagedBuilderCorePlugin.log(e);
+ buildInfo = null;
+ }
+ }
+
private static IManagedConfigElementProvider createConfigProvider(
DefaultManagedConfigElement element) throws CoreException {
@@ -774,7 +862,17 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
return false;
}
- private static ManagedBuildInfo findBuildInfo(IResource resource, boolean create) {
+ /* (non-Javadoc)
+ * Provate helper method that first checks to see if a build information
+ * object has been associated with the project for the current workspace
+ * session. If one cannot be found, one is created from the project file
+ * associated with the argument. If there is no prject file or the load
+ * fails for some reason, the method will return <code>null</code>
+ *
+ * @param resource
+ * @return
+ */
+ private static ManagedBuildInfo findBuildInfo(IResource resource/*, boolean create*/) {
// I am sick of NPEs
if (resource == null) return null;
@@ -796,55 +894,40 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
buildInfo.updateOwner(resource);
}
} catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
return null;
}
+ // Nothing in session store, so see if we can load it from cdtbuild
if (buildInfo == null && resource instanceof IProject) {
- // Nothing in session store, so see if we can load it from cdtbuild
buildInfo = loadBuildInfo((IProject)resource);
- }
-
- if (buildInfo == null && create) {
try {
- // Create a new build info object for the project
- buildInfo = new ManagedBuildInfo(resource, true);
- // Associate the build info with the project for the duration of the session
- resource.setSessionProperty(buildInfoProperty, buildInfo);
+ // Check if the project needs its container initialized
+ initBuildInfoContainer(buildInfo);
} catch (CoreException e) {
- return null;
+ // We can live without a path entry container if the build information is valid
+ ManagedBuilderCorePlugin.log(e);
}
}
-
return buildInfo;
}
/**
- * Answers the build information for the <code>IResource</code> in the
- * argument. If the <code>create</code> is true, then a new build information
- * repository will be created for the resource.
- *
- * @param resource
- * @param create
- * @return IManagedBuildInfo
- */
- public static IManagedBuildInfo getBuildInfo(IResource resource, boolean create) {
- return (IManagedBuildInfo) findBuildInfo(resource, create);
- }
-
- /**
- * Answers, but does not create, the managed build information for the
+ * Finds, but does not create, the managed build information for the
* argument.
*
- * @see ManagedBuildManager#getBuildInfo(IResource, boolean)
- * @param resource
- * @return IManagedBuildInfo
+ * @see ManagedBuildManager#initBuildInfo(IResource)
+ * @param resource The resource to search for managed build information on.
+ * @return IManagedBuildInfo The build information object for the resource.
*/
public static IManagedBuildInfo getBuildInfo(IResource resource) {
- return (IManagedBuildInfo) findBuildInfo(resource, false);
+ return (IManagedBuildInfo) findBuildInfo(resource.getProject());
}
/**
- * @return
+ * Answers the current version of the managed builder plugin.
+ *
+ * @return the current version of the managed builder plugin
*/
public static PluginVersionIdentifier getBuildInfoVersion() {
return buildInfoVersion;
@@ -864,7 +947,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
* @see org.eclipse.cdt.core.parser.IScannerInfoProvider#getScannerInformation(org.eclipse.core.resources.IResource)
*/
public IScannerInfo getScannerInformation(IResource resource) {
- return (IScannerInfo) getBuildInfo(resource.getProject(), false);
+ return (IScannerInfo) getBuildInfo(resource.getProject());
}
/* (non-Javadoc)
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java
index 66fda3f3885..49069e81f73 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java
@@ -13,11 +13,14 @@ package org.eclipse.cdt.managedbuilder.core;
import java.lang.reflect.InvocationTargetException;
+import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
+import org.osgi.framework.BundleContext;
public class ManagedBuilderCorePlugin extends Plugin {
@@ -71,4 +74,26 @@ public class ManagedBuilderCorePlugin extends Plugin {
ResourcesPlugin.getPlugin().getLog().log(status);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ // Turn on logging for plugin when debugging
+ super.start(context);
+ configurePluginDebugOptions();
+ }
+
+ private static final String PATH_ENTRY = getUniqueIdentifier() + "/debug/pathEntry"; //$NON-NLS-1$
+
+ /**
+ *
+ */
+ private void configurePluginDebugOptions() {
+ if (isDebugging()) {
+ String option = Platform.getDebugOption(PATH_ENTRY);
+ if (option != null) {
+ ManagedBuildCPathEntryContainer.VERBOSE = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
+ }
+ }
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
index c80290fa863..0dfce1aeb84 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java
@@ -42,13 +42,9 @@ 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.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -61,72 +57,34 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
private static final QualifiedName defaultConfigProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "defaultConfig"); //$NON-NLS-1$
private static final QualifiedName defaultTargetProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "defaultTarget"); //$NON-NLS-1$
// The path container used for all managed projects
- private static final IContainerEntry containerEntry = CoreModel.newContainerEntry(new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER")); //$NON-NLS-1$
+ public static final IContainerEntry containerEntry = CoreModel.newContainerEntry(new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER")); //$NON-NLS-1$
- private ICProject cModelElement;
+ private boolean containerCreated;
+ private ICProject cProject;
private String defaultConfigIds;
private Map defaultConfigMap;
private ITarget defaultTarget;
private String defaultTargetId;
- private ITarget selectedTarget;
private boolean isDirty;
- private boolean rebuildNeeded;
private IResource owner;
+ private boolean rebuildNeeded;
+ private ITarget selectedTarget;
private Map targetMap;
private List targetList;
- private String version;
+ private String version;
/**
- * For compatability.
+ * Basic contructor used when the project is brand new.
*
* @param owner
*/
public ManagedBuildInfo(IResource owner) {
- this(owner, true);
- }
-
- /**
- * Create a new managed build information for the IResource specified in the argument
- *
- * @param owner
- * @param intializeEntries
- * @since 2.0
- */
- public ManagedBuildInfo(IResource owner, boolean intializeEntries) {
this.owner = owner;
- cModelElement = CoreModel.getDefault().create(owner.getProject());
-
- try {
- IPathEntry[] entries = cModelElement.getRawPathEntries();
- if (entries.length > 0 && entries[0].equals(containerEntry)) {
-
- } else {
- Job initJob = new Job(ManagedMakeMessages.getFormattedString("ManagedBuildInfo.message.job.init", getOwner().getName())) { //$NON-NLS-1$
- protected IStatus run(IProgressMonitor monitor) {
- try {
- // Set the raw path entries
- cModelElement.setRawPathEntries(new IPathEntry[]{containerEntry}, new NullProgressMonitor());
- } catch (CModelException e) {
- return new Status(IStatus.ERROR,
- ManagedBuilderCorePlugin.getUniqueIdentifier(),
- -1,
- e.getLocalizedMessage(),
- e);
- }
- return new Status(IStatus.OK,
- ManagedBuilderCorePlugin.getUniqueIdentifier(),
- IStatus.OK,
- ManagedMakeMessages.getFormattedString("ManagedBuildInfo.message.init.ok", getOwner().getName()), //$NON-NLS-1$
- null);
- }
+ cProject = CoreModel.getDefault().create(owner.getProject());
- };
- initJob.schedule();
- }
- } catch (CModelException e) {
- ManagedBuilderCorePlugin.log(e);
- }
+ // The container for this project has never been created
+ containerCreated = false;
// Does not need a save but should be rebuilt
isDirty = false;
@@ -150,10 +108,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
// Again, hitting this error just means the default config is not set
return;
}
-
- if(intializeEntries) {
- initializePathEntries();
- }
}
/**
@@ -164,16 +118,16 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @param element
*/
public ManagedBuildInfo(IResource owner, Element element) {
- this(owner, false);
+ this(owner);
+ // Container has already been created for this project
+ containerCreated = true;
// Inflate the targets
NodeList targetNodes = element.getElementsByTagName(ITarget.TARGET_ELEMENT_NAME);
for (int targIndex = targetNodes.getLength() - 1; targIndex >= 0; --targIndex) {
new Target(this, (Element)targetNodes.item(targIndex));
}
-
- initializePathEntries();
-
+
// Switch the rebuild off since this is an existing project
rebuildNeeded = false;
}
@@ -242,7 +196,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
return name;
}
-
+ public ICProject getCProject() {
+ return cProject;
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getCleanCommand()
@@ -436,9 +392,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
private ArrayList getIncludePathEntries() {
// Extract the resolved paths from the project (if any)
ArrayList paths = new ArrayList();
- if (cModelElement != null) {
+ if (cProject != null) {
try {
- IPathEntry[] entries = cModelElement.getResolvedPathEntries();
+ IPathEntry[] entries = cProject.getResolvedPathEntries();
for (int index = 0; index < entries.length; ++index) {
int kind = entries[index].getEntryKind();
if (kind == IPathEntry.CDT_INCLUDE) {
@@ -505,9 +461,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
private HashMap getMacroPathEntries() {
HashMap macros = new HashMap();
- if (cModelElement != null) {
+ if (cProject != null) {
try {
- IPathEntry[] entries = cModelElement.getResolvedPathEntries();
+ IPathEntry[] entries = cProject.getResolvedPathEntries();
for (int index = 0; index < entries.length; ++index) {
if (entries[index].getEntryKind() == IPathEntry.CDT_MACRO) {
IMacroEntry macro = (IMacroEntry) entries[index];
@@ -865,8 +821,8 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
*/
private void initializePathEntries() {
try {
- IPathEntryContainer container = new ManagedBuildCPathEntryContainer(this);
- CoreModel.getDefault().setPathEntryContainer(new ICProject[]{cModelElement}, container, new NullProgressMonitor());
+ IPathEntryContainer container = new ManagedBuildCPathEntryContainer(getOwner().getProject());
+ CoreModel.getDefault().setPathEntryContainer(new ICProject[]{cProject}, container, new NullProgressMonitor());
} catch (CModelException e) {
ManagedBuilderCorePlugin.log(e);
}
@@ -908,19 +864,23 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
setDirty(false);
}
+ public void setContainerCreated(boolean isCreated) {
+ containerCreated = isCreated;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setDefaultConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
*/
public void setDefaultConfiguration(IConfiguration configuration) {
// Sanity
- if (configuration== null) return;
+ if (configuration == null) return;
// Get the target associated with the argument
ITarget target = configuration.getTarget();
// See if there is anything to be done
IConfiguration oldDefault = getDefaultConfiguration(target);
- if (!configuration.equals(oldDefault)) {
+ if (defaultTarget == null || !configuration.equals(oldDefault)) {
// Make sure it is the default
setDefaultTarget(target);
// Make the argument the
@@ -960,7 +920,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
defaultTarget = target;
defaultTargetId = target.getId();
persistDefaultTarget();
- initializePathEntries();
+ if (containerCreated) {
+ initializePathEntries();
+ }
}
}
@@ -1028,17 +990,11 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
target.updateOwner(resource);
}
// And finally update the cModelElement
- cModelElement = CoreModel.getDefault().create(owner.getProject());
- try {
- CoreModel.setRawPathEntries(cModelElement, new IPathEntry[]{containerEntry}, new NullProgressMonitor());
- } catch (CModelException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- initializePathEntries();
-
+ cProject = CoreModel.getDefault().create(owner.getProject());
+
// Save everything
setDirty(true);
+ setRebuildState(true);
}
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java
index ac234b25306..60c0dba655e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java
@@ -98,7 +98,7 @@ public class Target extends BuildObject implements ITarget {
this.cleanCommand = parent.getCleanCommand();
// Hook me up
- IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner, true);
+ IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner);
buildInfo.addTarget(this);
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java
index af5d169c64a..78abc9f9155 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) Apr 21, 2004 IBM Corporation and others.
+ * Copyright (c) 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
@@ -19,7 +19,6 @@ import java.util.Map;
import java.util.Vector;
import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.IIncludeEntry;
import org.eclipse.cdt.core.model.IMacroEntry;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.model.IPathEntryContainer;
@@ -52,21 +51,34 @@ import org.eclipse.core.runtime.Platform;
* @since 2.0
*/
public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
-
private static final String BUILDER_ID = MakeCorePlugin.getUniqueIdentifier() + ".ScannerConfigBuilder"; //$NON-NLS-1$
+ private static final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$
+ private static final String ERROR_HEADER = "PathEntryContainer error ["; //$NON-NLS-1$
+ private static final String TRACE_FOOTER = "]: "; //$NON-NLS-1$
+ private static final String TRACE_HEADER = "PathEntryContainer trace ["; //$NON-NLS-1$
+
private ITarget defaultTarget;
private Vector entries;
+ private IProject project;
private ManagedBuildInfo info;
+ public static boolean VERBOSE = false;
+ public static void outputTrace(String resourceName, String message) {
+ System.out.println(TRACE_HEADER + resourceName + TRACE_FOOTER + message + NEWLINE);
+ }
+
+ public static void outputError(String resourceName, String message) {
+ System.err.println(ERROR_HEADER + resourceName + TRACE_FOOTER + message + NEWLINE);
+ }
+
/**
* Creates a new path container for the managed buildd project.
*
* @param info the build information associated with the project
*/
- public ManagedBuildCPathEntryContainer(ManagedBuildInfo info) {
+ public ManagedBuildCPathEntryContainer(IProject project) {
super();
- this.info = info;
- defaultTarget = info.getDefaultTarget();
+ this.project = project;
entries = new Vector();
}
@@ -91,7 +103,7 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
}
if (add) {
- entries.add(CoreModel.newMacroEntry(new Path(""), macro, value)); //$NON-NLS-1$
+ entries.add(CoreModel.newMacroEntry(Path.EMPTY, macro, value));
}
}
@@ -101,24 +113,12 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
// A little checking is needed to avoid adding duplicates
Iterator pathIter = paths.listIterator();
while (pathIter.hasNext()) {
- boolean add = true;
String path = (String) pathIter.next();
- // Make sure there is no other path with the same value
- Iterator entryIter = entries.listIterator();
- while (entryIter.hasNext()) {
- IPathEntry entry = (IPathEntry) entryIter.next();
- if (entry.getEntryKind() == IPathEntry.CDT_INCLUDE) {
- if (((IIncludeEntry)entry).getFullIncludePath().equals(path)) {
- add = false;
- break;
- }
- }
- }
- if (add) {
- entries.add(CoreModel.newIncludeEntry(new Path(""), null, new Path(path), true)); //$NON-NLS-1$
+ IPathEntry entry = CoreModel.newIncludeEntry(Path.EMPTY, Path.EMPTY, new Path(path), true);
+ if (!entries.contains(entry)) {
+ entries.add(entry);
}
}
-
}
protected void calculateBuiltIns(ITarget defaultTarget, IConfiguration config) {
@@ -190,35 +190,38 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getPathEntries()
*/
public IPathEntry[] getPathEntries() {
- // TODO figure out when I can skip this step
- if (entries.isEmpty()) {
- // Load the toolchain-spec'd collector
- defaultTarget = info.getDefaultTarget();
- if (defaultTarget == null) {
- // The build information has not been loaded yet
- return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
- }
- ITarget parent = defaultTarget.getParent();
- if (parent == null) {
- // The build information has not been loaded yet
- return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
- }
- // See if we can load a dynamic resolver
- String baseTargetId = parent.getId();
- IManagedScannerInfoCollector collector = ManagedBuildManager.getScannerInfoCollector(baseTargetId);
- if (collector != null) {
- collector.setProject(info.getOwner().getProject());
- calculateEntriesDynamically((IProject)info.getOwner(), collector);
- addIncludePaths(collector.getIncludePaths());
- addDefinedSymbols(collector.getDefinedSymbols());
+ info = (ManagedBuildInfo) ManagedBuildManager.getBuildInfo(project);
+
+ // Load the toolchain-spec'd collector
+ defaultTarget = info.getDefaultTarget();
+ if (defaultTarget == null) {
+ // The build information has not been loaded yet
+ return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
+ }
+ ITarget parent = defaultTarget.getParent();
+ if (parent == null) {
+ // The build information has not been loaded yet
+ ManagedBuildCPathEntryContainer.outputError(project.getName(), "Build information has not been loaded yet"); //$NON-NLS-1$
+ return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
+ }
+ // See if we can load a dynamic resolver
+ String baseTargetId = parent.getId();
+ IManagedScannerInfoCollector collector = ManagedBuildManager.getScannerInfoCollector(baseTargetId);
+ if (collector != null) {
+ ManagedBuildCPathEntryContainer.outputTrace(project.getName(), "Path entries collected dynamically"); //$NON-NLS-1$
+ collector.setProject(info.getOwner().getProject());
+ calculateEntriesDynamically((IProject)info.getOwner(), collector);
+ addIncludePaths(collector.getIncludePaths());
+ addDefinedSymbols(collector.getDefinedSymbols());
+ } else {
+ // If none supplied, use the built-ins
+ IConfiguration config = info.getDefaultConfiguration(defaultTarget);
+ if (config != null) {
+ calculateBuiltIns(defaultTarget, config);
+ ManagedBuildCPathEntryContainer.outputTrace(project.getName(), "Path entries set using built-in definitions from " + config.getName()); //$NON-NLS-1$
} else {
- // If none supplied, use the built-ins
- IConfiguration config = info.getDefaultConfiguration(defaultTarget);
- if (config != null) {
- calculateBuiltIns(defaultTarget, config);
- } else {
- return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
- }
+ ManagedBuildCPathEntryContainer.outputError(project.getName(), "Configuration is null"); //$NON-NLS-1$
+ return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
}
}
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildPathEntryContainerInitializer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildPathEntryContainerInitializer.java
new file mode 100644
index 00000000000..8b93c14ec07
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildPathEntryContainerInitializer.java
@@ -0,0 +1,40 @@
+/**********************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.managedbuilder.internal.scannerconfig;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.PathEntryContainerInitializer;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * @since 2.0
+ */
+public class ManagedBuildPathEntryContainerInitializer extends PathEntryContainerInitializer {
+
+ /**
+ * Need a zero-argument constructor to allow the system to create
+ * the intitializer
+ */
+ public ManagedBuildPathEntryContainerInitializer() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.model.PathEntryContainerInitializer#initialize(org.eclipse.core.runtime.IPath, org.eclipse.cdt.core.model.ICProject)
+ */
+ public void initialize(IPath containerPath, ICProject project) throws CoreException {
+ CoreModel.getDefault().setPathEntryContainer(new ICProject[]{project}, new ManagedBuildCPathEntryContainer(project.getProject()), null);
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java
index 6d5eaa05ff7..9e241caff00 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java
@@ -546,7 +546,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
IProject dep = refdProjects[i];
if (!dep.exists()) continue;
if (addDeps) {
- buffer.append("dependents:" + NEWLINE); //$NON-NLS-1
+ buffer.append("dependents:" + NEWLINE); //$NON-NLS-1$
addDeps = false;
}
String buildDir = dep.getLocation().toString();
@@ -1163,7 +1163,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
// Some echo implementations misbehave and put the -n and newline in the output
- if (firstLine.startsWith("-n")) {
+ if (firstLine.startsWith("-n")) { //$NON-NLS-1$
// Create a vector with all the strings
Vector tokens = new Vector(dependencies.length);
for (int index = 1; index < dependencies.length; ++index) {
@@ -1184,7 +1184,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
} catch (ArrayIndexOutOfBoundsException e) {
secondLine = new String();
}
- if (secondLine.startsWith("'")) {
+ if (secondLine.startsWith("'")) { //$NON-NLS-1$
// This is the Win32 implementation of echo (MinGW without MSYS)
outBuffer.append(secondLine.substring(1) + WHITESPACE);
} else {
@@ -1198,7 +1198,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
} catch (ArrayIndexOutOfBoundsException e) {
thirdLine = new String();
}
- int lastIndex = thirdLine.lastIndexOf("'");
+ int lastIndex = thirdLine.lastIndexOf("'"); //$NON-NLS-1$
if (lastIndex != -1) {
if (lastIndex == 0) {
outBuffer.append(WHITESPACE);
@@ -1223,7 +1223,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
Iterator iter = tokens.listIterator(3);
while (iter.hasNext()) {
String nextElement = (String)iter.next();
- if (nextElement.endsWith("\\")) {
+ if (nextElement.endsWith("\\")) { //$NON-NLS-1$
outBuffer.append(nextElement + NEWLINE + WHITESPACE);
} else {
outBuffer.append(nextElement + WHITESPACE);

Back to the top