-
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 602 suites 13m 0s ⏱️ For more details on these failures, see this check. Results for commit cfea01e. ♻️ 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.
2c4aa3f
to
84316a4
Compare
84316a4
to
d01e65c
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.
d01e65c
to
70bd427
Compare
@alicetrifu Is this PR still work in progress? |
Hello @ghentschke , This should be done. I see that the logs are not available anymore for this, but the comments should be fixed. I see that meanwhile this got into conflict. Should I fix this? |
That would be great. I think we should fix this, since another user has stumbled around this issue. See eclipse-cdt/cdt-lsp#531
Yes |
@ghentschke, I have fixed the conflict directly form the Github UI. I hope this is fine. Will wait for the final result of the checks. Thank you! |
There is still a failed unit test. I am not sure if it relates to this PR. |
@ghentschke , This does not seem to be related to my PR indeed. But I am not sure why I have the problem with the Licence. I had this in the past as well and @Kummallinen rerun this for me. I think there are some issues with my permissions. Any idea on what I should do next to fix this ? Thank you! |
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.