mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix bugs with external dependency calculation
This commit is contained in:
parent
55872940c2
commit
b3614c4ad4
1 changed files with 228 additions and 175 deletions
|
@ -289,6 +289,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
private IProject project;
|
||||
private IResource[] projectResources;
|
||||
private Vector ruleList;
|
||||
private Vector depLineList;
|
||||
private Vector subdirList;
|
||||
private IPath topBuildDir;
|
||||
private Set outputExtensionsSet;
|
||||
|
@ -1505,11 +1506,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
|
||||
// We can't have duplicates in a makefile
|
||||
if (getRuleList().contains(buildRule)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
getRuleList().add(buildRule);
|
||||
}
|
||||
buffer.append(buildRule + NEWLINE);
|
||||
if (bTargetTool) {
|
||||
buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + MESSAGE_START_BUILD + WHITESPACE + OUT_MACRO + SINGLE_QUOTE + NEWLINE);
|
||||
|
@ -1579,13 +1578,18 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
// Just emit a blank line
|
||||
buffer.append(NEWLINE);
|
||||
}
|
||||
}
|
||||
|
||||
// If we have secondary outputs, output dependency rules without commands
|
||||
if (enumeratedSecondaryOutputs.size() > 0) {
|
||||
String primaryOutput = (String)enumeratedPrimaryOutputs.get(0);
|
||||
for (int i=0; i<enumeratedSecondaryOutputs.size(); i++) {
|
||||
String output = (String)enumeratedSecondaryOutputs.get(0);
|
||||
buffer.append(output + COLON + WHITESPACE + primaryOutput + NEWLINE);
|
||||
String depLine = output + COLON + WHITESPACE + primaryOutput + NEWLINE;
|
||||
if (!getDepLineList().contains(depLine)) {
|
||||
getDepLineList().add(depLine);
|
||||
buffer.append(depLine);
|
||||
}
|
||||
}
|
||||
buffer.append(NEWLINE);
|
||||
}
|
||||
|
@ -2177,14 +2181,12 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
buildRule += WHITESPACE + addlPath.toString();
|
||||
}
|
||||
|
||||
// No duplicates in a makefile. If we already have this rule, return
|
||||
// No duplicates in a makefile. If we already have this rule, don't add it or the commands to build the file
|
||||
if (getRuleList().contains(buildRule)) {
|
||||
// TODO: Should we assert that this is a pattern rule?
|
||||
return;
|
||||
}
|
||||
else {
|
||||
getRuleList().add(buildRule);
|
||||
}
|
||||
|
||||
// Echo starting message
|
||||
buffer.append(buildRule + NEWLINE);
|
||||
|
@ -2273,6 +2275,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
}
|
||||
|
||||
// Determine if there are any dependencies to calculate
|
||||
// TODO: Note that there is an assumption built into this method that if the build rule is the same
|
||||
// for a set of resources, the dependency command will also be the same. That is, this method
|
||||
// will not reach this code if the build rule is the same (see above).
|
||||
if (doDepGen && depGen.getCalculatorType() == IManagedDependencyGenerator.TYPE_COMMAND) {
|
||||
buffer.append(WHITESPACE + LOGICAL_AND + WHITESPACE + LINEBREAK);
|
||||
// Get the dependency rule out of the generator
|
||||
|
@ -2284,26 +2289,51 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
buffer.append(NEWLINE);
|
||||
buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + MESSAGE_FINISH_FILE + WHITESPACE + IN_MACRO + SINGLE_QUOTE + NEWLINE);
|
||||
buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + WHITESPACE + SINGLE_QUOTE + NEWLINE + NEWLINE);
|
||||
}
|
||||
|
||||
|
||||
// Add separate dependency lines per file if necessary
|
||||
// Determine if there are calculated dependencies
|
||||
String calculatedDependencies = null;
|
||||
boolean addedDepLines = false;
|
||||
String depLine;
|
||||
if (depGen != null && depGen.getCalculatorType() != IManagedDependencyGenerator.TYPE_COMMAND) {
|
||||
Vector addlDepsVector = calculateDependenciesForSource(depGen, tool, relativePath, resource);
|
||||
if (addlDepsVector != null && addlDepsVector.size() > 0) {
|
||||
calculatedDependencies = new String();
|
||||
for (int i=0; i<addlDepsVector.size(); i++) {
|
||||
buffer.append(primaryOutputName + COLON + WHITESPACE + addlDepsVector.get(i).toString() + NEWLINE);
|
||||
calculatedDependencies += WHITESPACE + addlDepsVector.get(i).toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (calculatedDependencies != null) {
|
||||
depLine = primaryOutputName + COLON + calculatedDependencies + NEWLINE;
|
||||
if (!getDepLineList().contains(depLine)) {
|
||||
getDepLineList().add(depLine);
|
||||
addedDepLines = true;
|
||||
buffer.append(depLine);
|
||||
}
|
||||
}
|
||||
|
||||
// Add any additional outputs here using dependency lines
|
||||
for (int i=1; i<enumeratedPrimaryOutputs.size(); i++) { // Starting a 1 is intentional
|
||||
buffer.append(((IPath)enumeratedPrimaryOutputs.get(i)).toString() + COLON + WHITESPACE + primaryOutputName + NEWLINE);
|
||||
depLine = ((IPath)enumeratedPrimaryOutputs.get(i)).toString() + COLON + WHITESPACE + primaryOutputName;
|
||||
if (calculatedDependencies != null) depLine += calculatedDependencies;
|
||||
depLine += NEWLINE;
|
||||
if (!getDepLineList().contains(depLine)) {
|
||||
getDepLineList().add(depLine);
|
||||
addedDepLines = true;
|
||||
buffer.append(depLine);
|
||||
}
|
||||
}
|
||||
for (int i=0; i<enumeratedSecondaryOutputs.size(); i++) {
|
||||
buffer.append(((IPath)enumeratedSecondaryOutputs.get(i)).toString() + COLON + WHITESPACE + primaryOutputName + NEWLINE);
|
||||
depLine = ((IPath)enumeratedSecondaryOutputs.get(i)).toString() + COLON + WHITESPACE + primaryOutputName;
|
||||
if (calculatedDependencies != null) depLine += calculatedDependencies;
|
||||
depLine += NEWLINE;
|
||||
if (!getDepLineList().contains(depLine)) {
|
||||
getDepLineList().add(depLine);
|
||||
addedDepLines = true;
|
||||
buffer.append(depLine);
|
||||
}
|
||||
}
|
||||
if (addedDepLines) {
|
||||
buffer.append(NEWLINE);
|
||||
|
@ -2510,10 +2540,20 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
case IManagedDependencyGenerator.TYPE_INDEXER:
|
||||
case IManagedDependencyGenerator.TYPE_EXTERNAL:
|
||||
IResource[] res = depGen.findDependencies(resource, project);
|
||||
if (res != null) {
|
||||
for (int i=0; i<res.length; i++) {
|
||||
IPath dep = res[i].getProjectRelativePath();
|
||||
IPath dep = null;
|
||||
if (res[i] != null) {
|
||||
IPath addlPath = res[i].getLocation();
|
||||
if (addlPath != null) {
|
||||
dep = calculateRelativePath(getTopBuildDir(), addlPath);
|
||||
}
|
||||
}
|
||||
if (dep != null) {
|
||||
deps.add(dep);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IManagedDependencyGenerator.TYPE_NODEPS:
|
||||
|
@ -2984,6 +3024,19 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
|||
return ruleList;
|
||||
}
|
||||
|
||||
/* (non-javadoc)
|
||||
* Returns the list of known dependency lines. This keeps me from generating duplicate
|
||||
* lines.
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
protected Vector getDepLineList() {
|
||||
if (depLineList == null) {
|
||||
depLineList = new Vector();
|
||||
}
|
||||
return depLineList;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* R E S O U R C E V I S I T O R M E T H O D S
|
||||
************************************************************************/
|
||||
|
|
Loading…
Add table
Reference in a new issue