-
Notifications
You must be signed in to change notification settings - Fork 222
Added API to manually run CMake #1483
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?
Changes from all commits
35070b3
f70ef1b
c522997
6314dbd
1d4ca49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2026 Renesas Electronics Europe and others. | ||
| * | ||
| * This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License 2.0 | ||
| * which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| *******************************************************************************/ | ||
| package org.eclipse.cdt.cmake.example.handler; | ||
|
|
||
| import java.io.IOException; | ||
| import java.text.MessageFormat; | ||
|
|
||
| import org.eclipse.cdt.cmake.core.CMakeBuildConfiguration; | ||
| import org.eclipse.cdt.cmake.example.Messages; | ||
| import org.eclipse.cdt.core.build.ICBuildConfiguration; | ||
| import org.eclipse.cdt.core.build.ICBuildConfigurationManager; | ||
| import org.eclipse.cdt.debug.core.CDebugCorePlugin; | ||
| import org.eclipse.cdt.launch.LaunchUtils; | ||
| import org.eclipse.core.commands.AbstractHandler; | ||
| import org.eclipse.core.commands.ExecutionEvent; | ||
| import org.eclipse.core.commands.ExecutionException; | ||
| import org.eclipse.core.resources.IProject; | ||
| import org.eclipse.core.resources.WorkspaceJob; | ||
| import org.eclipse.core.runtime.CoreException; | ||
| import org.eclipse.core.runtime.ILog; | ||
| import org.eclipse.core.runtime.IProgressMonitor; | ||
| import org.eclipse.core.runtime.IStatus; | ||
| import org.eclipse.core.runtime.Status; | ||
| import org.eclipse.debug.core.ILaunchConfiguration; | ||
| import org.eclipse.launchbar.core.ILaunchBarManager; | ||
|
|
||
| public class ConfigureCMakeProjectHandler extends AbstractHandler { | ||
|
|
||
| @Override | ||
| public Object execute(ExecutionEvent event) throws ExecutionException { | ||
| ICBuildConfigurationManager configManager = CDebugCorePlugin.getService(ICBuildConfigurationManager.class); | ||
| ILaunchBarManager launchBarManager = CDebugCorePlugin.getService(ILaunchBarManager.class); | ||
| try { | ||
| ILaunchConfiguration activeLaunchConfiguration; | ||
| activeLaunchConfiguration = launchBarManager.getActiveLaunchConfiguration(); | ||
| IProject project = LaunchUtils.getProject(activeLaunchConfiguration); | ||
| ICBuildConfiguration buildConfig = configManager.getBuildConfiguration(project.getActiveBuildConfig()); | ||
| if (buildConfig instanceof CMakeBuildConfiguration cbc) { | ||
| WorkspaceJob job = new WorkspaceJob("Configuring CMake Project...") { //$NON-NLS-1$ | ||
| @Override | ||
| public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { | ||
| try { | ||
| return cbc.configureCMakeBuildFiles(monitor); | ||
| } catch (CoreException | IOException e) { | ||
| return Status.error(MessageFormat.format(Messages.ConfigureCMakeProjectHandler_ConfigError, | ||
| project.getName()), e); | ||
| } | ||
| } | ||
| }; | ||
| job.setRule(project); | ||
| job.schedule(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This job modifies project state: markers, resource refresh, and scanner information. Should it set a scheduling rule before scheduling, probably the project, to avoid running concurrently with other workspace operations on the same project?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm with you on this one. I'm not quite sure if there's another WS job running during CMake configuration process, so I'll play it safe here and set rule to it as suggested. |
||
| } | ||
| } catch (CoreException e) { | ||
| ILog.of(getClass()).error("Error getting CBuildConfiguration", e); //$NON-NLS-1$ | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| NewExtendedCMakeProjectWizard_WindowTitle=New CMake Project | ||
| NewExtendedCMakeProjectWizard_PageTitle=New CMake Project | ||
| NewExtendedCMakeProjectWizard_Description=Specify properties of new CMake project. | ||
| ConfigureCMakeProjectHandler_ConfigError=Failed to perform CMake configuration for project {0} |
Uh oh!
There was an error while loading. Please reload this page.