diff options
author | Leo Treggiari | 2005-05-09 03:37:42 +0000 |
---|---|---|
committer | Leo Treggiari | 2005-05-09 03:37:42 +0000 |
commit | 5bde16a1f94ebe5b52d4d065b2aa5f7315b62cb3 (patch) | |
tree | 31c921b790d4ecffa10859849ae62c303e410dc8 /build/org.eclipse.cdt.managedbuilder.core | |
parent | 05adf9b80590c9eeea445ecb8dd8a475816ab4c1 (diff) | |
download | org.eclipse.cdt-5bde16a1f94ebe5b52d4d065b2aa5f7315b62cb3.tar.gz org.eclipse.cdt-5bde16a1f94ebe5b52d4d065b2aa5f7315b62cb3.tar.xz org.eclipse.cdt-5bde16a1f94ebe5b52d4d065b2aa5f7315b62cb3.zip |
Second set of changes for multiple input & output
Gnu definitions are updated to use new schema elements
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.core')
21 files changed, 701 insertions, 263 deletions
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"/> </extension> +<!-- =================================================================================== --> +<!-- Define C/C++ "object" files ContentTypes --> +<!-- =================================================================================== --> + <extension point="org.eclipse.core.runtime.contentTypes"> + <!-- declares a content type for object files --> + <content-type id="compiledObjectFile" name="%objectFileName" + priority="high"/> + <!-- declares a content type for executable files --> + <content-type id="executableFile" name="%executableName" + priority="high"/> + <!-- declares a content type for static libraries --> + <content-type id="staticLibrary" name="%staticLibraryName" + priority="high"/> + <!-- declares a content type for shared libraries --> + <content-type id="sharedLibrary" name="%sharedLibraryName" + priority="high"/> + </extension> + + <extension point="org.eclipse.core.runtime.contentTypes"> + <file-association + content-type="org.eclipse.cdt.managedbuilder.core.compiledObjectFile" + file-extensions="obj,o"/> + </extension> + + <extension point="org.eclipse.core.runtime.contentTypes"> + <file-association + content-type="org.eclipse.cdt.managedbuilder.core.executableFile" + file-extensions="exe,"/> + </extension> + + <extension point="org.eclipse.core.runtime.contentTypes"> + <file-association + content-type="org.eclipse.cdt.managedbuilder.core.staticLibrary" + file-extensions="lib,a"/> + </extension> + + <extension point="org.eclipse.core.runtime.contentTypes"> + <file-association + content-type="org.eclipse.cdt.managedbuilder.core.sharedLibrary" + file-extensions="dll,so"/> + </extension> + </plugin> 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 <meta.section type="examples"/>
</appInfo>
<documentation>
- 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.]
</documentation>
</annotation>
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 <code>IOption</code> in the receiver with the specified + * ID, or an option with a superclass with this id. + * + * <p>If the receiver does not have an option with that ID, the method + * returns <code>null</code>. It is the responsibility of the caller to + * verify the return value. + * + * @param id unique identifier of the option to search for + * @return <code>IOption</code> + * @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<targetToolIds.length; i++) { + String targetToolId = targetToolIds[i]; + for (int j=0; j<tools.length; j++) { + ITool targetTool = tools[j]; + ITool tool = targetTool; + do { + if (targetToolId.equals(tool.getId())) { + return targetTool; + } + tool = tool.getSuperClass(); + } while (tool != null); + } } - return null; } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java index 015f080e8dd..d32325a5eb7 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java @@ -595,7 +595,7 @@ public class InputType extends BuildObject implements IInputType { while (iter.hasNext()) { AdditionalInput ai = (AdditionalInput) iter.next(); boolean match = false; - String[] tokens = ai.getPaths().split(";"); //$NON-NLS-1$ + String[] tokens = ai.getPaths(); if (tokens.length == inputTokens.length) { match = true; for (int i = 0; i < tokens.length; i++) { @@ -637,11 +637,10 @@ public class InputType extends BuildObject implements IInputType { int kind = current.getKind(); if (kind == IAdditionalInput.KIND_ADDITIONAL_DEPENDENCY || kind == IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY) { - String paths = current.getPaths(); + String[] paths = current.getPaths(); if (paths != null) { - String[] pathTokens = paths.split(";"); //$NON-NLS-1$ - for (int i = 0; i < pathTokens.length; i++) { - deps.add(Path.fromOSString(pathTokens[i])); + for (int i = 0; i < paths.length; i++) { + deps.add(Path.fromOSString(paths[i])); } } } @@ -660,11 +659,10 @@ public class InputType extends BuildObject implements IInputType { int kind = current.getKind(); if (kind == IAdditionalInput.KIND_ADDITIONAL_INPUT || kind == IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY) { - String paths = current.getPaths(); + String[] paths = current.getPaths(); if (paths != null) { - String[] pathTokens = paths.split(";"); //$NON-NLS-1$ - for (int i = 0; i < pathTokens.length; i++) { - ins.add(Path.fromOSString(pathTokens[i])); + for (int i = 0; i < paths.length; i++) { + ins.add(Path.fromOSString(paths[i])); } } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java index 571007d30ae..92fa003c498 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java @@ -440,13 +440,12 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { } } } + //add paths specified in the environment + String envIncludePaths[] = ManagedBuildManager.getEnvironmentVariableProvider().getBuildPaths(config,IEnvVarBuildPath.BUILDPATH_INCLUDE); + if(envIncludePaths != null) + paths.addAll(Arrays.asList(envIncludePaths)); } - - //add paths specified in the environment - String envIncludePaths[] = ManagedBuildManager.getEnvironmentVariableProvider().getBuildPaths(config,IEnvVarBuildPath.BUILDPATH_INCLUDE); - if(envIncludePaths != null) - paths.addAll(Arrays.asList(envIncludePaths)); - + // Answer the results as an array return (String[])paths.toArray(new String[paths.size()]); } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OutputType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OutputType.java index d7f9ed7b597..a5969f547dc 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OutputType.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OutputType.java @@ -685,7 +685,7 @@ public class OutputType extends BuildObject implements IOutputType { /* (non-Javadoc) * @see org.eclipse.cdt.core.build.managed.IOuputType#getOutputNames() */ - public String getOutputNames() { + public String[] getOutputNames() { if (outputNames == null) { // If I have a superClass, ask it if (superClass != null) { @@ -694,14 +694,15 @@ public class OutputType extends BuildObject implements IOutputType { return null; } } - return outputNames; + String[] nameTokens = outputNames.split(";"); //$NON-NLS-1$ + return nameTokens; } /* (non-Javadoc) * @see org.eclipse.cdt.core.build.managed.IOuputType#setOutputNames() */ - public void getOutputNames(String names) { + public void setOutputNames(String names) { if (names == null && outputNames == null) return; if (outputNames == null || names == null || !(names.equals(outputNames))) { outputNames = names; @@ -713,14 +714,16 @@ public class OutputType extends BuildObject implements IOutputType { * @see org.eclipse.cdt.core.build.managed.IOuputType#getPrimaryInputType() */ public IInputType getPrimaryInputType() { - if (primaryInputType == null) { + IInputType ret = primaryInputType; + if (ret == null) { if (superClass != null) { - return superClass.getPrimaryInputType(); - } else { - return null; + ret = superClass.getPrimaryInputType(); + } + if (ret == null) { + ret = getParent().getPrimaryInputType(); } } - return primaryInputType; + return ret; } /* (non-Javadoc) diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java index 4e8f53326a9..3e052ac304a 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java @@ -242,9 +242,11 @@ public class Tool extends BuildObject implements ITool, IOptionCategory { } else if (toolElement.getNodeName().equals(ITool.OPTION_CAT)) { new OptionCategory(this, (Element)toolElement); } else if (toolElement.getNodeName().equals(ITool.INPUT_TYPE)) { - new InputType(this, (Element)toolElement); + InputType inputType = new InputType(this, (Element)toolElement); + addInputType(inputType); } else if (toolElement.getNodeName().equals(ITool.OUTPUT_TYPE)) { - new OutputType(this, (Element)toolElement); + OutputType outputType = new OutputType(this, (Element)toolElement); + addOutputType(outputType); } } } @@ -924,6 +926,28 @@ public class Tool extends BuildObject implements ITool, IOptionCategory { } /* (non-Javadoc) + * @see org.eclipse.cdt.core.build.managed.ITool#getOptionBySuperClassId(java.lang.String) + */ + public IOption getOptionBySuperClassId(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 = 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; + } + + /* (non-Javadoc) * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getChildCategories() */ public IOptionCategory[] getChildCategories() { @@ -973,7 +997,8 @@ public class Tool extends BuildObject implements ITool, IOptionCategory { IInputType ourType = (IInputType)ourTypes.get(i); int j; for (j = 0; j < types.length; j++) { - if (ourType.getSuperClass().getId().equals(types[j].getId())) { + if (ourType.getSuperClass() != null && + ourType.getSuperClass().getId().equals(types[j].getId())) { types[j] = ourType; break; } @@ -1045,7 +1070,8 @@ public class Tool extends BuildObject implements ITool, IOptionCategory { IOutputType ourType = (IOutputType)ourTypes.get(i); int j; for (j = 0; j < types.length; j++) { - if (ourType.getSuperClass().getId().equals(types[j].getId())) { + if (ourType.getSuperClass() != null && + ourType.getSuperClass().getId().equals(types[j].getId())) { types[j] = ourType; break; } @@ -1533,10 +1559,37 @@ public class Tool extends BuildObject implements ITool, IOptionCategory { List allDeps = new ArrayList(); IInputType[] types = getInputTypes(); for (int i=0; i<types.length; i++) { - IPath[] deps = types[i].getAdditionalDependencies(); + IInputType type = types[i]; + // Additional dependencies come from 2 places. + // 1. From AdditionalInput childen + IPath[] deps = type.getAdditionalDependencies(); for (int j=0; j<deps.length; j++) { allDeps.add(deps[j]); } + // 2. From InputTypes that other than the primary input type + if (!type.getPrimaryInput()) { + if (type.getOptionId() != null) { + IOption option = getOptionBySuperClassId(type.getOptionId()); + 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(); + } + allDeps.addAll(inputs); + } catch( BuildException ex ) { + } + } + } else if (type.getBuildVariable() != null && type.getBuildVariable().length() > 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<types.length; i++) { - IPath[] res = types[i].getAdditionalResources(); + IInputType type = types[i]; + // Additional dependencies come from 2 places. + // 1. From AdditionalInput childen + IPath[] res = type.getAdditionalResources(); for (int j=0; j<res.length; j++) { allRes.add(res[j]); } + // 2. From InputTypes that other than the primary input type + if (!type.getPrimaryInput()) { + String var = type.getBuildVariable(); + if (var != null && var.length() > 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,21 +839,46 @@ 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) */ public String getErrorParserIds(IConfiguration config) { @@ -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<outs2.size(); i++) { + buffer.append(WHITESPACE + (String)outs2.get(i)); + } + buffer.append(NEWLINE + NEWLINE); + } + // Add all the needed dummy and phony targets buffer.append(".PHONY: all clean dependents" + NEWLINE); //$NON-NLS-1$ buffer.append(".SECONDARY:"); //$NON-NLS-1$ @@ -1340,14 +1360,23 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { Vector inputs = new Vector(); Vector dependencies = new Vector(); Vector outputs = new Vector(); - Vector enumeratedOutputs = new Vector(); + Vector enumeratedPrimaryOutputs = new Vector(); + Vector enumeratedSecondaryOutputs = new Vector(); Vector outputVariables = new Vector(); String outputPrefix = EMPTY_STRING; - if (!getToolInputsOutputs(tool, inputs, dependencies, outputs, enumeratedOutputs, outputVariables, - bTargetTool, managedProjectOutputs)) { + + if (!getToolInputsOutputs(tool, inputs, dependencies, outputs, + enumeratedPrimaryOutputs, enumeratedSecondaryOutputs, + outputVariables, bTargetTool, managedProjectOutputs)) { return false; } + // If we have no primary output, make all of the secondary outputs the primary output + if (enumeratedPrimaryOutputs.size() == 0) { + enumeratedPrimaryOutputs = enumeratedSecondaryOutputs; + enumeratedSecondaryOutputs.clear(); + } + // Add the output variables for this tool to our list outputVarsAdditionsList.addAll(outputVariables); @@ -1355,20 +1384,20 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { String buildRule = EMPTY_STRING; String outflag = tool.getOutputFlag(); - Iterator iter = enumeratedOutputs.listIterator(); + String primaryOutputs = EMPTY_STRING; boolean first = true; - while(iter.hasNext()) { - String output = (String)iter.next(); - if (!first) buildRule += WHITESPACE; + for (int i=0; i<enumeratedPrimaryOutputs.size(); i++) { + String output = (String)enumeratedPrimaryOutputs.get(i); + if (!first) primaryOutputs += WHITESPACE; first = false; - buildRule += output; + primaryOutputs += output; } - buildRule += (COLON + WHITESPACE); - iter = inputs.listIterator(); + + buildRule += (primaryOutputs + COLON + WHITESPACE); + first = true; - iter = dependencies.listIterator(); - while(iter.hasNext()) { - String input = (String)iter.next(); + for (int i=0; i<dependencies.size(); i++) { + String input = (String)dependencies.get(i); if (!first) buildRule += WHITESPACE; first = false; buildRule += input; @@ -1398,7 +1427,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { String[] cmdInputs = (String[])inputs.toArray(new String[inputs.size()]); IManagedCommandLineGenerator gen = tool.getCommandLineGenerator(); IManagedCommandLineInfo cmdLInfo = gen.generateCommandLineInfo( tool, tool.getToolCommand(), - flags, outflag, outputPrefix, OUT_MACRO, cmdInputs, tool.getCommandLinePattern() ); + flags, outflag, outputPrefix, primaryOutputs, cmdInputs, tool.getCommandLinePattern() ); // The command to build String buildCmd = null; if( cmdLInfo == null ) { @@ -1409,7 +1438,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { // TODO report error toolFlags = EMPTY_STRING; } - buildCmd = tool.getToolCommand() + WHITESPACE + toolFlags + WHITESPACE + outflag + WHITESPACE + outputPrefix + OUT_MACRO + WHITESPACE + IN_MACRO; + buildCmd = tool.getToolCommand() + WHITESPACE + toolFlags + WHITESPACE + outflag + WHITESPACE + outputPrefix + primaryOutputs + WHITESPACE + IN_MACRO; } else buildCmd = cmdLInfo.getCommandLine(); buffer.append(TAB + AT + ECHO + WHITESPACE + buildCmd + NEWLINE); @@ -1426,6 +1455,17 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + MESSAGE_FINISH_FILE + WHITESPACE + OUT_MACRO + SINGLE_QUOTE + NEWLINE); } buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + WHITESPACE + SINGLE_QUOTE + NEWLINE + NEWLINE); + + // If we have secondary outputs, output dependency rules without commands + if (enumeratedSecondaryOutputs.size() > 0) { + String primaryOutput = (String)enumeratedPrimaryOutputs.get(0); + for (int i=0; i<enumeratedSecondaryOutputs.size(); i++) { + String output = (String)enumeratedSecondaryOutputs.get(0); + buffer.append(output + COLON + WHITESPACE + primaryOutput + NEWLINE); + } + buffer.append(NEWLINE); + } + return true; } @@ -1465,8 +1505,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { } protected boolean getToolInputsOutputs(ITool tool, - Vector inputs, Vector dependencies, Vector outputs, Vector enumeratedOutputs, Vector outputVariables, - boolean bTargetTool, Vector managedProjectOutputs) { + Vector inputs, Vector dependencies, Vector outputs, + Vector enumeratedPrimaryOutputs, Vector enumeratedSecondaryOutputs, + Vector outputVariables, boolean bTargetTool, Vector managedProjectOutputs) { // Get the information regarding the tool's inputs and outputs from the objects // created by calculateToolInputsOutputs @@ -1482,7 +1523,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { // Populate the output Vectors inputs.addAll(toolInfo.getCommandInputs()); outputs.addAll(toolInfo.getCommandOutputs()); - enumeratedOutputs.addAll(toolInfo.getEnumeratedOutputs()); + enumeratedPrimaryOutputs.addAll(toolInfo.getEnumeratedPrimaryOutputs()); + enumeratedSecondaryOutputs.addAll(toolInfo.getEnumeratedSecondaryOutputs()); outputVariables.addAll(toolInfo.getOutputVariables()); dependencies.addAll(toolInfo.getCommandDependencies()); @@ -1494,6 +1536,37 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { } return true; } + + /* (non-Javadoc) + * @param fileHandle + * @throws CoreException + */ + protected Vector calculateSecondaryOutputs(IOutputType[] secondaryOutputs) { + Vector buildVars = new Vector(); + for (int i=0; i<buildTools.length; i++) { + // Add the specified output build variables + IOutputType[] outTypes = buildTools[i].getOutputTypes(); + if (outTypes != null && outTypes.length > 0) { + for (int j=0; j<outTypes.length; j++) { + IOutputType outType = outTypes[j]; + // Is this one of the secondary outputs? + // Look for an outputType with this ID, or one with a superclass with this id + thisType: + for (int k = 0; k < secondaryOutputs.length; k++) { + IOutputType matchType = outType; + do { + if (matchType.getId().equals(secondaryOutputs[k].getId())) { + buildVars.add(outType.getBuildVariable()); + break thisType; + } + matchType = matchType.getSuperClass(); + } while (matchType != null); + } + } + } + } + return buildVars; + } /************************************************************************* @@ -1566,16 +1639,16 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); String macroName = (String)entry.getKey(); - addMacroAdditionPrefix(buildVarToRuleStringMap, macroName, "$(ROOT)/" + relativePath, true); //$NON-NLS-1$ + addMacroAdditionPrefix(buildVarToRuleStringMap, macroName, null, false); } iterator = buildOutVars.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); String macroName = (String)entry.getKey(); - addMacroAdditionPrefix(buildVarToRuleStringMap, macroName, "./" + relativePath, true); + addMacroAdditionPrefix(buildVarToRuleStringMap, macroName, "./" + relativePath, true); //$NON-NLS-1$ } // Create an entry for the DEPS macro - addMacroAdditionPrefix(buildVarToRuleStringMap, DEPS_MACRO, "./" + relativePath, true); + addMacroAdditionPrefix(buildVarToRuleStringMap, DEPS_MACRO, "./" + relativePath, true); //$NON-NLS-1$ // String buffers StringBuffer buffer = new StringBuffer(); // Return buffer @@ -1601,7 +1674,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { } // Write out the macro addition entries to the buffer - buffer.append(writeAdditionMacros(buildVarToRuleStringMap, true)); + buffer.append(writeAdditionMacros(buildVarToRuleStringMap)); return buffer.append(ruleBuffer + NEWLINE); } @@ -1642,7 +1715,20 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { continue; } // Add the resource name to the makefile line that adds resources to the build variable - addMacroAdditionFile(buildVarToRuleStringMap, varName, resource.getName()); + String srcName; + if (generatedSource) { + srcName = resource.getName(); + } else { + String resourceLocation = resource.getLocation().toString(); + String projectLocation = project.getLocation().toString(); + //if (resource.isLinked()) { NOTE: we don't use this since children of linked resources return false + if(!resourceLocation.startsWith(projectLocation)) { + srcName = resourceLocation; + } else { + srcName = "$(ROOT)/" + relativePath + resource.getName(); //$NON-NLS-1$ + } + } + addMacroAdditionFile(buildVarToRuleStringMap, varName, srcName); // Generate the rule to build this source file IInputType inputType = tool.getInputType(ext); @@ -1670,7 +1756,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { // For support of pre-CDT 3.0 integrations. buildVariable = OBJS_MACRO; //$NON-NLS-1$ } - Vector generatedOutputs = calculateOutputsForSource(tool, relativePath, resource); + Vector generatedOutputs = calculateOutputsForSource(tool, relativePath, resource, false); for (int k=0; k<generatedOutputs.size(); k++) { // TODO - this will only work for outputs generated below the build output directory? // try an option that generates an output outside of the project @@ -1724,13 +1810,14 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { String outflag = null; String outputPrefix = null; IManagedDependencyGenerator depGen = info.getDependencyGenerator(inputExtension); - boolean doDepGen = (depGen != null && depGen.getCalculatorType() == IManagedDependencyGenerator.TYPE_COMMAND); + boolean doDepGen = (depGen != null && depGen.getCalculatorType() == IManagedDependencyGenerator.TYPE_COMMAND); + boolean patternRule = false; // If the tool creates a dependency file, add it to the list if (doDepGen) { String depFile = relativePath + resourceName + DOT + DEP_EXT; getDependencyMakefiles().add(depFile); - generatedDepFile.append(depFile); + generatedDepFile.append(resourceName + DOT + DEP_EXT); } /* @@ -1755,15 +1842,27 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { // We need to check whether we have any resource specific build information. IResourceConfiguration resConfig = null; if( config != null ) resConfig = config.getResourceConfiguration(resource.getFullPath().toString()); + + ITool tool; + if( resConfig != null) { + ITool[] tools = resConfig.getTools(); + tool = tools[0]; + } else { + tool = info.getToolFromInputExtension(inputExtension); + } // figure out path to use to resource + String primaryOutputName = EMPTY_STRING; + String primaryDependencyName = EMPTY_STRING; + //if (resource.isLinked()) { NOTE: we don't use this since children of linked resources return false if(!resourceLocation.toString().startsWith(projectLocation)) { // it IS linked, so use the actual location isItLinked = true; resourcePath = resourceLocation.toString(); // Need a hardcoded rule, not a pattern rule, as a linked file // can reside in any path - buildRule = relativePath + resourceName + OptDotExt + COLON + WHITESPACE + resourcePath; + primaryOutputName = relativePath + resourceName + OptDotExt; + primaryDependencyName = resourcePath; } else { // use the relative path (not really needed to store per se but in the future someone may want this) resourcePath = relativePath; @@ -1771,33 +1870,35 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { // The rule and command to add to the makefile String home = (generatedSource)? DOT : ROOT; if( resConfig != null) { - buildRule = resourcePath + resourceName + OptDotExt + COLON + WHITESPACE + home + SEPARATOR + resourcePath + resourceName + DOT + inputExtension; + // Need a hardcoded rule, not a pattern rule + primaryOutputName = resourcePath + resourceName + OptDotExt; + primaryDependencyName = home + SEPARATOR + resourcePath + resourceName + DOT + inputExtension; } else { - buildRule = relativePath + WILDCARD + OptDotExt + COLON + WHITESPACE + home + SEPARATOR + resourcePath + WILDCARD + DOT + inputExtension; + primaryOutputName = relativePath + WILDCARD + OptDotExt; + primaryDependencyName = home + SEPARATOR + resourcePath + WILDCARD + DOT + inputExtension; + patternRule = true; } } // end fix for PR 70491 - // Add any additional dependencies specified: - // 1. in additionalInput elements - // 2. from a dependency calculator not of TYPE_COMMAND - ITool tool; - if( resConfig != null) { - ITool[] tools = resConfig.getTools(); - tool = tools[0]; - } else { - tool = info.getToolFromInputExtension(inputExtension); + buildRule = primaryOutputName; + + // If this is a pattern rule, add any additional outputs here + String otherPrimaryOutputs = EMPTY_STRING; + if (patternRule) { + Vector addlOutputs = calculateOutputsForSource(tool, relativePath, resource, true); + for (int i=0; i<addlOutputs.size(); i++) { + otherPrimaryOutputs += WHITESPACE + ((IPath)addlOutputs.get(i)).toString(); + } } - // Get any additional dependencies specified for the tool + + buildRule += otherPrimaryOutputs + COLON + WHITESPACE + primaryDependencyName; + + // Other additional inputs + // Get any additional dependencies specified for the tool in other InputType elements and AdditionalInput elements IPath[] addlDepPaths = tool.getAdditionalDependencies(); for (int i=0; i<addlDepPaths.length; i++) { buildRule += WHITESPACE + addlDepPaths[i].toString(); } - if (depGen != null && depGen.getCalculatorType() != IManagedDependencyGenerator.TYPE_COMMAND) { - Vector addlDepsVector = calculateDependenciesForSource(depGen, tool, relativePath, resource); - for (int i=0; i<addlDepsVector.size(); i++) { - buildRule += WHITESPACE + addlDepsVector.get(i).toString(); - } - } // No duplicates in a makefile if (getRuleList().contains(buildRule)) { @@ -1824,7 +1925,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { // TODO add some routines to catch this flags = EMPTY_STRING_ARRAY; } - // Get any additional dependencies specified for the tool + // Other additional inputs + // Get any additional dependencies specified for the tool in other InputType elements and AdditionalInput elements IPath[] addlInputPaths = tool.getAdditionalResources(); for (int i=0; i<addlInputPaths.length; i++) { inputs.add(addlDepPaths[i].toString()); @@ -1832,7 +1934,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { // Call the command line generator IManagedCommandLineGenerator cmdLGen = tool.getCommandLineGenerator(); cmdLInfo = cmdLGen.generateCommandLineInfo( tool, cmd, flags, outflag, outputPrefix, - OUT_MACRO, (String[])inputs.toArray(new String[inputs.size()]), tool.getCommandLinePattern() ); + OUT_MACRO + otherPrimaryOutputs, (String[])inputs.toArray(new String[inputs.size()]), tool.getCommandLinePattern() ); String buildCmd = cmdLInfo.getCommandLine(); buffer.append(TAB + AT + ECHO + WHITESPACE + buildCmd + NEWLINE); @@ -1847,17 +1949,19 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { outflag = info.getOutputFlag(outputExtension); outputPrefix = info.getOutputPrefix(outputExtension); String[] flags = buildFlags.split( "\\s" ); //$NON-NLS-1$ - // Get any additional dependencies specified for the tool + // Other additional inputs + // Get any additional dependencies specified for the tool in other InputType elements and AdditionalInput elements IPath[] addlInputPaths = tool.getAdditionalResources(); for (int i=0; i<addlInputPaths.length; i++) { inputs.add(addlDepPaths[i].toString()); } // Call the command line generator cmdLInfo = info.generateCommandLineInfo( inputExtension, flags, outflag, outputPrefix, - OUT_MACRO, (String[])inputs.toArray(new String[inputs.size()]) ); + OUT_MACRO + otherPrimaryOutputs, (String[])inputs.toArray(new String[inputs.size()]) ); // The command to build String buildCmd = null; - if( cmdLInfo == null ) buildCmd = cmd + WHITESPACE + buildFlags + WHITESPACE + outflag + WHITESPACE + outputPrefix + OUT_MACRO + WHITESPACE + IN_MACRO; + if( cmdLInfo == null ) buildCmd = cmd + WHITESPACE + buildFlags + WHITESPACE + + outflag + WHITESPACE + outputPrefix + OUT_MACRO + otherPrimaryOutputs + WHITESPACE + IN_MACRO; else buildCmd = cmdLInfo.getCommandLine(); buffer.append(TAB + AT + ECHO + WHITESPACE + buildCmd + NEWLINE); buffer.append(TAB + AT + buildCmd); @@ -1875,6 +1979,30 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { buffer.append(NEWLINE); buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + MESSAGE_FINISH_FILE + WHITESPACE + IN_MACRO + SINGLE_QUOTE + NEWLINE); buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + WHITESPACE + SINGLE_QUOTE + NEWLINE + NEWLINE); + + + // Add separate dependency lines per file if necessary + boolean addedDepLines = false; + if (depGen != null && depGen.getCalculatorType() != IManagedDependencyGenerator.TYPE_COMMAND) { + Vector addlDepsVector = calculateDependenciesForSource(depGen, tool, relativePath, resource); + for (int i=0; i<addlDepsVector.size(); i++) { + buffer.append(primaryOutputName + COLON + WHITESPACE + addlDepsVector.get(i).toString() + NEWLINE); + addedDepLines = true; + } + } + + // If this is NOT a pattern rule, add any additional outputs here using dependency lines + if (!patternRule) { + Vector addlOutputs = calculateOutputsForSource(tool, relativePath, resource, true); + for (int i=0; i<addlOutputs.size(); i++) { + buffer.append(((IPath)addlOutputs.get(i)).toString() + COLON + WHITESPACE + primaryOutputName + NEWLINE); + addedDepLines = true; + } + } + if (addedDepLines) { + buffer.append(NEWLINE); + } + } /* (non-Javadoc) @@ -1895,7 +2023,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { * @param resource * @return Vector of IPaths that are relative to the build directory */ - protected Vector calculateOutputsForSource(ITool tool, String relativePath, IResource resource) { + protected Vector calculateOutputsForSource(ITool tool, + String relativePath, IResource resource, boolean ignorePrimary) { Vector outputs = new Vector(); String inExt = resource.getFileExtension(); String outExt = tool.getOutputExtension(inExt); @@ -1904,13 +2033,14 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { if (outTypes != null && outTypes.length > 0) { for (int i=0; i<outTypes.length; i++) { IOutputType type = outTypes[i]; + boolean primaryOutput = (type == tool.getPrimaryOutputType()); + if (primaryOutput && ignorePrimary) continue; String outputPrefix = type.getOutputPrefix(); String variable = type.getBuildVariable(); boolean multOfType = type.getMultipleOfType(); - boolean primaryOutput = (type == tool.getPrimaryOutputType()); - IOption option = 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 @@ -1950,9 +2080,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { } else // 4. If outputNames is specified, use it if (outputNames != null) { - String[] pathTokens = outputNames.split(";"); //$NON-NLS-1$ - for (int j = 0; j < pathTokens.length; j++) { - outputs.add(Path.fromOSString(pathTokens[j])); + for (int j = 0; j < outputNames.length; j++) { + outputs.add(Path.fromOSString(outputNames[j])); } } else { // 4. Use the name pattern to generate a transformation macro @@ -1990,14 +2119,16 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { // In this case, the output file name is the input file name with // the output extension. - IPath outPath = resource.getFullPath().removeFileExtension(); - String outPrefix = tool.getOutputPrefix(); - if (outPrefix.length() > 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<inTypes.length; i++) { IInputType type = inTypes[i]; String variable = type.getBuildVariable(); + boolean primaryInput = type.getPrimaryInput(); boolean useFileExts = false; - if (variable.length() > 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; j<projResources.length; j++) { - if (projResources[i].getType() == IResource.FILE) { - String fileExt = projResources[i].getFileExtension(); - for (int k=0; k<exts.length; k++) { - if (fileExt.equals(exts[k])) { - // TODO - is project relative correct? - if (!useFileExts) { - myCommandInputs.add(projResources[i].getProjectRelativePath()); + + // Use file extensions + 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; j<projResources.length; j++) { + if (projResources[i].getType() == IResource.FILE) { + String fileExt = projResources[i].getFileExtension(); + for (int k=0; k<exts.length; k++) { + if (fileExt.equals(exts[k])) { + // TODO - is project relative correct? + if (!useFileExts) { + myCommandInputs.add(projResources[i].getProjectRelativePath()); + if (primaryInput) { + myCommandDependencies.add(0, projResources[i].getProjectRelativePath()); + } else { + myCommandDependencies.add(projResources[i].getProjectRelativePath()); + } + } + myEnumeratedInputs.add(projResources[i].getProjectRelativePath()); + break; } - myEnumeratedInputs.add(projResources[i].getProjectRelativePath()); - break; } } } } + } else { + // Rule will be generated by addRuleForSource } - } else { - // Rule will be generated by addRuleForSource } } + // Get any additional inputs specified in the manifest file or the project file IAdditionalInput[] addlInputs = type.getAdditionalInputs(); if (addlInputs != null) { @@ -201,12 +255,11 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { int kind = addlInput.getKind(); if (kind == IAdditionalInput.KIND_ADDITIONAL_INPUT || kind == IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY) { - String paths = addlInput.getPaths(); + String[] paths = addlInput.getPaths(); if (paths != null) { - String[] pathTokens = paths.split(";"); //$NON-NLS-1$ - for (int k = 0; k < pathTokens.length; k++) { - myCommandInputs.add(pathTokens[k]); - myEnumeratedInputs.add(pathTokens[k]); + for (int k = 0; k < paths.length; k++) { + myCommandInputs.add(paths[k]); + myEnumeratedInputs.add(paths[k]); } } } @@ -233,7 +286,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { if (done) { commandInputs.addAll(myCommandInputs); - commandDependencies.addAll(myCommandDependencies); + commandDependencies.addAll(0, myCommandDependencies); enumeratedInputs.addAll(myEnumeratedInputs); inputsCalculated = true; return true; @@ -243,7 +296,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { } /* - * The priorities for determining the names of the ouputs of a tool are: + * The priorities for determining the names of the outputs of a tool are: * 1. If the tool is the build target and primary output, use artifact name & extension * 2. If an option is specified, use the value of the option * 3. If a nameProvider is specified, call it @@ -251,12 +304,16 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { * 5. Use the name pattern to generate a transformation macro * so that the source names can be transformed into the target names * using the built-in string substitution functions of <code>make</code>. + * + * 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; i<myBuildVars.size(); i++) { @@ -548,11 +615,10 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo { int kind = addlInput.getKind(); if (kind == IAdditionalInput.KIND_ADDITIONAL_DEPENDENCY || kind == IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY) { - String paths = addlInput.getPaths(); + String[] paths = addlInput.getPaths(); if (paths != null) { - String[] pathTokens = paths.split(";"); //$NON-NLS-1$ - for (int k = 0; k < pathTokens.length; k++) { - myCommandDependencies.add(pathTokens[k]); + for (int k = 0; k < paths.length; k++) { + myCommandDependencies.add(paths[k]); //myEnumeratedInputs.add(pathTokens[k]); } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject21.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject21.java new file mode 100644 index 00000000000..04da0a2d011 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject21.java @@ -0,0 +1,73 @@ +/********************************************************************** + * Copyright (c) 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 + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Intel Corporation - Initial API and implementation + **********************************************************************/ +package org.eclipse.cdt.managedbuilder.projectconverter; + + +import java.io.File; + +import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.WorkspaceJob; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.ISchedulingRule; + +class UpdateManagedProject21 { + + /** + * @param monitor the monitor to allow users to cancel the long-running operation + * @param project the <code>IProject</code> 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, |