diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/.classpath b/build/org.eclipse.cdt.managedbuilder.core.tests/.classpath index ec976833fce..14d41daf60e 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/.classpath +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/.classpath @@ -1,8 +1,24 @@ - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml index f5f7d616476..e31ef0b4db0 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml @@ -16,6 +16,7 @@ + @@ -1202,9 +1203,9 @@ + isTest="true" + name="testgnu21.exe" + id="cdt.managedbuild.target.testgnu21.exe"> + name="testgnu21.so" + id="cdt.managedbuild.target.testgnu21.so"> + id="cdt.managedbuild.target.testgnu21.lib"> $(@:%.o=%.d) && \ + gcc -MM -MG -P -w -O0 -g3 -Wall -c -fmessage-length=0 $< >> $(@:%.o=%.d) + @echo 'Finished building: $<' + @echo ' ' + + diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedFolder/f1.c b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedFolder/f1.c new file mode 100644 index 00000000000..5e77893b8a6 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedFolder/f1.c @@ -0,0 +1,8 @@ +#include +#include "test_ar.h" + +void f1_ar() +{ + printf ( "Hello from f1_ar.\n" ) ; + return ; +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedFolder/f2.c b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedFolder/f2.c new file mode 100644 index 00000000000..56e2c730d4d --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedFolder/f2.c @@ -0,0 +1,8 @@ +#include +#include "test_ar.h" + +void f2_ar() +{ + printf ( "Hello from f2_ar.\n" ) ; + return ; +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedFolder/test_ar.h b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedFolder/test_ar.h new file mode 100644 index 00000000000..55e38f0d5ac --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedFolder/test_ar.h @@ -0,0 +1,2 @@ +void f1_ar() ; +void f2_ar() ; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedLib/f1.c b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedLib/f1.c new file mode 100644 index 00000000000..5e77893b8a6 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedLib/f1.c @@ -0,0 +1,8 @@ +#include +#include "test_ar.h" + +void f1_ar() +{ + printf ( "Hello from f1_ar.\n" ) ; + return ; +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedLib/f2.c b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedLib/f2.c new file mode 100644 index 00000000000..56e2c730d4d --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedLib/f2.c @@ -0,0 +1,8 @@ +#include +#include "test_ar.h" + +void f2_ar() +{ + printf ( "Hello from f2_ar.\n" ) ; + return ; +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedLib/linkedLib.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedLib/linkedLib.zip new file mode 100644 index 00000000000..c13a0f08a77 Binary files /dev/null and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedLib/linkedLib.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedLib/test_ar.h b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedLib/test_ar.h new file mode 100644 index 00000000000..55e38f0d5ac --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/linkedLib/test_ar.h @@ -0,0 +1,2 @@ +void f1_ar() ; +void f2_ar() ; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/multiResConfig/testResCfg.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/multiResConfig/testResCfg.zip new file mode 100644 index 00000000000..d60c3f775ce Binary files /dev/null and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/multiResConfig/testResCfg.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/singleFileExe/testSingleExe.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/singleFileExe/testSingleExe.zip new file mode 100644 index 00000000000..e8ba2abbf1f Binary files /dev/null and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/singleFileExe/testSingleExe.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/twoFileSO/testDoubleSO.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/twoFileSO/testDoubleSO.zip new file mode 100644 index 00000000000..c4e8bd95c9d Binary files /dev/null and b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/test21Projects/twoFileSO/testDoubleSO.zip differ diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java index b867f1f4163..cf40dbf8c39 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/testplugin/ManagedBuildTestHelper.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2004 Intel Corporation and others. + * Copyright (c) 2004, 2005 Intel 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 @@ -11,6 +11,8 @@ package org.eclipse.cdt.managedbuilder.testplugin; import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.zip.ZipFile; @@ -18,23 +20,37 @@ import java.util.zip.ZipFile; import junit.framework.Assert; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.ICDescriptor; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; +import org.eclipse.cdt.managedbuilder.core.IManagedProject; +import org.eclipse.cdt.managedbuilder.core.IProjectType; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; +import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature; import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceDescription; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.ui.dialogs.IOverwriteQuery; import org.eclipse.ui.wizards.datatransfer.ImportOperation; import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider; +//import org.eclipse.compare.structuremergeviewer.Differencer; +//import org.eclipse.compare.ResourceNode;; public class ManagedBuildTestHelper { + /* (non-Javadoc) * Create a new project named name or return the project in * the workspace of the same name if it exists. @@ -43,19 +59,23 @@ public class ManagedBuildTestHelper { * @return * @throws CoreException */ - static public IProject createProject(String name) throws CoreException { + static public IProject createProject(String name, IPath location, String projectId, String projectTypeId) throws CoreException { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject newProjectHandle = root.getProject(name); IProject project = null; if (!newProjectHandle.exists()) { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IWorkspaceDescription workspaceDesc = workspace.getDescription(); - workspaceDesc.setAutoBuilding(false); - workspace.setDescription(workspaceDesc); - IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); - //description.setLocation(root.getLocation()); - project = CCorePlugin.getDefault().createCProject(description, newProjectHandle, new NullProgressMonitor(), MakeCorePlugin.MAKE_PROJECT_ID); + if (projectId.equals(ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID)) { + project = createNewManagedProject(newProjectHandle, name, location, projectId, projectTypeId); + } else { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IWorkspaceDescription workspaceDesc = workspace.getDescription(); + workspaceDesc.setAutoBuilding(false); + workspace.setDescription(workspaceDesc); + IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); + //description.setLocation(root.getLocation()); + project = CCorePlugin.getDefault().createCProject(description, newProjectHandle, new NullProgressMonitor(), MakeCorePlugin.MAKE_PROJECT_ID); + } } else { newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, null); project = newProjectHandle; @@ -94,15 +114,20 @@ public class ManagedBuildTestHelper { } } - static public IProject createProject(String projectName, File zip) throws CoreException, InvocationTargetException, IOException { + static public IProject createProject(String projectName, File zip, IPath location, String projectTypeId) throws CoreException, InvocationTargetException, IOException { IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); IProject project= root.getProject(projectName); if (project.exists()) removeProject(projectName); - importFilesFromZip(new ZipFile(zip),project.getFullPath(),null); + IPath destPath = (location != null) ? + location : + project.getFullPath(); + if (zip != null) { + importFilesFromZip(new ZipFile(zip), destPath, null); + } - return createProject(projectName); + return createProject(projectName, location, ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID, projectTypeId); } static public void importFilesFromZip(ZipFile srcZipFile, IPath destPath, IProgressMonitor monitor) throws InvocationTargetException { @@ -116,6 +141,234 @@ public class ManagedBuildTestHelper { op.run(monitor); } catch (InterruptedException e) { // should not happen + Assert.assertTrue(false); } } -} + + static public IProject createNewManagedProject(IProject newProjectHandle, String name, IPath location, + String projectId, String projectTypeId) throws CoreException { + // Create the base project + IProject project = null; + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IWorkspaceDescription workspaceDesc = workspace.getDescription(); + workspaceDesc.setAutoBuilding(false); + workspace.setDescription(workspaceDesc); + IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); + if (location != null) { + description.setLocation(location); + } + project = CCorePlugin.getDefault().createCProject(description, newProjectHandle, new NullProgressMonitor(), projectId); + // Add the managed build nature and builder + addManagedBuildNature(project); + + // Find the base project type definition + IProjectType[] projTypes = ManagedBuildManager.getDefinedProjectTypes(); + IProjectType projType = ManagedBuildManager.getProjectType(projectTypeId); + Assert.assertNotNull(projType); + + // Create the managed-project (.cdtbuild) for our project that builds an executable. + IManagedProject newProject = null; + try { + newProject = ManagedBuildManager.createManagedProject(project, projType); + } catch (Exception e) { + Assert.fail("Failed to create managed project for: " + project.getName()); + } + Assert.assertEquals(newProject.getName(), projType.getName()); + Assert.assertFalse(newProject.equals(projType)); + ManagedBuildManager.setNewProjectVersion(project); + // Copy over the configs + IConfiguration defaultConfig = null; + IConfiguration[] configs = projType.getConfigurations(); + for (int i = 0; i < configs.length; ++i) { + // Make the first configuration the default + if (i == 0) { + defaultConfig = newProject.createConfiguration(configs[i], projType.getId() + "." + i); + } else { + newProject.createConfiguration(configs[i], projType.getId() + "." + i); + } + } + ManagedBuildManager.setDefaultConfiguration(project, defaultConfig); + + // Initialize the path entry container + IStatus initResult = ManagedBuildManager.initBuildInfoContainer(project); + if (initResult.getCode() != IStatus.OK) { + Assert.fail("Initializing build information failed for: " + project.getName() + " because: " + initResult.getMessage()); + } + return project; + } + + static public void addManagedBuildNature (IProject project) { + // Create the buildinformation object for the project + IManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project); + info.setValid(true); + + // Add the managed build nature + try { + ManagedCProjectNature.addManagedNature(project, new NullProgressMonitor()); + ManagedCProjectNature.addManagedBuilder(project, new NullProgressMonitor()); + } catch (CoreException e) { + Assert.fail("Test failed on adding managed build nature or builder: " + e.getLocalizedMessage()); + } + + // Associate the project with the managed builder so the clients can get proper information + ICDescriptor desc = null; + try { + desc = CCorePlugin.getDefault().getCProjectDescription(project, true); + desc.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID); + desc.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, ManagedBuildManager.INTERFACE_IDENTITY); + } catch (CoreException e) { + Assert.fail("Test failed on adding managed builder as scanner info provider: " + e.getLocalizedMessage()); + } + try { + desc.saveProjectData(); + } catch (CoreException e) { + Assert.fail("Test failed on saving the ICDescriptor data: " + e.getLocalizedMessage()); } + } + + static public void compareBenchmarks(IProject project, IPath testDir, IPath[] files) { + try { + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (Exception e) { + Assert.fail("File " + files[0].lastSegment() + " - project refresh failed."); + } + for (int i=0; i 1) { + IPath newDir = tmpSrcDir; + do { + IPath dir = file.uptoSegment(1); + newDir = newDir.append(dir); + file = file.removeFirstSegments(1); + succeed = newDir.toFile().mkdir(); + } while (file.segmentCount() > 1); + } + IPath destFile = tmpSrcDir.append(files[i]); + FileWriter writer = null; + try { + writer = new FileWriter(destFile.toFile()); + } catch (Exception e) { + Assert.fail("File " + files[i].toString() + " could not be written."); + } + try { + int c; + do { + c = srcReader.read(); + if (c == -1) break; + writer.write(c); + } while (c != -1); + srcReader.close(); + writer.close(); + } catch (Exception e) { + Assert.fail("File " + file.toString() + " could not be copied."); + } + } + } + } + } + return tmpSrcDir; + } + + static public void deleteTempDir(IPath tmpSubDir, IPath[] files) { + IPath tmpSrcDir = null; + String userDirStr = System.getProperty("user.home"); + if (userDirStr != null) { + IPath userDir = Path.fromOSString(userDirStr); + tmpSrcDir = userDir.append(tmpSubDir); + if (userDir.toString().equalsIgnoreCase(tmpSrcDir.toString())) { + Assert.fail("Temporary sub-directory cannot be the empty string."); + } else { + File tmpSrcDirFile = tmpSrcDir.toFile(); + if (!tmpSrcDirFile.exists()) { + Assert.fail("Temporary directory " + tmpSrcDirFile.toString() + " does not exist."); + } else { + boolean succeed; + for (int i=0; i 0) { + if (i == 0) { + String configName = info.getDefaultConfiguration().getName(); + IPath buildDir = Path.fromOSString(configName); + ManagedBuildTestHelper.compareBenchmarks(curProject, buildDir, files); + } + } + } + } + + for(int i = 0; i < projects.length; i++) + ManagedBuildTestHelper.removeProject(projects[i].getName()); + } + + private void createPathVariable(IPath tmpDir) { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + workspace = ResourcesPlugin.getWorkspace(); + IPathVariableManager pathMan = workspace.getPathVariableManager(); + String name = MBS_TEMP_DIR; + try { + if (pathMan.validateName(name).isOK() && pathMan.validateValue(tmpDir).isOK()) { + pathMan.setValue(name, tmpDir); + } else { + fail("could not create the path variable " + name); + } + } catch (Exception e) {fail("could not create the path variable " + name);} + } + + private void createFileLink(IProject project, IPath tmpDir, String linkName, String fileName) { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + String name = MBS_TEMP_DIR; + if (!pathVariableCreated) { + createPathVariable(tmpDir); + pathVariableCreated = true; + } + + try { + // Now we can create a linked resource relative to the defined path variable: + IFile linkF1 = project.getFile(linkName); + IPath location = new Path("MBSTemp/" + fileName); + if (workspace.validateLinkLocation(linkF1, location).isOK()) { + linkF1.createLink(location, IResource.NONE, null); + } else { + fail("could not create the link to " + name); + } + } catch (Exception e) {fail("could not create the link to " + name);} + } + + /* (non-Javadoc) + * tests 2.1 style tool integration for a single file executable + */ + public void testSingleFileExe(){ + IPath[] makefiles = { + Path.fromOSString("makefile"), + Path.fromOSString("objects.mk"), + Path.fromOSString("sources.mk"), + Path.fromOSString("subdir.mk")}; + IProject[] projects = createProjects("singleFileExe", null, null, true); + buildProjects(projects, makefiles); + } + + /* (non-Javadoc) + * tests 2.1 style tool integration for a two file SO + */ + public void testTwoFileSO(){ + IPath[] makefiles = { + Path.fromOSString("makefile"), + Path.fromOSString("objects.mk"), + Path.fromOSString("sources.mk"), + Path.fromOSString("subdir.mk")}; + IProject[] projects = createProjects("twoFileSO", null, null, true); + buildProjects(projects, makefiles); + } + + /* (non-Javadoc) + * tests 2.1 style tool integration for multiple source files & a resource configuration + */ + public void testMultiResConfig(){ + IPath[] makefiles = { + Path.fromOSString("makefile"), + Path.fromOSString("objects.mk"), + Path.fromOSString("sources.mk"), + Path.fromOSString("subdir.mk"), + Path.fromOSString("source1/subdir.mk"), + Path.fromOSString("source2/subdir.mk"), + Path.fromOSString("source2/source21/subdir.mk")}; + IProject[] projects = createProjects("multiResConfig", null, null, true); + buildProjects(projects, makefiles); + } + + /* (non-Javadoc) + * tests 2.1 style tool integration for linked files + */ + public void testLinkedLib(){ + IPath[] makefiles = { + Path.fromOSString("makefile"), + Path.fromOSString("objects.mk"), + //Path.fromOSString("subdir.mk") // Can't compare this yet since it contains absolute paths! + Path.fromOSString("sources.mk")}; + IPath[] linkedFiles = { + Path.fromOSString("f1.c"), + Path.fromOSString("f2.c"), + Path.fromOSString("test_ar.h")}; + File srcDirFile = CTestPlugin.getFileInPlugin(new Path("resources/test21Projects/linkedLib/")); + IPath srcDir = Path.fromOSString(srcDirFile.toString()); + IPath tmpSubDir = Path.fromOSString("CDTMBSTest"); + IPath tmpDir = ManagedBuildTestHelper.copyFilesToTempDir(srcDir, tmpSubDir, linkedFiles); + try { + IProject[] projects = createProjects("linkedLib", null, "cdt.managedbuild.target.testgnu21.lib", true); + // There should be only one project. Add our linked files to it. + IProject project = projects[0]; + createFileLink(project, tmpDir, "f1.c", "f1.c"); + createFileLink(project, tmpDir, "f2link.c", "f2.c"); + createFileLink(project, tmpDir, "test_ar.h", "test_ar.h"); + // Build the project + buildProjects(projects, makefiles); + } finally {ManagedBuildTestHelper.deleteTempDir(tmpSubDir, linkedFiles);} + } + + /* (non-Javadoc) + * tests 2.1 style tool integration for a linked folder + */ + public void testLinkedFolder(){ + IPath[] makefiles = { + Path.fromOSString("makefile"), + Path.fromOSString("objects.mk"), + Path.fromOSString("subdir.mk"), + Path.fromOSString("sources.mk")}; + IPath[] linkedFiles = { + Path.fromOSString("f1.c"), + Path.fromOSString("f2.c"), + Path.fromOSString("test_ar.h"), + Path.fromOSString("Benchmarks/makefile"), + Path.fromOSString("Benchmarks/objects.mk"), + Path.fromOSString("Benchmarks/subdir.mk"), + Path.fromOSString("Benchmarks/sources.mk")}; + File srcDirFile = CTestPlugin.getFileInPlugin(new Path("resources/test21Projects/linkedFolder/")); + IPath srcDir = Path.fromOSString(srcDirFile.toString()); + IPath tmpSubDir = Path.fromOSString("CDTMBSTest"); + IPath tmpDir = ManagedBuildTestHelper.copyFilesToTempDir(srcDir, tmpSubDir, linkedFiles); + if (!pathVariableCreated) { + createPathVariable(tmpDir); + pathVariableCreated = true; + } + try { + IPath location = Path.fromOSString(MBS_TEMP_DIR); + IProject[] projects = createProjects("linkedFolder", location, "cdt.managedbuild.target.testgnu21.lib", false); + // Build the project + buildProjects(projects, makefiles); + } finally {ManagedBuildTestHelper.deleteTempDir(tmpSubDir, linkedFiles);} + } +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedProjectUpdateTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedProjectUpdateTests.java index 914c5f8e162..b1a2fdcca9b 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedProjectUpdateTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ManagedProjectUpdateTests.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2004 Intel Corporation and others. + * Copyright (c) 2004, 2005 Intel 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 @@ -26,6 +26,7 @@ import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Path; import org.eclipse.ui.dialogs.IOverwriteQuery; @@ -40,8 +41,10 @@ public class ManagedProjectUpdateTests extends TestCase { suite.addTest(new ManagedProjectUpdateTests("testProjectUpdate12_Update")); suite.addTest(new ManagedProjectUpdateTests("testProjectUpdate20_Update")); + suite.addTest(new ManagedProjectUpdateTests("testProjectUpdate21_Update")); suite.addTest(new ManagedProjectUpdateTests("testProjectUpdate12_NoUpdate")); suite.addTest(new ManagedProjectUpdateTests("testProjectUpdate20_NoUpdate")); + suite.addTest(new ManagedProjectUpdateTests("testProjectUpdate21_NoUpdate")); return suite; } @@ -75,7 +78,7 @@ public class ManagedProjectUpdateTests extends TestCase { projectName = projectName.substring(0,projectName.length()-".zip".length()); if(projectName.length() == 0) continue; - IProject project = ManagedBuildTestHelper.createProject(projectName,projectZips[i]); + IProject project = ManagedBuildTestHelper.createProject(projectName, projectZips[i], null, null); if(project != null) projectList.add(project); } @@ -89,7 +92,8 @@ public class ManagedProjectUpdateTests extends TestCase { return (IProject[])projectList.toArray(new IProject[projectList.size()]); } - private void doTestProjectUpdate(String version, boolean updateProject, boolean overwriteBackupFiles){ + private void doTestProjectUpdate(String version, boolean updateProject, boolean overwriteBackupFiles, + IPath[] files){ IOverwriteQuery queryALL = new IOverwriteQuery(){ public String queryOverwrite(String file) { return ALL; @@ -99,8 +103,8 @@ public class ManagedProjectUpdateTests extends TestCase { return NO_ALL; }}; - UpdateManagedProjectManager.setBackupFileOverwriteQuery(updateProject ? queryALL : queryNOALL); - UpdateManagedProjectManager.setUpdateProjectQuery(overwriteBackupFiles ? queryALL : queryNOALL); + UpdateManagedProjectManager.setBackupFileOverwriteQuery(overwriteBackupFiles ? queryALL : queryNOALL); + UpdateManagedProjectManager.setUpdateProjectQuery(updateProject ? queryALL : queryNOALL); IProject projects[] = createVersionProjects(version); if(projects == null || projects.length == 0) @@ -132,6 +136,15 @@ public class ManagedProjectUpdateTests extends TestCase { catch(OperationCanceledException e){ fail("the project \"" + curProject.getName() + "\" build was cancelled, exception message: " + e.getMessage()); } + + //compare the generated makefiles to their benchmarks + if (files != null && files.length > 0) { + if (i == 0) { + String configName = info.getDefaultConfiguration().getName(); + IPath buildDir = Path.fromOSString(configName); + ManagedBuildTestHelper.compareBenchmarks(curProject, buildDir, files); + } + } } } @@ -144,7 +157,12 @@ public class ManagedProjectUpdateTests extends TestCase { * in case when user chooses to update the project */ public void testProjectUpdate12_Update(){ - doTestProjectUpdate("1.2",true,true); + IPath[] makefiles = { + Path.fromOSString("makefile"), + Path.fromOSString("objects.mk"), + Path.fromOSString("sources.mk"), + Path.fromOSString("subdir.mk")}; + doTestProjectUpdate("1.2", true, true, makefiles); } /* (non-Javadoc) @@ -152,7 +170,26 @@ public class ManagedProjectUpdateTests extends TestCase { * in case when user chooses to update the project */ public void testProjectUpdate20_Update(){ - doTestProjectUpdate("2.0",true,true); + IPath[] makefiles = { + Path.fromOSString("makefile"), + Path.fromOSString("objects.mk"), + Path.fromOSString("sources.mk"), + Path.fromOSString("subdir.mk")}; + doTestProjectUpdate("2.0", true, true, makefiles); + } + + /* (non-Javadoc) + * tests project v2.1 update + * in case when user chooses to update the project + */ + public void testProjectUpdate21_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.1", true, true, makefiles); } /* (non-Javadoc) @@ -160,7 +197,7 @@ public class ManagedProjectUpdateTests extends TestCase { * in case when user chooses not to update the project */ public void testProjectUpdate12_NoUpdate(){ - doTestProjectUpdate("1.2",false,true); + doTestProjectUpdate("1.2", false, true, null); } /* (non-Javadoc) @@ -168,6 +205,14 @@ public class ManagedProjectUpdateTests extends TestCase { * in case when user chooses not to update the project */ public void testProjectUpdate20_NoUpdate(){ - doTestProjectUpdate("2.0",false,true); + doTestProjectUpdate("2.0", false, true, null); + } + + /* (non-Javadoc) + * tests project v2.1 update + * in case when user chooses not to update the project + */ + public void testProjectUpdate21_NoUpdate(){ + doTestProjectUpdate("2.1", false, true, null); } } diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ResourceBuildCoreTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ResourceBuildCoreTests.java index d1566ae3db5..dc9f3b1a25f 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ResourceBuildCoreTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuild/core/tests/ResourceBuildCoreTests.java @@ -17,7 +17,6 @@ import junit.framework.TestCase; import junit.framework.TestSuite; import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.ICDescriptor; import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; @@ -31,6 +30,7 @@ import org.eclipse.cdt.managedbuilder.core.IOptionCategory; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature; import org.eclipse.cdt.managedbuilder.internal.core.Tool; +import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; @@ -84,7 +84,7 @@ public class ResourceBuildCoreTests extends TestCase { project = createProject(projectName); // Now associate the builder with the project - addManagedBuildNature(project); + ManagedBuildTestHelper.addManagedBuildNature(project); IProjectDescription description = project.getDescription(); // Make sure it has a managed nature if (description != null) { @@ -97,7 +97,7 @@ public class ResourceBuildCoreTests extends TestCase { // Find the base project type definition IProjectType[] projTypes = ManagedBuildManager.getDefinedProjectTypes(); - IProjectType projType = ManagedBuildManager.getProjectType("cdt.managedbuild.target.testgnu.exe"); + IProjectType projType = ManagedBuildManager.getProjectType("cdt.managedbuild.target.testgnu21.exe"); assertNotNull(projType); // Create the managed-project (.cdtbuild) for our project that builds an executable. @@ -271,7 +271,7 @@ public class ResourceBuildCoreTests extends TestCase { project = createProject(projectName); // Now associate the builder with the project - addManagedBuildNature(project); + ManagedBuildTestHelper.addManagedBuildNature(project); IProjectDescription description = project.getDescription(); // Make sure it has a managed nature if (description != null) { @@ -284,7 +284,7 @@ public class ResourceBuildCoreTests extends TestCase { // Find the base project type definition IProjectType[] projTypes = ManagedBuildManager.getDefinedProjectTypes(); - IProjectType projType = ManagedBuildManager.getProjectType("cdt.managedbuild.target.testgnu.exe"); + IProjectType projType = ManagedBuildManager.getProjectType("cdt.managedbuild.target.testgnu21.exe"); assertNotNull(projType); // Create the managed-project (.cdtbuild) for our project that builds an executable. @@ -372,7 +372,7 @@ public class ResourceBuildCoreTests extends TestCase { project = createProject(projectName); // Now associate the builder with the project - addManagedBuildNature(project); + ManagedBuildTestHelper.addManagedBuildNature(project); IProjectDescription description = project.getDescription(); // Make sure it has a managed nature if (description != null) { @@ -385,7 +385,7 @@ public class ResourceBuildCoreTests extends TestCase { // Find the base project type definition IProjectType[] projTypes = ManagedBuildManager.getDefinedProjectTypes(); - IProjectType projType = ManagedBuildManager.getProjectType("cdt.managedbuild.target.testgnu.exe"); + IProjectType projType = ManagedBuildManager.getProjectType("cdt.managedbuild.target.testgnu21.exe"); assertNotNull(projType); // Create the managed-project (.cdtbuild) for our project that builds an executable. @@ -624,7 +624,7 @@ public class ResourceBuildCoreTests extends TestCase { try { project = createProject(projectName); // Now associate the builder with the project - addManagedBuildNature(project); + ManagedBuildTestHelper.addManagedBuildNature(project); IProjectDescription description = project.getDescription(); // Make sure it has a managed nature if (description != null) { @@ -637,7 +637,7 @@ public class ResourceBuildCoreTests extends TestCase { // Find the base project type definition IProjectType[] projTypes = ManagedBuildManager.getDefinedProjectTypes(); - IProjectType projType = ManagedBuildManager.getProjectType("cdt.managedbuild.target.testgnu.exe"); + IProjectType projType = ManagedBuildManager.getProjectType("cdt.managedbuild.target.testgnu21.exe"); assertNotNull(projType); // Create the managed-project (.cdtbuild) for our project that builds a dummy executable @@ -711,34 +711,5 @@ public class ResourceBuildCoreTests extends TestCase { // checkBuildTestSettings(info); ManagedBuildManager.removeBuildInfo(project); } - - private void addManagedBuildNature (IProject project) { - // Create the buildinformation object for the project - IManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project); - info.setValid(true); - - // Add the managed build nature - try { - ManagedCProjectNature.addManagedNature(project, new NullProgressMonitor()); - // ManagedCProjectNature.addManagedBuilder(project, new NullProgressMonitor()); - } catch (CoreException e) { - fail("Test failed on adding managed build nature or builder: " + e.getLocalizedMessage()); - } - - // Associate the project with the managed builder so the clients can get proper information - ICDescriptor desc = null; - try { - desc = CCorePlugin.getDefault().getCProjectDescription(project, true); - desc.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID); - desc.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, ManagedBuildManager.INTERFACE_IDENTITY); - } catch (CoreException e) { - fail("Test failed on adding managed builder as scanner info provider: " + e.getLocalizedMessage()); - } - try { - desc.saveProjectData(); - } catch (CoreException e) { - fail("Test failed on saving the ICDescriptor data: " + e.getLocalizedMessage()); } - } - } \ No newline at end of file diff --git a/build/org.eclipse.cdt.managedbuilder.core/plugin.properties b/build/org.eclipse.cdt.managedbuilder.core/plugin.properties index e02c184fb59..0642eac89d8 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/plugin.properties +++ b/build/org.eclipse.cdt.managedbuilder.core/plugin.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2003, 2004 IBM Corporation and others. +# Copyright (c) 2003, 2005 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 @@ -13,4 +13,9 @@ providerName=Eclipse.org GeneratedMakefileCBuilder.name=Generated Makefile Builder ManagedBuildNature.name=Managed Builder Project -ManagedMakeProject.name=Managed Make Project \ No newline at end of file +ManagedMakeProject.name=Managed Make Project + +objectFileName=Object File +executableName=Executable File +staticLibraryName=Static Library +sharedLibraryName=Shared Library diff --git a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml index 7a7a29b5e70..e54cc6a881b 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml @@ -121,4 +121,46 @@ type="text"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd b/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd index 79f85f11548..1e2ccbe535b 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd +++ b/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd @@ -1330,15 +1330,7 @@ If the "buildPathResolver" attribute is specified, the "pathDelim - The following is an example of the extension point usage: -<p> -<pre> - <extension - id="buildExample" - name="Definitions for Build Example" - point="org.eclipse.cdt.managedbuilder.core.buildDefinitions"> - etc... -</pre> + [Enter examples here.] diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IAdditionalInput.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IAdditionalInput.java index 62b0050d647..f8b82373dd8 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IAdditionalInput.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IAdditionalInput.java @@ -39,15 +39,15 @@ public interface IAdditionalInput { public IInputType getParent(); /** - * Returns a semi-colon separated list of the relative or absolute paths of the resources + * Returns an array of the relative or absolute paths of the resources * to which this element applies. * The resources must be a member of the project, the output from another tool in the * tool-chain, or an external file. The file name of the path can use GNU Make pattern * rule syntax (in order to generate the name from the input file name). * - * @return String + * @return String[] */ - public String getPaths(); + public String[] getPaths(); /** * Sets semi-colon separated list of the relative or absolute paths of the resources to diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOutputType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOutputType.java index 470042d5bb5..9965d7cd7b3 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOutputType.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOutputType.java @@ -189,18 +189,18 @@ public interface IOutputType extends IBuildObject { public void setOutputPrefix(String prefix); /** - * Returns the paths of the complete set of output files for this outputType + * Returns the file names of the complete set of output files for this outputType * - * @return String + * @return String[] */ - public String getOutputNames(); + public String[] getOutputNames(); /** - * Sets the complete set of output files for this outputType + * Sets the complete set of output file names for this outputType * * @param names */ - public void getOutputNames(String names); + public void setOutputNames(String names); /** * Returns the pattern, using the Gnu pattern rule syntax, for deriving the diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java index 6a44e523ac8..81d8efe4de8 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ITool.java @@ -102,6 +102,20 @@ public interface ITool extends IBuildObject { * @since 2.0 */ public IOption getOptionById(String id); + + /** + * Get the IOption in the receiver with the specified + * ID, or an option with a superclass with this id. + * + *

