[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Bugzilla #91308, #102773 MBS fix
|
Title: Bugzilla #91308, #102773 MBS fix
<<mbcoretests_binfotests1.txt>> <<mbcore_binfo1.txt>>
Attached are two patches which fix bugzilla entries #91308 and #102773.
One patch is for org.eclipse.cdt.managedbuilder.core.
The other patch is for org.eclipse.cdt.managedbuilder.core.tests, which
required a change because the bugfix exposed a problem in a test, which
is now resolved.
Bob
Index: tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildMacrosTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildMacrosTests.java,v
retrieving revision 1.3
diff -u -r1.3 ManagedBuildMacrosTests.java
--- tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildMacrosTests.java 20 Jun 2005 20:52:14 -0000 1.3
+++ tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildMacrosTests.java 8 Jul 2005 20:11:05 -0000
@@ -648,6 +648,9 @@
assertTrue(addMacro(TO_SAVE_W, IBuildMacro.VALUE_TEXT, TO_SAVE_W,
IBuildMacroProvider.CONTEXT_WORKSPACE, worksp));
try {
+ // Save the buildinfo, and then remove it, to be complete
+ ManagedBuildManager.saveBuildInfo(proj, true);
+ ManagedBuildManager.removeBuildInfo(proj);
proj.close(null);
proj.open(null);
} catch (CoreException e) {
Index: src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java,v
retrieving revision 1.52
diff -u -r1.52 ManagedBuildManager.java
--- src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java 6 Jul 2005 17:56:13 -0000 1.52
+++ src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java 8 Jul 2005 20:10:25 -0000
@@ -116,6 +116,7 @@
private static final String VERSION_ELEMENT_NAME = "fileVersion"; //$NON-NLS-1$
private static final String MANIFEST_VERSION_ERROR ="ManagedBuildManager.error.manifest.version.error"; //$NON-NLS-1$
private static final String PROJECT_VERSION_ERROR ="ManagedBuildManager.error.project.version.error"; //$NON-NLS-1$
+ private static final String PROJECT_FILE_ERROR = "ManagedBuildManager.error.project.file.missing"; //$NON-NLS-1$
private static final String MANIFEST_ERROR_HEADER = "ManagedBuildManager.error.manifest.header"; //$NON-NLS-1$
public static final String MANIFEST_ERROR_RESOLVING = "ManagedBuildManager.error.manifest.resolving"; //$NON-NLS-1$
public static final String MANIFEST_ERROR_DUPLICATE = "ManagedBuildManager.error.manifest.duplicate"; //$NON-NLS-1$
@@ -1464,6 +1465,18 @@
}
/* (non-Javadoc)
+ * Determine if the .cdtbuild file is present, which will determine if build information
+ * can be loaded externally or not. Return true if present, false otherwise.
+ */
+ private static boolean canLoadBuildInfo(final IProject project) {
+ IFile file = project.getFile(SETTINGS_FILE_NAME);
+ if (file == null) return false;
+ File cdtbuild = file.getLocation().toFile();
+ if (cdtbuild == null) return false;
+ return cdtbuild.exists();
+ }
+
+ /* (non-Javadoc)
* Load the build information for the specified resource from its project
* file. Pay attention to the version number too.
*/
@@ -1471,9 +1484,11 @@
ManagedBuildInfo buildInfo = null;
IFile file = project.getFile(SETTINGS_FILE_NAME);
File cdtbuild = file.getLocation().toFile();
- if (!cdtbuild.exists())
- return null;
-
+ if (!cdtbuild.exists()) {
+ // If we cannot find the .cdtbuild project file, throw an exception and let the user know
+ throw new BuildException(ManagedMakeMessages.getFormattedString(PROJECT_FILE_ERROR, project.getName()));
+ }
+
// So there is a project file, load the information there
InputStream stream = new FileInputStream(cdtbuild);
try {
@@ -1931,10 +1946,10 @@
}
}
- /**
+ /*
* 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
+ * build target or configuation information. It is the responsibility
* 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.
@@ -2035,7 +2050,7 @@
return null;
}
- if(buildInfo == null && resource instanceof IProject)
+ if (buildInfo == null && resource instanceof IProject)
buildInfo = findBuildInfoSynchronized((IProject)resource);
/*
// Nothing in session store, so see if we can load it from cdtbuild
@@ -2058,6 +2073,47 @@
}
/* (non-Javadoc)
+ * Determine if build information can be found. Various attempts are made
+ * to find the information, and if successful, true is returned; false otherwise.
+ * Typically, this routine would be called prior to findBuildInfo, to deterimine
+ * if findBuildInfo should be called to actually do the loading of build
+ * information, if possible
+ * @param resource
+ * @return
+ */
+ private static boolean canFindBuildInfo(IResource resource) {
+
+ if (resource == null) return false;
+
+ // Make sure the extension information is loaded first
+ try {
+ loadExtensions();
+ } catch (BuildException e) {
+ e.printStackTrace();
+ return false;
+ }
+
+ ManagedBuildInfo buildInfo = null;
+
+ // Check if there is any build info associated with this project for this session
+ try {
+ buildInfo = (ManagedBuildInfo)resource.getSessionProperty(buildInfoProperty);
+ } catch (CoreException e) {
+ // Continue, to see if any of the upcoming checks are successful
+ }
+
+ if (buildInfo == null && resource instanceof IProject) {
+ // Check weather getBuildInfo is called from converter
+ buildInfo = UpdateManagedProjectManager.getConvertedManagedBuildInfo((IProject)resource);
+ if (buildInfo != null) return true;
+ // Check if the build information can be loaded from the .cdtbuild file
+ return canLoadBuildInfo(((IProject)resource));
+ }
+
+ return (buildInfo != null);
+ }
+
+ /* (non-Javadoc)
* this method is called if managed build info session property
* was not set. The caller will use the project rule
* to synchronize with other callers
@@ -2094,7 +2150,7 @@
}
// Check weather getBuildInfo is called from converter
- if(buildInfo == null) {
+ if (buildInfo == null) {
buildInfo = UpdateManagedProjectManager.getConvertedManagedBuildInfo(project);
if (buildInfo != null) return buildInfo;
}
@@ -2161,6 +2217,18 @@
}
/**
+ * Determines if the managed build information for the
+ * argument can be found.
+ *
+ * @see ManagedBuildManager#initBuildInfo(IResource)
+ * @param resource The resource to search for managed build information on.
+ * @return boolean True if the build info can be found; false otherwise.
+ */
+ public static boolean canGetBuildInfo(IResource resource) {
+ return canFindBuildInfo(resource.getProject());
+ }
+
+ /**
* Answers the current version of the managed builder plugin.
*
* @return the current version of the managed builder plugin
Index: src/org/eclipse/cdt/managedbuilder/internal/core/ManagedMakeProject.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedMakeProject.java,v
retrieving revision 1.5
diff -u -r1.5 ManagedMakeProject.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/ManagedMakeProject.java 6 Jul 2005 18:25:25 -0000 1.5
+++ src/org/eclipse/cdt/managedbuilder/internal/core/ManagedMakeProject.java 8 Jul 2005 20:10:25 -0000
@@ -66,28 +66,33 @@
private void updateBinaryParsers(ICDescriptor cDescriptor) throws CoreException {
IManagedBuildInfo buildInfo = null;
String[] ids = null;
- try {
- IProject project = cDescriptor.getProject();
- buildInfo = ManagedBuildManager.getBuildInfo(project);
- if (buildInfo != null) {
- IConfiguration config = buildInfo.getDefaultConfiguration();
- if (config == null && buildInfo.getManagedProject() != null) {
- IConfiguration[] configs = buildInfo.getManagedProject().getConfigurations();
- if (configs != null && configs.length > 0)
- config = configs[0];
- }
- if (config != null) {
- // Get the values from the current configuration
- IToolChain toolChain = config.getToolChain();
- if (toolChain != null) {
- ITargetPlatform targPlatform = toolChain.getTargetPlatform();
- if (targPlatform != null) {
- ids = targPlatform.getBinaryParserList();
- }
+ IProject project = cDescriptor.getProject();
+
+ // If we cannot get the build information, it may be due to the fact that the
+ // build information is yet to be created, due to a synchronization issue
+ // Don't do anything now to the binary parsers because there is nothing meaningful to do.
+ // This routine should be invoked later, when the required build information is available
+ if (!ManagedBuildManager.canGetBuildInfo(project)) return;
+
+ buildInfo = ManagedBuildManager.getBuildInfo(project);
+ if (buildInfo != null) {
+ IConfiguration config = buildInfo.getDefaultConfiguration();
+ if (config == null && buildInfo.getManagedProject() != null) {
+ IConfiguration[] configs = buildInfo.getManagedProject().getConfigurations();
+ if (configs != null && configs.length > 0)
+ config = configs[0];
+ }
+ if (config != null) {
+ // Get the values from the current configuration
+ IToolChain toolChain = config.getToolChain();
+ if (toolChain != null) {
+ ITargetPlatform targPlatform = toolChain.getTargetPlatform();
+ if (targPlatform != null) {
+ ids = targPlatform.getBinaryParserList();
}
}
}
- } catch (Exception e) {return;}
+ }
cDescriptor.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
if (ids != null) {
Index: src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties,v
retrieving revision 1.30
diff -u -r1.30 PluginResources.properties
--- src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties 6 Jul 2005 17:56:13 -0000 1.30
+++ src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties 8 Jul 2005 20:10:25 -0000
@@ -48,9 +48,10 @@
ManagedBuildManager.error.manifest.option.filter=Option {0} uses an unsupported resourceFilter attribute value. The option was ignored.
ManagedBuildManager.error.manifest.option.valuehandler=Could not load value handler {0} in option {1}.
ManagedBuildManager.error.open_failed_title=Managed Make Project File Error
-ManagedBuildManager.error.open_failed=The Managed Make project file could not be read because of the following error.\n\n{0}\n\nManaged Make functionality will not be available for this project.
+ManagedBuildManager.error.open_failed=The Managed Make project file could not be read because of the following error:\n\n{0}\n\nManaged Make functionality will not be available for this project.
ManagedBuildManager.error.project.version.error=The version number of the project {0} is greater than the Managed Build System version number.
ManagedBuildManager.error.id.nomatch=Error loading Managed Make project information for project {0}. The tool definitions used to create the project are not available.
+ManagedBuildManager.error.project.file.missing=The Managed Make project file for project {0} is missing.
# Makefile Generator Messages
MakefileGenerator.message.start.file=Building file:
MakefileGenerator.message.finish.file=Finished building:
Index: src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java,v
retrieving revision 1.1
diff -u -r1.1 ResourceChangeHandler.java
--- src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java 6 Jul 2005 17:56:13 -0000 1.1
+++ src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java 8 Jul 2005 20:10:25 -0000
@@ -253,13 +253,17 @@
private IManagedBuilderMakefileGenerator getInitializedGenerator(IProject project){
IManagedBuilderMakefileGenerator makeGen = (IManagedBuilderMakefileGenerator)fBuildFileGeneratorMap.get(project);
- if(makeGen == null){
- try{
- if(project.hasNature(ManagedCProjectNature.MNG_NATURE_ID)){
+ if (makeGen == null) {
+ try {
+ if (project.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) {
+ // Determine if we can access the build info before actually trying
+ // If not, don't try, to avoid putting up a dialog box warning the user
+ if (!ManagedBuildManager.canGetBuildInfo(project)) return null;
+
IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
- if(buildInfo != null){
+ if (buildInfo != null){
IConfiguration defaultCfg = buildInfo.getDefaultConfiguration();
- if(defaultCfg != null){
+ if (defaultCfg != null) {
makeGen = ManagedBuildManager.getBuildfileGenerator(defaultCfg);
makeGen.initialize(project,buildInfo,new NullProgressMonitor());
fBuildFileGeneratorMap.put(project,makeGen);
@@ -267,6 +271,7 @@
}
}
} catch (CoreException e){
+ return null;
}
}
return makeGen;