-
Notifications
You must be signed in to change notification settings - Fork 215
Fix for the compiler path in compile_commands.json file #1138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Test Results 602 files - 34 602 suites - 34 13m 17s ⏱️ - 23m 13s Results for commit 2c4aa3f. ± Comparison against base commit 04105c2. This pull request removes 1217 tests.
♻️ This comment has been updated with latest results. |
1151c1e
to
dabaf25
Compare
...eclipse/cdt/managedbuilder/internal/core/jsoncdb/generator/CompilationDatabaseGenerator.java
Outdated
Show resolved
Hide resolved
dabaf25
to
080da79
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like roughly the correct solution. Just some cleanup and review the caching.
...eclipse/cdt/managedbuilder/internal/core/jsoncdb/generator/CompilationDatabaseGenerator.java
Outdated
Show resolved
Hide resolved
...eclipse/cdt/managedbuilder/internal/core/jsoncdb/generator/CompilationDatabaseGenerator.java
Outdated
Show resolved
Hide resolved
...eclipse/cdt/managedbuilder/internal/core/jsoncdb/generator/CompilationDatabaseGenerator.java
Outdated
Show resolved
Hide resolved
080da79
to
d448a14
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works well in the normal cases, but there are some corner cases that aren't handled well, see the individual comments.
...eclipse/cdt/managedbuilder/internal/core/jsoncdb/generator/CompilationDatabaseGenerator.java
Show resolved
Hide resolved
...eclipse/cdt/managedbuilder/internal/core/jsoncdb/generator/CompilationDatabaseGenerator.java
Outdated
Show resolved
Hide resolved
d448a14
to
2c4aa3f
Compare
if (arguments.length <= 1) { | ||
return ""; //$NON-NLS-1$ | ||
} | ||
return String.join(" ", Arrays.copyOfRange(arguments, 1, arguments.length)); //$NON-NLS-1$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an invalid way of converting a list to a command line string. For example gcc "My file.c" -o "My file.o"
would turn into "/usr/bin/gcc" My file.c -o My file.o
which won't be interpreted properly. Please ensure quoting is done as appropriate and meets the spec of compile_commands.json linked here
org.eclipse.cdt.utils.CommandLineUtil.argumentsToString(Collection, boolean) may or may not actually match the requirements. I hope that it does as it would be simpler than implementing a new case. If argumentsToString does not meet requirements, I recommend adding a new method to CommandLineUtil and the appropriate tests to CommandLineUtilTest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @jonahgraham . Thank you for the review. I Think we need to fix this by implementing indeed a new case. I did this and also added a JUnit test especially for this so we can check this properly.
Please let me know if you think we need to do any other adjustments.
Thank you!
private String findCompilerInPath(ITool tool, IConfiguration config) { | ||
if (toolMap.containsKey(tool)) { | ||
return "\"" + toolMap.get(tool) + "\""; //$NON-NLS-1$//$NON-NLS-2$ | ||
private String findCompilerInPath(ITool tool, IConfiguration config, String compilerName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tool
is now unused.
private String findCompilerInPath(ITool tool, IConfiguration config, String compilerName) { | |
private String findCompilerInPath(IConfiguration config, String compilerName) { |
@@ -70,7 +71,7 @@ public final class CompilationDatabaseGenerator { | |||
* Checked on each build | |||
* Used before we look up the environment | |||
*/ | |||
private Map<ITool, String> toolMap = new HashMap<>(); | |||
private Map<String, String> toolMap = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we now have a key of a string it is much less obvious what that key is, so please document it. Perhaps a line like this in the javadoc: Map of compiler name (as calculated by {@link #getCompilerName(String)}) to the absolute path of the compiler.
Compiler path was wrongly created when anything was set on the "Prefix" option from "Cross Settings". The code needs to check if anything is set there before creating the default path for the compiler.
2c4aa3f
to
84316a4
Compare
Compiler path was wrongly created when anything was set on the "Prefix" option from "Cross Settings". The code needs to check if anything is set there before creating the default path for the compiler.