Skip to content
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 user additional CMake arugments at the end. #814

Merged
merged 3 commits into from
Sep 12, 2024

Conversation

ewaterlander
Copy link
Contributor

The additional CMake arguments added by the user in the launch configuration UI are added at the end of the CMake command, such that the user is able to override arguments set by the system.

The additional CMake arguments added by the user in the launch
configuration UI are added at the end of the CMake command, such that
the user is able to override arguments set by the system.
@ewaterlander
Copy link
Contributor Author

Hi @betamaxbandit
See this change.

@betamaxbandit
Copy link
Contributor

Hi @ewaterlander ,
Seems like a good idea.
Just to confirm the intention here is that the last define value on the CMake command line is used in preference to the same define earlier in the line?

For example, the following CMake invocation has 2 CMAKE_BUILD_TYPE defines and it is the last, Debug, that CMake uses:

cmake -G MinGW Makefiles -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON C:\Users\betamax\cdt-only2\runtime-New_configuration_CDT2\cmake_hw -DCMAKE_BUILD_TYPE=Debug

Is this correct?

@ewaterlander
Copy link
Contributor Author

Hi @ewaterlander , Seems like a good idea. Just to confirm the intention here is that the last define value on the CMake command line is used in preference to the same define earlier in the line?

For example, the following CMake invocation has 2 CMAKE_BUILD_TYPE defines and it is the last, Debug, that CMake uses:

cmake -G MinGW Makefiles -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON C:\Users\betamax\cdt-only2\runtime-New_configuration_CDT2\cmake_hw -DCMAKE_BUILD_TYPE=Debug

Is this correct?

Yes, that is correct. The last -DCMAKE_BUILD_TYPE= argument prevails.

@ewaterlander
Copy link
Contributor Author

ewaterlander commented Jun 6, 2024

I looked a bit further at the code. Above my change, on line 80, there is also a call CommandDescriptorBuilder.appendCMakeArguments(args, cmakeProperties.getExtraArguments());
Here cmakeProperties.getExtraArguments() returns an empty list.

cmakeProperties.getExtraArguments() is getting settings that were stored in /.settings/CDT-cmake.yaml
This file was created in CMakeBuildConfiguration.getPropertiesController().

In CMakeBuildConfiguration.build() the settings from this file are loaded at line 162:
ICMakeProperties cmakeProperties = getPropertiesController().load();

There is no place in the code where extra arguments are stored in this file, so you will always get an empty list.

The launch configuration UI stores the additional CMake arguments in the project's preference store, and I think that is the correct place. The method I moved to the end also gets the settings from there.

I think the the YAML file can go. It is actually not used and it only makes the code confusing. There is no need for an extra YAML file to store CMake settings. I will make a separate PR.

Copy link
Contributor

@betamaxbandit betamaxbandit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review LGTM.

@betamaxbandit
Copy link
Contributor

I looked a bit further at the code. Above my change, on line 80, there is also a call CommandDescriptorBuilder.appendCMakeArguments(args, cmakeProperties.getExtraArguments()); Here cmakeProperties.getExtraArguments() returns an empty list.

cmakeProperties.getExtraArguments() is getting settings that were stored in /.settings/CDT-cmake.yaml This file was created in CMakeBuildConfiguration.getPropertiesController().

In CMakeBuildConfiguration.build() the settings from this file are loaded at line 162: ICMakeProperties cmakeProperties = getPropertiesController().load();

There is no place in the code where extra arguments are stored in this file, so you will always get an empty list.

The launch configuration UI stores the additional CMake arguments in the project's preference store, and I think that is the correct place. The method I moved to the end also gets the settings from there.

I think the the YAML file can go. It is actually not used and it only makes the code confusing. There is no need for an extra YAML file to store CMake settings. I will make a separate PR.

I would urge caution.
1)
I override com.renesas.cdt.epl.cmake.core.CMakeBuildConfiguration.build(int, Map<String, String>, IConsole, IProgressMonitor).
And in it I I use the ICMakePropertiesController to set my own extra arguments, similar to this:

	ICMakePropertiesController propertiesController = getAdapter(ICMakePropertiesController.class);
	ICMakeProperties cmakeProps = propertiesController.load();
	cmakeProps.setExtraArguments(extraArguments);
	propertiesController.save(cmakeProps);

So I suggest not removing:
CommandDescriptorBuilder.appendCMakeArguments(args, cmakeProperties.getExtraArguments());

  1. Regarding the Yaml file, I've often wondered what it's purpose is.
    Could it be related to the CMake GUI?
    Perhaps Martin Weber knows - I've forgotten his github handle.

