1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Fix for echo implementation problems on some target platforms that will cause source-level dep targets to be written out wrong. On Solaris, the echo was putting the -n argument in the file and a newline. On MinGW without MSYS (i.e., the Win32 implemetation), the output contained -n ' which is worse. The solution is to parse for this type of garbage in the dependency files when they are being updated

This commit is contained in:
Sean Evoy 2004-05-27 23:46:56 +00:00
parent fc34ca8ab5
commit fb764be87a

View file

@ -367,7 +367,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
// Say goodbye to the nice user
buffer.append(NEWLINE);
buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + MESSAGE_FINISH_FILE + WHITESPACE + IN_MACRO + SINGLE_QUOTE + NEWLINE + TAB + AT + ECHO + NEWLINE + NEWLINE);
buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + MESSAGE_FINISH_FILE + WHITESPACE + IN_MACRO + SINGLE_QUOTE + NEWLINE);
}
@ -587,7 +587,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
buffer.append(NEWLINE);
buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + MESSAGE_START_BUILD + WHITESPACE + OUT_MACRO + SINGLE_QUOTE + NEWLINE);
buffer.append(TAB + cmd + WHITESPACE + flags + WHITESPACE + outflag + WHITESPACE + OUT_MACRO + WHITESPACE + "$(OBJS) $(USER_OBJS) $(LIBS)" + NEWLINE); //$NON-NLS-1$
buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + MESSAGE_FINISH_FILE + WHITESPACE + OUT_MACRO + SINGLE_QUOTE + NEWLINE + TAB + AT + ECHO + NEWLINE + NEWLINE);
buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + MESSAGE_FINISH_FILE + WHITESPACE + OUT_MACRO + SINGLE_QUOTE + NEWLINE + NEWLINE);
// Always add a clean target
buffer.append("clean:" + NEWLINE); //$NON-NLS-1$
@ -1131,21 +1131,97 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
if (inBuffer != null) {
// Here are the tokens in the file
String[] dependencies = inBuffer.toString().split("\\s"); //$NON-NLS-1$
if (dependencies.length == 0) return;
// If we are doing an incremental build, only update the files that do not have a comment
if (dependencies.length > 0 && !force) {
String firstLine = dependencies[0];
String firstLine = dependencies[0];
if (!force) {
if (firstLine.startsWith(COMMENT_SYMBOL)) {
return;
}
}
// Dummy targets to add to the makefile
// Put the generated comments in
outBuffer = addDefaultHeader();
outBuffer.append(inBuffer);
// Some echo implementations misbehave and put the -n and newline in the output
if (firstLine.startsWith("-n")) {
// Create a vector with all the strings
Vector tokens = new Vector(dependencies.length);
for (int index = 1; index < dependencies.length; ++index) {
String token = dependencies[index];
if (token.length() > 0) {
tokens.add(token);
}
}
tokens.trimToSize();
// Now let's parse:
// Win32 outputs -n '<path>/<file>.d <path>/'
// POSIX outputs -n <path>/<file>.d <path>/
// Get the dep file name
String secondLine;
try {
secondLine = (String) tokens.get(0);
} catch (ArrayIndexOutOfBoundsException e) {
secondLine = new String();
}
if (secondLine.startsWith("'")) {
// This is the Win32 implementation of echo (MinGW without MSYS)
outBuffer.append(secondLine.substring(1) + WHITESPACE);
} else {
outBuffer.append(secondLine + WHITESPACE);
}
// The relative path to the build goal comes next
String thirdLine;
try {
thirdLine = (String) tokens.get(1);
} catch (ArrayIndexOutOfBoundsException e) {
thirdLine = new String();
}
int lastIndex = thirdLine.lastIndexOf("'");
if (lastIndex != -1) {
if (lastIndex == 0) {
outBuffer.append(WHITESPACE);
} else {
outBuffer.append(thirdLine.substring(0, lastIndex - 1));
}
} else {
outBuffer.append(thirdLine);
}
// followed by the actual dependencies
String fourthLine;
try {
fourthLine = (String) tokens.get(2);
} catch (ArrayIndexOutOfBoundsException e) {
fourthLine = new String();
}
outBuffer.append(fourthLine + WHITESPACE);
// Now do the rest
try {
Iterator iter = tokens.listIterator(3);
while (iter.hasNext()) {
String nextElement = (String)iter.next();
if (nextElement.endsWith("\\")) {
outBuffer.append(nextElement + NEWLINE + WHITESPACE);
} else {
outBuffer.append(nextElement + WHITESPACE);
}
}
} catch (IndexOutOfBoundsException e) {
}
} else {
outBuffer.append(inBuffer);
}
outBuffer.append(NEWLINE);
save = true;
// Dummy targets to add to the makefile
for (int i = 0; i < dependencies.length; ++i) {
IPath dep = new Path(dependencies[i]);
String extension = dep.getFileExtension();