1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for problem converting CDT 1.2 & 2.0 projects

This commit is contained in:
Leo Treggiari 2005-06-28 16:53:14 +00:00
parent 3dc2073d23
commit 03cb2a3ec9
13 changed files with 92 additions and 46 deletions

View file

@ -45,6 +45,8 @@ public class ManagedProjectUpdateTests extends TestCase {
suite.addTest(new ManagedProjectUpdateTests("testProjectUpdate12_NoUpdate"));
suite.addTest(new ManagedProjectUpdateTests("testProjectUpdate20_NoUpdate"));
suite.addTest(new ManagedProjectUpdateTests("testProjectUpdate21_NoUpdate"));
// TODO: This is affected by the TODO in UpdateManagedProjectManager
//suite.addTest(new ManagedProjectUpdateTests("testProjectUpdate21CPP_Update"));
return suite;
}
@ -122,8 +124,16 @@ public class ManagedProjectUpdateTests extends TestCase {
if(isCompatible){
//check for correct update
if(!updateProject){
if (!updateProject) {
//TODO: if the user has chosen not to update the project the .cdtbuild file should not change
} else {
// Make sure that we have a valid project
if (info == null ||
info.getManagedProject() == null ||
info.getManagedProject().isValid() == false)
{
fail("the project \"" + curProject.getName() + "\" was not properly converted");
}
}
//check whether the project builds without errors
@ -192,6 +202,19 @@ public class ManagedProjectUpdateTests extends TestCase {
doTestProjectUpdate("2.1", true, true, makefiles);
}
/* (non-Javadoc)
* tests project v2.1 update of a C++ project with C source files
*/
public void testProjectUpdate21CPP_Update(){
IPath[] makefiles = {
Path.fromOSString("makefile"),
Path.fromOSString("objects.mk"),
Path.fromOSString("sources.mk"),
Path.fromOSString("subdir.mk"),
Path.fromOSString("Functions/subdir.mk")};
doTestProjectUpdate("2.1CPP", true, true, makefiles);
}
/* (non-Javadoc)
* tests project v1.2 update
* in case when user chooses not to update the project

View file

@ -1514,28 +1514,33 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
buildInfo = new ManagedBuildInfo(project, (Element)node, fileVersion);
if (fileVersion != null) {
buildInfo.setVersion(fileVersion);
}
// Check to see if all elements could be loaded correctly - for example,
// if references in the project file could not be resolved to extension
// elements
if (buildInfo.getManagedProject() == null ||
(!buildInfo.getManagedProject().isValid())) {
// The load failed
throw new Exception(ManagedMakeMessages.getFormattedString("ManagedBuildManager.error.id.nomatch", project.getName())); //$NON-NLS-1$
}
// Each ToolChain/Tool/Builder element maintain two separate
// converters if available
// 0ne for previous Mbs versions and one for current Mbs version
// walk through the project hierarchy and call the converters
// written for previous mbs versions
if ( checkForMigrationSupport(buildInfo, false) != true ) {
// display an error message that the project is no loadable
if (buildInfo.getManagedProject() == null ||
PluginVersionIdentifier version = new PluginVersionIdentifier(fileVersion);
PluginVersionIdentifier version21 = new PluginVersionIdentifier("2.1"); //$NON-NLS-1$
// CDT 2.1 is the first version using the new MBS model
if (version.isGreaterOrEqualTo(version21)) {
// Check to see if all elements could be loaded correctly - for example,
// if references in the project file could not be resolved to extension
// elements
if (buildInfo.getManagedProject() == null ||
(!buildInfo.getManagedProject().isValid())) {
// The load failed
throw new Exception(ManagedMakeMessages.getFormattedString("ManagedBuildManager.error.id.nomatch", project.getName())); //$NON-NLS-1$
}
// Each ToolChain/Tool/Builder element maintain two separate
// converters if available
// 0ne for previous Mbs versions and one for current Mbs version
// walk through the project hierarchy and call the converters
// written for previous mbs versions
if ( checkForMigrationSupport(buildInfo, false) != true ) {
// display an error message that the project is not loadable
if (buildInfo.getManagedProject() == null ||
(!buildInfo.getManagedProject().isValid())) {
// The load failed
throw new Exception(ManagedMakeMessages.getFormattedString("ManagedBuildManager.error.id.nomatch", project.getName())); //$NON-NLS-1$
}
}
}
}
// Upgrade the project's CDT version if necessary

View file

@ -339,7 +339,7 @@ public class Configuration extends BuildObject implements IConfiguration {
// Hook me up
managedProject.addConfiguration(this);
setDirty(true);
setRebuildState(true);
rebuildNeeded = true;
}
/*
@ -1096,7 +1096,7 @@ public class Configuration extends BuildObject implements IConfiguration {
if (extension == null && artifactExtension == null) return;
if (artifactExtension == null || extension == null || !artifactExtension.equals(extension)) {
artifactExtension = extension;
setRebuildState(true);
rebuildNeeded = true;
isDirty = true;
}
}
@ -1108,7 +1108,7 @@ public class Configuration extends BuildObject implements IConfiguration {
if (name == null && artifactName == null) return;
if (artifactName == null || name == null || !artifactName.equals(name)) {
artifactName = name;
setRebuildState(true);
rebuildNeeded = true;
isDirty = true;
}
}
@ -1184,7 +1184,7 @@ public class Configuration extends BuildObject implements IConfiguration {
if (step == null && prebuildStep == null) return;
if (prebuildStep == null || step == null || !prebuildStep.equals(step)) {
prebuildStep = step;
setRebuildState(true);
rebuildNeeded = true;
isDirty = true;
}
}
@ -1197,7 +1197,7 @@ public class Configuration extends BuildObject implements IConfiguration {
if (step == null && postbuildStep == null) return;
if (postbuildStep == null || step == null || !postbuildStep.equals(step)) {
postbuildStep = step;
setRebuildState(true);
rebuildNeeded = true;
isDirty = true;
}
}
@ -1209,7 +1209,7 @@ public class Configuration extends BuildObject implements IConfiguration {
if (announceStep == null && preannouncebuildStep == null) return;
if (preannouncebuildStep == null || announceStep == null || !preannouncebuildStep.equals(announceStep)) {
preannouncebuildStep = announceStep;
setRebuildState(true);
rebuildNeeded = true;
isDirty = true;
}
}
@ -1221,7 +1221,7 @@ public class Configuration extends BuildObject implements IConfiguration {
if (announceStep == null && postannouncebuildStep == null) return;
if (postannouncebuildStep == null || announceStep == null || !postannouncebuildStep.equals(announceStep)) {
postannouncebuildStep = announceStep;
setRebuildState(true);
rebuildNeeded = true;
isDirty = true;
}
}

View file

@ -73,7 +73,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
// The path container used for all managed projects
public static final IContainerEntry containerEntry = CoreModel.newContainerEntry(new Path("org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER")); //$NON-NLS-1$
private static final QualifiedName defaultConfigProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), DEFAULT_CONFIGURATION);
private static final QualifiedName defaultTargetProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), DEFAULT_TARGET);
//private static final QualifiedName defaultTargetProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), DEFAULT_TARGET);
public static final String MAJOR_SEPERATOR = ";"; //$NON-NLS-1$
public static final String MINOR_SEPERATOR = "::"; //$NON-NLS-1$
private static final String EMPTY_STRING = new String();
@ -791,6 +791,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
*
*/
public void initializePathEntries() {
if (!isValid()) return;
try {
IPathEntryContainer container = new ManagedBuildCPathEntryContainer(getOwner().getProject());
CoreModel.setPathEntryContainer(new ICProject[]{cProject}, container, new NullProgressMonitor());

View file

@ -80,7 +80,7 @@ public class ProjectType extends BuildObject implements IProjectType {
// Load the configuration children
IManagedConfigElement[] configs = element.getChildren(IConfiguration.CONFIGURATION_ELEMENT_NAME);
String [] usedConfigNames = new String[0];
String [] usedConfigNames = new String[configs.length];
IConfigurationNameProvider configurationNameProvder = getConfigurationNameProvider();
if ( configurationNameProvder != null ) {

View file

@ -734,7 +734,7 @@ class UpdateManagedProject12 {
}
// Upgrade the version
((ManagedBuildInfo)info).setVersion(ManagedBuildManager.getBuildInfoVersion().toString());
((ManagedBuildInfo)info).setVersion("2.1.0");
info.setValid(true);
} catch (CoreException e){
throw e;

View file

@ -94,7 +94,7 @@ class UpdateManagedProject20 {
}
}
// Upgrade the version
((ManagedBuildInfo)info).setVersion(ManagedBuildManager.getBuildInfoVersion().toString());
((ManagedBuildInfo)info).setVersion("2.1.0");
info.setValid(true);
}catch (CoreException e){
throw e;
@ -377,7 +377,7 @@ class UpdateManagedProject20 {
for(int i = 0; i < options.length; i++){
IOption curOption = options[i];
IOption parent = curOption.getSuperClass();
String curOptionId = curOption.getId();
//String curOptionId = curOption.getId();
if(parent == null)
continue;

View file

@ -64,26 +64,31 @@ class UpdateManagedProject21 {
// did in CDT 2.*. Otherwise the .c files will not be compiled by default since CDT 3.0 switched to using
// Eclipse content types.
if (CoreModel.hasCCNature(project)) {
IResource[] files = project.members();
for (int i=0; i<files.length; i++) {
String ext = files[i].getFileExtension();
if (ext != null && ext.equals("c")) { //$NON-NLS-1$
/*
* What to do here is not yet decided
try {
try {
IResource[] files = project.members(IProject.EXCLUDE_DERIVED);
for (int i=0; i<files.length; i++) {
String ext = files[i].getFileExtension();
if (ext != null && ext.equals("c")) { //$NON-NLS-1$
IContentTypeManager manager = Platform.getContentTypeManager();
IContentType contentType = manager.getContentType("org.eclipse.cdt.core.cxxSource"); //$NON-NLS-1$
IScopeContext projectScope = new ProjectScope(project);
IContentTypeSettings settings = contentType.getSettings(projectScope);
// TODO: we need to add the default extensions too...
// First, copy the extensions from the "global" content type
String[] specs = contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
for (int j = 0; j < specs.length; j++) {
settings.addFileSpec(specs[j], IContentType.FILE_EXTENSION_SPEC);
}
specs = contentType.getFileSpecs(IContentType.FILE_NAME_SPEC);
for (int j = 0; j < specs.length; j++) {
settings.addFileSpec(specs[j], IContentType.FILE_NAME_SPEC);
}
// Add the .c extension
settings.addFileSpec("c", IContentType.FILE_EXTENSION_SPEC); //$NON-NLS-1$
} catch (CoreException e) {
// TODO: Issue message??
break;
}
*/
break;
}
} catch (CoreException e) {
// Ignore errors. User will need to manually add .c extension if necessary
}
}

View file

@ -25,6 +25,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@ -326,8 +327,19 @@ public class UpdateManagedProjectManager {
*/
static public void updateProject(final IProject project, ManagedBuildInfo info)
throws CoreException{
try{
getUpdateManager(project).doProjectUpdate(info);
try {
// Refresh the project here since we may be called before an import operation has fully
// completed setting up the project's resources
IWorkspace workspace = project.getWorkspace();
final ManagedBuildInfo mbsInfo = info;
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
};
// TODO: This is causing a "workspace locked" error (sometimes), but I don't know why...
//workspace.run(runnable, project, IWorkspace.AVOID_UPDATE, null);
getUpdateManager(project).doProjectUpdate(mbsInfo);
} finally {
removeUpdateManager(project);
// We have to this here since we use java.io.File to handle the update.