If the receiver does not have an option with that ID, the method + * returns null. It is the responsibility of the caller to + * verify the return value. + * + * @param id unique identifier of the option to search for + * @return IOption + * @since 3.0 + */ + public IOption getOptionBySuperClassId(String id); /** * Returns the complete list of options that are available for this tool. @@ -187,7 +201,8 @@ public interface ITool extends IBuildObject { /** * Returns all of the additional input resources of all InputType children. - * Note: This does not include additional dependencies. + * Note: This does not include the primary InputType and does not include + * additional dependencies. * * @return IPath[] */ @@ -195,7 +210,8 @@ public interface ITool extends IBuildObject { /** * Returns all of the additional dependency resources of all InputType children. - * Note: This does not include additional inputs. + * Note: This does not include the primary InputType and does not include + * additional inputs. * * @return IPath[] */ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolChain.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolChain.java index 399d9569fa0..ff6da2e3fcd 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolChain.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolChain.java @@ -264,18 +264,37 @@ public interface IToolChain extends IBuildObject { public void setScannerConfigDiscoveryProfileId(String profileId); /** - * Returns the id in this tool-chain that creates the build artifact. + * Returns the sem-colon separated list of Tool ids containing each + * tool that can create the final build artifact (the end target of + * the build). MBS will use the first ID in the list that matches + * a Tool in the ToolChain. One reason for specifying a list, is + * that different versions of a tool can be selected based upon the + * project nature (e.g. different tool definitions for a linker for C vs. C++). * * @return String */ - public String getTargetToolId(); + public String getTargetToolIds(); /** - * Sets the tool in this tool-chain that creates the build artifact. + * Sets the sem-colon separated list of Tool ids containing each + * tool that can create the final build artifact (the end target of + * the build). * - * @param targetToolId + * @param targetToolIds */ - public void setTargetTool(String targetToolId); + public void setTargetToolIds(String targetToolIds); + + /** + * Returns the list of Tool ids containing each + * tool that can create the final build artifact (the end target of + * the build). MBS will use the first ID in the list that matches + * a Tool in the ToolChain. One reason for specifying a list, is + * that different versions of a tool can be selected based upon the + * project nature (e.g. different tool definitions for a linker for C vs. C++). + * + * @return String[] + */ + public String[] getTargetToolList(); /** * Returns the OutputTypes in this tool-chain, besides the primary diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java index 29858ecef50..1c54ebeacb3 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java @@ -114,8 +114,8 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI public static final String MANIFEST_ERROR_DUPLICATE = "ManagedBuildManager.error.manifest.duplicate"; //$NON-NLS-1$ private static final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$ - // This is the version of the manifest and project files that - private static final PluginVersionIdentifier buildInfoVersion = new PluginVersionIdentifier(2, 1, 0); + // This is the version of the manifest and project files + private static final PluginVersionIdentifier buildInfoVersion = new PluginVersionIdentifier(3, 0, 0); private static Map depCalculatorsMap; private static boolean projectTypesLoaded = false; // Project types defined in the manifest files @@ -1291,11 +1291,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI // This is a 1.2 manifest and we are compatible for now return true; } - // isCompatibleWith will return FALSE, if: - // o The major versions are not equal - // o The major versions are equal, but the remainder of the manifest version # is - // greater than the MBS version # - return(buildInfoVersion.isCompatibleWith(version)); + return(buildInfoVersion.isGreaterOrEqualTo(version)); } /* (non-Javadoc) @@ -1322,20 +1318,21 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI // Since 2.0 this will be a processing instruction containing version if (rootElement.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE) { // This is a 1.2 project and it must be updated - } else { // Make sure that the version is compatible with the manager fileVersion = rootElement.getNodeValue(); PluginVersionIdentifier version = new PluginVersionIdentifier(fileVersion); - // isCompatibleWith will return FALSE, if: - // o The major versions are not equal - // o The major versions are equal, but the remainder of the .cdtbuild version # is - // greater than the MBS version # - if (!buildInfoVersion.isCompatibleWith(version)) { - throw new BuildException(ManagedMakeMessages.getFormattedString(PROJECT_VERSION_ERROR, project.getName())); - } if (buildInfoVersion.isGreaterThan(version)) { - // TODO Upgrade the project + // This is >= 2.0 project, but earlier than the current MBS version - it may need to be updated + } else { + // This is a + // isCompatibleWith will return FALSE, if: + // o The major versions are not equal + // o The major versions are equal, but the remainder of the .cdtbuild version # is + // greater than the MBS version # + if (!buildInfoVersion.isCompatibleWith(version)) { + throw new BuildException(ManagedMakeMessages.getFormattedString(PROJECT_VERSION_ERROR, project.getName())); + } } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java index a33a4403667..c949d6ea3e6 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java @@ -210,8 +210,12 @@ public class AdditionalInput implements IAdditionalInput { /* (non-Javadoc) * @see org.eclipse.cdt.core.build.managed.IAdditionalInput#getPaths() */ - public String getPaths() { - return paths; + public String[] getPaths() { + if (paths == null) { + return null; + } + String[] nameTokens = paths.split(";"); //$NON-NLS-1$ + return nameTokens; } /* (non-Javadoc) @@ -229,6 +233,9 @@ public class AdditionalInput implements IAdditionalInput { * @see org.eclipse.cdt.core.build.managed.IAdditionalInput#getKind() */ public int getKind() { + if (kind == null) { + return KIND_ADDITIONAL_INPUT_DEPENDENCY; + } return kind.intValue(); } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java index e2e6474568e..8b8a8a8d311 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java @@ -642,22 +642,26 @@ public class Configuration extends BuildObject implements IConfiguration { * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTargetTool() */ public ITool getTargetTool() { - String targetToolId = toolChain.getTargetToolId(); - if (targetToolId == null) return null; + String[] targetToolIds = toolChain.getTargetToolList(); + if (targetToolIds == null || targetToolIds.length == 0) return null; - // Look for a tool with this ID, or a tool with a superclass with this id + // For each target tool id, in list order, + // look for a tool with this ID, or a tool with a superclass with this id. + // Stop when we find a match ITool[] tools = getFilteredTools(); - for (int i = 0; i < tools.length; i++) { - ITool targetTool = tools[i]; - ITool tool = targetTool; - do { - if (targetToolId.equals(tool.getId())) { - return targetTool; - } - tool = tool.getSuperClass(); - } while (tool != null); + for (int i=0; i 0) { + allDeps.add("$(" + type.getBuildVariable() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + } + } } return (IPath[])allDeps.toArray(new IPath[allDeps.size()]); } @@ -1548,10 +1601,20 @@ public class Tool extends BuildObject implements ITool, IOptionCategory { List allRes = new ArrayList(); IInputType[] types = getInputTypes(); for (int i=0; i 0) { + allRes.add("$(" + type.getBuildVariable() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + } + } } return (IPath[])allRes.toArray(new IPath[allRes.size()]); } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java index 406cc3c76bc..aa76a5ff413 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java @@ -54,7 +54,7 @@ public class ToolChain extends BuildObject implements IToolChain { private String errorParserIds; private List osList; private List archList; - private String targetToolId; + private String targetToolIds; private String secondaryOutputIds; private Boolean isAbstract; private String scannerConfigDiscoveryProfileId; @@ -216,8 +216,8 @@ public class ToolChain extends BuildObject implements IToolChain { if (toolChain.archList != null) { archList = new ArrayList(toolChain.archList); } - if (toolChain.targetToolId != null) { - targetToolId = new String(toolChain.targetToolId); + if (toolChain.targetToolIds != null) { + targetToolIds = new String(toolChain.targetToolIds); } if (toolChain.secondaryOutputIds != null) { secondaryOutputIds = new String(toolChain.secondaryOutputIds); @@ -321,7 +321,7 @@ public class ToolChain extends BuildObject implements IToolChain { secondaryOutputIds = element.getAttribute(SECONDARY_OUTPUTS); // Get the target tool id - targetToolId = element.getAttribute(TARGET_TOOL); + targetToolIds = element.getAttribute(TARGET_TOOL); // Get the scanner config discovery profile id scannerConfigDiscoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID); @@ -415,7 +415,7 @@ public class ToolChain extends BuildObject implements IToolChain { // Get the target tool id if (element.hasAttribute(TARGET_TOOL)) { - targetToolId = element.getAttribute(TARGET_TOOL); + targetToolIds = element.getAttribute(TARGET_TOOL); } // Get the scanner config discovery profile id @@ -490,8 +490,8 @@ public class ToolChain extends BuildObject implements IToolChain { element.setAttribute(SECONDARY_OUTPUTS, secondaryOutputIds); } - if (targetToolId != null) { - element.setAttribute(TARGET_TOOL, targetToolId); + if (targetToolIds != null) { + element.setAttribute(TARGET_TOOL, targetToolIds); } if (scannerConfigDiscoveryProfileId != null) { @@ -839,20 +839,45 @@ public class ToolChain extends BuildObject implements IToolChain { } /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getTargetTool() + * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getTargetToolIds() */ - public String getTargetToolId() { - if (targetToolId == null) { + public String getTargetToolIds() { + if (targetToolIds == null) { // Ask superClass for its list if (superClass != null) { - return superClass.getTargetToolId(); + return superClass.getTargetToolIds(); } else { return null; } } - return targetToolId; + return targetToolIds; } + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getTargetToolList() + */ + public String[] getTargetToolList() { + String IDs = getTargetToolIds(); + String[] targetTools; + if (IDs != null) { + // Check for an empty string + if (IDs.length() == 0) { + targetTools = new String[0]; + } else { + StringTokenizer tok = new StringTokenizer(IDs, ";"); //$NON-NLS-1$ + List list = new ArrayList(tok.countTokens()); + while (tok.hasMoreElements()) { + list.add(tok.nextToken()); + } + String[] strArr = {""}; //$NON-NLS-1$ + targetTools = (String[]) list.toArray(strArr); + } + } else { + targetTools = new String[0]; + } + return targetTools; + } + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getErrorParserIds(IConfiguration) */ @@ -975,12 +1000,12 @@ public class ToolChain extends BuildObject implements IToolChain { } /* (non-Javadoc) - * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setTargetTool() + * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setTargetToolIds() */ - public void setTargetTool(String newId) { - if (targetToolId == null && newId == null) return; - if (targetToolId == null || newId == null || !newId.equals(targetToolId)) { - targetToolId = newId; + public void setTargetToolIds(String newIds) { + if (targetToolIds == null && newIds == null) return; + if (targetToolIds == null || newIds == null || !newIds.equals(targetToolIds)) { + targetToolIds = newIds; isDirty = true; } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java index bbbc29f49b0..bdbe2e49916 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java @@ -1061,6 +1061,10 @@ public class ToolReference implements IToolReference { public void setCustomBuildStep(boolean customBuildStep) { } + public IOption getOptionBySuperClassId(String id) { + return null; + } + /* * The following methods are added to allow the converter from ToolReference -> Tool * to retrieve the actual value of attributes. These routines do not go to the diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java index 2d8175b8dbd..e6147f0de67 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java @@ -240,11 +240,13 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { private static final String OBJS_MACRO = "OBJS"; //$NON-NLS-1$ private static final String DEPS_MACRO = "DEPS"; //$NON-NLS-1$ + private static final String MACRO_ADDITION_ADDPREFIX_HEADER = "${addprefix "; //$NON-NLS-1$ private static final String MACRO_ADDITION_ADDPREFIX_SUFFIX = "," + WHITESPACE + LINEBREAK; //$NON-NLS-1$ private static final String MACRO_ADDITION_PREFIX_SUFFIX = "+=" + WHITESPACE + LINEBREAK; //$NON-NLS-1$ private static final String PREBUILD = "pre-build"; //$NON-NLS-1$ private static final String MAINBUILD = "main-build"; //$NON-NLS-1$ private static final String POSTBUILD = "post-build"; //$NON-NLS-1$ + private static final String SECONDARY_OUTPUTS = "secondary-outputs"; //$NON-NLS-1$ // Local variables needed by generator private String buildTargetName; @@ -1144,6 +1146,13 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { if (buildTargetExt.length() > 0) { buffer.append(DOT + buildTargetExt); } + + // Add the Secondary Outputs to the all target, if any + IOutputType[] secondaryOutputs = config.getToolChain().getSecondaryOutputs(); + if (secondaryOutputs.length > 0) { + buffer.append(WHITESPACE + SECONDARY_OUTPUTS); + } + buffer.append(NEWLINE + NEWLINE); /* @@ -1218,6 +1227,17 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { buffer.append(TAB + DASH + AT + ECHO + WHITESPACE + SINGLE_QUOTE + WHITESPACE + SINGLE_QUOTE + NEWLINE + NEWLINE); } + + // Add the Secondary Outputs target, if needed + if (secondaryOutputs.length > 0) { + buffer.append(SECONDARY_OUTPUTS + COLON); + Vector outs2 = calculateSecondaryOutputs(secondaryOutputs); + for (int i=0; i 0) { + String primaryOutput = (String)enumeratedPrimaryOutputs.get(0); + for (int i=0; i 0) { + for (int j=0; j 0) { for (int i=0; i 0) { - String outName = outPrefix + outPath.lastSegment(); - outPath = outPath.removeLastSegments(1).append(outName); + if (!ignorePrimary) { + IPath outPath = Path.fromOSString(resource.getFullPath().removeFileExtension().lastSegment()); + String outPrefix = tool.getOutputPrefix(); + if (outPrefix.length() > 0) { + String outName = outPrefix + outPath.lastSegment(); + outPath = outPath.removeLastSegments(1).append(outName); + } + outPath = outPath.addFileExtension(outExt); + outputs.add(outPath); } - outPath = outPath.addFileExtension(outExt); - outputs.add(outPath); } return outputs; @@ -2143,9 +2274,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { protected void addMacroAdditionPrefix(HashMap map, String macroName, String relativePath, boolean addPrefix) { // there is no entry in the map, so create a buffer for this macro StringBuffer tempBuffer = new StringBuffer(); - tempBuffer.append(macroName + WHITESPACE + MACRO_ADDITION_PREFIX_SUFFIX); //$NON-NLS-1$ + tempBuffer.append(macroName + WHITESPACE + MACRO_ADDITION_PREFIX_SUFFIX); if (addPrefix) { - tempBuffer.append("${addprefix " + relativePath + MACRO_ADDITION_ADDPREFIX_SUFFIX); //$NON-NLS-1$ //$NON-NLS-2$ + tempBuffer.append(MACRO_ADDITION_ADDPREFIX_HEADER + relativePath + MACRO_ADDITION_ADDPREFIX_SUFFIX); } // have to store the buffer in String form as StringBuffer is not a sublcass of Object @@ -2186,7 +2317,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { /* (non-Javadoc) * Write all macro addition entries in a map to the buffer */ - protected StringBuffer writeAdditionMacros(HashMap map, boolean addPrefix) { + protected StringBuffer writeAdditionMacros(HashMap map) { StringBuffer buffer = new StringBuffer(); // Add the comment buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(MOD_VARS) + NEWLINE); @@ -2199,12 +2330,17 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { // Check if we added any files to the rule // Currently, we do this by comparing the end of the rule buffer to MACRO_ADDITION_PREFIX_SUFFIX if (!(macroString.endsWith(MACRO_ADDITION_PREFIX_SUFFIX)) && - !(macroString.endsWith(MACRO_ADDITION_ADDPREFIX_SUFFIX))) { + !(macroString.endsWith(MACRO_ADDITION_ADDPREFIX_SUFFIX))) { StringBuffer currentBuffer = new StringBuffer(); - currentBuffer.append( macroString); // Close off the rule - if (addPrefix) { - currentBuffer.append("}"); //$NON-NLS-1$ + if (macroString.indexOf(MACRO_ADDITION_ADDPREFIX_HEADER) >= 0) { + currentBuffer.append(macroString + "}" + NEWLINE); //$NON-NLS-1$ + } else { + // Remove the final "/" + if (macroString.endsWith(LINEBREAK)) { + macroString = macroString.substring(0, (macroString.length() - 2)) + NEWLINE; + } + currentBuffer.append(macroString); } currentBuffer.append(NEWLINE); @@ -2404,28 +2540,6 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { } return ruleList; } - - /* (non-Javadoc) - * Returns the option that matches the option ID in this tool - */ - public IOption getOption(ITool tool, String optionId) { - if (optionId == null) return null; - - // Look for an option with this ID, or an option with a superclass with this id - IOption[] options = tool.getOptions(); - for (int i = 0; i < options.length; i++) { - IOption targetOption = options[i]; - IOption option = targetOption; - do { - if (optionId.equals(option.getId())) { - return targetOption; - } - option = option.getSuperClass(); - } while (option != null); - } - - return null; - } /************************************************************************* * R E S O U R C E V I S I T O R M E T H O D S diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/IManagedBuildGnuToolInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/IManagedBuildGnuToolInfo.java index c883f6bf50b..654b263c23c 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/IManagedBuildGnuToolInfo.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/IManagedBuildGnuToolInfo.java @@ -59,11 +59,18 @@ public interface IManagedBuildGnuToolInfo { public Vector getCommandOutputs(); /** - * Returns the raw list of tool's output file names. + * Returns the raw list of tool's primary output file names. * * @return Vector */ - public Vector getEnumeratedOutputs(); + public Vector getEnumeratedPrimaryOutputs(); + + /** + * Returns the raw list of tool's secondary output file names. + * + * @return Vector + */ + public Vector getEnumeratedSecondaryOutputs(); /** * Returns the raw list of tool's output variable names. diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java index eb5de96fcde..71f933b9831 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java @@ -61,7 +61,8 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { private Vector commandInputs = new Vector(); private Vector enumeratedInputs = new Vector(); private Vector commandOutputs = new Vector(); - private Vector enumeratedOutputs = new Vector(); + private Vector enumeratedPrimaryOutputs = new Vector(); + private Vector enumeratedSecondaryOutputs = new Vector(); private Vector outputVariables = new Vector(); private Vector commandDependencies = new Vector(); //private Vector enumeratedDependencies = new Vector(); @@ -103,8 +104,12 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { return commandOutputs; } - public Vector getEnumeratedOutputs() { - return enumeratedOutputs; + public Vector getEnumeratedPrimaryOutputs() { + return enumeratedPrimaryOutputs; + } + + public Vector getEnumeratedSecondaryOutputs() { + return enumeratedSecondaryOutputs; } public Vector getOutputVariables() { @@ -138,61 +143,110 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { public boolean calculateInputs(GnuMakefileGenerator makeGen, IResource[] projResources, boolean lastChance) { // Get the inputs for this tool invocation // Note that command inputs that are also dependencies are also added to the command dependencies list + + /* The priorities for determining the names of the inputs of a tool are: + * 1. If an option is specified, use the value of the option. + * 2. If a build variable is specified, use the files that have been added to the build variable as + * the output(s) of other build steps. + * 3. Use the file extensions and the resources in the project + */ boolean done = true; - Vector myCommandInputs = new Vector(); - Vector myCommandDependencies = new Vector(); - Vector myEnumeratedInputs = new Vector(); + Vector myCommandInputs = new Vector(); // Inputs for the tool command line + Vector myCommandDependencies = new Vector(); // Dependencies for the make rule + Vector myEnumeratedInputs = new Vector(); // Complete list of individual inputs IInputType[] inTypes = tool.getInputTypes(); if (inTypes != null && inTypes.length > 0) { for (int i=0; i 0) { - String cmdVariable = variable = "$(" + variable + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - myCommandInputs.add(cmdVariable); - myCommandDependencies.add(cmdVariable); - // If there is an output variable with the same name, get - // the files associated with it. - List outMacroList = makeGen.getBuildVariableList(variable, true); - if (outMacroList != null) { - myEnumeratedInputs.addAll(outMacroList); - } else { - // If "last chance", then calculate using file extensions below - if (lastChance) { - useFileExts = true; + IOption option = tool.getOptionBySuperClassId(type.getOptionId()); + + // Option? + if (option != null) { + try { + List inputs = new ArrayList(); + int optType = option.getValueType(); + if (optType == IOption.STRING) { + inputs.add(option.getStringValue()); + } else if ( + optType == IOption.STRING_LIST || + optType == IOption.LIBRARIES || + optType == IOption.OBJECTS) { + inputs = (List)option.getValue(); + } + //myCommandInputs.add(inputs); + if (primaryInput) { + myCommandDependencies.add(0, inputs); } else { - done = false; - break; + myCommandDependencies.add(inputs); + } + //myEnumeratedInputs.add(inputs); + } catch( BuildException ex ) { + } + + } else { + + // Build Variable? + if (variable.length() > 0) { + String cmdVariable = variable = "$(" + variable + ")"; //$NON-NLS-1$ //$NON-NLS-2$ + myCommandInputs.add(cmdVariable); + if (primaryInput) { + myCommandDependencies.add(0, cmdVariable); + } else { + myCommandDependencies.add(cmdVariable); + } + // If there is an output variable with the same name, get + // the files associated with it. + List outMacroList = makeGen.getBuildVariableList(variable, true); + if (outMacroList != null) { + myEnumeratedInputs.addAll(outMacroList); + } else { + // If "last chance", then calculate using file extensions below + if (lastChance) { + useFileExts = true; + } else { + done = false; + break; + } } } - } - if (variable.length() == 0 || useFileExts) { - if (type.getMultipleOfType()) { - // Calculate myEnumeratedInputs using the file extensions and the resources in the project - String[] exts = tool.getAllInputExtensions(); - if (projResources != null) { - for (int j=0; jmake. + * + * NOTE: If an option is not specified and this is not the primary output type, the outputs + * from the type are not added to the command line */ public boolean calculateOutputs(GnuMakefileGenerator makeGen, HashSet handledInputExtensions, boolean lastChance) { boolean done = true; Vector myCommandOutputs = new Vector(); - Vector myEnumeratedOutputs = new Vector(); + Vector myEnumeratedPrimaryOutputs = new Vector(); + Vector myEnumeratedSecondaryOutputs = new Vector(); HashMap myOutputMacros = new HashMap(); // The next two fields are used together Vector myBuildVars = new Vector(); @@ -272,9 +329,9 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { String variable = type.getBuildVariable(); boolean multOfType = type.getMultipleOfType(); boolean primaryOutput = (type == tool.getPrimaryOutputType()); - IOption option = makeGen.getOption(tool, type.getOptionId()); + IOption option = tool.getOptionBySuperClassId(type.getOptionId()); IManagedOutputNameProvider nameProvider = type.getNameProvider(); - String outputNames = type.getOutputNames(); + String[] outputNames = type.getOutputNames(); // 1. If the tool is the build target and this is the primary output, // use artifact name & extension @@ -306,7 +363,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { } } } - myCommandOutputs.addAll(outputs); + //myCommandOutputs.addAll(outputs); typeEnumeratedOutputs.addAll(outputs); if (variable.length() > 0) { if (myOutputMacros.containsKey(variable)) { @@ -334,7 +391,9 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { } outNames = nameProvider.getOutputNames(tool, inputPaths); if (outNames != null) { - myCommandOutputs.addAll(Arrays.asList(outNames)); + if (primaryOutput) { + myCommandOutputs.addAll(Arrays.asList(outNames)); + } typeEnumeratedOutputs.addAll(Arrays.asList(outNames)); } } @@ -350,10 +409,11 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { } else // 4. If outputNames is specified, use it if (outputNames != null) { - String[] pathTokens = outputNames.split(";"); //$NON-NLS-1$ - if (pathTokens.length > 0) { - List namesList = Arrays.asList(pathTokens); - myCommandOutputs.addAll(namesList); + if (outputNames.length > 0) { + List namesList = Arrays.asList(outputNames); + if (primaryOutput) { + myCommandOutputs.addAll(namesList); + } typeEnumeratedOutputs.addAll(namesList); if (variable.length() > 0) { if (myOutputMacros.containsKey(variable)) { @@ -405,7 +465,9 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { fileName = "default"; //$NON-NLS-1$ } // Replace the % with the file name - myCommandOutputs.add(namePattern.replaceAll("%", fileName)); //$NON-NLS-1$ + if (primaryOutput) { + myCommandOutputs.add(namePattern.replaceAll("%", fileName)); //$NON-NLS-1$ + } typeEnumeratedOutputs.add(namePattern.replaceAll("%", fileName)); //$NON-NLS-1$ if (variable.length() > 0) { List outputs = new ArrayList(); @@ -425,7 +487,11 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { myBuildVars.add(variable); myBuildVarsValues.add(typeEnumeratedOutputs); } - myEnumeratedOutputs.addAll(typeEnumeratedOutputs); + if (primaryOutput) { + myEnumeratedPrimaryOutputs.addAll(typeEnumeratedOutputs); + } else { + myEnumeratedSecondaryOutputs.addAll(typeEnumeratedOutputs); + } } } else { if (bIsTargetTool) { @@ -435,7 +501,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { outputName += (DOT + targetExt); } myCommandOutputs.add(outputName); - myEnumeratedOutputs.add(outputName); + myEnumeratedPrimaryOutputs.add(outputName); } else { // For support of pre-CDT 3.0 integrations. // NOTE WELL: This only supports the case of a single "target tool" @@ -463,7 +529,8 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { if (done) { commandOutputs.addAll(myCommandOutputs); - enumeratedOutputs.addAll(myEnumeratedOutputs); + enumeratedPrimaryOutputs.addAll(myEnumeratedPrimaryOutputs); + enumeratedSecondaryOutputs.addAll(myEnumeratedSecondaryOutputs); outputVariables.addAll(myOutputMacros.keySet()); outputsCalculated = true; for (int i=0; iIProject that needs to be upgraded + * @throws CoreException + */ + static void doProjectUpdate(IProgressMonitor monitor, final IProject project) throws CoreException { + String[] projectName = new String[]{project.getName()}; + IFile file = project.getFile(ManagedBuildManager.SETTINGS_FILE_NAME); + File settingsFile = file.getLocation().toFile(); + if (!settingsFile.exists()) { + monitor.done(); + return; + } + + // Backup the file + monitor.beginTask(ConverterMessages.getFormattedString("UpdateManagedProject20.0", projectName), 1); //$NON-NLS-1$ + IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); + UpdateManagedProjectManager.backupFile(file, "_21backup", monitor, project); //$NON-NLS-1$ + // No physical conversion is need since the 3.0 model is a superset of the 2.1 model + // Just upgrade the version + ((ManagedBuildInfo)info).setVersion(ManagedBuildManager.getBuildInfoVersion().toString()); + info.setValid(true); + + // Save the updated file + // If the tree is locked spawn a job to this. + IWorkspace workspace = project.getWorkspace(); + boolean treeLock = workspace.isTreeLocked(); + ISchedulingRule rule = workspace.getRuleFactory().createRule(project); + if (treeLock) { + WorkspaceJob job = new WorkspaceJob("Updating managed Project") { + public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { + ManagedBuildManager.saveBuildInfo(project, true); + return Status.OK_STATUS; + } + }; + job.setRule(rule); + job.schedule(); + } else { + ManagedBuildManager.saveBuildInfo(project, true); + } + monitor.done(); + } +} diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java index 6cb433cf7c3..3726ecdad8b 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2004 Intel Corporation and others. + * Copyright (c) 2004, 2005 Intel 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 @@ -112,7 +112,7 @@ public class UpdateManagedProjectManager { PluginVersionIdentifier compVersion = ManagedBuildManager.getBuildInfoVersion(); - if(projVersion.isEquivalentTo(compVersion)) + if(compVersion.isEquivalentTo(projVersion)) return true; return false; } @@ -291,6 +291,10 @@ public class UpdateManagedProjectManager { UpdateManagedProject20.doProjectUpdate(monitor, fProject); version = getManagedBuildInfoVersion(info.getVersion()); } + if(version.isEquivalentTo(new PluginVersionIdentifier(2,1,0))){ + UpdateManagedProject21.doProjectUpdate(monitor, fProject); + version = getManagedBuildInfoVersion(info.getVersion()); + } if(!isCompatibleProject(info)){ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1, diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml index 587086b25e6..7d9c205c958 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml @@ -118,12 +118,9 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id="cdt.managedbuild.tool.gnu.archiver.cygwin.lib.release" + superClass="cdt.managedbuild.tool.gnu.archiver"> - - + @@ -2187,6 +2343,7 @@ archList="all" osList="macosx" name="%ToolChainName.Dbg" + targetTool="cdt.managedbuild.tool.macosx.c.linker.macosx.exe.debug;cdt.managedbuild.tool.macosx.cpp.linker.macosx.exe.debug" scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile" id="cdt.managedbuild.toolchain.gnu.macosx.exe.debug"> + + + + + + + +