Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorMarc-Andre Laperle2020-05-10 19:11:11 +0000
committerMarc-André Laperle2020-07-11 21:28:56 +0000
commitd017917f3584c4bdc06f77a58159918124b0a2c2 (patch)
tree2dc7ca3f3f8c1c9f3a5fd089d97f0e3cd983342d /build
parent063301deca2976648fb6878dbc45eaa27e3f9915 (diff)
downloadorg.eclipse.cdt-d017917f3584c4bdc06f77a58159918124b0a2c2.tar.gz
org.eclipse.cdt-d017917f3584c4bdc06f77a58159918124b0a2c2.tar.xz
org.eclipse.cdt-d017917f3584c4bdc06f77a58159918124b0a2c2.zip
Bug 563006 - CDB settings provider/parser doesn't support "arguments"
One flaw with this implementation is that the "arguments" coming from the CDB do not have shell quoting and shell escaping of quotes whereas the current implementations of Build Output parsers assume some form of shell quoting. This means that simply joining strings of arguments with spaces will be missing the expected shell quoting and possibly misparsed by the build output parsers. It is not clear to be at this point if this should be fixed or not as it might involve revamping the existing build output parsers to add the concept of shell/environment and this could also affect potential extenders. In this current form, simple cases with no spacing and quote escaping involved work correctly and is still a nice improvement. Change-Id: Ia81796e63c748318b34696998ac4a467712e5f96 Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>
Diffstat (limited to 'build')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/CompilationDatabaseParserTest.java47
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/CompilationDatabaseParser.java7
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/CompileCommand.java4
3 files changed, 55 insertions, 3 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/CompilationDatabaseParserTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/CompilationDatabaseParserTest.java
index 09877e1ae60..3e77a2bfda7 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/CompilationDatabaseParserTest.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/CompilationDatabaseParserTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2019 Marc-Andre Laperle.
+ * Copyright (c) 2019, 2020 Marc-Andre Laperle.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -88,11 +88,17 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
}
private void createTestProject() throws Exception {
- createTestProject(true, true, true, true, true);
+ createTestProject(true, true, true, true, true, false);
}
private void createTestProject(boolean useAbsoluteSourcePath, boolean haveCommandDir, boolean validCommandDir,
boolean haveCommandLine, boolean validCommandLine) throws Exception {
+ createTestProject(useAbsoluteSourcePath, haveCommandDir, validCommandDir, haveCommandLine, validCommandLine,
+ false);
+ }
+
+ private void createTestProject(boolean useAbsoluteSourcePath, boolean haveCommandDir, boolean validCommandDir,
+ boolean haveCommandLine, boolean validCommandLine, boolean haveCommandArguments) throws Exception {
fProject = ResourceHelper.createCDTProjectWithConfig(getName());
fFolder = ResourceHelper.createFolder(fProject, "folder");
@@ -140,6 +146,10 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
else
command.command = "foo";
}
+ if (haveCommandArguments) {
+ command.arguments = new String[] { "g++", "-I" + fFolder.getLocation().toOSString(), "-DFOO=2",
+ sourceFilePath };
+ }
// Command for proj/test.cpp
CompileCommand command2 = new CompileCommand();
@@ -162,6 +172,11 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
command2.command = "foo";
}
+ if (haveCommandArguments) {
+ command2.arguments = new String[] { "g++", "-I" + fFolder.getLocation().toOSString(), "-DFOO=3",
+ sourceFilePath2 };
+ }
+
CompileCommand[] commands = new CompileCommand[2];
commands[0] = command;
commands[1] = command2;
@@ -820,6 +835,34 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
assertFalse(CDataUtil.isExcluded(tu.getPath(), resCfgDescription.getSourceEntries()));
}
+ public void testParseCDB_CommandArguments() throws Exception {
+ createTestProject(true, true, true, false, false, true);
+
+ ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(fProject);
+ ICElement ce = CCorePlugin.getDefault().getCoreModel().create(fOutsideCdbSourceFile.getFullPath());
+ ITranslationUnit tu = (ITranslationUnit) ce;
+ assertFalse(
+ CDataUtil.isExcluded(tu.getPath(), getConfigurationDescription(fProject, false).getSourceEntries()));
+
+ CompilationDatabaseParser parser = (CompilationDatabaseParser) LanguageSettingsManager
+ .getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
+ assertTrue(parser.isEmpty());
+ parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
+ parser.setCompilationDataBasePathProperty(fCdbFile.getLocation().toOSString());
+ addLanguageSettingsProvider(parser);
+
+ ICConfigurationDescription cfgDescription = getConfigurationDescription(fProject, true);
+
+ parser.processCompileCommandsFile(null, cfgDescription);
+ CoreModel.getDefault().setProjectDescription(cfgDescription.getProjectDescription().getProject(),
+ cfgDescription.getProjectDescription());
+ joingLanguageSettingsJobs();
+
+ assertExpectedEntries(parser);
+
+ ICConfigurationDescription resCfgDescription = getConfigurationDescription(fProject, false);
+ }
+
public void testClear() throws Exception {
createTestProject();
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/CompilationDatabaseParser.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/CompilationDatabaseParser.java
index 3bc795e6399..008b05e9c11 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/CompilationDatabaseParser.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/CompilationDatabaseParser.java
@@ -308,7 +308,12 @@ public class CompilationDatabaseParser extends LanguageSettingsSerializableProvi
}
}
- outputParser.processLine(c.getCommand());
+ String command = c.getCommand();
+ if (command != null) {
+ outputParser.processLine(command);
+ } else if (c.getArguments() != null) {
+ outputParser.processLine(String.join(" ", c.getArguments())); //$NON-NLS-1$
+ }
parseCmdsMonitor.worked(1);
}
LanguageSettingsStorage storage = outputParser.copyStorage();
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/CompileCommand.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/CompileCommand.java
index 3675d94dc07..fa58863dee4 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/CompileCommand.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/CompileCommand.java
@@ -18,6 +18,7 @@ public class CompileCommand {
public String directory;
public String command;
public String file;
+ public String[] arguments;
public String getDirectory() {
return directory;
@@ -31,4 +32,7 @@ public class CompileCommand {
return file;
}
+ public String[] getArguments() {
+ return arguments;
+ }
}

Back to the top