mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Changes to better support output files in non-default locations
Some TODOs remain, particularly, some client interfaces need to change in the future
This commit is contained in:
parent
1a9c0d8eb7
commit
c93b5d938b
6 changed files with 107 additions and 76 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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,6 +16,12 @@ 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;
|
||||
|
|
|
@ -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 <code>null</code>, use the file extension to find the name
|
||||
* @param generatedSource if <code>true</code>, 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<buildTools.length; j++) {
|
||||
if (buildTools[j].buildsFileType(ext)) {
|
||||
|
@ -1851,14 +1853,14 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
List varList = (List)buildSrcVars.get(varName);
|
||||
// Since we don't know how these files will be used, we store them using a "location"
|
||||
// path rather than a relative path
|
||||
varList.add(resource.getLocation());
|
||||
varList.add(sourceLocation);
|
||||
} else {
|
||||
// Add the resource to the list of all resources associated with a variable.
|
||||
List varList = (List)buildOutVars.get(varName);
|
||||
if (varList != null) {
|
||||
// Since we don't know how these files will be used, we store them using a "location"
|
||||
// path rather than a relative path
|
||||
varList.add(resource.getLocation());
|
||||
varList.add(sourceLocation);
|
||||
}
|
||||
}
|
||||
if (!buildVarToRuleStringMap.containsKey(varName)) {
|
||||
|
@ -1866,7 +1868,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
continue;
|
||||
}
|
||||
// Add the resource name to the makefile line that adds resources to the build variable
|
||||
addMacroAdditionFile(buildVarToRuleStringMap, varName, relativePath, resource, generatedSource);
|
||||
addMacroAdditionFile(buildVarToRuleStringMap, varName, relativePath, sourceLocation, generatedSource);
|
||||
|
||||
// Generate the rule to build this source file
|
||||
IInputType primaryInputType = tool.getPrimaryInputType();
|
||||
|
@ -1877,7 +1879,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
// Try to add the rule for the file
|
||||
StringBuffer generatedDepFile = new StringBuffer();
|
||||
Vector generatedOutputs = new Vector();
|
||||
addRuleForSource(relativePath, ruleBuffer, resource, generatedSource, generatedDepFile, generatedOutputs);
|
||||
addRuleForSource(relativePath, ruleBuffer, resource, sourceLocation, generatedSource, generatedDepFile, generatedOutputs);
|
||||
|
||||
// If the rule generates a dependency file, add the file to the DEPS variable
|
||||
if (generatedDepFile.length() > 0) {
|
||||
|
@ -1898,12 +1900,18 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
}
|
||||
|
||||
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
|
||||
IPath generatedOutput = getBuildWorkingDir().addTrailingSeparator().append(relativePath).addTrailingSeparator().append((IPath)generatedOutputs.get(k));
|
||||
IPath generatedOutput;
|
||||
if (((IPath)generatedOutputs.get(k)).isAbsolute()) {
|
||||
// TODO: Should we use relative paths when possible (e.g., see MbsMacroSupplier.calculateRelPath)
|
||||
generatedOutput = (IPath)generatedOutputs.get(k);
|
||||
} else {
|
||||
generatedOutput = project.getLocation().append(getBuildWorkingDir()).append((IPath)generatedOutputs.get(k));
|
||||
}
|
||||
// If this file has an absolute path, then the generateOutputResource will not be correct
|
||||
// because the file is not under the project. We use this resource in the calls to the dependency generator
|
||||
IResource generateOutputResource = project.getFile(generatedOutput);
|
||||
addFragmentMakefileEntriesForSource(buildVarToRuleStringMap, ruleBuffer,
|
||||
folder, relativePath, generateOutputResource, buildVariable, true);
|
||||
folder, relativePath, generateOutputResource, generatedOutput, buildVariable, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1914,7 +1922,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
IOutputType[] secondaryOutputs = config.getToolChain().getSecondaryOutputs();
|
||||
if (secondaryOutputs.length > 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<enumeratedPrimaryOutputs.size(); i++) { // Starting a 1 is intentional
|
||||
|
@ -2017,16 +2027,19 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
* then we must get the actual location of the resource, rather
|
||||
* than the relative path.
|
||||
*/
|
||||
IPath resourceLocation = resource.getLocation();
|
||||
String projectLocation = project.getLocation().toString();
|
||||
|
||||
// Optput file location needed for the file-specific build macros
|
||||
// TODO: Is primaryOutputName always build directory relative?
|
||||
IPath outputLocation = project.getLocation().append(getBuildWorkingDir()).append(primaryOutputName);
|
||||
IPath outputLocation = Path.fromOSString(primaryOutputName);
|
||||
if (!outputLocation.isAbsolute()) {
|
||||
outputLocation = project.getLocation().append(getBuildWorkingDir()).append(primaryOutputName);
|
||||
}
|
||||
|
||||
// A separate rule is needed for the resource in case the explicit file-specific macros
|
||||
// are referenced
|
||||
boolean fileExplicitMacrosReferenced = MacroResolver.getReferencedExplitFileMacros(tool).length > 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<outPaths.length; j++) {
|
||||
IPath outPath = outPaths[j];
|
||||
|
@ -2324,10 +2337,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));
|
||||
}
|
||||
}
|
||||
} else
|
||||
|
@ -2341,10 +2354,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));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -2377,10 +2390,10 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
|
||||
if (primaryOutput) {
|
||||
ruleOutputs.add(0, namePatternPath);
|
||||
enumeratedPrimaryOutputs.add(0, resolvePercent(namePatternPath, resource));
|
||||
enumeratedPrimaryOutputs.add(0, resolvePercent(namePatternPath, sourceLocation));
|
||||
} else {
|
||||
ruleOutputs.add(namePatternPath);
|
||||
enumeratedSecondaryOutputs.add(resolvePercent(namePatternPath, resource));
|
||||
enumeratedSecondaryOutputs.add(resolvePercent(namePatternPath, sourceLocation));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2398,7 +2411,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
IPath outPath = Path.fromOSString(relativePath + outPrefix + WILDCARD);
|
||||
outPath = outPath.addFileExtension(outExt);
|
||||
ruleOutputs.add(0, outPath);
|
||||
enumeratedPrimaryOutputs.add(0, resolvePercent(outPath, resource));
|
||||
enumeratedPrimaryOutputs.add(0, resolvePercent(outPath, sourceLocation));
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
@ -2407,9 +2420,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
* If the path contains a %, returns the path resolved using the resource name
|
||||
*
|
||||
*/
|
||||
protected IPath resolvePercent(IPath outPath, IResource resource) {
|
||||
protected IPath resolvePercent(IPath outPath, IPath sourceLocation) {
|
||||
// Get the input file name
|
||||
String fileName = resource.getFullPath().removeFileExtension().lastSegment();
|
||||
String fileName = sourceLocation.removeFileExtension().lastSegment();
|
||||
// Replace the % with the file name
|
||||
String outName = outPath.toOSString().replaceAll("%", fileName); //$NON-NLS-1$
|
||||
return Path.fromOSString(outName);
|
||||
|
@ -2583,19 +2596,27 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
* example.c, \
|
||||
*/
|
||||
protected void addMacroAdditionFile(HashMap map, String macroName,
|
||||
String relativePath, IResource resource, boolean generatedSource) {
|
||||
// Add the resource name to the makefile line that adds resources to the build variable
|
||||
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;
|
||||
IPath projectLocation = project.getLocation();
|
||||
IPath dirLocation = projectLocation;
|
||||
if (generatedSource) {
|
||||
srcName = resource.getName();
|
||||
dirLocation = dirLocation.append(getBuildWorkingDir());
|
||||
}
|
||||
if (dirLocation.isPrefixOf(sourceLocation)) {
|
||||
IPath srcPath = sourceLocation.removeFirstSegments(dirLocation.segmentCount()).setDevice(null);
|
||||
if (generatedSource) {
|
||||
srcName = "./" + srcPath.toString(); //$NON-NLS-1$
|
||||
} 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;
|
||||
srcName = "$(ROOT)/" + srcPath.toString(); //$NON-NLS-1$
|
||||
}
|
||||
} else {
|
||||
srcName = "$(ROOT)/" + relativePath + resource.getName(); //$NON-NLS-1$
|
||||
if (generatedSource && !sourceLocation.isAbsolute()) {
|
||||
srcName = "./" + relativePath + sourceLocation.lastSegment().toString(); // $NON-NLS-1$
|
||||
} else {
|
||||
// TODO: Should we use relative paths when possible (e.g., see MbsMacroSupplier.calculateRelPath)
|
||||
srcName = sourceLocation.toString();
|
||||
}
|
||||
}
|
||||
addMacroAdditionFile(map, macroName, srcName);
|
||||
|
@ -2848,7 +2869,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
IPath path = (IPath)list.get(i);
|
||||
if (locationType != ABSOLUTE) {
|
||||
if (dirLocation.isPrefixOf(path)) {
|
||||
path = path.removeFirstSegments(dirLocation.matchingFirstSegments(path));
|
||||
path = path.removeFirstSegments(dirLocation.segmentCount()).setDevice(null);
|
||||
}
|
||||
}
|
||||
fileList.add(path.toString());
|
||||
|
@ -2932,7 +2953,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
* deleted. As a result, the directories that are generated for the output
|
||||
* should be removed as well.
|
||||
*
|
||||
* @param resource
|
||||
* @param container
|
||||
*/
|
||||
protected void appendDeletedSubdirectory(IContainer container) {
|
||||
// No point in adding a folder if the parent is already there
|
||||
|
|
|
@ -247,7 +247,7 @@ public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
|
|||
IPath resPath = projResources[j].getLocation();
|
||||
IPath bldLocation = project.getLocation().append(makeGen.getBuildWorkingDir());
|
||||
if (bldLocation.isPrefixOf(resPath)) {
|
||||
resPath = resPath.removeFirstSegments(bldLocation.matchingFirstSegments(resPath));
|
||||
resPath = resPath.removeFirstSegments(bldLocation.segmentCount()).setDevice(null);
|
||||
}
|
||||
myEnumeratedInputs.add(resPath.toString());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue