mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-22 00:15:25 +02:00
Fix fog bug 64952 -- Indexer being called when it doesn't need to run
This commit is contained in:
parent
a9c11b6167
commit
5f5b6bc0d7
16 changed files with 392 additions and 211 deletions
|
@ -57,10 +57,12 @@ import org.eclipse.core.resources.IWorkspaceRoot;
|
|||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
|
||||
public class ManagedBuildCoreTests extends TestCase {
|
||||
private static final boolean boolVal = true;
|
||||
private static final String testConfigId = "test.config.override";
|
||||
|
@ -165,6 +167,11 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
IProject project = null;
|
||||
try {
|
||||
project = createProject(projectName);
|
||||
IProjectDescription description = project.getDescription();
|
||||
// Make sure it has a managed nature
|
||||
if (description != null) {
|
||||
assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
fail("Failed to open project in 'testMakeCommandManipulation': " + e.getLocalizedMessage());
|
||||
}
|
||||
|
@ -204,12 +211,18 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
IProject project = null;
|
||||
try {
|
||||
project = createProject(projectName);
|
||||
IProjectDescription description = project.getDescription();
|
||||
// Make sure it has a managed nature
|
||||
if (description != null) {
|
||||
assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
fail("Failed to open project in 'testScannerInfoInterface': " + e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
//These are the expected path settings
|
||||
final String[] expectedPaths = new String[5];
|
||||
|
||||
// This first path is a built-in, so it will not be manipulated by build manager
|
||||
expectedPaths[0] = "/usr/gnu/include";
|
||||
expectedPaths[1] = (new Path("/usr/include")).toOSString();
|
||||
|
@ -227,11 +240,13 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
fail("Failed adding new target to project: " + e.getLocalizedMessage());
|
||||
}
|
||||
assertNotNull(newTarget);
|
||||
|
||||
// Copy over the configs
|
||||
IConfiguration[] baseConfigs = baseTarget.getConfigurations();
|
||||
for (int i = 0; i < baseConfigs.length; ++i) {
|
||||
newTarget.createConfiguration(baseConfigs[i], baseConfigs[i].getId() + "." + i);
|
||||
}
|
||||
|
||||
// Change the default configuration to the sub config
|
||||
IConfiguration[] configs = newTarget.getConfigurations();
|
||||
assertEquals(4, configs.length);
|
||||
|
@ -251,15 +266,6 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
|
||||
assertNotNull(provider);
|
||||
|
||||
// Check the build information right away
|
||||
IScannerInfo currentSettings = provider.getScannerInformation(project);
|
||||
Map currentSymbols = currentSettings.getDefinedSymbols();
|
||||
// It should simply contain the built-in
|
||||
assertTrue(currentSymbols.containsKey("BUILTIN"));
|
||||
assertEquals((String)currentSymbols.get("BUILTIN"), "");
|
||||
String[] currentPaths = currentSettings.getIncludePaths();
|
||||
assertTrue(Arrays.equals(expectedPaths, currentPaths));
|
||||
|
||||
// Now subscribe (note that the method will be called after a change
|
||||
provider.subscribe(project, new IScannerInfoChangeListener () {
|
||||
public void changeNotification(IResource project, IScannerInfo info) {
|
||||
|
@ -279,6 +285,16 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
}
|
||||
});
|
||||
|
||||
// Check the build information before we change it
|
||||
IScannerInfo currentSettings = provider.getScannerInformation(project);
|
||||
|
||||
Map currentSymbols = currentSettings.getDefinedSymbols();
|
||||
// It should simply contain the built-in
|
||||
assertTrue(currentSymbols.containsKey("BUILTIN"));
|
||||
assertEquals((String)currentSymbols.get("BUILTIN"), "");
|
||||
String[] currentPaths = currentSettings.getIncludePaths();
|
||||
assertTrue(Arrays.equals(expectedPaths, currentPaths));
|
||||
|
||||
// Add some defined symbols programmatically
|
||||
String[] expectedSymbols = {"DEBUG", "GNOME = ME "};
|
||||
IConfiguration defaultConfig = buildInfo.getDefaultConfiguration(newTarget);
|
||||
|
@ -329,6 +345,11 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
|
||||
// Open the test project
|
||||
IProject project = createProject(projectName);
|
||||
IProjectDescription description = project.getDescription();
|
||||
// Make sure it has a managed nature
|
||||
if (description != null) {
|
||||
assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
|
||||
}
|
||||
|
||||
// Make sure there is one and only one target with 3 configs
|
||||
ITarget[] definedTargets = ManagedBuildManager.getTargets(project);
|
||||
|
@ -403,6 +424,11 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
IProject project = null;
|
||||
try {
|
||||
project = createProject(projectName);
|
||||
IProjectDescription description = project.getDescription();
|
||||
// Make sure it has a managed nature
|
||||
if (description != null) {
|
||||
assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
fail("Failed to open project: " + e.getLocalizedMessage());
|
||||
}
|
||||
|
@ -484,6 +510,14 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
}
|
||||
}
|
||||
ManagedBuildManager.setDefaultConfiguration(project, defaultConfig);
|
||||
|
||||
// Initialize the path entry container
|
||||
IStatus initResult = ManagedBuildManager.initBuildInfoContainer(project);
|
||||
if (initResult.getCode() != IStatus.OK) {
|
||||
fail("Initializing build information failed for: " + project.getName() + " because: " + initResult.getMessage());
|
||||
}
|
||||
|
||||
// Now test the results out
|
||||
checkRootTarget(target);
|
||||
|
||||
// Override the "String Option in Category" option value
|
||||
|
@ -541,6 +575,11 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
IProject project = null;
|
||||
try {
|
||||
project = createProject(projectName);
|
||||
IProjectDescription description = project.getDescription();
|
||||
// Make sure it has a managed nature
|
||||
if (description != null) {
|
||||
assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
fail("Failed to open project: " + e.getLocalizedMessage());
|
||||
}
|
||||
|
@ -569,6 +608,11 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
}
|
||||
try {
|
||||
project = createProject(projectRename);
|
||||
description = project.getDescription();
|
||||
// Make sure it has a managed nature
|
||||
if (description != null) {
|
||||
assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
fail("Failed to open renamed project: " + e.getLocalizedMessage());
|
||||
}
|
||||
|
@ -618,6 +662,11 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
}
|
||||
try {
|
||||
project = createProject(projectName);
|
||||
description = project.getDescription();
|
||||
// Make sure it has a managed nature
|
||||
if (description != null) {
|
||||
assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
fail("Failed to open re-renamed project: " + e.getLocalizedMessage());
|
||||
}
|
||||
|
@ -643,6 +692,9 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
}
|
||||
|
||||
private void addManagedBuildNature (IProject project) {
|
||||
// Create the buildinformation object for the project
|
||||
ManagedBuildManager.createBuildInfo(project);
|
||||
|
||||
// Add the managed build nature
|
||||
try {
|
||||
ManagedCProjectNature.addManagedNature(project, new NullProgressMonitor());
|
||||
|
@ -1316,10 +1368,10 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
if (description != null) {
|
||||
assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
|
||||
}
|
||||
|
||||
} catch (CoreException e) {
|
||||
fail("Test failed on error parser project creation: " + e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
// There should not be any targets defined for this project yet
|
||||
assertEquals(0, ManagedBuildManager.getTargets(project).length);
|
||||
|
||||
|
@ -1339,6 +1391,14 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
ITarget target = targets[0];
|
||||
assertEquals(target, newTarget);
|
||||
assertFalse(target.equals(targetDef));
|
||||
|
||||
// Initialize the path entry container
|
||||
IStatus initResult = ManagedBuildManager.initBuildInfoContainer(project);
|
||||
if (initResult.getCode() != IStatus.OK) {
|
||||
fail("Initializing build information failed for: " + project.getName() + " because: " + initResult.getMessage());
|
||||
}
|
||||
|
||||
// Test this out
|
||||
checkErrorParsersTarget(target);
|
||||
|
||||
// Save, close, reopen and test again
|
||||
|
@ -1456,3 +1516,4 @@ public class ManagedBuildCoreTests extends TestCase {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
4
build/org.eclipse.cdt.managedbuilder.core/.options
Normal file
4
build/org.eclipse.cdt.managedbuilder.core/.options
Normal file
|
@ -0,0 +1,4 @@
|
|||
org.eclipse.cdt.managedbuilder.core/debug=true
|
||||
|
||||
# Reports path entry container activity
|
||||
org.eclipse.cdt.managedbuilder.core/debug/pathEntry=false
|
|
@ -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>
|
||||
|
|
|
@ -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);
|
||||
* // 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;
|
||||
}
|
||||
|
||||
if (buildInfo == null && resource instanceof IProject) {
|
||||
// Nothing in session store, so see if we can load it from cdtbuild
|
||||
if (buildInfo == null && resource instanceof IProject) {
|
||||
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)
|
||||
|
|
|
@ -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$
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
/**
|
||||
* 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());
|
||||
cProject = 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);
|
||||
}
|
||||
|
||||
};
|
||||
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,7 +118,9 @@ 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);
|
||||
|
@ -172,8 +128,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
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,9 +920,11 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
|||
defaultTarget = target;
|
||||
defaultTargetId = target.getId();
|
||||
persistDefaultTarget();
|
||||
if (containerCreated) {
|
||||
initializePathEntries();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setSelectedTarget(org.eclipse.cdt.core.build.managed.ITarget)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,25 +113,13 @@ 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;
|
||||
IPathEntry entry = CoreModel.newIncludeEntry(Path.EMPTY, Path.EMPTY, new Path(path), true);
|
||||
if (!entries.contains(entry)) {
|
||||
entries.add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (add) {
|
||||
entries.add(CoreModel.newIncludeEntry(new Path(""), null, new Path(path), true)); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void calculateBuiltIns(ITarget defaultTarget, IConfiguration config) {
|
||||
ITool[] tools = config.getFilteredTools(info.getOwner().getProject());
|
||||
|
@ -190,8 +190,8 @@ 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()) {
|
||||
info = (ManagedBuildInfo) ManagedBuildManager.getBuildInfo(project);
|
||||
|
||||
// Load the toolchain-spec'd collector
|
||||
defaultTarget = info.getDefaultTarget();
|
||||
if (defaultTarget == null) {
|
||||
|
@ -201,12 +201,14 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
|||
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());
|
||||
|
@ -216,11 +218,12 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
|||
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 {
|
||||
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()]);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -48,7 +48,7 @@ public class ErrorParserBlock extends AbstractErrorParserBlock {
|
|||
// page before the "C/C++ Build" page.
|
||||
|
||||
// Get the build information
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project, true);
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
||||
target = info.getDefaultTarget();
|
||||
}
|
||||
if (target != null) {
|
||||
|
|
|
@ -31,7 +31,7 @@ public class ManagedBuilderUIImages {
|
|||
// Subdirectory (under the package containing this class) where 16 color images are
|
||||
private static URL iconBaseURL = null;
|
||||
static {
|
||||
iconBaseURL = Platform.getBundle(ManagedBuilderUIPlugin.getUniqueIdentifier()).getEntry("icons/");
|
||||
iconBaseURL = Platform.getBundle(ManagedBuilderUIPlugin.getUniqueIdentifier()).getEntry("icons/"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private static final String NAME_PREFIX= ManagedBuilderUIPlugin.getUniqueIdentifier() + '.';
|
||||
|
|
|
@ -173,7 +173,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
|||
GridData gd;
|
||||
|
||||
// Initialize the key data
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject(), true);
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
|
||||
if (info.getVersion() == null) {
|
||||
// Display a message page instead of the properties control
|
||||
final Label invalidInfo = new Label(composite, SWT.LEFT);
|
||||
|
|
|
@ -141,7 +141,7 @@ public class ManagedBuilderPropertyPage extends PropertyPage implements ICOption
|
|||
IProject project = getProject();
|
||||
ITarget target = ManagedBuildManager.getSelectedTarget(project);
|
||||
if (target == null) {
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project, true);
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
||||
target = info.getDefaultTarget();
|
||||
ManagedBuildManager.setSelectedTarget(project, target);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@ public class NewManagedCProjectWizard extends NewManagedProjectWizard {
|
|||
super(title, description);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.wizard.IWizard#addPages()
|
||||
*/
|
||||
public void addPages() {
|
||||
// Add the default page for all new managed projects
|
||||
super.addPages();
|
||||
|
|
|
@ -21,9 +21,11 @@ import org.eclipse.cdt.managedbuilder.core.ITarget;
|
|||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
|
||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
|
||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
|
||||
import org.eclipse.cdt.ui.wizards.NewCProjectWizard;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
|
||||
|
@ -89,27 +91,34 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
|
|||
// super.doRun() just creates the project and does not assign a builder to it.
|
||||
super.doRun(new SubProgressMonitor(monitor, 5));
|
||||
|
||||
// Add the managed build nature
|
||||
// Add the managed build nature and builder
|
||||
ICDescriptor desc = null;
|
||||
try {
|
||||
monitor.subTask(ManagedBuilderUIMessages.getResourceString(MSG_ADD_NATURE));
|
||||
ManagedCProjectNature.addManagedNature(newProject, new SubProgressMonitor(monitor, 1));
|
||||
} catch (CoreException e) {
|
||||
// Bail out of the project creation
|
||||
}
|
||||
// Add the builder
|
||||
try {
|
||||
monitor.subTask(ManagedBuilderUIMessages.getResourceString(MSG_ADD_BUILDER));
|
||||
ManagedCProjectNature.addManagedBuilder(newProject, new SubProgressMonitor(monitor, 1));
|
||||
desc = CCorePlugin.getDefault().getCProjectDescription(newProject);
|
||||
desc.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
|
||||
desc.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, ManagedBuildManager.INTERFACE_IDENTITY);
|
||||
desc.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
||||
} catch (CoreException e) {
|
||||
// Bail out of the project creation
|
||||
ManagedBuilderUIPlugin.log(e);
|
||||
}
|
||||
|
||||
// Add the target to the project
|
||||
ITarget newTarget = null;
|
||||
try {
|
||||
ManagedBuildManager.createBuildInfo(newProject);
|
||||
ITarget parent = targetConfigurationPage.getSelectedTarget();
|
||||
newTarget = ManagedBuildManager.createTarget(newProject, parent);
|
||||
if (newTarget != null) {
|
||||
try {
|
||||
// org.eclipse.cdt.core.ELF or org.eclipse.cdt.core.PE
|
||||
desc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, newTarget.getBinaryParserId());
|
||||
} catch (CoreException e) {
|
||||
ManagedBuilderUIPlugin.log(e);
|
||||
}
|
||||
String artifactName = newProject.getName();
|
||||
newTarget.setArtifactName(artifactName);
|
||||
IConfiguration [] selectedConfigs = targetConfigurationPage.getSelectedConfigurations();
|
||||
|
@ -132,20 +141,7 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
|
|||
ManagedBuildManager.setNewProjectVersion(newProject);
|
||||
}
|
||||
} catch (BuildException e) {
|
||||
// TODO Flag the error to the user
|
||||
}
|
||||
|
||||
// Associate the project with the managed builder so the clients can get proper information
|
||||
try {
|
||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(newProject);
|
||||
desc.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
|
||||
desc.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, ManagedBuildManager.INTERFACE_IDENTITY);
|
||||
|
||||
desc.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
||||
// org.eclipse.cdt.core.ELF or org.eclipse.cdt.core.PE
|
||||
desc.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, newTarget.getBinaryParserId());
|
||||
} catch (CoreException e) {
|
||||
// TODO Flag the error to the user
|
||||
ManagedBuilderUIPlugin.log(e);
|
||||
}
|
||||
|
||||
// Modify the project settings
|
||||
|
@ -171,8 +167,12 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
|
|||
* @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunEpilogue(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
protected void doRunEpilogue(IProgressMonitor monitor) {
|
||||
// Auto-generated method stub
|
||||
|
||||
// Get my initializer to run
|
||||
IStatus initResult = ManagedBuildManager.initBuildInfoContainer(newProject);
|
||||
if (initResult.getCode() != IStatus.OK) {
|
||||
// At this point, I can live with a failure
|
||||
ManagedBuilderUIPlugin.log(initResult);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
Loading…
Add table
Reference in a new issue