mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 08:46:02 +02:00
Bug 178731, launch configs know which build configuration to use. Also use the build config name in the default launch config name.
This commit is contained in:
parent
ea5018aece
commit
0d758fd981
5 changed files with 103 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2006 QNX Software Systems and others.
|
* Copyright (c) 2000, 2007 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,7 +7,8 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - initial API and implementation
|
* QNX Software Systems - initial API and implementation
|
||||||
* Ken Ryall (Nokia) - https://bugs.eclipse.org/bugs/show_bug.cgi?id=118894
|
* Ken Ryall (Nokia) - bug 118894
|
||||||
|
* Ken Ryall (Nokia) - bug 178731
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.core;
|
package org.eclipse.cdt.debug.core;
|
||||||
|
|
||||||
|
@ -34,6 +35,12 @@ public interface ICDTLaunchConfigurationConstants {
|
||||||
*/
|
*/
|
||||||
public static final String ATTR_PROJECT_NAME = CDT_LAUNCH_ID + ".PROJECT_ATTR"; //$NON-NLS-1$
|
public static final String ATTR_PROJECT_NAME = CDT_LAUNCH_ID + ".PROJECT_ATTR"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch configuration attribute key. The value is the ID of the project's
|
||||||
|
* build configuration that should be used when a build is required before launch.
|
||||||
|
*/
|
||||||
|
public static final String ATTR_PROJECT_BUILD_CONFIG_ID = CDT_LAUNCH_ID + ".PROJECT_BUILD_CONFIG_ID_ATTR"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch configuration attribute key. The value is a string specifying
|
* Launch configuration attribute key. The value is a string specifying
|
||||||
* application a C/C++ launch configuration.
|
* application a C/C++ launch configuration.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2006 QNX Software Systems and others.
|
* Copyright (c) 2005, 2007 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - initial API and implementation
|
* QNX Software Systems - initial API and implementation
|
||||||
* Andrew Ferguson (andrew.ferguson@arm.com) - bug 123997
|
* Andrew Ferguson (andrew.ferguson@arm.com) - bug 123997
|
||||||
|
* Ken Ryall (Nokia) - bug 178731
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.launch;
|
package org.eclipse.cdt.launch;
|
||||||
|
|
||||||
|
@ -33,12 +34,15 @@ import org.eclipse.cdt.core.ICExtensionReference;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||||
import org.eclipse.cdt.core.model.ICModelMarker;
|
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
|
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
||||||
|
import org.eclipse.cdt.ui.newui.CDTPropertyManager;
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
|
@ -534,6 +538,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
|
||||||
}
|
}
|
||||||
|
|
||||||
monitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.building") + project.getName()); //$NON-NLS-1$
|
monitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.building") + project.getName()); //$NON-NLS-1$
|
||||||
|
setBuildConfiguration(configuration, project);
|
||||||
project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new SubProgressMonitor(monitor, scale));
|
project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new SubProgressMonitor(monitor, scale));
|
||||||
} finally {
|
} finally {
|
||||||
monitor.done();
|
monitor.done();
|
||||||
|
@ -542,6 +547,29 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up a project for building by making sure the active configuration is the one used
|
||||||
|
* when the launch was created.
|
||||||
|
* @param configuration
|
||||||
|
* @param buildProject
|
||||||
|
*/
|
||||||
|
private void setBuildConfiguration(ILaunchConfiguration configuration, IProject buildProject) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
String buildConfigID = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, ""); //$NON-NLS-1$
|
||||||
|
ICProjectDescription projDes = CDTPropertyManager.getProjectDescription(buildProject);
|
||||||
|
|
||||||
|
if (buildConfigID.length() > 0 && projDes != null)
|
||||||
|
{
|
||||||
|
ICConfigurationDescription buildConfiguration = projDes.getConfigurationById(buildConfigID);
|
||||||
|
buildConfiguration.setActive();
|
||||||
|
CDTPropertyManager.performOk(null);
|
||||||
|
//AbstractPage.updateViews(buildProject);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (CoreException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for compile errors in the current project and any of its
|
* Searches for compile errors in the current project and any of its
|
||||||
* prerequisite projects. If any compile errors, give the user a chance to
|
* prerequisite projects. If any compile errors, give the user a chance to
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Ken Ryall (Nokia) - bug 178731
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.launch.internal;
|
package org.eclipse.cdt.launch.internal;
|
||||||
|
|
||||||
|
@ -15,6 +16,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
|
@ -190,6 +192,13 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
|
||||||
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
||||||
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, debugConfig.getID());
|
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, debugConfig.getID());
|
||||||
|
|
||||||
|
ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(bin.getCProject().getProject());
|
||||||
|
if (projDes != null)
|
||||||
|
{
|
||||||
|
String buildConfigID = projDes.getActiveConfiguration().getId();
|
||||||
|
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, buildConfigID);
|
||||||
|
}
|
||||||
|
|
||||||
// Load up the debugger page to set the defaults. There should probably be a separate
|
// Load up the debugger page to set the defaults. There should probably be a separate
|
||||||
// extension point for this.
|
// extension point for this.
|
||||||
ICDebuggerPage page = CDebugUIPlugin.getDefault().getDebuggerPage(debugConfig.getID());
|
ICDebuggerPage page = CDebugUIPlugin.getDefault().getDebuggerPage(debugConfig.getID());
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2006 QNX Software Systems and others.
|
* Copyright (c) 2005, 2007 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Ken Ryall (Nokia) - bug 178731
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.launch.ui;
|
package org.eclipse.cdt.launch.ui;
|
||||||
|
|
||||||
|
@ -15,6 +16,7 @@ import org.eclipse.cdt.core.ICDescriptor;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -124,6 +126,11 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
||||||
if (cProject != null && cProject.exists()) {
|
if (cProject != null && cProject.exists()) {
|
||||||
name = cProject.getElementName();
|
name = cProject.getElementName();
|
||||||
config.setMappedResources(new IResource[] {cProject.getProject()});
|
config.setMappedResources(new IResource[] {cProject.getProject()});
|
||||||
|
|
||||||
|
ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(cProject.getProject());
|
||||||
|
String buildConfigID = projDes.getActiveConfiguration().getId();
|
||||||
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, buildConfigID);
|
||||||
|
|
||||||
}
|
}
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - initial API and implementation
|
* QNX Software Systems - initial API and implementation
|
||||||
|
* Ken Ryall (Nokia) - bug 178731
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.launch.ui;
|
package org.eclipse.cdt.launch.ui;
|
||||||
|
|
||||||
|
@ -22,6 +23,7 @@ import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchImages;
|
import org.eclipse.cdt.launch.internal.ui.LaunchImages;
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
||||||
|
@ -286,7 +288,15 @@ public class CMainTab extends CLaunchConfigurationTab {
|
||||||
public void performApply(ILaunchConfigurationWorkingCopy config) {
|
public void performApply(ILaunchConfigurationWorkingCopy config) {
|
||||||
ICProject cProject = this.getCProject();
|
ICProject cProject = this.getCProject();
|
||||||
if (cProject != null)
|
if (cProject != null)
|
||||||
|
{
|
||||||
config.setMappedResources(new IResource[] { cProject.getProject() });
|
config.setMappedResources(new IResource[] { cProject.getProject() });
|
||||||
|
ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(cProject.getProject());
|
||||||
|
if (projDes != null)
|
||||||
|
{
|
||||||
|
String buildConfigID = projDes.getActiveConfiguration().getId();
|
||||||
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, buildConfigID);
|
||||||
|
}
|
||||||
|
}
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, fProjText.getText());
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, fProjText.getText());
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, fProgText.getText());
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, fProgText.getText());
|
||||||
if (fTerminalButton != null) {
|
if (fTerminalButton != null) {
|
||||||
|
@ -617,6 +627,28 @@ public class CMainTab extends CLaunchConfigurationTab {
|
||||||
* Set the program name attributes on the working copy based on the ICElement
|
* Set the program name attributes on the working copy based on the ICElement
|
||||||
*/
|
*/
|
||||||
protected void initializeProgramName(ICElement cElement, ILaunchConfigurationWorkingCopy config) {
|
protected void initializeProgramName(ICElement cElement, ILaunchConfigurationWorkingCopy config) {
|
||||||
|
|
||||||
|
boolean renamed = false;
|
||||||
|
|
||||||
|
if (!(cElement instanceof IBinary))
|
||||||
|
{
|
||||||
|
cElement = cElement.getCProject();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cElement instanceof ICProject) {
|
||||||
|
|
||||||
|
IProject project = cElement.getCProject().getProject();
|
||||||
|
String name = project.getName();
|
||||||
|
ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project);
|
||||||
|
if (projDes != null) {
|
||||||
|
String buildConfigName = projDes.getActiveConfiguration().getName();
|
||||||
|
name = name + " " + buildConfigName; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
name = getLaunchConfigurationDialog().generateName(name);
|
||||||
|
config.rename(name);
|
||||||
|
renamed = true;
|
||||||
|
}
|
||||||
|
|
||||||
IBinary binary = null;
|
IBinary binary = null;
|
||||||
if (cElement instanceof ICProject) {
|
if (cElement instanceof ICProject) {
|
||||||
IBinary[] bins = getBinaryFiles((ICProject)cElement);
|
IBinary[] bins = getBinaryFiles((ICProject)cElement);
|
||||||
|
@ -631,6 +663,8 @@ public class CMainTab extends CLaunchConfigurationTab {
|
||||||
String path;
|
String path;
|
||||||
path = binary.getResource().getProjectRelativePath().toOSString();
|
path = binary.getResource().getProjectRelativePath().toOSString();
|
||||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, path);
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, path);
|
||||||
|
if (!renamed)
|
||||||
|
{
|
||||||
String name = binary.getElementName();
|
String name = binary.getElementName();
|
||||||
int index = name.lastIndexOf('.');
|
int index = name.lastIndexOf('.');
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
|
@ -638,7 +672,12 @@ public class CMainTab extends CLaunchConfigurationTab {
|
||||||
}
|
}
|
||||||
name = getLaunchConfigurationDialog().generateName(name);
|
name = getLaunchConfigurationDialog().generateName(name);
|
||||||
config.rename(name);
|
config.rename(name);
|
||||||
} else {
|
renamed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!renamed)
|
||||||
|
{
|
||||||
String name = getLaunchConfigurationDialog().generateName(cElement.getCProject().getElementName());
|
String name = getLaunchConfigurationDialog().generateName(cElement.getCProject().getElementName());
|
||||||
config.rename(name);
|
config.rename(name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue