mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Account for compiler path
This commit is contained in:
parent
8501c97f9b
commit
da2ab70bac
2 changed files with 22 additions and 3 deletions
|
@ -344,6 +344,9 @@ public class GCCBuildCommandParserTest extends TestCase {
|
|||
IFile file3=ResourceHelper.createFile(project, "file3.cpp");
|
||||
IFile file4=ResourceHelper.createFile(project, "file4.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);
|
||||
String languageId = ls.getLanguageId();
|
||||
|
||||
|
@ -357,6 +360,9 @@ public class GCCBuildCommandParserTest extends TestCase {
|
|||
parser.processLine("g++ -I/path0 file3.cpp");
|
||||
parser.processLine("c++ -I/path0 file4.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();
|
||||
|
||||
// check populated entries
|
||||
|
@ -381,6 +387,18 @@ public class GCCBuildCommandParserTest extends TestCase {
|
|||
List<ICLanguageSettingEntry> entries = parser.getSettingEntries(cfgDescription, file5, languageId);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
|
|||
public abstract class AbstractBuildCommandParser extends AbstractLanguageSettingsOutputScanner implements
|
||||
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 int OPTION_GROUP = 0;
|
||||
|
||||
|
@ -34,8 +35,8 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting
|
|||
*/
|
||||
@SuppressWarnings("nls")
|
||||
private static final String[] PATTERN_TEMPLATES = {
|
||||
"\\s*\"?${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" + "()([^'\"\\s]*\\.${EXTENSIONS_PATTERN})(\\s.*)?[\r\n]*", // compiling unquoted file
|
||||
"${COMPILER_PATTERN}.*\\s" + "(['\"])(.*\\.${EXTENSIONS_PATTERN})\\${COMPILER_GROUPS+1}(\\s.*)?[\r\n]*" // compiling quoted file
|
||||
};
|
||||
private static final int FILE_GROUP = 2;
|
||||
|
||||
|
@ -43,7 +44,7 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting
|
|||
@SuppressWarnings("nls")
|
||||
private String getCompilerCommandPattern() {
|
||||
String parameter = getCustomParameter();
|
||||
return "(" + parameter + ")";
|
||||
return "\\s*\"?("+LEADING_PATH_PATTERN+")?(" + parameter + ")\"?";
|
||||
}
|
||||
|
||||
private int adjustFileGroup() {
|
||||
|
|
Loading…
Add table
Reference in a new issue