-
Notifications
You must be signed in to change notification settings - Fork 210
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
Add UI for specifying CMake tools and generators' locations #1067
base: main
Are you sure you want to change the base?
Add UI for specifying CMake tools and generators' locations #1067
Conversation
Test Results 603 files 603 suites 13m 26s ⏱️ Results for commit 5aa5354. ♻️ This comment has been updated with latest results. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
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.
Thanks for this change. Please have a look at my comments and don't hesitate to reach out to me or @betamaxbandit if you need any clarification.
cmake/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakePreferencePage.java
Outdated
Show resolved
Hide resolved
cmake/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakePreferencePage.java
Show resolved
Hide resolved
...eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/CMakeBuildEnvironmentSupplier.java
Outdated
Show resolved
Hide resolved
...eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/CMakeBuildEnvironmentSupplier.java
Outdated
Show resolved
Hide resolved
...rg.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/EnvironmentVariableManager.java
Outdated
Show resolved
Hide resolved
@@ -225,6 +227,10 @@ IEnvironmentContextInfo getDefaultContextInfo(Object level) { | |||
* or null if the the given level is not supported | |||
*/ | |||
public IEnvironmentContextInfo getContextInfo(Object level) { | |||
if (level instanceof ICBuildConfiguration || level instanceof IBuildConfiguration buildConfiguration | |||
&& buildConfiguration.getAdapter(ICBuildConfiguration.class) != null) { | |||
return new CMakeEnvironmentContextInfo(getDefaultContextInfo(level)); |
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.
Can you explain what this code does a bit please as I don't understand full effect of this, but I do find it unexpected that we do getAdapter for ICBuildConfiguration, but then don't pass the ICBuildConfiguration to getDefaultContextInfo.
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.
when I test using a default CMake project, the level here is an instance of IBuildConfiguration.
When getDefaultContextInfo(IBuildConfiguration)
is called, the return context info would contain 3 suppliers as:
suppliers = new ICoreEnvironmentVariableSupplier[] { EnvironmentVariableManager.fBuildConfigSupplier, EnvironmentVariableManager.fToolChainSupplier, EnvironmentVariableManager.fUserSupplier
But, if I call getDefaultContextInfo(ICBuildConfiguration) here, the supplier would only be
suppliers = new ICoreEnvironmentVariableSupplier[] { EnvironmentVariableManager.fUserSupplier, EnvironmentVariableManager.fEclipseSupplier
I'm not so certain about the impact on this one, so level
is use here to avoid getting the false DefaultEnvironmentContextInfo
Here is the code block that I mentioned above: cdt/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/DefaultEnvironmentContextInfo.java
/*
* answers the list of suppliers that should be used for the given context
*/
protected ICoreEnvironmentVariableSupplier[] getSuppliers(Object context) {
ICoreEnvironmentVariableSupplier suppliers[];
if (context instanceof ICConfigurationDescription)
suppliers = new ICoreEnvironmentVariableSupplier[] { EnvironmentVariableManager.fUserSupplier,
EnvironmentVariableManager.fExternalSupplier };
else if (context instanceof IBuildConfiguration)
suppliers = new ICoreEnvironmentVariableSupplier[] { EnvironmentVariableManager.fBuildConfigSupplier,
EnvironmentVariableManager.fToolChainSupplier, EnvironmentVariableManager.fUserSupplier };
else
suppliers = new ICoreEnvironmentVariableSupplier[] { EnvironmentVariableManager.fUserSupplier,
EnvironmentVariableManager.fEclipseSupplier };
return suppliers;
}
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.
Hi @DangMinhTam382 ,
thanks for the explanation, but TBH I don't understand exactly what is required here.
I think @Kummallinen had a specific requirement here.
cmake/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakePreferencePage.java
Outdated
Show resolved
Hide resolved
...eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/CMakeBuildEnvironmentSupplier.java
Outdated
Show resolved
Hide resolved
This comment was marked as resolved.
This comment was marked as resolved.
cmake/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakePreferencePage.java
Show resolved
Hide resolved
@@ -225,6 +227,10 @@ IEnvironmentContextInfo getDefaultContextInfo(Object level) { | |||
* or null if the the given level is not supported | |||
*/ | |||
public IEnvironmentContextInfo getContextInfo(Object level) { | |||
if (level instanceof ICBuildConfiguration || level instanceof IBuildConfiguration buildConfiguration | |||
&& buildConfiguration.getAdapter(ICBuildConfiguration.class) != null) { | |||
return new CMakeEnvironmentContextInfo(getDefaultContextInfo(level)); |
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.
Hi @DangMinhTam382 ,
thanks for the explanation, but TBH I don't understand exactly what is required here.
I think @Kummallinen had a specific requirement here.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
ce6f147
to
4bffb8d
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
4bffb8d
to
dcbc752
Compare
This comment was marked as resolved.
This comment was marked as resolved.
072517e
to
05f5471
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.
@DangMinhTam382 Sorry for how many individual comments there are - most are trivial to fix and some of them are minor. But a handful of them are blocking. Please let me know if you have any follow-up questions.
....core.tests/misc/org/eclipse/cdt/internal/core/envvar/CMakeBuildEnvironmentSupplierTest.java
Outdated
Show resolved
Hide resolved
....core.tests/misc/org/eclipse/cdt/internal/core/envvar/CMakeBuildEnvironmentSupplierTest.java
Outdated
Show resolved
Hide resolved
import org.osgi.service.prefs.Preferences; | ||
|
||
/** | ||
* Test for IDE_82683_REQ_004_005 |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
....core.tests/misc/org/eclipse/cdt/internal/core/envvar/CMakeBuildEnvironmentSupplierTest.java
Outdated
Show resolved
Hide resolved
....core.tests/misc/org/eclipse/cdt/internal/core/envvar/CMakeBuildEnvironmentSupplierTest.java
Outdated
Show resolved
Hide resolved
generatorLocationTextBox = new Text(locationComp, SWT.BORDER); | ||
generatorLocationTextBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); | ||
generatorLocationTextBox.setEditable(false); | ||
generatorLocationTextBox.setText(String.join(VALUE_DELIMITER, generatorLocations)); |
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 text box can grow really wide as it tries to fit the whole string here. So if you have long or many paths you end up with very wide locationComp and end up with a horizontal scroll bar on the preference page
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.
Thanks for pointing this out! I do notice it when reopen dialog after long locations added.
I added this block right here to make locationComp has a widthHint so it won't be too wide.
https://github.com/DangMinhTam382/cdt/blob/45be12bb62a98052d2728a682f848def892203e9/cmake/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakePreferencePage.java#L200-L203
cmake/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/CMakePreferencePage.java
Outdated
Show resolved
Hide resolved
...eclipse.cdt.core/src/org/eclipse/cdt/internal/core/envvar/CMakeBuildEnvironmentSupplier.java
Outdated
Show resolved
Hide resolved
....core.tests/misc/org/eclipse/cdt/internal/core/envvar/CMakeBuildEnvironmentSupplierTest.java
Outdated
Show resolved
Hide resolved
....core.tests/misc/org/eclipse/cdt/internal/core/envvar/CMakeBuildEnvironmentSupplierTest.java
Outdated
Show resolved
Hide resolved
@betamaxbandit / @DangMinhTam382 / @Kummallinen I have spent a bunch of time trying to understand what is going on here, and I have left a long review. However now that I have completed it I feel many parts of the review are at too low a level and miss out on the higher level objectives #1000 IDE-82683-REQ-004 and IDE-82683-REQ-005 aim to set out. The quoted items are from the PDF in #1000 on those requirements, with some bolding by me for emphasis. Here are some issues that must resolved:
The new CMake variable supplier is applying itself to non-CMake projects. e.g. if I build a Makefile core build project the settings in the new CMake preference page affect the PATH used for it.
I am unsure how this requirement is being implemented.
The new CMake variable supplier is added to the available suppliers with A particular use case that does not work, although it is implied to work by the new GUI, is if:
If I build, it will still use Note that this isn't actually a regression. The same "wrong" cmake is used when I don't have this PR. But I think that this new GUI/preference should solve this bug.
When debugging, the PATH in the inferior is broken with |
Thanks for details analysis @jonahgraham...
This pollution of the environment is a serious issue. |
When I spec'd this in IDE_82683_REQ_004 I did not elaborate. This item comes from requirement IDE_82683_REQ_003 which is not being implemented in the CDT12.0 timeframe, so the specification has not been developed. I assumed it could be "added" on later. I presume the cmake location values preference node (CMakeBuildEnvironmentSupplier.CMAKE_LOCATION) could be set by the quick fix action without needing to add API. Is this adequate? |
Are the following locations on your PATH environment variable before you launch eclipse? Surely if that is the case then both these paths constitute what I referred to in my spec as "system" paths. And surely eclipse can have no control over which is used; it's purely down to order. Have I understood correctly? |
My PATH when launching eclipse looks like (simplified to highlight issue) In a terminal if I run:
However (without this patch), when building a CMake project in the IDE, which If I am using:
I expected this patch to solve the problem described in the last paragraph, which means that when I manually configure
Therefore my conclusion is that this implementation does not solve the bug, and it make it even less clear to the user what is happening. My expectation as a user is if I choose This same problem applies to the generators, i.e the wrong ninja + make can be picked up. The same problem also applies on Windows, depending how you setup your machine. The workaround for the current HEAD of CDT is one of:
|
Thanks for the detailed analysis Mr. @jonahgraham , However, I high doubt these issues could be resolved in time for the CDT 12.0.0 release. |
Thanks @DangMinhTam382 for letting me know. I have removed the milestone and I have set this to a Draft state until it is ready for more work. Let me know when you want me to review it again. |
4a7fdd1
to
45be12b
Compare
Adding UI into CMake Preference page that allow user to specify the location of the CMake tool and the location of CMake generators. Added Unit test Addresses Issue: CDT CMake Improvements eclipse-cdt#1000, IDE-82683-REQ-004 and IDE-82683-REQ-005
45be12b
to
5aa5354
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 code review and marked as resolved all issues that are fully resolved. The higher level design issue is still outstanding and we should discuss that at the end of March/early April
ICdtVariableManager vm = CCorePlugin.getDefault().getCdtVariableManager(); | ||
return vm.resolveValue(value, null, CMakeBuildEnvironmentSupplier.EMPTY_STRING, null); | ||
} catch (CdtVariableException e) { | ||
Activator.log(e); |
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 empty message can be solved by adding some additional context, such as:
Activator.log(e); | |
Activator.log(Activator.errorStatus("Some informative message here about failing to resolve the variable", e)); |
testButton.addListener(SWT.Selection, e -> { | ||
try { | ||
Process p = Runtime.getRuntime().exec(new String[] { | ||
resolveVariableValue(cmakeLocation) + File.separatorChar + "cmake", "--version" }); //$NON-NLS-1$ //$NON-NLS-2$ |
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 resolveVariableValue returns null here I think this will mean that null/cmake
will be the result.
String.format(CMakeBuildEnvironmentSupplier.LOCATION_NODE, index), | ||
CMakeBuildEnvironmentSupplier.EMPTY_STRING)); | ||
} | ||
generatorLocations = genlocs.toArray(new String[0]); |
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.
You can use more recent Java way to avoid having to resize the array:
generatorLocations = genlocs.toArray(new String[0]); | |
generatorLocations = genlocs.toArray(String[]::new); |
Thanks for the review, sir!
|
Add UI for specifying CMake tools and generators locations
Adding UI into CMake Preference page that allow user to specify the
location of the CMake tool and the location of CMake generators.
Added CMakeBuildEnvironmentSupplier.class for ICBuildConfiguration
Addresses Issue: CDT CMake Improvements #1000, IDE-82683-REQ-004 and
IDE-82683-REQ-005