mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,7 +7,8 @@
|
|||
*
|
||||
* Contributors:
|
||||
* 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;
|
||||
|
||||
|
@ -34,6 +35,12 @@ public interface ICDTLaunchConfigurationConstants {
|
|||
*/
|
||||
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
|
||||
* 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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
* Andrew Ferguson (andrew.ferguson@arm.com) - bug 123997
|
||||
* Ken Ryall (Nokia) - bug 178731
|
||||
*******************************************************************************/
|
||||
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.model.ICModelMarker;
|
||||
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.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
||||
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.IFile;
|
||||
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$
|
||||
setBuildConfiguration(configuration, project);
|
||||
project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new SubProgressMonitor(monitor, scale));
|
||||
} finally {
|
||||
monitor.done();
|
||||
|
@ -542,6 +547,29 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
|
|||
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
|
||||
* prerequisite projects. If any compile errors, give the user a chance to
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Ken Ryall (Nokia) - bug 178731
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.launch.internal;
|
||||
|
||||
|
@ -15,6 +16,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.IBinary;
|
||||
|
@ -189,7 +191,14 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
|
|||
ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
|
||||
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
|
||||
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
|
||||
// extension point for this.
|
||||
ICDebuggerPage page = CDebugUIPlugin.getDefault().getDebuggerPage(debugConfig.getID());
|
||||
|
@ -419,7 +428,7 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut {
|
|||
return;
|
||||
}
|
||||
int count = results.size();
|
||||
if (count == 0) {
|
||||
if (count == 0) {
|
||||
MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_binaries")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
} else if (count > 1) {
|
||||
bin = chooseBinary(results, mode);
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Ken Ryall (Nokia) - bug 178731
|
||||
*******************************************************************************/
|
||||
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.ICElement;
|
||||
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.launch.internal.ui.LaunchUIPlugin;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -124,6 +126,11 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
|
|||
if (cProject != null && cProject.exists()) {
|
||||
name = cProject.getElementName();
|
||||
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);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
* Ken Ryall (Nokia) - bug 178731
|
||||
*******************************************************************************/
|
||||
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.ICElement;
|
||||
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.launch.internal.ui.LaunchImages;
|
||||
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
||||
|
@ -286,7 +288,15 @@ public class CMainTab extends CLaunchConfigurationTab {
|
|||
public void performApply(ILaunchConfigurationWorkingCopy config) {
|
||||
ICProject cProject = this.getCProject();
|
||||
if (cProject != null)
|
||||
{
|
||||
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_PROGRAM_NAME, fProgText.getText());
|
||||
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
|
||||
*/
|
||||
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;
|
||||
if (cElement instanceof ICProject) {
|
||||
IBinary[] bins = getBinaryFiles((ICProject)cElement);
|
||||
|
@ -631,14 +663,21 @@ public class CMainTab extends CLaunchConfigurationTab {
|
|||
String path;
|
||||
path = binary.getResource().getProjectRelativePath().toOSString();
|
||||
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, path);
|
||||
String name = binary.getElementName();
|
||||
int index = name.lastIndexOf('.');
|
||||
if (index > 0) {
|
||||
name = name.substring(0, index);
|
||||
if (!renamed)
|
||||
{
|
||||
String name = binary.getElementName();
|
||||
int index = name.lastIndexOf('.');
|
||||
if (index > 0) {
|
||||
name = name.substring(0, index);
|
||||
}
|
||||
name = getLaunchConfigurationDialog().generateName(name);
|
||||
config.rename(name);
|
||||
renamed = true;
|
||||
}
|
||||
name = getLaunchConfigurationDialog().generateName(name);
|
||||
config.rename(name);
|
||||
} else {
|
||||
}
|
||||
|
||||
if (!renamed)
|
||||
{
|
||||
String name = getLaunchConfigurationDialog().generateName(cElement.getCProject().getElementName());
|
||||
config.rename(name);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue