From 232e3d71536134a8fe722f133a8af7d785345790 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Tue, 1 Oct 2019 21:47:06 -0400 Subject: [PATCH] Bug 551089 - Builds with libraries having spaces in the name fail - add new checkIfQuotedOption() method to GnuMakefileGenerator - have ensurePathIsGNUMakeTargetRuleCompatibleSyntax() look to see if the path is actually an option with path in which case if it is quoted, do not try to escape white space Change-Id: I67a286962ba67acb75d1f8c29cac47069ab07353 --- .../makegen/gnu/GnuMakefileGenerator.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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 b75bdcfea10..6e081c3e0e8 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 @@ -38,6 +38,8 @@ import java.util.List; import java.util.Map.Entry; import java.util.Set; import java.util.Vector; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.settings.model.CSourceEntry; @@ -111,6 +113,9 @@ import org.eclipse.core.runtime.SubProgressMonitor; public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { private static final IPath DOT_SLASH_PATH = new Path("./"); //$NON-NLS-1$ + private Pattern doubleQuotedOption = Pattern.compile("--?[a-zA-Z]+.*?\\\".*?\\\".*"); //$NON-NLS-1$ + private Pattern singleQuotedOption = Pattern.compile("--?[a-zA-Z]+.*?'.*?'.*"); //$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 @@ -3482,6 +3487,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { String nextToken = tokenIter.next(); token += WHITESPACE + nextToken; if (!nextToken.endsWith("\\")) { //$NON-NLS-1$ + //$NON-NLS-1$ break; } } @@ -4478,7 +4484,23 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { */ /* see https://bugs.eclipse.org/bugs/show_bug.cgi?id=129782 */ public String ensurePathIsGNUMakeTargetRuleCompatibleSyntax(String path) { - return escapeWhitespaces(ensureUnquoted(path)); + boolean isQuotedOption = false; + if (path.startsWith("-")) { //$NON-NLS-1$ + isQuotedOption = checkIfQuotedOption(path); + } + if (!isQuotedOption) + return escapeWhitespaces(ensureUnquoted(path)); + return path; + } + + private boolean checkIfQuotedOption(String path) { + Matcher m1 = doubleQuotedOption.matcher(path); + if (m1.matches()) + return true; + Matcher m2 = singleQuotedOption.matcher(path); + if (m2.matches()) + return true; + return false; } /**