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

CMakeToolChainManager removeToolChainFile not working #908

Closed
alirana01 opened this issue Oct 7, 2024 · 2 comments · Fixed by #909
Closed

CMakeToolChainManager removeToolChainFile not working #908

alirana01 opened this issue Oct 7, 2024 · 2 comments · Fixed by #909
Milestone

Comments

@alirana01
Copy link
Contributor

Describe the bug
CMakeToolChainManager is not removing the cmake toolchains. I can still see them even after calling the remove function.

To Reproduce
We have cmake toolchains that are initialized like and added using the CMakeToolChainManager. The issue is that when I am trying to remove them by calling the removeToolChainFile the tcId calculated there is at times different than the one that is used while adding them. Because of this the toolchains are not removed and I am still able to see them in the Preferences.

Expected behavior
Calling the toolchain manager's remove method should remove the toolchains from the eclipse preferences.

Code
My function to remove all CMake ToolChains.

	/**
	 * Removes all the cmake toolchains in the current environment
	 */
	public void removeCmakeToolChains()
	{
		ICMakeToolChainManager cmakeTcManager = CCorePlugin.getService(ICMakeToolChainManager.class);
		List<ICMakeToolChainFile> cIcMakeToolChainFiles = new ArrayList<>(cmakeTcManager.getToolChainFiles());
		for (ICMakeToolChainFile cmakeToolchain : cIcMakeToolChainFiles)
		{
			try
			{
				cmakeTcManager.removeToolChainFile(cmakeToolchain);
			}
			catch (Exception e)
			{
				Logger.log(e);
			}
		}
	}

The addToolChainFile(ICMakeToolChainFile file) function in CMakeToolChainManager is calculating tcId using
makeToolChainId(toolchain);

but the removeToolChainFile(ICMakeToolChainFile file) is using this

String tcId = makeToolChainId(file.getProperty(CMakeBuildConfiguration.TOOLCHAIN_TYPE),
				file.getProperty(CMakeBuildConfiguration.TOOLCHAIN_ID));

I am not sure why these two are different while debugging calculating the tcId using the way in add I am able to successfully remove these.

Version Information (please complete the following information):

  • OS and OS Version/extra details: [e.g. Windows, Linux, macOS] (all)
  • Eclipse Version: v4.33.0 2024-09
  • CDT Version: 11.6.1
@alirana01
Copy link
Contributor Author

I also wanted to become a contributor to eclipse and have a branch and some code ready to push but seems like I need to have some access before doing that I have followed the CONTRIBUTING.MD guide and waiting for the approval to get it

@jonahgraham
Copy link
Member

I also wanted to become a contributor to eclipse and have a branch and some code ready to push but seems like I need to have some access before doing that I have followed the CONTRIBUTING.MD guide and waiting for the approval to get it

Contributions are certainly welcome. Please push your change to your fork and create a PR and thanks in advance!

See Create a Pull Request for your commit(s). for instructions.

@jonahgraham jonahgraham linked a pull request Oct 8, 2024 that will close this issue
jonahgraham pushed a commit that referenced this issue Oct 8, 2024
Resolves that the calculated ID in the removal function was different than the one in the add

Fixes #908
@jonahgraham jonahgraham added this to the 12.0.0 milestone Oct 8, 2024
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 a pull request may close this issue.

2 participants