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 cd858cdcfd8..c10e22e9023 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 @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Rational Software - Initial API and implementation * ARM Ltd. - Minor changes to echo commands @@ -92,36 +92,36 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; /** - * This is a specialized makefile generator that takes advantage of the + * This is a specialized makefile generator that takes advantage of the * extensions present in Gnu Make. - * + * * @since 1.2 */ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { - private static final IPath DOT_SLASH_PATH = new Path("./"); //$NON-NLS-1$ - + private static final IPath DOT_SLASH_PATH = new Path("./"); //$NON-NLS-1$ + /** * This class walks the delta supplied by the build system to determine - * what resources have been changed. The logic is very simple. If a - * buildable resource (non-header) has been added or removed, the directories - * in which they are located are "dirty" so the makefile fragments for them + * what resources have been changed. The logic is very simple. If a + * buildable resource (non-header) has been added or removed, the directories + * in which they are located are "dirty" so the makefile fragments for them * have to be regenerated. *

- * The actual dependencies are recalculated as a result of the build step - * itself. We are relying on make to do the right things when confronted - * with a dependency on a moved header file. That said, make will treat - * the missing header file in a dependency rule as a target it has to build - * unless told otherwise. These dummy targets are added to the makefile - * to avoid a missing target error. + * The actual dependencies are recalculated as a result of the build step + * itself. We are relying on make to do the right things when confronted + * with a dependency on a moved header file. That said, make will treat + * the missing header file in a dependency rule as a target it has to build + * unless told otherwise. These dummy targets are added to the makefile + * to avoid a missing target error. */ public class ResourceDeltaVisitor implements IResourceDeltaVisitor { - private GnuMakefileGenerator generator; + private final GnuMakefileGenerator generator; // private IManagedBuildInfo info; - private IConfiguration config; + private final IConfiguration config; /** - * The constructor + * The constructor */ public ResourceDeltaVisitor(GnuMakefileGenerator generator, IManagedBuildInfo info) { this.generator = generator; @@ -137,7 +137,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta) */ public boolean visit(IResourceDelta delta) throws CoreException { - // Should the visitor keep iterating in current directory + // Should the visitor keep iterating in current directory boolean keepLooking = false; IResource resource = delta.getResource(); IResourceInfo rcInfo = config.getResourceInfo(resource.getProjectRelativePath(), false); @@ -173,8 +173,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { keepLooking = true; break; } - } - + } + if (resource.getType() == IResource.FOLDER) { // I only care about delete event switch (delta.getKind()) { @@ -195,7 +195,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } } else { // If the resource is part of the generated directory structure don't recurse - if (resource.getType() == IResource.ROOT || + if (resource.getType() == IResource.ROOT || (isSource && !generator.isGeneratedResource(resource))) { keepLooking = true; } @@ -203,17 +203,17 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { return keepLooking; } - } + } + - /** * This class is used to recursively walk the project and determine which - * modules contribute buildable source files. + * modules contribute buildable source files. */ protected class ResourceProxyVisitor implements IResourceProxyVisitor { - private GnuMakefileGenerator generator; - private IConfiguration config; + private final GnuMakefileGenerator generator; + private final IConfiguration config; // private IManagedBuildInfo info; /** @@ -234,24 +234,24 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { * @see org.eclipse.core.resources.IResourceProxyVisitor#visit(org.eclipse.core.resources.IResourceProxy) */ public boolean visit(IResourceProxy proxy) throws CoreException { - // No point in proceeding, is there + // No point in proceeding, is there if (generator == null) { return false; } - + IResource resource = proxy.requestResource(); boolean isSource = isSource(resource.getProjectRelativePath()); - + // Is this a resource we should even consider if (proxy.getType() == IResource.FILE) { // If this resource has a Resource Configuration and is not excluded or // if it has a file extension that one of the tools builds, add the sudirectory to the list -// boolean willBuild = false; +// boolean willBuild = false; IResourceInfo rcInfo = config.getResourceInfo(resource.getProjectRelativePath(), false); if (isSource/* && !rcInfo.isExcluded()*/) { boolean willBuild = false; if(rcInfo instanceof IFolderInfo){ - String ext = resource.getFileExtension(); + String ext = resource.getFileExtension(); if (((IFolderInfo)rcInfo).buildsFileType(ext) && // If this file resource is a generated resource, then it is uninteresting !generator.isGeneratedResource(resource)) { @@ -260,7 +260,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } else { willBuild = true; } - + if(willBuild) generator.appendBuildSubdirectory(resource); } @@ -268,10 +268,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { // if ((resConfig == null) || (!(resConfig.isExcluded()))) { // generator.appendBuildSubdirectory(resource); // } -// } +// } return false; } else if (proxy.getType() == IResource.FOLDER){ - + if(!isSource || generator.isGeneratedResource(resource)) return false; return true; @@ -288,26 +288,26 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { //private static final String AUTO_DEP = COMMENT + ".autodeps"; //$NON-NLS-1$ //private static final String MESSAGE = "ManagedMakeBuilder.message"; //$NON-NLS-1$ //private static final String BUILD_ERROR = MESSAGE + ".error"; //$NON-NLS-1$ - + //private static final String DEP_INCL = COMMENT + ".module.dep.includes"; //$NON-NLS-1$ private static final String HEADER = COMMENT + ".header"; //$NON-NLS-1$ - + protected static final String MESSAGE_FINISH_BUILD = ManagedMakeMessages.getResourceString("MakefileGenerator.message.finish.build"); //$NON-NLS-1$ protected static final String MESSAGE_FINISH_FILE = ManagedMakeMessages.getResourceString("MakefileGenerator.message.finish.file"); //$NON-NLS-1$ protected static final String MESSAGE_START_BUILD = ManagedMakeMessages.getResourceString("MakefileGenerator.message.start.build"); //$NON-NLS-1$ protected static final String MESSAGE_START_FILE = ManagedMakeMessages.getResourceString("MakefileGenerator.message.start.file"); //$NON-NLS-1$ protected static final String MESSAGE_START_DEPENDENCY = ManagedMakeMessages.getResourceString("MakefileGenerator.message.start.dependency"); //$NON-NLS-1$ protected static final String MESSAGE_NO_TARGET_TOOL = ManagedMakeMessages.getResourceString("MakefileGenerator.message.no.target"); //$NON-NLS-1$ - //private static final String MOD_INCL = COMMENT + ".module.make.includes"; //$NON-NLS-1$ - private static final String MOD_LIST = COMMENT + ".module.list"; //$NON-NLS-1$ - private static final String MOD_VARS = COMMENT + ".module.variables"; //$NON-NLS-1$ - private static final String MOD_RULES = COMMENT + ".build.rule"; //$NON-NLS-1$ - private static final String BUILD_TOP = COMMENT + ".build.toprules"; //$NON-NLS-1$ - private static final String ALL_TARGET = COMMENT + ".build.alltarget"; //$NON-NLS-1$ + //private static final String MOD_INCL = COMMENT + ".module.make.includes"; //$NON-NLS-1$ + private static final String MOD_LIST = COMMENT + ".module.list"; //$NON-NLS-1$ + private static final String MOD_VARS = COMMENT + ".module.variables"; //$NON-NLS-1$ + private static final String MOD_RULES = COMMENT + ".build.rule"; //$NON-NLS-1$ + private static final String BUILD_TOP = COMMENT + ".build.toprules"; //$NON-NLS-1$ + private static final String ALL_TARGET = COMMENT + ".build.alltarget"; //$NON-NLS-1$ private static final String MAINBUILD_TARGET = COMMENT + ".build.mainbuildtarget"; //$NON-NLS-1$ - private static final String BUILD_TARGETS = COMMENT + ".build.toptargets"; //$NON-NLS-1$ + private static final String BUILD_TARGETS = COMMENT + ".build.toptargets"; //$NON-NLS-1$ private static final String SRC_LISTS = COMMENT + ".source.list"; //$NON-NLS-1$ - + private static final String EMPTY_STRING = new String(); private static final String[] EMPTY_STRING_ARRAY = new String[0]; @@ -315,17 +315,17 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { 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$ - + 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$ + // Enumerations - public static final int + public static final int PROJECT_RELATIVE = 1, PROJECT_SUBDIR_RELATIVE = 2, ABSOLUTE = 3; - + class ToolInfoHolder { ITool[] buildTools; boolean[] buildToolsUsed; @@ -333,8 +333,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { Set outputExtensionsSet; List dependencyMakefiles; } - - + + // Local variables needed by generator private String buildTargetName; private String buildTargetExt; @@ -360,28 +360,28 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { private IPath topBuildDir; // Build directory - relative to the workspace // private Set outputExtensionsSet; // Maps of macro names (String) to values (List) - private HashMap buildSrcVars = new HashMap(); // Map of source file build variable names + private final HashMap buildSrcVars = new HashMap(); // Map of source file build variable names // to a List of source file Path's - private HashMap buildOutVars = new HashMap(); // Map of output file build variable names + private final HashMap buildOutVars = new HashMap(); // Map of output file build variable names // to a List of output file Path's - private HashMap buildDepVars = new HashMap(); // Map of dependency file build variable names + private final HashMap buildDepVars = new HashMap(); // Map of dependency file build variable names // to a List of GnuDependencyGroupInfo objects - private LinkedHashMap topBuildOutVars = new LinkedHashMap(); + private final LinkedHashMap topBuildOutVars = new LinkedHashMap(); // Dependency file variables // private Vector dependencyMakefiles; // IPath's - relative to the top build directory or absolute - + private ICSourceEntry srcEntries[]; - - + + public GnuMakefileGenerator() { super(); } - + /************************************************************************* * IManagedBuilderMakefileGenerator M E T H O D S ************************************************************************/ - + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator#initialize() * @@ -405,7 +405,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { buildTargetName = info.getBuildArtifactName(); // Get its extension buildTargetExt = info.getBuildArtifactExtension(); - + try{ //try to resolve the build macros in the target extension buildTargetExt = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat( @@ -416,7 +416,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { info.getDefaultConfiguration()); } catch (BuildMacroException e){ } - + try{ //try to resolve the build macros in the target name String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat( @@ -430,7 +430,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } catch (BuildMacroException e){ } - + if (buildTargetExt == null) { buildTargetExt = new String(); } @@ -479,7 +479,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } catch (CoreException e) { throw e; } catch (IOException e) { - } + } } /** @@ -489,7 +489,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { ToolInfoHolder h, Vector depExts, // Vector of dependency file extensions IManagedDependencyGenerator2[] postProcessors) { - + boolean callPopulateDummyTargets = false; for (int i=0; iStringBuffer containing all of the required targets to * properly build the project. - * + * * @param outputVarsAdditionsList list to add needed build output variables to * @param rebuild * @return StringBuffer @@ -1313,7 +1310,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { WHITESPACE, IBuildMacroProvider.CONTEXT_CONFIGURATION, config); - + } catch (BuildMacroException e){ } postbuildStep = postbuildStep.trim(); // Remove leading and trailing whitespace (and control characters) @@ -1335,14 +1332,14 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { // There are 2 exceptions; the project does not exist or it is not open // and neither conditions apply if we are building for it .... } -*/ +*/ // If a prebuild step exists, redefine the all target to be // all: {pre-build} main-build // and then reset the "traditional" all target to main-build // This will allow something meaningful to happen if the generated // makefile is // extracted and run standalone via "make all" - // + // String defaultTarget = "all:"; //$NON-NLS-1$ if (prebuildStep.length() > 0) { @@ -1362,7 +1359,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { buffer.append(NEWLINE + NEWLINE); // Add the comment for the "main-build" target - buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(MAINBUILD_TARGET) + NEWLINE); + buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(MAINBUILD_TARGET) + NEWLINE); } else // Add the comment for the "All" target @@ -1370,17 +1367,17 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { // Write out the all target first in case someone just runs make // all: or mainbuild: - + String outputPrefix = EMPTY_STRING; - if (targetTool != null) { + if (targetTool != null) { outputPrefix = targetTool.getOutputPrefix(); } - buffer.append(defaultTarget + WHITESPACE + outputPrefix + buffer.append(defaultTarget + WHITESPACE + outputPrefix + ensurePathIsGNUMakeTargetRuleCompatibleSyntax(buildTargetName)); 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) { @@ -1400,15 +1397,14 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { if (refConfigs.length > 0) { boolean addDeps = true; // if (refdProjects != null) { - for (int i = 0; i < refConfigs.length; i++) { + for (IConfiguration depCfg : refConfigs) { // IProject dep = refdProjects[i]; - IConfiguration depCfg = refConfigs[i]; if(!depCfg.isManagedBuildOn()) continue; // if (!dep.exists()) continue; if (addDeps) { - buffer.append("dependents:" + NEWLINE); //$NON-NLS-1$ + buffer.append("dependents:" + NEWLINE); //$NON-NLS-1$ addDeps = false; } String buildDir = depCfg.getOwner().getLocation().toString(); @@ -1417,11 +1413,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { // Add the current configuration to the makefile path // IManagedBuildInfo depInfo = ManagedBuildManager.getBuildInfo(dep); buildDir += SEPARATOR + depCfg.getName(); - + // Extract the build artifact to add to the dependency list String depTarget = depCfg.getArtifactName(); String depExt = depCfg.getArtifactExtension(); - + try{ //try to resolve the build macros in the artifact extension depExt = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat( @@ -1432,7 +1428,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { config); } catch (BuildMacroException e){ } - + try{ //try to resolve the build macros in the artifact name String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat( @@ -1462,9 +1458,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { // } buffer.append(NEWLINE); } - + // Add the targets tool rules - buffer.append(addTargetsRules(targetTool, + buffer.append(addTargetsRules(targetTool, outputVarsAdditionsList, managedProjectOutputs, (postbuildStep.length() > 0))); // Add the prebuild step target, if specified @@ -1485,7 +1481,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } buffer.append(TAB + DASH + postbuildStep + NEWLINE); buffer.append(TAB + DASH + AT + ECHO_BLANK_LINE + NEWLINE); - } + } // Add the Secondary Outputs target, if needed if (secondaryOutputs.length > 0) { @@ -1494,7 +1490,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { for (int i=0; i 0) { buffer.append(WHITESPACE + POSTBUILD); } - buffer.append(NEWLINE); + buffer.append(NEWLINE); Iterator refIter = managedProjectOutputs.listIterator(); while(refIter.hasNext()) { buffer.append((String)refIter.next() + COLON + NEWLINE); } buffer.append(NEWLINE); - + // Include makefile.targets supplemental makefile buffer.append("-include " + ROOT + SEPARATOR + MAKEFILE_TARGETS + NEWLINE); //$NON-NLS-1$ @@ -1524,7 +1520,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { * 1 the rule for the final target tool * 2 the rules for all of the tools that use multipleOfType in their primary input type * 3 the rules for all tools that use the output of #2 tools - * + * * @param outputVarsAdditionsList list to add needed build output variables to * @param managedProjectOutputs Other projects in the workspace that this project depends upon * @return StringBuffer @@ -1534,17 +1530,17 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { StringBuffer buffer = new StringBuffer(); // Add the comment buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(BUILD_TOP) + NEWLINE); - + ToolInfoHolder h = (ToolInfoHolder)toolInfos.getValue(); ITool[] buildTools = h.buildTools; boolean[] buildToolsUsed = h.buildToolsUsed; // Get the target tool and generate the rule - if (targetTool != null) { + if (targetTool != null) { // Note that the name of the target we pass to addRuleForTool does not // appear to be used there (and tool outputs are consulted directly), but // we quote it anyway just in case it starts to use it in future. - if (addRuleForTool(targetTool, buffer, true, - ensurePathIsGNUMakeTargetRuleCompatibleSyntax(buildTargetName), buildTargetExt, + if (addRuleForTool(targetTool, buffer, true, + ensurePathIsGNUMakeTargetRuleCompatibleSyntax(buildTargetName), buildTargetExt, outputVarsAdditionsList, managedProjectOutputs, postbuildStep)) { // Mark the target tool as processed for (int i=0; i 0) command = resolvedCommand; - + } catch (BuildMacroException e){ } String[] cmdInputs = (String[])inputs.toArray(new String[inputs.size()]); IManagedCommandLineGenerator gen = tool.getCommandLineGenerator(); - IManagedCommandLineInfo cmdLInfo = gen.generateCommandLineInfo( tool, command, + IManagedCommandLineInfo cmdLInfo = gen.generateCommandLineInfo( tool, command, flags, outflag, outputPrefix, primaryOutputs, cmdInputs, tool.getCommandLinePattern() ); - + // The command to build String buildCmd = null; if( cmdLInfo == null ) { String toolFlags; - try { + try { toolFlags = tool.getToolCommandFlagsString(null,null); } catch( BuildException ex ) { // TODO report error @@ -1725,7 +1721,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { buildCmd = command + WHITESPACE + toolFlags + WHITESPACE + outflag + WHITESPACE + outputPrefix + primaryOutputs + WHITESPACE + IN_MACRO; } else buildCmd = cmdLInfo.getCommandLine(); - + // resolve any remaining macros in the command after it has been // generated try { @@ -1742,31 +1738,31 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } catch (BuildMacroException e) { } - + //buffer.append(TAB + AT + escapedEcho(buildCmd)); //buffer.append(TAB + AT + buildCmd); buffer.append(TAB + buildCmd); - + // TODO // NOTE WELL: Dependency file generation is not handled for this type of Tool - + // Echo finished message buffer.append(NEWLINE); buffer.append(TAB + AT + escapedEcho((bTargetTool ? MESSAGE_FINISH_BUILD : MESSAGE_FINISH_FILE) + WHITESPACE + OUT_MACRO)); - buffer.append(TAB + AT + ECHO_BLANK_LINE); - + buffer.append(TAB + AT + ECHO_BLANK_LINE); + // If there is a post build step, then add a recursive invocation of MAKE to invoke it after the main build // Note that $(MAKE) will instantiate in the recusive invocation to the make command that was used to invoke - // the makefile originally + // the makefile originally if (bEmitPostBuildStepCall) { - buffer.append(TAB + MAKE + WHITESPACE + NO_PRINT_DIR + WHITESPACE + POSTBUILD + NEWLINE + NEWLINE); + buffer.append(TAB + MAKE + WHITESPACE + NO_PRINT_DIR + WHITESPACE + POSTBUILD + NEWLINE + NEWLINE); } else { // Just emit a blank line buffer.append(NEWLINE); } } - + // If we have secondary outputs, output dependency rules without commands if (enumeratedSecondaryOutputs.size() > 0 || additionalTargets.size() > 0) { String primaryOutput = (String)enumeratedPrimaryOutputs.get(0); @@ -1796,22 +1792,22 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { ITool[] buildTools = h.buildTools; boolean[] buildToolsUsed = h.buildToolsUsed; IOutputType[] outTypes = generatingTool.getOutputTypes(); - for (int i=0; inull, use the file extension to find the name * @param generatedSource if true, this file was generated by another tool in the tool-chain */ - protected void addFragmentMakefileEntriesForSource (LinkedHashMap buildVarToRuleStringMap, StringBuffer ruleBuffer, - IFolder folder, String relativePath, IResource resource, IPath sourceLocation, IResourceInfo rcInfo, + protected void addFragmentMakefileEntriesForSource (LinkedHashMap buildVarToRuleStringMap, StringBuffer ruleBuffer, + IFolder folder, String relativePath, IResource resource, IPath sourceLocation, IResourceInfo rcInfo, String varName, boolean generatedSource) { - + // Determine which tool, if any, builds files with this extension String ext = sourceLocation.getFileExtension(); ITool tool = null; @@ -2064,7 +2059,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { // resConfig = (IFileInfo)rcInfo; // } //end remove - + // Use the tool from the resource configuration if there is one if (rcInfo instanceof IFileInfo) { IFileInfo fi = (IFileInfo)rcInfo; @@ -2078,7 +2073,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { ToolInfoHolder h = getToolInfo(rcInfo.getPath()); ITool buildTools[] = h.buildTools; - + // if(tool == null){ // for (int j=0; j 0) { for (int k=0; k 0) { - buildVariable = bV; + buildVariable = bV; break; } } @@ -2163,7 +2158,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { // For support of pre-CDT 3.0 integrations. buildVariable = OBJS_MACRO; } - + for (int k=0; k 0) { if (isSecondaryOutputVar(h, secondaryOutputs, varName)) { - addMacroAdditionFile(buildVarToRuleStringMap, varName, relativePath, sourceLocation, generatedSource); + addMacroAdditionFile(buildVarToRuleStringMap, varName, relativePath, sourceLocation, generatedSource); } } } @@ -2222,7 +2217,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { /* (non-Javadoc) * Adds the source file to the appropriate build variable - * + * * @param buildVarToRuleStringMap map of build variable names to the list of files assigned to the variable * @param ext the file extension of the file * @param varName the build variable to add this invocation's outputs to @@ -2231,7 +2226,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { * @param sourceLocation the full path of the source * @param generatedSource if true, this file was generated by another tool in the tool-chain */ - protected void addToBuildVar (LinkedHashMap buildVarToRuleStringMap, String ext, + protected void addToBuildVar (LinkedHashMap buildVarToRuleStringMap, String ext, String varName, String relativePath, IPath sourceLocation, boolean generatedSource) { List varList = null; if (varName == null) { @@ -2242,7 +2237,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { varList = (List)buildOutVars.get(varName); } // Add the resource to the list of all resources associated with a variable. - // Do not allow duplicates - there is no reason to and it can be 'bad' - + // Do not allow duplicates - there is no reason to and it can be 'bad' - // e.g., having the same object in the OBJS list can cause duplicate symbol errors from the linker if ((varList != null) && !(varList.contains(sourceLocation))) { // Since we don't know how these files will be used, we store them using a "location" @@ -2256,15 +2251,15 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } } } - - private IManagedCommandLineInfo generateToolCommandLineInfo(ITool tool, String sourceExtension, String[] flags, + + private IManagedCommandLineInfo generateToolCommandLineInfo(ITool tool, String sourceExtension, String[] flags, String outputFlag, String outputPrefix, String outputName, String[] inputResources, IPath inputLocation, IPath outputLocation ){ String cmd = tool.getToolCommand(); //try to resolve the build macros in the tool command try{ String resolvedCommand = null; - + if ((inputLocation != null && inputLocation.toString().indexOf(" ") != -1) || //$NON-NLS-1$ (outputLocation != null && outputLocation.toString().indexOf(" ") != -1) ) //$NON-NLS-1$ { @@ -2293,22 +2288,22 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } if((resolvedCommand = resolvedCommand.trim()).length() > 0) cmd = resolvedCommand; - + } catch (BuildMacroException e){ } IManagedCommandLineGenerator gen = tool.getCommandLineGenerator(); - return gen.generateCommandLineInfo( tool, cmd, - flags, outputFlag, outputPrefix, outputName, inputResources, + return gen.generateCommandLineInfo( tool, cmd, + flags, outputFlag, outputPrefix, outputName, inputResources, tool.getCommandLinePattern() ); - + } - + /* (non-Javadoc) * Create a rule for this source file. We create a pattern rule if possible. - * + * * This is an example of a pattern rule: - * + * * /%.: ..//%. * @echo Building file: $< * @echo Invoking tool xxx @@ -2318,8 +2313,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { * -P -MM -MG $< >> $(@:%.o=%.d) * @echo Finished building: $< * @echo ' ' - * - * Note that the macros all come from the build model and are + * + * Note that the macros all come from the build model and are * resolved to a real command before writing to the module * makefile, so a real command might look something like: * source1/%.o: ../source1/%.cpp @@ -2331,7 +2326,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { * g++ -P -MM -MG -g -O2 -c -I/cygdrive/c/eclipse/workspace/Project/headers $< >> $(@:%.o=%.d) * @echo Finished building: $< * @echo ' ' - * + * * @param relativePath top build output directory relative path of the current output directory * @param buffer buffer to populate with the build rule * @param resource the source file for this invocation of the tool @@ -2341,10 +2336,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { * @param generatedDepFile build directory relative paths of the dependency files generated by the rule * @param enumeratedOutputs vector of the filenames that are the output of this rule */ - protected void addRuleForSource(String relativePath, StringBuffer buffer, IResource resource, - IPath sourceLocation, IResourceInfo rcInfo, + protected void addRuleForSource(String relativePath, StringBuffer buffer, IResource resource, + IPath sourceLocation, IResourceInfo rcInfo, boolean generatedSource, Vector generatedDepFiles, Vector enumeratedOutputs) { - + String fileName = sourceLocation.removeFileExtension().lastSegment(); String inputExtension = sourceLocation.getFileExtension(); String outputExtension; @@ -2360,9 +2355,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { IFolderInfo foInfo = (IFolderInfo)rcInfo; tool = foInfo.getToolFromInputExtension(inputExtension); } - + ToolInfoHolder h = getToolInfo(rcInfo.getPath()); - + outputExtension = tool.getOutputExtension(inputExtension); if(outputExtension == null) outputExtension = EMPTY_STRING; @@ -2380,7 +2375,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { if (t != null) { int calcType = t.getCalculatorType(); if (calcType <= IManagedDependencyGeneratorType.TYPE_OLD_TYPE_LIMIT) { - oldDepGen = (IManagedDependencyGenerator)t; + oldDepGen = (IManagedDependencyGenerator)t; doDepGen = (calcType == IManagedDependencyGeneratorType.TYPE_COMMAND); if (doDepGen) { IPath depFile = Path.fromOSString(relativePath + fileName + DOT + DEP_EXT); @@ -2388,36 +2383,36 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { generatedDepFiles.add(depFile); } } else { - depGen = (IManagedDependencyGenerator2)t; + depGen = (IManagedDependencyGenerator2)t; doDepGen = (calcType == IManagedDependencyGeneratorType.TYPE_BUILD_COMMANDS); IBuildObject buildContext = rcInfo;//(resConfig != null) ? (IBuildObject)resConfig : (IBuildObject)config; - + depInfo = depGen.getDependencySourceInfo(resource.getProjectRelativePath(), resource, buildContext, tool, getBuildWorkingDir()); - + if (calcType == IManagedDependencyGeneratorType.TYPE_BUILD_COMMANDS) { depCommands = (IManagedDependencyCommands)depInfo; depFiles = depCommands.getDependencyFiles(); } else if (calcType == IManagedDependencyGeneratorType.TYPE_PREBUILD_COMMANDS) { depPreBuild = (IManagedDependencyPreBuild)depInfo; depFiles = depPreBuild.getDependencyFiles(); - } + } if (depFiles != null) { - for (int i=0; i 0) - optDotExt = DOT + outputExtension; + optDotExt = DOT + outputExtension; Vector ruleOutputs = new Vector(); - Vector enumeratedPrimaryOutputs = new Vector(); // IPaths relative to the top build directory + Vector enumeratedPrimaryOutputs = new Vector(); // IPaths relative to the top build directory Vector enumeratedSecondaryOutputs = new Vector(); // IPaths relative to the top build directory calculateOutputsForSource(tool, relativePath, resource, sourceLocation, ruleOutputs, enumeratedPrimaryOutputs, enumeratedSecondaryOutputs); enumeratedOutputs.addAll(enumeratedPrimaryOutputs); @@ -2432,38 +2427,38 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { for (int i=1; i 0 || BuildMacroProvider.getReferencedExplitFileMacros(tool .getToolCommand(), IBuildMacroProvider.CONTEXT_FILE, new FileContextData(sourceLocation, outputLocation, null, tool)).length > 0; - + // Get and resolve the command String cmd = tool.getToolCommand(); - + try { String resolvedCommand = null; if (!needExplicitRuleForFile) { @@ -2494,7 +2489,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } catch (BuildMacroException e) { } - + String defaultOutputName = EMPTY_STRING; String primaryDependencyName = EMPTY_STRING; String patternPrimaryDependencyName = EMPTY_STRING; @@ -2513,7 +2508,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { patternRule = false; } else { // Use the relative path (not really needed to store per se but in the future someone may want this) - resourcePath = relativePath; + resourcePath = relativePath; // The rule and command to add to the makefile if( rcInfo instanceof IFileInfo || needExplicitRuleForFile) { // Need a hardcoded rule, not a pattern rule @@ -2532,14 +2527,14 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { if (depCommands != null) { needExplicitDependencyCommands = !depCommands.areCommandsGeneric(); } - - // If we still think that we are using a pattern rule, check a few more things + + // If we still think that we are using a pattern rule, check a few more things if (patternRule) { patternRule = false; // Make sure that at least one of the rule outputs contains a %. for (int i=0; i= 0) { //$NON-NLS-1$ + if (ruleOutput.indexOf('%') >= 0) { patternRule = true; break; } @@ -2548,7 +2543,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { patternRule = !needExplicitDependencyCommands; } } - + // Begin building the rule for this source file String buildRule = EMPTY_STRING; @@ -2559,7 +2554,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { boolean first = true; for (int i=0; i= 0) { //$NON-NLS-1$ + if (ruleOutput.indexOf('%') >= 0) { if (first) { first = false; } else { @@ -2572,16 +2567,16 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } else { buildRule += primaryOutputName; } - + String buildRuleDependencies = primaryDependencyName; String patternBuildRuleDependencies = patternPrimaryDependencyName; // 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 0) { - for (int i=0; i 0) { + if (addlDeps != null && addlDeps.length > 0) { calculatedDependencies = new String(); - for (int i=0; i 0) - optDotExt = DOT + depExt; + optDotExt = DOT + depExt; depLine += escapeWhitespaces(relativePath + WILDCARD + optDotExt); } else { depLine += escapeWhitespaces((depFiles[i]).toString()); @@ -2900,8 +2894,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { addedDepLines = true; buffer.append(depLine + NEWLINE); buffer.append(TAB + AT + escapedEcho(MESSAGE_START_DEPENDENCY + WHITESPACE + OUT_MACRO)); - for (int i=0; i 0) b = true; - ManagedBuildManager.setOption(rcInfo, tool, assignToOption, b); + ManagedBuildManager.setOption(rcInfo, tool, assignToOption, b); } else if (optType == IOption.ENUMERATED) { if (allRes.size() > 0) { String s = allRes.get(0).toString(); @@ -3069,10 +3062,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } } } - return (IPath[])allRes.toArray(new IPath[allRes.size()]); + return (IPath[])allRes.toArray(new IPath[allRes.size()]); } - - + + /* (non-Javadoc) * Returns the output IPaths for this invocation of the tool with the specified source file /* @@ -3082,33 +3075,32 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { * 2. If an option is specified, use the value of the option * 3. If a nameProvider is specified, call it * 4. If outputNames is specified, use it - * 5. Use the name pattern to generate a transformation macro - * so that the source names can be transformed into the target names + * 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 make. - * + * * @param tool * @param relativePath build output directory relative path of the current output directory * @param resource - * @param ruleOutputs Vector of rule IPaths that are relative to the build directory - * @param enumeratedPrimaryOutputs Vector of IPaths of primary outputs - * that are relative to the build directory - * @param enumeratedSecondaryOutputs Vector of IPaths of secondary outputs - * that are relative to the build directory - */ - protected void calculateOutputsForSource(ITool tool, String relativePath, IResource resource, + * @param ruleOutputs Vector of rule IPaths that are relative to the build directory + * @param enumeratedPrimaryOutputs Vector of IPaths of primary outputs + * that are relative to the build directory + * @param enumeratedSecondaryOutputs Vector of IPaths of secondary outputs + * that are relative to the build directory + */ + protected void calculateOutputsForSource(ITool tool, String relativePath, IResource resource, IPath sourceLocation, Vector ruleOutputs, Vector enumeratedPrimaryOutputs, Vector enumeratedSecondaryOutputs) { String inExt = sourceLocation.getFileExtension(); String outExt = tool.getOutputExtension(inExt); IResourceInfo rcInfo = tool.getParentResourceInfo(); - + IOutputType[] outTypes = tool.getOutputTypes(); if (outTypes != null && outTypes.length > 0) { - for (int i=0; i 0) outputName = resolved; } catch (BuildMacroException e){ @@ -3250,7 +3242,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { IPath outPath = Path.fromOSString(outputName); // If only a file name is specified, add the relative path of this output directory if (outPath.segmentCount() == 1) { - outPath = Path.fromOSString(relativePath + (String)outputList.get(j)); + outPath = Path.fromOSString(relativePath + (String)outputList.get(j)); } if (primaryOutput) { ruleOutputs.add(j, outPath); @@ -3261,7 +3253,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } } } catch( BuildException ex ) {} - } else + } else // 3. If a nameProvider is specified, call it if (nameProvider != null) { IPath[] inPaths = new IPath[1]; @@ -3270,7 +3262,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { for (int j=0; jmake. if (multOfType) { // This case is not handled - a nameProvider or outputNames must be specified // TODO - report error } else { String namePattern = type.getNamePattern(); - IPath namePatternPath = null; + IPath namePatternPath = null; if (namePattern == null || namePattern.length() == 0) { namePattern = relativePath + outputPrefix + IManagedBuilderMakefileGenerator.WILDCARD; if (outExt != null && outExt.length() > 0) { @@ -3376,10 +3368,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { namePatternPath = Path.fromOSString(namePattern); // If only a file name is specified, add the relative path of this output directory if (namePatternPath.segmentCount() == 1) { - namePatternPath = Path.fromOSString(relativePath + namePatternPath.toString()); + namePatternPath = Path.fromOSString(relativePath + namePatternPath.toString()); } } - + if (primaryOutput) { ruleOutputs.add(0, namePatternPath); enumeratedPrimaryOutputs.add(0, resolvePercent(namePatternPath, sourceLocation)); @@ -3388,7 +3380,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { enumeratedSecondaryOutputs.add(resolvePercent(namePatternPath, sourceLocation)); } } - } + } } } else { // For support of pre-CDT 3.0 integrations. @@ -3407,43 +3399,43 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { //} } } - + /* (non-Javadoc) - * If the path contains a %, returns the path resolved using the resource name + * If the path contains a %, returns the path resolved using the resource name * */ protected IPath resolvePercent(IPath outPath, IPath sourceLocation) { // Get the input file name String fileName = sourceLocation.removeFileExtension().lastSegment(); // Replace the % with the file name - String outName = outPath.toOSString().replaceAll("%", fileName); //$NON-NLS-1$ + String outName = outPath.toOSString().replaceAll("%", fileName); //$NON-NLS-1$ IPath result = Path.fromOSString(outName); return DOT_SLASH_PATH.isPrefixOf(outPath) ? DOT_SLASH_PATH.append(result) : result; } - + /* (non-Javadoc) * Returns the dependency IPaths for this invocation of the tool with the specified source file - * + * * @param depGen the dependency calculator * @param tool tool used to build the source file * @param relativePath build output directory relative path of the current output directory * @param resource source file to scan for dependencies - * @return Vector of IPaths that are relative to the build directory - */ + * @return Vector of IPaths that are relative to the build directory + */ protected IPath[] oldCalculateDependenciesForSource(IManagedDependencyGenerator depGen, ITool tool, String relativePath, IResource resource) { Vector deps = new Vector(); int type = depGen.getCalculatorType(); - + switch (type) { case IManagedDependencyGeneratorType.TYPE_INDEXER: case IManagedDependencyGeneratorType.TYPE_EXTERNAL: IResource[] res = depGen.findDependencies(resource, project); if (res != null) { - for (int i=0; iIPaths relative to the build directory - * + * * @param depCalculator the dependency calculator - * @return IPath[] that are relative to the build directory - */ + * @return IPath[] that are relative to the build directory + */ protected IPath[] calculateDependenciesForSource(IManagedDependencyCalculator depCalculator) { IPath[] addlDeps = depCalculator.getDependencies(); if (addlDeps != null) { for (int i=0; iSet containing all of the output extensions + * + * @return a Set containing all of the output extensions */ public Set getOutputExtensions(ToolInfoHolder h) { if (h.outputExtensionsSet == null) { @@ -3543,11 +3535,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { // It is presumed that this set is not very large (likely < 10) so // a HashSet should provide good performance. h.outputExtensionsSet = new HashSet(); - + // For each tool for the target, lookup the kinds of sources it outputs // and add that to our list of output extensions. - for (int i=0; itrue if the dependency file is modified + * + * @return a true if the dependency file is modified */ static public boolean populateDummyTargets(IConfiguration cfg, IFile makefile, boolean force) throws CoreException, IOException { return populateDummyTargets(cfg.getRootFolderInfo(), makefile, force); @@ -3578,7 +3569,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { static public boolean populateDummyTargets(IResourceInfo rcInfo, IFile makefile, boolean force) throws CoreException, IOException { if (makefile == null || !makefile.exists()) return false; - + // Get the contents of the dependency file InputStream contentStream = makefile.getContents(false); Reader in = new InputStreamReader(contentStream); @@ -3591,10 +3582,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { inBuffer.append(readBuffer); n = in.read(readBuffer); } - contentStream.close(); - - // The rest of this operation is equally expensive, so - // if we are doing an incremental build, only update the + contentStream.close(); + + // The rest of this operation is equally expensive, so + // if we are doing an incremental build, only update the // files that do not have a comment if (inBuffer == null) return false; String inBufferString = inBuffer.toString(); @@ -3605,17 +3596,16 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { // Try to determine if this file already has dummy targets defined. // If so, we will only add the comment. String[] bufferLines = inBufferString.split("[\\r\\n]"); //$NON-NLS-1$ - for (int i=0; i/.d /' // POSIX outputs -n /.d / @@ -3674,7 +3664,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } else { outBuffer.append(secondToken + WHITESPACE); } - + // The relative path to the build goal comes next String thirdToken; try { @@ -3692,22 +3682,22 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } else { outBuffer.append(thirdToken); } - + // Followed by the target output by the compiler plus ':' // If we see any empty tokens here, assume they are the result of // a line feed output by "echo" and skip them String fourthToken; int nToken = 3; - try { + try { do { fourthToken = (String) deps.get(nToken++); } while (fourthToken.length() == 0); - + } catch (ArrayIndexOutOfBoundsException e) { fourthToken = new String(); } outBuffer.append(fourthToken + WHITESPACE); - + // Followed by the actual dependencies try { Iterator iter = deps.listIterator(nToken); @@ -3719,16 +3709,16 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { outBuffer.append(nextElement + WHITESPACE); } } - } catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { } } else { outBuffer.append(inBuffer); } - + outBuffer.append(NEWLINE); save = true; - + IFolderInfo fo = null; if(rcInfo instanceof IFolderInfo){ fo = (IFolderInfo)rcInfo; @@ -3744,24 +3734,24 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { String extension = dep.getFileExtension(); if (fo.isHeaderFile(extension)) { /* - * The formatting here is + * The formatting here is * : */ outBuffer.append(dummy + COLON + NEWLINE + NEWLINE); } } - + // Write them out to the makefile if (save) { Util.save(outBuffer, makefile); return true; - } + } return false; } - + /** * prepend all instanced of '\' or '"' with a backslash - * + * * @param string * @return */ @@ -3769,14 +3759,14 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { String escapedString = string.replaceAll("'", "'\"'\"'"); //$NON-NLS-1$ //$NON-NLS-2$ return ECHO + WHITESPACE + SINGLE_QUOTE + escapedString + SINGLE_QUOTE + NEWLINE; } - + static public String ECHO_BLANK_LINE = ECHO + WHITESPACE + SINGLE_QUOTE + WHITESPACE + SINGLE_QUOTE + NEWLINE; - + /* (non-Javadoc) * Outputs a comment formatted as follows: * ##### ....... ##### * # - * ##### ....... ##### + * ##### ....... ##### */ static protected StringBuffer addDefaultHeader() { StringBuffer buffer = new StringBuffer(); @@ -3794,17 +3784,17 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { for (int i = 0; i < COLS_PER_LINE; i++) { buffer.append(COMMENT_SYMBOL); } - buffer.append(NEWLINE); + buffer.append(NEWLINE); } static public boolean containsSpecialCharacters(String path) { return path.matches(".*(\\s|[\\{\\}\\(\\)\\$\\@%=;]).*"); //$NON-NLS-1$ } - + /* (non-Javadoc) * Answers the argument with all whitespaces replaced with an escape sequence. - * + * * @param path */ static public String escapeWhitespaces(String path) { @@ -3838,7 +3828,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { if (addPrefix) { 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 map.put(macroName, tempBuffer.toString()); } @@ -3851,10 +3841,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { protected void addMacroAdditionFile(HashMap map, String macroName, String filename) { StringBuffer buffer = new StringBuffer(); buffer.append(map.get(macroName)); - + // escape whitespace in the filename filename = escapeWhitespaces(filename); - + buffer.append(filename + WHITESPACE + LINEBREAK); // re-insert string in the map map.put(macroName, buffer.toString()); @@ -3865,7 +3855,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { * File additions look like: * example.c, \ */ - protected void addMacroAdditionFile(HashMap map, String macroName, + protected void addMacroAdditionFile(HashMap map, String macroName, String relativePath, IPath sourceLocation, boolean generatedSource) { // Add the source file path to the makefile line that adds source files to the build variable String srcName; @@ -3889,7 +3879,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { srcName = sourceLocation.toString(); } } - addMacroAdditionFile(map, macroName, srcName); + addMacroAdditionFile(map, macroName, srcName); } /* (non-Javadoc) @@ -3917,7 +3907,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { StringBuffer buffer = new StringBuffer(); // Add the comment buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(MOD_VARS) + NEWLINE); - + Collection bufferCollection = map.values(); Iterator collectionIterator = bufferCollection.iterator(); while(collectionIterator.hasNext()) @@ -3942,7 +3932,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { // the whole file buffer.append(currentBuffer); } - } + } return buffer.append(NEWLINE); } @@ -3953,13 +3943,13 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { StringBuffer buffer = new StringBuffer(); // Add the comment buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(MOD_VARS) + NEWLINE); - + for (int i=0; iOperationCanceledException. - * + * * @see org.eclipse.core.runtime.OperationCanceledException#OperationCanceledException() */ protected void checkCancel() { @@ -4322,15 +4312,15 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { /* (non-Javadoc) * Return or create the folder needed for the build output. If we are - * creating the folder, set the derived bit to true so the CM system - * ignores the contents. If the resource exists, respect the existing - * derived setting. - * + * creating the folder, set the derived bit to true so the CM system + * ignores the contents. If the resource exists, respect the existing + * derived setting. + * * @param string * @return IPath */ private IPath createDirectory(String dirName) throws CoreException { - // Create or get the handle for the build directory + // Create or get the handle for the build directory IFolder folder = project.getFolder(dirName); if (!folder.exists()) { // Make sure that parent folders exist @@ -4342,7 +4332,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { createDirectory(parentPath.toString()); } } - + // Now make the requested folder try { folder.create(true, true, null); @@ -4359,16 +4349,16 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { folder.setDerived(true); } } - + return folder.getFullPath(); } /* (non-Javadoc) - * Return or create the makefile needed for the build. If we are creating - * the resource, set the derived bit to true so the CM system ignores - * the contents. If the resource exists, respect the existing derived + * Return or create the makefile needed for the build. If we are creating + * the resource, set the derived bit to true so the CM system ignores + * the contents. If the resource exists, respect the existing derived * setting. - * + * * @param makefilePath * @return IFile */ @@ -4396,7 +4386,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { else throw e; } - + return newFile; } @@ -4428,11 +4418,11 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { depFile.delete(true, new SubProgressMonitor(monitor, 1)); } catch (CoreException e) { // This had better be allowed during a build - + } - } + } } - + private IPath inFullPathFromOutFullPath(IPath path){ IPath inPath = null; if(topBuildDir.isPrefixOf(path)){ @@ -4441,7 +4431,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } return inPath; } - + /** * @param deletedFile */ @@ -4473,7 +4463,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { IPath absolutePath = deletedFile.getLocation(); depFilePaths[0] = ManagedBuildManager.calculateRelativePath(getTopBuildDir(), absolutePath); depFilePaths[0] = depFilePaths[0].removeFileExtension().addFileExtension(DEP_EXT); - } else if (calcType == IManagedDependencyGeneratorType.TYPE_BUILD_COMMANDS || + } else if (calcType == IManagedDependencyGeneratorType.TYPE_BUILD_COMMANDS || calcType == IManagedDependencyGeneratorType.TYPE_PREBUILD_COMMANDS) { IManagedDependencyGenerator2 depGen = (IManagedDependencyGenerator2)depType; IManagedDependencyInfo depInfo = depGen.getDependencySourceInfo( @@ -4484,23 +4474,23 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { depFilePaths = depCommands.getDependencyFiles(); } else if (calcType == IManagedDependencyGeneratorType.TYPE_PREBUILD_COMMANDS) { IManagedDependencyPreBuild depPreBuild = (IManagedDependencyPreBuild)depInfo; - depFilePaths = depPreBuild.getDependencyFiles(); - } + depFilePaths = depPreBuild.getDependencyFiles(); + } } - } + } } // Delete the files if they exist if (depFilePaths != null) { - for (int i=0; iString - * + * * @param file * @return */ @@ -4552,13 +4542,13 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } return answer; } - + /* (non-Javadoc) - * Answers a Vector containing a list of directories that are invalid for the - * build for some reason. At the moment, the only reason a directory would - * not be considered for the build is if it contains a space in the relative + * Answers a Vector containing a list of directories that are invalid for the + * build for some reason. At the moment, the only reason a directory would + * not be considered for the build is if it contains a space in the relative * path from the project root. - * + * * @return a a list of directories that are invalid for the build */ private Vector getInvalidDirList() { @@ -4567,9 +4557,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } return invalidDirList; } - + /* (non-javadoc) - * + * * @return Vector */ private Vector getModifiedList() { @@ -4581,7 +4571,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { /* (non-javadoc) * Answers the list of subdirectories (IContainer's) contributing source code to the build - * + * * @return List */ private Vector getSubdirList() { @@ -4601,7 +4591,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } catch (CoreException e) { // The resource doesn't exist so we should delete the output folder } - + // Figure out what the generated directory name is and delete it IPath moduleRelativePath = subDir.getProjectRelativePath(); IPath buildRoot = getBuildWorkingDir(); @@ -4616,7 +4606,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } catch (CoreException e) { // TODO Log this } - } + } } /* (non-Javadoc) @@ -4655,7 +4645,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { /** * Strips outermost quotes of Strings of the form "a" and 'a' or returns the original - * string if the input is not of this form. + * string if the input is not of this form. * @param path * @throws NullPointerException if path is null * @return a String without the outermost quotes (if the input has them) @@ -4663,7 +4653,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { public static String ensureUnquoted(String path) { boolean doubleQuoted = path.startsWith("\"") && path.endsWith("\""); //$NON-NLS-1$ //$NON-NLS-2$ boolean singleQuoted = path.startsWith("'") && path.endsWith("'"); //$NON-NLS-1$ //$NON-NLS-2$ - return doubleQuoted || singleQuoted ? path.substring(1,path.length()-1) : path; + return doubleQuoted || singleQuoted ? path.substring(1,path.length()-1) : path; } public void initialize(int buildKind, IConfiguration cfg, IBuilder builder, @@ -4686,7 +4676,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { buildTargetName = cfg.getArtifactName(); // Get its extension buildTargetExt = cfg.getArtifactExtension(); - + try{ //try to resolve the build macros in the target extension buildTargetExt = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat( @@ -4697,7 +4687,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { builder); } catch (BuildMacroException e){ } - + try{ //try to resolve the build macros in the target name String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat( @@ -4714,36 +4704,35 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { } catch (BuildMacroException e){ } - + if (buildTargetExt == null) { buildTargetExt = new String(); } // Cache the build tools config = cfg; - this.builder = builder; - + this.builder = builder; + initToolInfos(); //set the top build dir path topBuildDir = project.getFolder(cfg.getName()).getFullPath(); - + srcEntries = config.getSourceEntries(); if(srcEntries.length == 0){ srcEntries = new ICSourceEntry[]{new CSourceEntry(Path.EMPTY, null, ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH)}; } else { ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(config); - srcEntries = CDataUtil.resolveEntries(srcEntries, cfgDes); + srcEntries = CDataUtil.resolveEntries(srcEntries, cfgDes); } } - + private void initToolInfos(){ toolInfos = PathSettingsContainer.createRootContainer(); - + IResourceInfo rcInfos[] = config.getResourceInfos(); - for(int i = 0; i < rcInfos.length; i++){ - IResourceInfo rcInfo = rcInfos[i]; + for (IResourceInfo rcInfo : rcInfos) { if(rcInfo.isExcluded() /*&& !((ResourceInfo)rcInfo).isRoot()*/) continue; - + ToolInfoHolder h = getToolInfo(rcInfo.getPath(), true); if(rcInfo instanceof IFolderInfo){ IFolderInfo fo = (IFolderInfo)rcInfo; @@ -4774,7 +4763,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { private ToolInfoHolder getToolInfo(IPath path, boolean create){ PathSettingsContainer child = toolInfos.getChildContainer(path, create, create); - ToolInfoHolder h = null; + ToolInfoHolder h = null; if(child != null){ h = (ToolInfoHolder)child.getValue(); if(h == null && create){