diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
index 423cd37afff..56263758380 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
@@ -673,7 +673,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
if (root == null) {
return;
}
- IPath makefile = workingDirectory.addTrailingSeparator().append(generator.getMakefileName());
+ IPath makefile = workingDirectory.append(generator.getMakefileName());
if (root.getFileForLocation(makefile) == null) {
return;
}
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 809226de65f..e1514d49798 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
@@ -431,7 +431,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
location = new Path("."); //$NON-NLS-1$
}
if (config != null) {
- IPath root = location.addTrailingSeparator().append(config.getName());
+ IPath root = location.append(config.getName());
ITool[] tools = config.getFilteredTools();
for (int i = 0; i < tools.length; i++) {
ITool tool = tools[i];
@@ -458,7 +458,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
if (userPath.isAbsolute()) {
paths.add(userPath.toOSString());
} else {
- IPath absPath = root.addTrailingSeparator().append(userPath);
+ IPath absPath = root.append(userPath);
paths.add(absPath.makeAbsolute().toOSString());
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderMakefileGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderMakefileGenerator.java
index 4d48db10746..901b08f4f4f 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderMakefileGenerator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedBuilderMakefileGenerator.java
@@ -21,6 +21,10 @@ import org.eclipse.core.runtime.MultiStatus;
/**
* @since 2.0
+ *
+ * TODO: isGeneratedResource should take an IPath rather than an IResource,
+ * because an output file can be generated outside of the project directory.
+ * This will require a new interface.
*/
public interface IManagedBuilderMakefileGenerator {
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGenerator.java
index 4d32df0c6f2..9a20c92029d 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGenerator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGenerator.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
+ * Copyright (c) 2004, 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
@@ -16,7 +16,13 @@ import org.eclipse.core.resources.IResource;
/**
* @since 2.0
- */
+ *
+ * TODO: These methods should take IPath's rather than IResource's,
+ * because an output file from one tool can be used as an
+ * input file to another, and it can be generated outside of the
+ * project directory.
+ * This will require a new interface.
+*/
public interface IManagedDependencyGenerator {
public int TYPE_NODEPS = 0;
public int TYPE_COMMAND = 1;
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 f3f555bba6a..c4d74d09f4a 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
@@ -453,7 +453,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
checkCancel();
// Make sure that there is a makefile containing all the folders participating
- IPath srcsFilePath = topBuildDir.addTrailingSeparator().append(SRCSFILE_NAME);
+ IPath srcsFilePath = topBuildDir.append(SRCSFILE_NAME);
IFile srcsFileHandle = createFile(srcsFilePath);
buildSrcVars.clear();
buildOutVars.clear();
@@ -472,7 +472,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
continue;
}
// Make sure a fragment makefile exists
- IPath fragmentPath = getBuildWorkingDir().append(subdirectory.getProjectRelativePath()).addTrailingSeparator().append(MODFILE_NAME);
+ IPath fragmentPath = getBuildWorkingDir().append(subdirectory.getProjectRelativePath()).append(MODFILE_NAME);
IFile makeFragment = project.getFile(fragmentPath);
if (!makeFragment.exists()) {
// If one or both are missing, then add it to the list to be generated
@@ -525,7 +525,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
checkCancel();
// Re-create the top-level makefile
- IPath makefilePath = topBuildDir.addTrailingSeparator().append(MAKEFILE_NAME);
+ IPath makefilePath = topBuildDir.append(MAKEFILE_NAME);
IFile makefileHandle = createFile(makefilePath);
populateTopMakefile(makefileHandle, false);
checkCancel();
@@ -660,7 +660,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
checkCancel();
// Get the list of subdirectories
- IPath srcsFilePath = topBuildDir.addTrailingSeparator().append(SRCSFILE_NAME);
+ IPath srcsFilePath = topBuildDir.append(SRCSFILE_NAME);
IFile srcsFileHandle = createFile(srcsFilePath);
buildSrcVars.clear();
buildOutVars.clear();
@@ -687,13 +687,13 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
checkCancel();
// Create the top-level makefile
- IPath makefilePath = topBuildDir.addTrailingSeparator().append(MAKEFILE_NAME);
+ IPath makefilePath = topBuildDir.append(MAKEFILE_NAME);
IFile makefileHandle = createFile(makefilePath);
populateTopMakefile(makefileHandle, true);
checkCancel();
// Now finish up by adding all the object files
- IPath objFilePath = topBuildDir.addTrailingSeparator().append(OBJECTS_MAKFILE);
+ IPath objFilePath = topBuildDir.append(OBJECTS_MAKFILE);
IFile objsFileHandle = createFile(objFilePath);
populateObjectsMakefile(objsFileHandle);
checkCancel();
@@ -908,7 +908,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
IPath moduleOutputDir = createDirectory(moduleOutputPath.toString());
// Create a module makefile
- IFile modMakefile = createFile(moduleOutputDir.addTrailingSeparator().append(MODFILE_NAME));
+ IFile modMakefile = createFile(moduleOutputDir.append(MODFILE_NAME));
StringBuffer makeBuf = new StringBuffer();
makeBuf.append(addFragmentMakefileHeader());
makeBuf.append(addSources(module));
@@ -1791,7 +1791,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry)iterator.next();
String macroName = (String)entry.getKey();
- addMacroAdditionPrefix(buildVarToRuleStringMap, macroName, "./" + relativePath, true); //$NON-NLS-1$
+ addMacroAdditionPrefix(buildVarToRuleStringMap, macroName, "./" + relativePath, false); //$NON-NLS-1$
}
// Create an entry for the DEPS macro
addMacroAdditionPrefix(buildVarToRuleStringMap, DEPS_MACRO, "./" + relativePath, true); //$NON-NLS-1$
@@ -1814,7 +1814,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
if( (resConfig != null) && (resConfig.isExcluded()) )
continue;
addFragmentMakefileEntriesForSource(buildVarToRuleStringMap, ruleBuffer,
- folder, relativePath, resource, null, false);
+ folder, relativePath, resource, resource.getLocation(), null, false);
}
}
@@ -1830,14 +1830,16 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
* @param ruleBuffer buffer to add generated nmakefile text to
* @param folder the top level build output directory
* @param relativePath build output directory relative path of the current output directory
- * @param resource the source file for this invocation of the tool
+ * @param resource the source file for this invocation of the tool - this may be null for a generated output
+ * @param sourceLocation the full path of the source
* @param varName the build variable to add this invocation's outputs to
* if null
, 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, String varName, boolean generatedSource) {
+ IFolder folder, String relativePath, IResource resource, IPath sourceLocation, String varName, boolean generatedSource) {
// Determine which tool, if any, builds files with this extension
- String ext = resource.getFileExtension();
+ String ext = sourceLocation.getFileExtension();
boolean toolFound = false;
for (int j=0; j 0) {
@@ -1898,12 +1900,18 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
for (int k=0; k 0) {
if (isSecondaryOutputVar(secondaryOutputs, varName)) {
- addMacroAdditionFile(buildVarToRuleStringMap, varName, relativePath, resource, generatedSource);
+ addMacroAdditionFile(buildVarToRuleStringMap, varName, relativePath, sourceLocation, generatedSource);
}
}
}
@@ -1958,15 +1966,17 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
* @param enumeratedOutputs vector of the filenames that are the output of this rule
*/
protected void addRuleForSource(String relativePath, StringBuffer buffer, IResource resource,
- boolean generatedSource, StringBuffer generatedDepFile, Vector enumeratedOutputs) {
+ IPath sourceLocation, boolean generatedSource, StringBuffer generatedDepFile, Vector enumeratedOutputs) {
- String resourceName = getFileName(resource);
- String inputExtension = resource.getFileExtension();
+ String fileName = sourceLocation.removeFileExtension().lastSegment();
+ String inputExtension = sourceLocation.getFileExtension();
String outputExtension = info.getOutputExtension(inputExtension);
// We need to check whether we have any resource specific build information.
IResourceConfiguration resConfig = null;
- if( config != null ) resConfig = config.getResourceConfiguration(resource.getFullPath().toString());
+ if( !generatedSource && config != null ) {
+ resConfig = config.getResourceConfiguration(resource.getFullPath().toString());
+ }
ITool tool;
if( resConfig != null) {
@@ -1982,9 +1992,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// If the tool creates a dependency file, add it to the list
if (doDepGen) {
- String depFile = relativePath + resourceName + DOT + DEP_EXT;
+ String depFile = relativePath + fileName + DOT + DEP_EXT;
getDependencyMakefiles().add(depFile);
- generatedDepFile.append(resourceName + DOT + DEP_EXT);
+ generatedDepFile.append(fileName + DOT + DEP_EXT);
}
// Figure out the output paths
@@ -1995,14 +2005,14 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
Vector ruleOutputs = new Vector();
Vector enumeratedPrimaryOutputs = new Vector();
Vector enumeratedSecondaryOutputs = new Vector();
- calculateOutputsForSource(tool, relativePath, resource, ruleOutputs, enumeratedPrimaryOutputs, enumeratedSecondaryOutputs);
+ calculateOutputsForSource(tool, relativePath, resource, sourceLocation, ruleOutputs, enumeratedPrimaryOutputs, enumeratedSecondaryOutputs);
enumeratedOutputs.addAll(enumeratedPrimaryOutputs);
enumeratedOutputs.addAll(enumeratedSecondaryOutputs);
String primaryOutputName = null;
if (enumeratedPrimaryOutputs.size() > 0) {
primaryOutputName = ((IPath)enumeratedPrimaryOutputs.get(0)).toString();
} else {
- primaryOutputName = relativePath + resourceName + OptDotExt;
+ primaryOutputName = relativePath + fileName + OptDotExt;
}
String otherPrimaryOutputs = EMPTY_STRING;
for (int i=1; i 0 ||
- MacroResolver.getReferencedExplitFileMacros(tool.getToolCommand(),IBuildMacroProvider.CONTEXT_FILE, new FileContextData(resourceLocation,outputLocation,null,config.getToolChain())).length > 0;
+ MacroResolver.getReferencedExplitFileMacros(tool.getToolCommand(),IBuildMacroProvider.CONTEXT_FILE,
+ new FileContextData(sourceLocation, outputLocation, null, config.getToolChain())).length > 0;
//get and resolve command
String cmd = tool.getToolCommand();
try{
@@ -2034,7 +2047,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
EMPTY_STRING,
WHITESPACE,
IBuildMacroProvider.CONTEXT_FILE,
- new FileContextData(resourceLocation,outputLocation,null,info.getDefaultConfiguration().getToolChain()));
+ new FileContextData(sourceLocation, outputLocation, null, info.getDefaultConfiguration().getToolChain()));
if((resolvedCommand = resolvedCommand.trim()).length() > 0)
cmd = resolvedCommand;
@@ -2048,13 +2061,13 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
boolean patternRule = true;
//boolean isItLinked = false;
//if (resource.isLinked()) { NOTE: we don't use this since children of linked resources return false
- if(!resourceLocation.toString().startsWith(projectLocation)) {
+ if(!sourceLocation.toString().startsWith(projectLocation)) {
// it IS linked, so use the actual location
//isItLinked = true;
- resourcePath = resourceLocation.toString();
+ resourcePath = sourceLocation.toString();
// Need a hardcoded rule, not a pattern rule, as a linked file
// can reside in any path
- defaultOutputName = relativePath + resourceName + OptDotExt;
+ defaultOutputName = relativePath + fileName + OptDotExt;
primaryDependencyName = resourcePath;
patternRule = false;
} else {
@@ -2063,8 +2076,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// The rule and command to add to the makefile
if( resConfig != null || fileExplicitMacrosReferenced) {
// Need a hardcoded rule, not a pattern rule
- defaultOutputName = resourcePath + resourceName + OptDotExt;
- primaryDependencyName = home + SEPARATOR + resourcePath + resourceName + DOT + inputExtension;
+ defaultOutputName = resourcePath + fileName + OptDotExt;
+ primaryDependencyName = home + SEPARATOR + resourcePath + fileName + DOT + inputExtension;
patternRule = false;
} else {
defaultOutputName = relativePath + WILDCARD + OptDotExt;
@@ -2085,7 +2098,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
if (!patternRule) {
// Need to reset the primary dependency to be a filename rather than a pattern
- primaryDependencyName = home + SEPARATOR + resourcePath + resourceName + DOT + inputExtension;
+ primaryDependencyName = home + SEPARATOR + resourcePath + fileName + DOT + inputExtension;
}
}
@@ -2147,7 +2160,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
outputPrefix = tool.getOutputPrefix();
String[] flags = null;
try {
- flags = tool.getToolCommandFlags(resourceLocation,outputLocation);
+ flags = tool.getToolCommandFlags(sourceLocation, outputLocation);
} catch( BuildException ex ) {
// TODO add some routines to catch this
flags = EMPTY_STRING_ARRAY;
@@ -2170,7 +2183,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + tool.getAnnouncement() + SINGLE_QUOTE + NEWLINE);
String buildFlags = EMPTY_STRING;
try {
- buildFlags = tool.getToolCommandFlagsString(resourceLocation,outputLocation);
+ buildFlags = tool.getToolCommandFlagsString(sourceLocation, outputLocation);
} catch (BuildException e) {
}
outflag = info.getOutputFlag(outputExtension);
@@ -2184,7 +2197,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
// Call the command line generator
cmdLInfo = info.generateToolCommandLineInfo( inputExtension, flags, outflag, outputPrefix,
- OUT_MACRO + otherPrimaryOutputs, (String[])inputs.toArray(new String[inputs.size()]), resourceLocation, outputLocation );
+ OUT_MACRO + otherPrimaryOutputs, (String[])inputs.toArray(new String[inputs.size()]), sourceLocation, outputLocation );
// The command to build
String buildCmd = null;
if( cmdLInfo == null ) buildCmd = cmd + WHITESPACE + buildFlags + WHITESPACE +
@@ -2256,8 +2269,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
* that are relative to the build directory
*/
protected void calculateOutputsForSource(ITool tool, String relativePath, IResource resource,
- Vector ruleOutputs, Vector enumeratedPrimaryOutputs, Vector enumeratedSecondaryOutputs) {
- String inExt = resource.getFileExtension();
+ IPath sourceLocation, Vector ruleOutputs, Vector enumeratedPrimaryOutputs, Vector enumeratedSecondaryOutputs) {
+ String inExt = sourceLocation.getFileExtension();
String outExt = tool.getOutputExtension(inExt);
IOutputType[] outTypes = tool.getOutputTypes();
@@ -2303,10 +2316,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
}
if (primaryOutput) {
ruleOutputs.add(j, outPath);
- enumeratedPrimaryOutputs.add(j, resolvePercent(outPath, resource));
+ enumeratedPrimaryOutputs.add(j, resolvePercent(outPath, sourceLocation));
} else {
ruleOutputs.add(outPath);
- enumeratedSecondaryOutputs.add(resolvePercent(outPath, resource));
+ enumeratedSecondaryOutputs.add(resolvePercent(outPath, sourceLocation));
}
}
} catch( BuildException ex ) {}
@@ -2314,7 +2327,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// 3. If a nameProvider is specified, call it
if (nameProvider != null) {
IPath[] inPaths = new IPath[1];
- inPaths[0] = resource.getFullPath();
+ inPaths[0] = sourceLocation;
IPath[] outPaths = nameProvider.getOutputNames(tool, inPaths);
for (int j=0; j