mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-21 16:05: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.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IExtensionPoint;
|
import org.eclipse.core.runtime.IExtensionPoint;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
|
||||||
|
|
||||||
public class ManagedBuildCoreTests extends TestCase {
|
public class ManagedBuildCoreTests extends TestCase {
|
||||||
private static final boolean boolVal = true;
|
private static final boolean boolVal = true;
|
||||||
private static final String testConfigId = "test.config.override";
|
private static final String testConfigId = "test.config.override";
|
||||||
|
@ -165,6 +167,11 @@ public class ManagedBuildCoreTests extends TestCase {
|
||||||
IProject project = null;
|
IProject project = null;
|
||||||
try {
|
try {
|
||||||
project = createProject(projectName);
|
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) {
|
} catch (CoreException e) {
|
||||||
fail("Failed to open project in 'testMakeCommandManipulation': " + e.getLocalizedMessage());
|
fail("Failed to open project in 'testMakeCommandManipulation': " + e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
@ -204,12 +211,18 @@ public class ManagedBuildCoreTests extends TestCase {
|
||||||
IProject project = null;
|
IProject project = null;
|
||||||
try {
|
try {
|
||||||
project = createProject(projectName);
|
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) {
|
} catch (CoreException e) {
|
||||||
fail("Failed to open project in 'testScannerInfoInterface': " + e.getLocalizedMessage());
|
fail("Failed to open project in 'testScannerInfoInterface': " + e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
//These are the expected path settings
|
//These are the expected path settings
|
||||||
final String[] expectedPaths = new String[5];
|
final String[] expectedPaths = new String[5];
|
||||||
|
|
||||||
// This first path is a built-in, so it will not be manipulated by build manager
|
// This first path is a built-in, so it will not be manipulated by build manager
|
||||||
expectedPaths[0] = "/usr/gnu/include";
|
expectedPaths[0] = "/usr/gnu/include";
|
||||||
expectedPaths[1] = (new Path("/usr/include")).toOSString();
|
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());
|
fail("Failed adding new target to project: " + e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
assertNotNull(newTarget);
|
assertNotNull(newTarget);
|
||||||
|
|
||||||
// Copy over the configs
|
// Copy over the configs
|
||||||
IConfiguration[] baseConfigs = baseTarget.getConfigurations();
|
IConfiguration[] baseConfigs = baseTarget.getConfigurations();
|
||||||
for (int i = 0; i < baseConfigs.length; ++i) {
|
for (int i = 0; i < baseConfigs.length; ++i) {
|
||||||
newTarget.createConfiguration(baseConfigs[i], baseConfigs[i].getId() + "." + i);
|
newTarget.createConfiguration(baseConfigs[i], baseConfigs[i].getId() + "." + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the default configuration to the sub config
|
// Change the default configuration to the sub config
|
||||||
IConfiguration[] configs = newTarget.getConfigurations();
|
IConfiguration[] configs = newTarget.getConfigurations();
|
||||||
assertEquals(4, configs.length);
|
assertEquals(4, configs.length);
|
||||||
|
@ -251,15 +266,6 @@ public class ManagedBuildCoreTests extends TestCase {
|
||||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
|
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
|
||||||
assertNotNull(provider);
|
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
|
// Now subscribe (note that the method will be called after a change
|
||||||
provider.subscribe(project, new IScannerInfoChangeListener () {
|
provider.subscribe(project, new IScannerInfoChangeListener () {
|
||||||
public void changeNotification(IResource project, IScannerInfo info) {
|
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
|
// Add some defined symbols programmatically
|
||||||
String[] expectedSymbols = {"DEBUG", "GNOME = ME "};
|
String[] expectedSymbols = {"DEBUG", "GNOME = ME "};
|
||||||
IConfiguration defaultConfig = buildInfo.getDefaultConfiguration(newTarget);
|
IConfiguration defaultConfig = buildInfo.getDefaultConfiguration(newTarget);
|
||||||
|
@ -329,6 +345,11 @@ public class ManagedBuildCoreTests extends TestCase {
|
||||||
|
|
||||||
// Open the test project
|
// Open the test project
|
||||||
IProject project = createProject(projectName);
|
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
|
// Make sure there is one and only one target with 3 configs
|
||||||
ITarget[] definedTargets = ManagedBuildManager.getTargets(project);
|
ITarget[] definedTargets = ManagedBuildManager.getTargets(project);
|
||||||
|
@ -403,6 +424,11 @@ public class ManagedBuildCoreTests extends TestCase {
|
||||||
IProject project = null;
|
IProject project = null;
|
||||||
try {
|
try {
|
||||||
project = createProject(projectName);
|
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) {
|
} catch (CoreException e) {
|
||||||
fail("Failed to open project: " + e.getLocalizedMessage());
|
fail("Failed to open project: " + e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
@ -484,6 +510,14 @@ public class ManagedBuildCoreTests extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ManagedBuildManager.setDefaultConfiguration(project, defaultConfig);
|
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);
|
checkRootTarget(target);
|
||||||
|
|
||||||
// Override the "String Option in Category" option value
|
// Override the "String Option in Category" option value
|
||||||
|
@ -541,6 +575,11 @@ public class ManagedBuildCoreTests extends TestCase {
|
||||||
IProject project = null;
|
IProject project = null;
|
||||||
try {
|
try {
|
||||||
project = createProject(projectName);
|
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) {
|
} catch (CoreException e) {
|
||||||
fail("Failed to open project: " + e.getLocalizedMessage());
|
fail("Failed to open project: " + e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
@ -569,6 +608,11 @@ public class ManagedBuildCoreTests extends TestCase {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
project = createProject(projectRename);
|
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) {
|
} catch (CoreException e) {
|
||||||
fail("Failed to open renamed project: " + e.getLocalizedMessage());
|
fail("Failed to open renamed project: " + e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
@ -618,6 +662,11 @@ public class ManagedBuildCoreTests extends TestCase {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
project = createProject(projectName);
|
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) {
|
} catch (CoreException e) {
|
||||||
fail("Failed to open re-renamed project: " + e.getLocalizedMessage());
|
fail("Failed to open re-renamed project: " + e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
@ -643,6 +692,9 @@ public class ManagedBuildCoreTests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addManagedBuildNature (IProject project) {
|
private void addManagedBuildNature (IProject project) {
|
||||||
|
// Create the buildinformation object for the project
|
||||||
|
ManagedBuildManager.createBuildInfo(project);
|
||||||
|
|
||||||
// Add the managed build nature
|
// Add the managed build nature
|
||||||
try {
|
try {
|
||||||
ManagedCProjectNature.addManagedNature(project, new NullProgressMonitor());
|
ManagedCProjectNature.addManagedNature(project, new NullProgressMonitor());
|
||||||
|
@ -1316,10 +1368,10 @@ public class ManagedBuildCoreTests extends TestCase {
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
|
assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
fail("Test failed on error parser project creation: " + e.getLocalizedMessage());
|
fail("Test failed on error parser project creation: " + e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// There should not be any targets defined for this project yet
|
// There should not be any targets defined for this project yet
|
||||||
assertEquals(0, ManagedBuildManager.getTargets(project).length);
|
assertEquals(0, ManagedBuildManager.getTargets(project).length);
|
||||||
|
|
||||||
|
@ -1339,6 +1391,14 @@ public class ManagedBuildCoreTests extends TestCase {
|
||||||
ITarget target = targets[0];
|
ITarget target = targets[0];
|
||||||
assertEquals(target, newTarget);
|
assertEquals(target, newTarget);
|
||||||
assertFalse(target.equals(targetDef));
|
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);
|
checkErrorParsersTarget(target);
|
||||||
|
|
||||||
// Save, close, reopen and test again
|
// 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">
|
id="org.eclipse.cdt.managedbuilder.core.genmakebuilder">
|
||||||
</builder>
|
</builder>
|
||||||
</extension>
|
</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>
|
</plugin>
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -35,6 +36,8 @@ import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.AbstractCExtension;
|
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.IScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
|
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
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.IExtension;
|
||||||
import org.eclipse.core.runtime.IExtensionPoint;
|
import org.eclipse.core.runtime.IExtensionPoint;
|
||||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
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.Platform;
|
||||||
import org.eclipse.core.runtime.PluginVersionIdentifier;
|
import org.eclipse.core.runtime.PluginVersionIdentifier;
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
@ -345,16 +351,19 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
||||||
}
|
}
|
||||||
ListIterator iter = listeners.listIterator();
|
ListIterator iter = listeners.listIterator();
|
||||||
while (iter.hasNext()) {
|
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) {
|
public static void setNewProjectVersion(IProject newProject) {
|
||||||
// Get the build info for the argument
|
// Get the build info for the argument
|
||||||
ManagedBuildInfo info = findBuildInfo(newProject, false);
|
ManagedBuildInfo info = findBuildInfo(newProject);
|
||||||
info.setVersion(buildInfoVersion.toString());
|
info.setVersion(buildInfoVersion.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,7 +579,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
||||||
return parentTarget;
|
return parentTarget;
|
||||||
|
|
||||||
if (resource instanceof IProject) {
|
if (resource instanceof IProject) {
|
||||||
// Must be an extension target (why?)
|
// Must be an extension target
|
||||||
if (owner != null)
|
if (owner != null)
|
||||||
throw new BuildException(ManagedMakeMessages.getResourceString("ManagedBuildManager.error.owner_not_null")); //$NON-NLS-1$
|
throw new BuildException(ManagedMakeMessages.getResourceString("ManagedBuildManager.error.owner_not_null")); //$NON-NLS-1$
|
||||||
} else {
|
} else {
|
||||||
|
@ -585,6 +594,54 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
||||||
return new Target(resource, parentTarget);
|
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) {
|
private static boolean isVersionCompatible(IExtension extension) {
|
||||||
// We can ignore the qualifier
|
// We can ignore the qualifier
|
||||||
PluginVersionIdentifier version = null;
|
PluginVersionIdentifier version = null;
|
||||||
|
@ -619,6 +676,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
// So there is a project file, load the information there
|
||||||
try {
|
try {
|
||||||
InputStream stream = file.getContents();
|
InputStream stream = file.getContents();
|
||||||
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
|
@ -655,9 +713,9 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
||||||
project.setSessionProperty(buildInfoProperty, buildInfo);
|
project.setSessionProperty(buildInfoProperty, buildInfo);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
ManagedBuilderCorePlugin.log(e);
|
||||||
buildInfo = null;
|
buildInfo = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildInfo;
|
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(
|
private static IManagedConfigElementProvider createConfigProvider(
|
||||||
DefaultManagedConfigElement element) throws CoreException {
|
DefaultManagedConfigElement element) throws CoreException {
|
||||||
|
|
||||||
|
@ -774,7 +862,17 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
||||||
return false;
|
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
|
// I am sick of NPEs
|
||||||
if (resource == null) return null;
|
if (resource == null) return null;
|
||||||
|
|
||||||
|
@ -796,55 +894,40 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
||||||
buildInfo.updateOwner(resource);
|
buildInfo.updateOwner(resource);
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
ManagedBuilderCorePlugin.log(e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buildInfo == null && resource instanceof IProject) {
|
|
||||||
// Nothing in session store, so see if we can load it from cdtbuild
|
// Nothing in session store, so see if we can load it from cdtbuild
|
||||||
|
if (buildInfo == null && resource instanceof IProject) {
|
||||||
buildInfo = loadBuildInfo((IProject)resource);
|
buildInfo = loadBuildInfo((IProject)resource);
|
||||||
}
|
|
||||||
|
|
||||||
if (buildInfo == null && create) {
|
|
||||||
try {
|
try {
|
||||||
// Create a new build info object for the project
|
// Check if the project needs its container initialized
|
||||||
buildInfo = new ManagedBuildInfo(resource, true);
|
initBuildInfoContainer(buildInfo);
|
||||||
// Associate the build info with the project for the duration of the session
|
|
||||||
resource.setSessionProperty(buildInfoProperty, buildInfo);
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
return null;
|
// We can live without a path entry container if the build information is valid
|
||||||
|
ManagedBuilderCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildInfo;
|
return buildInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Answers the build information for the <code>IResource</code> in the
|
* Finds, but does not create, the managed build information for 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
|
|
||||||
* argument.
|
* argument.
|
||||||
*
|
*
|
||||||
* @see ManagedBuildManager#getBuildInfo(IResource, boolean)
|
* @see ManagedBuildManager#initBuildInfo(IResource)
|
||||||
* @param resource
|
* @param resource The resource to search for managed build information on.
|
||||||
* @return IManagedBuildInfo
|
* @return IManagedBuildInfo The build information object for the resource.
|
||||||
*/
|
*/
|
||||||
public static IManagedBuildInfo getBuildInfo(IResource 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() {
|
public static PluginVersionIdentifier getBuildInfoVersion() {
|
||||||
return buildInfoVersion;
|
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)
|
* @see org.eclipse.cdt.core.parser.IScannerInfoProvider#getScannerInformation(org.eclipse.core.resources.IResource)
|
||||||
*/
|
*/
|
||||||
public IScannerInfo getScannerInformation(IResource resource) {
|
public IScannerInfo getScannerInformation(IResource resource) {
|
||||||
return (IScannerInfo) getBuildInfo(resource.getProject(), false);
|
return (IScannerInfo) getBuildInfo(resource.getProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -13,11 +13,14 @@ package org.eclipse.cdt.managedbuilder.core;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Plugin;
|
import org.eclipse.core.runtime.Plugin;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
|
|
||||||
public class ManagedBuilderCorePlugin extends Plugin {
|
public class ManagedBuilderCorePlugin extends Plugin {
|
||||||
|
@ -71,4 +74,26 @@ public class ManagedBuilderCorePlugin extends Plugin {
|
||||||
ResourcesPlugin.getPlugin().getLog().log(status);
|
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.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
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.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
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.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.NodeList;
|
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 defaultConfigProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "defaultConfig"); //$NON-NLS-1$
|
||||||
private static final QualifiedName defaultTargetProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "defaultTarget"); //$NON-NLS-1$
|
private static final QualifiedName defaultTargetProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "defaultTarget"); //$NON-NLS-1$
|
||||||
// The path container used for all managed projects
|
// 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 String defaultConfigIds;
|
||||||
private Map defaultConfigMap;
|
private Map defaultConfigMap;
|
||||||
private ITarget defaultTarget;
|
private ITarget defaultTarget;
|
||||||
private String defaultTargetId;
|
private String defaultTargetId;
|
||||||
private ITarget selectedTarget;
|
|
||||||
private boolean isDirty;
|
private boolean isDirty;
|
||||||
private boolean rebuildNeeded;
|
|
||||||
private IResource owner;
|
private IResource owner;
|
||||||
|
private boolean rebuildNeeded;
|
||||||
|
private ITarget selectedTarget;
|
||||||
private Map targetMap;
|
private Map targetMap;
|
||||||
private List targetList;
|
private List targetList;
|
||||||
private String version;
|
private String version;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For compatability.
|
* Basic contructor used when the project is brand new.
|
||||||
*
|
*
|
||||||
* @param owner
|
* @param owner
|
||||||
*/
|
*/
|
||||||
public ManagedBuildInfo(IResource 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;
|
this.owner = owner;
|
||||||
cModelElement = CoreModel.getDefault().create(owner.getProject());
|
cProject = CoreModel.getDefault().create(owner.getProject());
|
||||||
|
|
||||||
try {
|
// The container for this project has never been created
|
||||||
IPathEntry[] entries = cModelElement.getRawPathEntries();
|
containerCreated = false;
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Does not need a save but should be rebuilt
|
// Does not need a save but should be rebuilt
|
||||||
isDirty = false;
|
isDirty = false;
|
||||||
|
@ -150,10 +108,6 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||||
// Again, hitting this error just means the default config is not set
|
// Again, hitting this error just means the default config is not set
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(intializeEntries) {
|
|
||||||
initializePathEntries();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,7 +118,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||||
* @param element
|
* @param element
|
||||||
*/
|
*/
|
||||||
public ManagedBuildInfo(IResource owner, Element 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
|
// Inflate the targets
|
||||||
NodeList targetNodes = element.getElementsByTagName(ITarget.TARGET_ELEMENT_NAME);
|
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));
|
new Target(this, (Element)targetNodes.item(targIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
initializePathEntries();
|
|
||||||
|
|
||||||
// Switch the rebuild off since this is an existing project
|
// Switch the rebuild off since this is an existing project
|
||||||
rebuildNeeded = false;
|
rebuildNeeded = false;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +196,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICProject getCProject() {
|
||||||
|
return cProject;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getCleanCommand()
|
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getCleanCommand()
|
||||||
|
@ -436,9 +392,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||||
private ArrayList getIncludePathEntries() {
|
private ArrayList getIncludePathEntries() {
|
||||||
// Extract the resolved paths from the project (if any)
|
// Extract the resolved paths from the project (if any)
|
||||||
ArrayList paths = new ArrayList();
|
ArrayList paths = new ArrayList();
|
||||||
if (cModelElement != null) {
|
if (cProject != null) {
|
||||||
try {
|
try {
|
||||||
IPathEntry[] entries = cModelElement.getResolvedPathEntries();
|
IPathEntry[] entries = cProject.getResolvedPathEntries();
|
||||||
for (int index = 0; index < entries.length; ++index) {
|
for (int index = 0; index < entries.length; ++index) {
|
||||||
int kind = entries[index].getEntryKind();
|
int kind = entries[index].getEntryKind();
|
||||||
if (kind == IPathEntry.CDT_INCLUDE) {
|
if (kind == IPathEntry.CDT_INCLUDE) {
|
||||||
|
@ -505,9 +461,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||||
|
|
||||||
private HashMap getMacroPathEntries() {
|
private HashMap getMacroPathEntries() {
|
||||||
HashMap macros = new HashMap();
|
HashMap macros = new HashMap();
|
||||||
if (cModelElement != null) {
|
if (cProject != null) {
|
||||||
try {
|
try {
|
||||||
IPathEntry[] entries = cModelElement.getResolvedPathEntries();
|
IPathEntry[] entries = cProject.getResolvedPathEntries();
|
||||||
for (int index = 0; index < entries.length; ++index) {
|
for (int index = 0; index < entries.length; ++index) {
|
||||||
if (entries[index].getEntryKind() == IPathEntry.CDT_MACRO) {
|
if (entries[index].getEntryKind() == IPathEntry.CDT_MACRO) {
|
||||||
IMacroEntry macro = (IMacroEntry) entries[index];
|
IMacroEntry macro = (IMacroEntry) entries[index];
|
||||||
|
@ -865,8 +821,8 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||||
*/
|
*/
|
||||||
private void initializePathEntries() {
|
private void initializePathEntries() {
|
||||||
try {
|
try {
|
||||||
IPathEntryContainer container = new ManagedBuildCPathEntryContainer(this);
|
IPathEntryContainer container = new ManagedBuildCPathEntryContainer(getOwner().getProject());
|
||||||
CoreModel.getDefault().setPathEntryContainer(new ICProject[]{cModelElement}, container, new NullProgressMonitor());
|
CoreModel.getDefault().setPathEntryContainer(new ICProject[]{cProject}, container, new NullProgressMonitor());
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
ManagedBuilderCorePlugin.log(e);
|
ManagedBuilderCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
@ -908,19 +864,23 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||||
setDirty(false);
|
setDirty(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setContainerCreated(boolean isCreated) {
|
||||||
|
containerCreated = isCreated;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setDefaultConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
|
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setDefaultConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
|
||||||
*/
|
*/
|
||||||
public void setDefaultConfiguration(IConfiguration configuration) {
|
public void setDefaultConfiguration(IConfiguration configuration) {
|
||||||
// Sanity
|
// Sanity
|
||||||
if (configuration== null) return;
|
if (configuration == null) return;
|
||||||
|
|
||||||
// Get the target associated with the argument
|
// Get the target associated with the argument
|
||||||
ITarget target = configuration.getTarget();
|
ITarget target = configuration.getTarget();
|
||||||
|
|
||||||
// See if there is anything to be done
|
// See if there is anything to be done
|
||||||
IConfiguration oldDefault = getDefaultConfiguration(target);
|
IConfiguration oldDefault = getDefaultConfiguration(target);
|
||||||
if (!configuration.equals(oldDefault)) {
|
if (defaultTarget == null || !configuration.equals(oldDefault)) {
|
||||||
// Make sure it is the default
|
// Make sure it is the default
|
||||||
setDefaultTarget(target);
|
setDefaultTarget(target);
|
||||||
// Make the argument the
|
// Make the argument the
|
||||||
|
@ -960,9 +920,11 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||||
defaultTarget = target;
|
defaultTarget = target;
|
||||||
defaultTargetId = target.getId();
|
defaultTargetId = target.getId();
|
||||||
persistDefaultTarget();
|
persistDefaultTarget();
|
||||||
|
if (containerCreated) {
|
||||||
initializePathEntries();
|
initializePathEntries();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setSelectedTarget(org.eclipse.cdt.core.build.managed.ITarget)
|
* @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);
|
target.updateOwner(resource);
|
||||||
}
|
}
|
||||||
// And finally update the cModelElement
|
// And finally update the cModelElement
|
||||||
cModelElement = CoreModel.getDefault().create(owner.getProject());
|
cProject = 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();
|
|
||||||
|
|
||||||
// Save everything
|
// Save everything
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
|
setRebuildState(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class Target extends BuildObject implements ITarget {
|
||||||
this.cleanCommand = parent.getCleanCommand();
|
this.cleanCommand = parent.getCleanCommand();
|
||||||
|
|
||||||
// Hook me up
|
// Hook me up
|
||||||
IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner, true);
|
IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner);
|
||||||
buildInfo.addTarget(this);
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Common Public License v1.0
|
* are made available under the terms of the Common Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -19,7 +19,6 @@ import java.util.Map;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
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.IMacroEntry;
|
||||||
import org.eclipse.cdt.core.model.IPathEntry;
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.core.model.IPathEntryContainer;
|
import org.eclipse.cdt.core.model.IPathEntryContainer;
|
||||||
|
@ -52,21 +51,34 @@ import org.eclipse.core.runtime.Platform;
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
||||||
|
|
||||||
private static final String BUILDER_ID = MakeCorePlugin.getUniqueIdentifier() + ".ScannerConfigBuilder"; //$NON-NLS-1$
|
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 ITarget defaultTarget;
|
||||||
private Vector entries;
|
private Vector entries;
|
||||||
|
private IProject project;
|
||||||
private ManagedBuildInfo info;
|
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.
|
* Creates a new path container for the managed buildd project.
|
||||||
*
|
*
|
||||||
* @param info the build information associated with the project
|
* @param info the build information associated with the project
|
||||||
*/
|
*/
|
||||||
public ManagedBuildCPathEntryContainer(ManagedBuildInfo info) {
|
public ManagedBuildCPathEntryContainer(IProject project) {
|
||||||
super();
|
super();
|
||||||
this.info = info;
|
this.project = project;
|
||||||
defaultTarget = info.getDefaultTarget();
|
|
||||||
entries = new Vector();
|
entries = new Vector();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +103,7 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (add) {
|
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
|
// A little checking is needed to avoid adding duplicates
|
||||||
Iterator pathIter = paths.listIterator();
|
Iterator pathIter = paths.listIterator();
|
||||||
while (pathIter.hasNext()) {
|
while (pathIter.hasNext()) {
|
||||||
boolean add = true;
|
|
||||||
String path = (String) pathIter.next();
|
String path = (String) pathIter.next();
|
||||||
// Make sure there is no other path with the same value
|
IPathEntry entry = CoreModel.newIncludeEntry(Path.EMPTY, Path.EMPTY, new Path(path), true);
|
||||||
Iterator entryIter = entries.listIterator();
|
if (!entries.contains(entry)) {
|
||||||
while (entryIter.hasNext()) {
|
entries.add(entry);
|
||||||
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$
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void calculateBuiltIns(ITarget defaultTarget, IConfiguration config) {
|
protected void calculateBuiltIns(ITarget defaultTarget, IConfiguration config) {
|
||||||
ITool[] tools = config.getFilteredTools(info.getOwner().getProject());
|
ITool[] tools = config.getFilteredTools(info.getOwner().getProject());
|
||||||
|
@ -190,8 +190,8 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
||||||
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getPathEntries()
|
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getPathEntries()
|
||||||
*/
|
*/
|
||||||
public IPathEntry[] getPathEntries() {
|
public IPathEntry[] getPathEntries() {
|
||||||
// TODO figure out when I can skip this step
|
info = (ManagedBuildInfo) ManagedBuildManager.getBuildInfo(project);
|
||||||
if (entries.isEmpty()) {
|
|
||||||
// Load the toolchain-spec'd collector
|
// Load the toolchain-spec'd collector
|
||||||
defaultTarget = info.getDefaultTarget();
|
defaultTarget = info.getDefaultTarget();
|
||||||
if (defaultTarget == null) {
|
if (defaultTarget == null) {
|
||||||
|
@ -201,12 +201,14 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
||||||
ITarget parent = defaultTarget.getParent();
|
ITarget parent = defaultTarget.getParent();
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
// The build information has not been loaded yet
|
// 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()]);
|
return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
|
||||||
}
|
}
|
||||||
// See if we can load a dynamic resolver
|
// See if we can load a dynamic resolver
|
||||||
String baseTargetId = parent.getId();
|
String baseTargetId = parent.getId();
|
||||||
IManagedScannerInfoCollector collector = ManagedBuildManager.getScannerInfoCollector(baseTargetId);
|
IManagedScannerInfoCollector collector = ManagedBuildManager.getScannerInfoCollector(baseTargetId);
|
||||||
if (collector != null) {
|
if (collector != null) {
|
||||||
|
ManagedBuildCPathEntryContainer.outputTrace(project.getName(), "Path entries collected dynamically"); //$NON-NLS-1$
|
||||||
collector.setProject(info.getOwner().getProject());
|
collector.setProject(info.getOwner().getProject());
|
||||||
calculateEntriesDynamically((IProject)info.getOwner(), collector);
|
calculateEntriesDynamically((IProject)info.getOwner(), collector);
|
||||||
addIncludePaths(collector.getIncludePaths());
|
addIncludePaths(collector.getIncludePaths());
|
||||||
|
@ -216,11 +218,12 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
||||||
IConfiguration config = info.getDefaultConfiguration(defaultTarget);
|
IConfiguration config = info.getDefaultConfiguration(defaultTarget);
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
calculateBuiltIns(defaultTarget, config);
|
calculateBuiltIns(defaultTarget, config);
|
||||||
|
ManagedBuildCPathEntryContainer.outputTrace(project.getName(), "Path entries set using built-in definitions from " + config.getName()); //$NON-NLS-1$
|
||||||
} else {
|
} 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()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
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];
|
IProject dep = refdProjects[i];
|
||||||
if (!dep.exists()) continue;
|
if (!dep.exists()) continue;
|
||||||
if (addDeps) {
|
if (addDeps) {
|
||||||
buffer.append("dependents:" + NEWLINE); //$NON-NLS-1
|
buffer.append("dependents:" + NEWLINE); //$NON-NLS-1$
|
||||||
addDeps = false;
|
addDeps = false;
|
||||||
}
|
}
|
||||||
String buildDir = dep.getLocation().toString();
|
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
|
// 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
|
// Create a vector with all the strings
|
||||||
Vector tokens = new Vector(dependencies.length);
|
Vector tokens = new Vector(dependencies.length);
|
||||||
for (int index = 1; index < dependencies.length; ++index) {
|
for (int index = 1; index < dependencies.length; ++index) {
|
||||||
|
@ -1184,7 +1184,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
secondLine = new String();
|
secondLine = new String();
|
||||||
}
|
}
|
||||||
if (secondLine.startsWith("'")) {
|
if (secondLine.startsWith("'")) { //$NON-NLS-1$
|
||||||
// This is the Win32 implementation of echo (MinGW without MSYS)
|
// This is the Win32 implementation of echo (MinGW without MSYS)
|
||||||
outBuffer.append(secondLine.substring(1) + WHITESPACE);
|
outBuffer.append(secondLine.substring(1) + WHITESPACE);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1198,7 +1198,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
thirdLine = new String();
|
thirdLine = new String();
|
||||||
}
|
}
|
||||||
int lastIndex = thirdLine.lastIndexOf("'");
|
int lastIndex = thirdLine.lastIndexOf("'"); //$NON-NLS-1$
|
||||||
if (lastIndex != -1) {
|
if (lastIndex != -1) {
|
||||||
if (lastIndex == 0) {
|
if (lastIndex == 0) {
|
||||||
outBuffer.append(WHITESPACE);
|
outBuffer.append(WHITESPACE);
|
||||||
|
@ -1223,7 +1223,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
||||||
Iterator iter = tokens.listIterator(3);
|
Iterator iter = tokens.listIterator(3);
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
String nextElement = (String)iter.next();
|
String nextElement = (String)iter.next();
|
||||||
if (nextElement.endsWith("\\")) {
|
if (nextElement.endsWith("\\")) { //$NON-NLS-1$
|
||||||
outBuffer.append(nextElement + NEWLINE + WHITESPACE);
|
outBuffer.append(nextElement + NEWLINE + WHITESPACE);
|
||||||
} else {
|
} else {
|
||||||
outBuffer.append(nextElement + WHITESPACE);
|
outBuffer.append(nextElement + WHITESPACE);
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class ErrorParserBlock extends AbstractErrorParserBlock {
|
||||||
// page before the "C/C++ Build" page.
|
// page before the "C/C++ Build" page.
|
||||||
|
|
||||||
// Get the build information
|
// Get the build information
|
||||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project, true);
|
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
||||||
target = info.getDefaultTarget();
|
target = info.getDefaultTarget();
|
||||||
}
|
}
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class ManagedBuilderUIImages {
|
||||||
// Subdirectory (under the package containing this class) where 16 color images are
|
// Subdirectory (under the package containing this class) where 16 color images are
|
||||||
private static URL iconBaseURL = null;
|
private static URL iconBaseURL = null;
|
||||||
static {
|
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() + '.';
|
private static final String NAME_PREFIX= ManagedBuilderUIPlugin.getUniqueIdentifier() + '.';
|
||||||
|
|
|
@ -173,7 +173,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
|
||||||
GridData gd;
|
GridData gd;
|
||||||
|
|
||||||
// Initialize the key data
|
// Initialize the key data
|
||||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject(), true);
|
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
|
||||||
if (info.getVersion() == null) {
|
if (info.getVersion() == null) {
|
||||||
// Display a message page instead of the properties control
|
// Display a message page instead of the properties control
|
||||||
final Label invalidInfo = new Label(composite, SWT.LEFT);
|
final Label invalidInfo = new Label(composite, SWT.LEFT);
|
||||||
|
|
|
@ -141,7 +141,7 @@ public class ManagedBuilderPropertyPage extends PropertyPage implements ICOption
|
||||||
IProject project = getProject();
|
IProject project = getProject();
|
||||||
ITarget target = ManagedBuildManager.getSelectedTarget(project);
|
ITarget target = ManagedBuildManager.getSelectedTarget(project);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project, true);
|
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
||||||
target = info.getDefaultTarget();
|
target = info.getDefaultTarget();
|
||||||
ManagedBuildManager.setSelectedTarget(project, target);
|
ManagedBuildManager.setSelectedTarget(project, target);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,9 @@ public class NewManagedCProjectWizard extends NewManagedProjectWizard {
|
||||||
super(title, description);
|
super(title, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.wizard.IWizard#addPages()
|
||||||
|
*/
|
||||||
public void addPages() {
|
public void addPages() {
|
||||||
// Add the default page for all new managed projects
|
// Add the default page for all new managed projects
|
||||||
super.addPages();
|
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.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
|
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
|
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.cdt.ui.wizards.NewCProjectWizard;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
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() just creates the project and does not assign a builder to it.
|
||||||
super.doRun(new SubProgressMonitor(monitor, 5));
|
super.doRun(new SubProgressMonitor(monitor, 5));
|
||||||
|
|
||||||
// Add the managed build nature
|
// Add the managed build nature and builder
|
||||||
|
ICDescriptor desc = null;
|
||||||
try {
|
try {
|
||||||
monitor.subTask(ManagedBuilderUIMessages.getResourceString(MSG_ADD_NATURE));
|
monitor.subTask(ManagedBuilderUIMessages.getResourceString(MSG_ADD_NATURE));
|
||||||
ManagedCProjectNature.addManagedNature(newProject, new SubProgressMonitor(monitor, 1));
|
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));
|
monitor.subTask(ManagedBuilderUIMessages.getResourceString(MSG_ADD_BUILDER));
|
||||||
ManagedCProjectNature.addManagedBuilder(newProject, new SubProgressMonitor(monitor, 1));
|
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) {
|
} catch (CoreException e) {
|
||||||
// Bail out of the project creation
|
ManagedBuilderUIPlugin.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the target to the project
|
// Add the target to the project
|
||||||
ITarget newTarget = null;
|
ITarget newTarget = null;
|
||||||
try {
|
try {
|
||||||
|
ManagedBuildManager.createBuildInfo(newProject);
|
||||||
ITarget parent = targetConfigurationPage.getSelectedTarget();
|
ITarget parent = targetConfigurationPage.getSelectedTarget();
|
||||||
newTarget = ManagedBuildManager.createTarget(newProject, parent);
|
newTarget = ManagedBuildManager.createTarget(newProject, parent);
|
||||||
if (newTarget != null) {
|
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();
|
String artifactName = newProject.getName();
|
||||||
newTarget.setArtifactName(artifactName);
|
newTarget.setArtifactName(artifactName);
|
||||||
IConfiguration [] selectedConfigs = targetConfigurationPage.getSelectedConfigurations();
|
IConfiguration [] selectedConfigs = targetConfigurationPage.getSelectedConfigurations();
|
||||||
|
@ -132,20 +141,7 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
|
||||||
ManagedBuildManager.setNewProjectVersion(newProject);
|
ManagedBuildManager.setNewProjectVersion(newProject);
|
||||||
}
|
}
|
||||||
} catch (BuildException e) {
|
} catch (BuildException e) {
|
||||||
// TODO Flag the error to the user
|
ManagedBuilderUIPlugin.log(e);
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modify the project settings
|
// 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)
|
* @see org.eclipse.cdt.ui.wizards.NewCProjectWizard#doRunEpilogue(org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
protected void doRunEpilogue(IProgressMonitor monitor) {
|
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)
|
/* (non-Javadoc)
|
||||||
|
|
Loading…
Add table
Reference in a new issue