diff options
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2Commands.java')
-rw-r--r--[-rwxr-xr-x] | build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2Commands.java | 73 |
1 files changed, 41 insertions, 32 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2Commands.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2Commands.java index ef3531b09c2..5859d3be60a 100755..100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2Commands.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2Commands.java @@ -33,9 +33,9 @@ import org.eclipse.core.runtime.Path; * See bugzilla 108715 for the discussion of dependency management that led to * the creation of this dependency calculator. Note also that this technique * exhibits the failure modes discussed in comment #5. - * + * * This class is used with DefaultGCCDependencyCalculator2. - * + * * @since 3.1 * @noextend This class is not intended to be subclassed by clients. * @noinstantiate This class is not intended to be instantiated by clients. @@ -47,19 +47,19 @@ public class DefaultGCCDependencyCalculator2Commands implements IPath source; IResource resource; IBuildObject buildContext; - ITool tool; + ITool tool; IPath topBuildDirectory; - + // Other Member variables IProject project; IPath sourceLocation; IPath outputLocation; boolean needExplicitRuleForFile; Boolean genericCommands = null; - + /** * Constructor - * + * * @param source The source file for which dependencies should be calculated * The IPath can be either relative to the project directory, or absolute in the file system. * @param resource The IResource corresponding to the source file. @@ -75,7 +75,7 @@ public class DefaultGCCDependencyCalculator2Commands implements this.buildContext = buildContext; this.tool = tool; this.topBuildDirectory = topBuildDirectory; - + // Compute the project if (buildContext instanceof IConfiguration) { IConfiguration config = (IConfiguration)buildContext; @@ -84,23 +84,23 @@ public class DefaultGCCDependencyCalculator2Commands implements IResourceInfo rcInfo = (IResourceInfo)buildContext; project = rcInfo.getParent().getOwner().getProject(); } - + IPath projectPath = new Path(EFSExtensionManager.getDefault().getPathFromURI(project.getLocationURI())); - + sourceLocation = (source.isAbsolute() ? source : projectPath.append(source)); outputLocation = projectPath.append(topBuildDirectory).append(getDependencyFiles()[0]); // A separate rule is needed for the resource in the case where explicit file-specific macros // are referenced, or if the resource contains special characters in its path (e.g., whitespace) - + /* fix for 137674 - * + * * We only need an explicit rule if one of the following is true: * - The resource is linked, and its full path to its real location contains special characters * - The resource is not linked, but its project relative path contains special characters - */ + */ boolean resourceNameRequiresExplicitRule = true; - + if(resource != null) { resourceNameRequiresExplicitRule = (resource.isLinked() && GnuMakefileGenerator @@ -108,15 +108,15 @@ public class DefaultGCCDependencyCalculator2Commands implements || (!resource.isLinked() && GnuMakefileGenerator .containsSpecialCharacters(resource.getProjectRelativePath().toString())); } - - needExplicitRuleForFile = resourceNameRequiresExplicitRule || + + needExplicitRuleForFile = resourceNameRequiresExplicitRule || BuildMacroProvider.getReferencedExplitFileMacros(tool).length > 0 || BuildMacroProvider.getReferencedExplitFileMacros( - tool.getToolCommand(), + tool.getToolCommand(), IBuildMacroProvider.CONTEXT_FILE, new FileContextData(sourceLocation, outputLocation, null, tool)).length > 0; - + if (needExplicitRuleForFile) genericCommands = new Boolean(false); } @@ -127,7 +127,7 @@ public class DefaultGCCDependencyCalculator2Commands implements * null resource. The net result of this is that dependency rules will * always be explicit and will never use pattern rules, as it is impossible * for the calculator to know whether the resource is linked or not. - * + * * @param source * The source file for which dependencies should be calculated * The IPath can be either relative to the project directory, or @@ -141,19 +141,20 @@ public class DefaultGCCDependencyCalculator2Commands implements * The top build directory of the configuration. This is the * working directory for the tool. This IPath is relative to the * project directory. - * + * * @see #DefaultGCCDependencyCalculator2Commands(IPath source, IResource resource, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) */ public DefaultGCCDependencyCalculator2Commands(IPath source, IBuildObject buildContext, ITool tool, IPath topBuildDirectory) { - this(source, (IResource) null, buildContext, tool, topBuildDirectory); + this(source, (IResource) null, buildContext, tool, topBuildDirectory); } - - + + /* * (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#areCommandsGeneric() - */ + */ + @Override public boolean areCommandsGeneric() { if (genericCommands == null) genericCommands = new Boolean(true); return genericCommands.booleanValue(); @@ -163,22 +164,23 @@ public class DefaultGCCDependencyCalculator2Commands implements * (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyCommandOptions() */ + @Override public String[] getDependencyCommandOptions() { - + String[] options = new String[4]; - // -MMD + // -MMD options[0] = "-MMD"; //$NON-NLS-1$ - // -MP + // -MP options[1] = "-MP"; //$NON-NLS-1$ // -MF$(@:%.o=%.d) - // Due to bug in GNU make $(@:%.o=%.d) applied to "/buggy path_with_3_spaces/f.o" - // becomes "/buggy path_with_3_spaces/f.d". To avoid this we have to insert + // Due to bug in GNU make $(@:%.o=%.d) applied to "/buggy path_with_3_spaces/f.o" + // becomes "/buggy path_with_3_spaces/f.d". To avoid this we have to insert // filename explicitly instead of substitution rule - if ( needExplicitRuleForFile ) { + if ( needExplicitRuleForFile ) { IPath outPath = getDependencyFiles()[0]; - options[2] = "-MF\"" + outPath.toString() + "\""; //$NON-NLS-1$ //$NON-NLS-2$ + options[2] = "-MF\"" + outPath.toString() + "\""; //$NON-NLS-1$ //$NON-NLS-2$ } else { - options[2] = "-MF\"$(@:%.o=%.d)\""; //$NON-NLS-1$ + options[2] = "-MF\"$(@:%.o=%.d)\""; //$NON-NLS-1$ } if( buildContext instanceof IResourceConfiguration || needExplicitRuleForFile ) { IPath outPath = getDependencyFiles()[0]; @@ -189,7 +191,7 @@ public class DefaultGCCDependencyCalculator2Commands implements // -MT"$(@:%.o=%.d) %.o" options[3] = "-MT\"$(@:%.o=%.d)\""; //$NON-NLS-1$ } - + return options; } @@ -197,6 +199,7 @@ public class DefaultGCCDependencyCalculator2Commands implements * (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getDependencyFiles() */ + @Override public IPath[] getDependencyFiles() { // The source file is project relative and the dependency file is top build directory relative // Remove the source extension and add the dependency extension @@ -217,6 +220,7 @@ public class DefaultGCCDependencyCalculator2Commands implements * (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPostToolDependencyCommands() */ + @Override public String[] getPostToolDependencyCommands() { // Nothing return null; @@ -226,6 +230,7 @@ public class DefaultGCCDependencyCalculator2Commands implements * (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCommands#getPreToolDependencyCommands() */ + @Override public String[] getPreToolDependencyCommands() { // Nothing return null; @@ -235,6 +240,7 @@ public class DefaultGCCDependencyCalculator2Commands implements * (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getBuildContext() */ + @Override public IBuildObject getBuildContext() { return buildContext; } @@ -243,6 +249,7 @@ public class DefaultGCCDependencyCalculator2Commands implements * (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getSource() */ + @Override public IPath getSource() { return source; } @@ -251,6 +258,7 @@ public class DefaultGCCDependencyCalculator2Commands implements * (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTool() */ + @Override public ITool getTool() { return tool; } @@ -259,6 +267,7 @@ public class DefaultGCCDependencyCalculator2Commands implements * (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo#getTopBuildDirectory() */ + @Override public IPath getTopBuildDirectory() { return topBuildDirectory; } |