@ewaterlander
Copy link
Contributor Author

ewaterlander commented Jun 7, 2024

I would urge caution. 1) I override com.renesas.cdt.epl.cmake.core.CMakeBuildConfiguration.build(int, Map<String, String>, IConsole, IProgressMonitor). And in it I I use the ICMakePropertiesController to set my own extra arguments, similar to this:

	ICMakePropertiesController propertiesController = getAdapter(ICMakePropertiesController.class);
	ICMakeProperties cmakeProps = propertiesController.load();
	cmakeProps.setExtraArguments(extraArguments);
	propertiesController.save(cmakeProps);

So I suggest not removing: CommandDescriptorBuilder.appendCMakeArguments(args, cmakeProperties.getExtraArguments());

  1. Regarding the Yaml file, I've often wondered what it's purpose is.
    Could it be related to the CMake GUI?
    Perhaps Martin Weber knows - I've forgotten his github handle.

If it would work correctly then the line
CommandDescriptorBuilder.appendCMakeArguments(args, cmakeProperties.getExtraArguments());
would add the user additional arguments (stored in YAML) and later they would be added again, because additional arguments are stored in the project preferences.
The reason we don't get double user arguments on the command line is that the YAML file is never saved. So the load() always returns an empty CMakeProperties.

Secondly there is a single YAML file for both Run and Debug. This is wrong.

I locally saved the YAML file. The user arguments are not stored correctly in the YAML file. So it is totally broken.

I will not remove it, but deprecate it.

This is how the YAML file looks like. Instead of arguments you get some identifier.

buildType: Release
cacheFile: ''
clearCache: false
debugOutput: false
debugTryCompile: false
extraArguments: &id001 []
linuxOverrides:
  command: cmake
  extraArguments: *id001
  generator: UnixMakefiles
  useDefaultCommand: true
trace: false
warnNoDev: false
warnUnitialized: false
warnUnused: false
windowsOverrides:
  command: cmake
  extraArguments: *id001
  generator: MinGWMakefiles
  useDefaultCommand: true

@betamaxbandit
Copy link
Contributor

Hi @15knots ,
Can you say what the purpose of the YAML file is please?

@ewaterlander
Copy link
Contributor Author

The only usage of the CMakePropertiesController is creating an empty new CMakeProperties by loading a non-existent YAML file. So my conclusion is that we can deprectate the CMakePropertiesController completely and remove all its usage.

I guess this is some old code that was not removed after somebody stored the CMake preferences in the project preferences, as it should be.

CMakePropertiesController was only used to create a new
CMakeProperties.  The load() method loads a YAML file
.settings/CDT-cmake.yaml which never existed, because the save()
method was never called.  There was no separate YAML file for Run and
Debug.

CMake properties are stored in the project preferences by the launch
config UI and these properties are used to construct the cmake command
line.
@ewaterlander
Copy link
Contributor Author

I deprecated CMakePropertiesController and removed its usage in this PR.

@ewaterlander
Copy link
Contributor Author

I was too fast. This will break your code. I will undo the last commit

@15knots
Copy link
Contributor

15knots commented Jun 8, 2024 via email

@betamaxbandit
Copy link
Contributor

Am Freitag, 7. Juni 2024, 12:27:09 CEST schrieb betamax:
Hi @15knots , Can you say what the purpose of the YAML file is please?
I planned to allowto persist option values for the cmake command-line on a per-projecz level in the yaml file. But when I found out that some of the cmake options are passed through totally undocumented properties from a project not being part of CDT (launchbar plugin) I gave up. You may safely delete the stuff dealing with that or find a way to combine both the YAML stettings and the launchbar settings. Martin

-- Cd wrttn wtht vwls s mch trsr.

Hi @15knots ,
thanks for replying.
I've created a new Issue for this:
#818

Please feel free to add comments or extra detail as you see fit.

Cheers John

@ewaterlander
Copy link
Contributor Author

Code review LGTM.

Hi @jonahgraham @betamaxbandit

John approved commit 1. Commit 3 reverted commit 2. I think this PR is OK for merging.

regards,

Erwin

@jonahgraham jonahgraham merged commit a65d3d7 into eclipse-cdt:main Sep 12, 2024
5 checks passed
@ewaterlander ewaterlander deleted the cmake_additional_args branch September 13, 2024 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants