From 9a654efbe39594d40d7ff7dbac1c0037b3521ad6 Mon Sep 17 00:00:00 2001 From: Fabrizio Iannetti Date: Fri, 16 Aug 2013 09:45:52 +0200 Subject: NEW - bug 394959: CDT GCC build output parser does not understand -isystem https://bugs.eclipse.org/bugs/show_bug.cgi?id=394959 Simple patch to treat -isystem as -I, so that at least the paths show up in the configuration: - added two include parse options (copied/adapted from -I) - added junit test case (copied/adapted from -I) Change-Id: Ib3f3764ad75def49f6ec180bfecc0d6f42eabb1d Signed-off-by: Fabrizio Iannetti Reviewed-on: https://git.eclipse.org/r/15584 Reviewed-by: Andrew Gvozdev IP-Clean: Andrew Gvozdev Tested-by: Andrew Gvozdev --- .../providers/tests/GCCBuildCommandParserTest.java | 61 ++++++++++++++++++++-- .../settings/providers/GCCBuildCommandParser.java | 2 + 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuildCommandParserTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuildCommandParserTest.java index be837ea7d71..6f8224a2ea4 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuildCommandParserTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuildCommandParserTest.java @@ -511,9 +511,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { } /** - * Parse variations of -I options. + * Parse variations of -isystem options. */ - public void testCIncludePathEntry() throws Exception { + public void testCISystemPathEntry() throws Exception { // Create model project and accompanied descriptions String projectName = getName(); IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); @@ -527,6 +527,57 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // create GCCBuildCommandParser GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + // parse line + parser.startup(cfgDescription, null); + parser.processLine("gcc" + // regular + + " -isystem/path0 " + // space after -isystem + + " -isystem /path1 " + // unknown option, should be ignored + + " -? " + // double-quoted path with spaces + + " -isystem\"/path with spaces\"" + // single-quoted path with spaces + + " -isystem'/path with spaces2'" + // second single-quoted and space after -isystem + + " -isystem '/path with spaces3'" + + " file.cpp"); + parser.shutdown(); + + // check populated entries + List entries = parser.getSettingEntries(cfgDescription, file, languageId); + CIncludePathEntry expected = new CIncludePathEntry("/path0", 0); + CIncludePathEntry entry = (CIncludePathEntry)entries.get(0); + assertEquals(expected.getName(), entry.getName()); + assertEquals(expected.getValue(), entry.getValue()); + assertEquals(expected.getKind(), entry.getKind()); + assertEquals(expected.getFlags(), entry.getFlags()); + assertEquals(expected, entry); + + assertEquals(new CIncludePathEntry("/path1", 0), entries.get(1)); + assertEquals(new CIncludePathEntry("/path with spaces", 0), entries.get(2)); + assertEquals(new CIncludePathEntry("/path with spaces2", 0), entries.get(3)); + assertEquals(new CIncludePathEntry("/path with spaces3", 0), entries.get(4)); + } + + /** + * Parse variations of -I options. + */ + public void testCIncludePathEntry() throws Exception { + // Create model project and accompanied descriptions + String projectName = getName(); + IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); + ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); + ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + + IFile file=ResourceHelper.createFile(project, "file.cpp"); + ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); + String languageId = ls.getLanguageId(); + + // create GCCBuildCommandParser + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + // parse line parser.startup(cfgDescription, null); parser.processLine("gcc" @@ -544,7 +595,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase { + " -I '/path with spaces3'" + " file.cpp"); parser.shutdown(); - + // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); CIncludePathEntry expected = new CIncludePathEntry("/path0", 0); @@ -554,13 +605,13 @@ public class GCCBuildCommandParserTest extends BaseTestCase { assertEquals(expected.getKind(), entry.getKind()); assertEquals(expected.getFlags(), entry.getFlags()); assertEquals(expected, entry); - + assertEquals(new CIncludePathEntry("/path1", 0), entries.get(1)); assertEquals(new CIncludePathEntry("/path with spaces", 0), entries.get(2)); assertEquals(new CIncludePathEntry("/path with spaces2", 0), entries.get(3)); assertEquals(new CIncludePathEntry("/path with spaces3", 0), entries.get(4)); } - + /** * Parse Mac Frameworks. */ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/GCCBuildCommandParser.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/GCCBuildCommandParser.java index b7153966a82..d114ae5fcd6 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/GCCBuildCommandParser.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/GCCBuildCommandParser.java @@ -33,6 +33,8 @@ public class GCCBuildCommandParser extends AbstractBuildCommandParser implements static final AbstractOptionParser[] optionParsers = { new IncludePathOptionParser("-I\\s*([\"'])(.*)\\1", "$2"), new IncludePathOptionParser("-I\\s*([^\\s\"']*)", "$1"), + new IncludePathOptionParser("-isystem\\s*([\"'])(.*)\\1", "$2"), + new IncludePathOptionParser("-isystem\\s*([^\\s\"']*)", "$1"), new IncludePathOptionParser("-(F|(iframework))\\s*([\"'])(.*)\\3", "$4", ICSettingEntry.FRAMEWORKS_MAC), new IncludePathOptionParser("-(F|(iframework))\\s*([^\\s\"']*)", "$3", ICSettingEntry.FRAMEWORKS_MAC), new IncludeFileOptionParser("-include\\s*([\"'])(.*)\\1", "$2"), -- cgit v1.2.3