1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-03 22:35:43 +02:00

Account for compiler path

This commit is contained in:
Andrew Gvozdev 2011-08-12 20:14:08 -04:00
parent 8501c97f9b
commit da2ab70bac
2 changed files with 22 additions and 3 deletions

View file

@ -344,6 +344,9 @@ public class GCCBuildCommandParserTest extends TestCase {
IFile file3=ResourceHelper.createFile(project, "file3.cpp"); IFile file3=ResourceHelper.createFile(project, "file3.cpp");
IFile file4=ResourceHelper.createFile(project, "file4.cpp"); IFile file4=ResourceHelper.createFile(project, "file4.cpp");
IFile file5=ResourceHelper.createFile(project, "file5.cpp"); IFile file5=ResourceHelper.createFile(project, "file5.cpp");
IFile file6=ResourceHelper.createFile(project, "file6.cpp");
IFile file7=ResourceHelper.createFile(project, "file7.cpp");
IFile file8=ResourceHelper.createFile(project, "file8.cpp");
ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file1.getProjectRelativePath(), true); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file1.getProjectRelativePath(), true);
String languageId = ls.getLanguageId(); String languageId = ls.getLanguageId();
@ -357,6 +360,9 @@ public class GCCBuildCommandParserTest extends TestCase {
parser.processLine("g++ -I/path0 file3.cpp"); parser.processLine("g++ -I/path0 file3.cpp");
parser.processLine("c++ -I/path0 file4.cpp"); parser.processLine("c++ -I/path0 file4.cpp");
parser.processLine("\"gcc\" -I/path0 file5.cpp"); parser.processLine("\"gcc\" -I/path0 file5.cpp");
parser.processLine("/absolute/path/gcc -I/path0 file6.cpp");
parser.processLine(" \"/absolute/path/gcc\" -I/path0 file7.cpp");
parser.processLine("../relative/path/gcc -I/path0 file8.cpp");
parser.shutdown(); parser.shutdown();
// check populated entries // check populated entries
@ -381,6 +387,18 @@ public class GCCBuildCommandParserTest extends TestCase {
List<ICLanguageSettingEntry> entries = parser.getSettingEntries(cfgDescription, file5, languageId); List<ICLanguageSettingEntry> entries = parser.getSettingEntries(cfgDescription, file5, languageId);
assertEquals(new CIncludePathEntry(path0, 0), entries.get(0)); assertEquals(new CIncludePathEntry(path0, 0), entries.get(0));
} }
{
List<ICLanguageSettingEntry> entries = parser.getSettingEntries(cfgDescription, file6, languageId);
assertEquals(new CIncludePathEntry(path0, 0), entries.get(0));
}
{
List<ICLanguageSettingEntry> entries = parser.getSettingEntries(cfgDescription, file7, languageId);
assertEquals(new CIncludePathEntry(path0, 0), entries.get(0));
}
{
List<ICLanguageSettingEntry> entries = parser.getSettingEntries(cfgDescription, file8, languageId);
assertEquals(new CIncludePathEntry(path0, 0), entries.get(0));
}
} }
/** /**

View file

@ -26,6 +26,7 @@ import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
public abstract class AbstractBuildCommandParser extends AbstractLanguageSettingsOutputScanner implements public abstract class AbstractBuildCommandParser extends AbstractLanguageSettingsOutputScanner implements
ILanguageSettingsBuildOutputScanner { ILanguageSettingsBuildOutputScanner {
private static final String LEADING_PATH_PATTERN = "\\S+[/\\\\]"; //$NON-NLS-1$
private static final Pattern OPTIONS_PATTERN = Pattern.compile("-[^\\s\"']*(\\s*((\".*?\")|('.*?')|([^-\\s][^\\s]+)))?"); //$NON-NLS-1$ private static final Pattern OPTIONS_PATTERN = Pattern.compile("-[^\\s\"']*(\\s*((\".*?\")|('.*?')|([^-\\s][^\\s]+)))?"); //$NON-NLS-1$
private static final int OPTION_GROUP = 0; private static final int OPTION_GROUP = 0;
@ -34,8 +35,8 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting
*/ */
@SuppressWarnings("nls") @SuppressWarnings("nls")
private static final String[] PATTERN_TEMPLATES = { private static final String[] PATTERN_TEMPLATES = {
"\\s*\"?${COMPILER_PATTERN}\"?.*\\s" + "()([^'\"\\s]*\\.${EXTENSIONS_PATTERN})(\\s.*)?[\r\n]*", // compiling unquoted file "${COMPILER_PATTERN}.*\\s" + "()([^'\"\\s]*\\.${EXTENSIONS_PATTERN})(\\s.*)?[\r\n]*", // compiling unquoted file
"\\s*\"?${COMPILER_PATTERN}\"?.*\\s" + "(['\"])(.*\\.${EXTENSIONS_PATTERN})\\${COMPILER_GROUPS+1}(\\s.*)?[\r\n]*" // compiling quoted file "${COMPILER_PATTERN}.*\\s" + "(['\"])(.*\\.${EXTENSIONS_PATTERN})\\${COMPILER_GROUPS+1}(\\s.*)?[\r\n]*" // compiling quoted file
}; };
private static final int FILE_GROUP = 2; private static final int FILE_GROUP = 2;
@ -43,7 +44,7 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting
@SuppressWarnings("nls") @SuppressWarnings("nls")
private String getCompilerCommandPattern() { private String getCompilerCommandPattern() {
String parameter = getCustomParameter(); String parameter = getCustomParameter();
return "(" + parameter + ")"; return "\\s*\"?("+LEADING_PATH_PATTERN+")?(" + parameter + ")\"?";
} }
private int adjustFileGroup() { private int adjustFileGroup() {