-
Notifications
You must be signed in to change notification settings - Fork 208
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
Added feature to generate compile_commands.json file #692
Added feature to generate compile_commands.json file #692
Conversation
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.
Quick initial pass
You also need to get your API baseline set correctly, as there mare API changes here so you need feedback from the API tooling to get the versions set correctly & all appropriate since tags in place
.../src/org/eclipse/cdt/managedbuilder/core/jsoncdb/generator/CompilationDatabaseGenerator.java
Outdated
Show resolved
Hide resolved
See https://github.com/eclipse-cdt/cdt/blob/main/CONTRIBUTING.md#setup-cdt-for-development-manual-setup for API tooling setup guidance |
...clipse/cdt/managedbuilder/core/jsoncdb/generator/CompilationDatabaseContributionManager.java
Outdated
Show resolved
Hide resolved
...clipse/cdt/managedbuilder/core/jsoncdb/generator/CompilationDatabaseContributionManager.java
Outdated
Show resolved
Hide resolved
...rg/eclipse/cdt/managedbuilder/core/jsoncdb/generator/api/CompilationDatabaseInformation.java
Outdated
Show resolved
Hide resolved
...g/eclipse/cdt/managedbuilder/core/jsoncdb/generator/api/ICompilationDatabaseContributor.java
Outdated
Show resolved
Hide resolved
....cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java
Outdated
Show resolved
Hide resolved
e668dea
to
e20eb76
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.
I have marked as Resolved those previous comments that seemed complete
...der.core/src/org/eclipse/cdt/managedbuilder/core/jsoncdb/CompilationDatabaseInformation.java
Outdated
Show resolved
Hide resolved
...clipse/cdt/managedbuilder/core/jsoncdb/generator/CompilationDatabaseContributionManager.java
Outdated
Show resolved
Hide resolved
....cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java
Outdated
Show resolved
Hide resolved
....cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java
Outdated
Show resolved
Hide resolved
e20eb76
to
e1c8915
Compare
...clipse/cdt/managedbuilder/core/jsoncdb/generator/CompilationDatabaseContributionManager.java
Outdated
Show resolved
Hide resolved
...clipse/cdt/managedbuilder/core/jsoncdb/generator/CompilationDatabaseContributionManager.java
Outdated
Show resolved
Hide resolved
...clipse/cdt/managedbuilder/core/jsoncdb/generator/CompilationDatabaseContributionManager.java
Outdated
Show resolved
Hide resolved
...clipse/cdt/managedbuilder/core/jsoncdb/generator/CompilationDatabaseContributionManager.java
Outdated
Show resolved
Hide resolved
.../src/org/eclipse/cdt/managedbuilder/core/jsoncdb/generator/CompilationDatabaseGenerator.java
Outdated
Show resolved
Hide resolved
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.
The code cleanliness failed, but not because of this PR. Once I merge #699 you will need to rebase this change.
e1c8915
to
beb9200
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.
I have done a partial review - there are still some concerns I have on the generator that I need to look at a little closer.
...clipse/cdt/managedbuilder/core/jsoncdb/generator/CompilationDatabaseContributionManager.java
Outdated
Show resolved
Hide resolved
factoryExtensions = new HashMap<>(); | ||
loadedInstances = 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.
I marked previous comments resolved around these fields because they weren't appearing on the latest patchset.
These fields lifecycle is unclear, made more complicated by the local variable with a similar name in initialise method.
Can these fields be final, assigned at declaration and have a clearer lifecycle? If my comment is unclear, let me know and I will provide a commit to explain it.
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.
I hope this is what you've meant, Jonah. If not, please let me know.
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 part of what I meant - I will add a commit to this PR to explain explicitly what I mean.
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.
I added b6c8e30 which shows what I meant. It is fairly minor, but removes some code and gets rid of the extra temporary map.
.../src/org/eclipse/cdt/managedbuilder/core/jsoncdb/generator/CompilationDatabaseGenerator.java
Outdated
Show resolved
Hide resolved
beb9200
to
e6fb475
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.
Not sure at what step we need to add some tests for this. In the meantime, this change (probably because we generate into "new" directory build
) causes a test failure in org.eclipse.cdt.managedbuilder.core.regressions.Bug_303953Test.testBuildAfterSourcefileDelete()
Please see this section of the testing document for how to run these tests in the dev environment.
Following our call yesterday we decided that a bit of work is needed on enabling the feature. Quoted from minutes:
|
743ca47
to
a3198c3
Compare
This has grown in scope - in light of our call today and the comment that @15knots made: #689 (comment) we do indeed need this to be settable with the default being the workspace setting. The workspace setting default should be off for now. |
We are going to hold off merging this until after we branch. We plan to branch very soon, a little earlier than normal. |
The conclusion of the meeting today is that the current location for generation (in CommonBuilder) is a reasonable short term solution. There may be better places in the future to keep the Similarly the placement of the output in |
a3198c3
to
c825859
Compare
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.cdt.managedbuilder.core.jsoncdb.generator; |
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.
If this isn't being exported probably should name this package as an internal. so "org.eclipse.cdt.managedbuilder.internal.core.jsoncdb.generator"
f7eb2c8
to
224f231
Compare
Hello @jonahgraham ,
It's worth mentioning that I never encountered this exception in the workspace, the output is always different from null. Do you have any suggestions on how I could address this issue, maybe? Currently, I've marked the test as skipped, but I believe this should be investigated further in the future. |
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 very close to me. I am about to merge in 11.6 version bump now that I have branched for 11.5. I'll try rebasing and see if I can reproduce the difference.
* @throws CoreException | ||
*/ | ||
@Test | ||
@Ignore("This will be temporary skipped due to builder error") |
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.
The difference between what you see in the workspace and what happens on the build machine is probably down to different sets of enabled bundles. See https://github.com/eclipse-cdt/cdt/blob/main/TESTING.md#using-limited-sets-of-plug-ins-in-tests (point 3)
224f231
to
b9f56ca
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.
The preferences page does not work. The performApply calling itself makes it fail catastrophically, but my attempt at the simple fix did not resolve the issue.
I made comments in the PR for most of the changes I made. I'll mark them as resolved, but wanted you to know why I changed what I did.
...tests/tests/org/eclipse/cdt/managedbuilder/core/tests/CompilationDatabaseGenerationTest.java
Outdated
Show resolved
Hide resolved
...tests/tests/org/eclipse/cdt/managedbuilder/core/tests/CompilationDatabaseGenerationTest.java
Outdated
Show resolved
Hide resolved
...tests/tests/org/eclipse/cdt/managedbuilder/core/tests/CompilationDatabaseGenerationTest.java
Outdated
Show resolved
Hide resolved
...tests/tests/org/eclipse/cdt/managedbuilder/core/tests/CompilationDatabaseGenerationTest.java
Outdated
Show resolved
Hide resolved
...tests/tests/org/eclipse/cdt/managedbuilder/core/tests/CompilationDatabaseGenerationTest.java
Outdated
Show resolved
Hide resolved
|
||
@Override | ||
public void performApply(IProgressMonitor monitor) throws CoreException { | ||
this.performApply(monitor); |
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.
Not sure what intention was here, but this calls itself and causes stack overflow. (Probably should do what is in the listener on line 71)
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.
I made this change, but the new code needs to be checked that it is correct.
generateFileCheckbox.setText(Messages.JsonCdbGeneratorPreferencePage_generateCompilationdatabase); | ||
generateFileCheckbox.addListener(SWT.Selection, e -> { | ||
boolean newValue = generateFileCheckbox.getSelection(); | ||
preferenceStore.setValue(ENABLE_FILE_GENERATION, newValue); |
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.
Lets avoid changing the preference until Apply is pressed
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.
I made this change, but the new code needs to be checked that it is correct.
...se/cdt/managedbuilder/internal/ui/compilationdatabase/CompilationDatabaseGeneratorBlock.java
Outdated
Show resolved
Hide resolved
...se/cdt/managedbuilder/internal/ui/compilationdatabase/CompilationDatabaseGeneratorBlock.java
Outdated
Show resolved
Hide resolved
...se/cdt/managedbuilder/internal/ui/compilationdatabase/CompilationDatabaseGeneratorBlock.java
Outdated
Show resolved
Hide resolved
Seeing as this implementation the preferences don't work, some additional time is needed here. I spent some time trying to replicate how @ghentschke and @ruspl-afed implemented preferences for cdt-lsp (e.g. EditorOptions and related classes). That implementation is a little complicated, but does allow all the configuration by products needed. (Unfortunately I ran out of time to do this before I went on vacation) |
e58842f
to
36aceae
Compare
36aceae
to
d530365
Compare
4cfbe34
to
245c225
Compare
9281017
to
502ca15
Compare
Includes: - Created a new extension point to provide the opportunity to incorporate additional information into the file - New tests for the generator - Preference page to enable/disable generator Fixes eclipse-cdt#689
0303c3a
to
deec4b6
Compare
deec4b6
to
bfce795
Compare
@ghentschke @Kummallinen @alicetrifu I added this additional commit (and squashed the rest) Generate compile_commands.json into standard build directory. That it is the file ends up in |
Assuming no objections to #692 (comment) and a clean build, this is ready to merge. |
That it is the file ends up in Debug/compile_commands.json instead of build/compile_commands.json. This lines up the behaviour of the generator with that of the code that generates a .clangd file in [ClangdConfigurationFileManager.java](https://github.com/eclipse-cdt/cdt-lsp/blob/ee297ee0ced1747352039e6ee25bcc80c10c7462/bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/internal/config/ClangdConfigurationFileManager.java) This code already supports vendors overriding to supply their own (or extended) .clangd contents.
bfce795
to
f13b0cb
Compare
I discussed this with William this morning and he/Renesas are happy to take advantage of the API that @ghentschke has provided in ClangdConfigurationFileManager to handle updating Therefore I am merging this now and we can start creating new issues as needed too. |
Added a new generator class to provide a compile_commands.json file in the "build" folder. Created a new extension point to provide the opportunity to incorporate additional information into the file.
Part of #689