1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 03:53:21 +02:00

[Bug 285904] Control build-before-launch activity per launch configuation

This commit is contained in:
Ken Ryall 2009-08-18 14:46:54 +00:00
parent c10f971d21
commit 6d98937144
7 changed files with 204 additions and 17 deletions

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.cdt.debug.core" version="2">
<resource path="src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java" type="org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants">
<filter id="403853384">
<message_arguments>
<message_argument value="org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants"/>
</message_arguments>
</filter>
</resource>
</component>

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.debug.core; singleton:=true
Bundle-Version: 6.0.0.qualifier
Bundle-Version: 6.1.0.qualifier
Bundle-Activator: org.eclipse.cdt.debug.core.CDebugCorePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2007 QNX Software Systems and others.
* Copyright (c) 2000, 2009 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
@ -12,6 +12,12 @@
*******************************************************************************/
package org.eclipse.cdt.debug.core;
/**
* Constants used for attributes in CDT launch configurations.
*
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
public interface ICDTLaunchConfigurationConstants {
public static final String CDT_LAUNCH_ID = "org.eclipse.cdt.launch"; //$NON-NLS-1$
@ -49,6 +55,22 @@ public interface ICDTLaunchConfigurationConstants {
*/
public static final String ATTR_PROJECT_NAME = CDT_LAUNCH_ID + ".PROJECT_ATTR"; //$NON-NLS-1$
/**
* Launch configuration attribute value constants for build before launch.
* @since 6.1 */
public static final int BUILD_BEFORE_LAUNCH_DISABLED = 0;
/** @since 6.1 */
public static final int BUILD_BEFORE_LAUNCH_ENABLED = 1;
/** @since 6.1 */
public static final int BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING = 2;
/**
* 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.
*/
/** @since 6.1 */
public static final String ATTR_BUILD_BEFORE_LAUNCH = CDT_LAUNCH_ID + ".ATTR_BUILD_BEFORE_LAUNCH_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.

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.launch; singleton:=true
Bundle-Version: 6.0.0.qualifier
Bundle-Version: 6.1.0.qualifier
Bundle-Activator: org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin

View file

@ -136,6 +136,11 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
private List orderedProjects;
private String preLaunchBuildConfiguration;
/**
* Used in conjunction with build before launch settings in the main tab.
*/
private boolean workspaceBuildBeforeLaunch;
abstract public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
throws CoreException;
@ -591,11 +596,24 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
* @return whether the debug platform should perform an incremental
* workspace build before the launch
* @throws CoreException
* if an exception occurrs while building
* if an exception occurs while building
*/
@Override
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
//This matches the old code, but I don't know that it is the right behaviour.
workspaceBuildBeforeLaunch = true;
// check the build before launch setting and honor it
int buildBeforeLaunchValue = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH,
ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING);
// we shouldn't be getting called if the workspace setting is disabled, so assume we need to
// build unless the user explicitly disabled it in the main tab of the launch.
if (buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED) {
return false;
}
//This matches the old code, but I don't know that it is the right behavior.
//We should be building the local project as well, not just the ordered projects
if(orderedProjects == null) {
return false;
@ -666,6 +684,26 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
*/
@Override
public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
if (!workspaceBuildBeforeLaunch) {
// buildForLaunch was not called which means that the workspace pref is disabled. see if the user enabled the
// launch specific setting in the main tab. if so, we do call buildBeforeLaunch here.
if (ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED == configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH,
ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING)) {
IProgressMonitor buildMonitor = new SubProgressMonitor(monitor, 10, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
buildMonitor.beginTask(LaunchMessages.getString("AbstractCLaunchDelegate.BuildBeforeLaunch"), 10); //$NON-NLS-1$
buildMonitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.PerformingBuild")); //$NON-NLS-1$
if (buildForLaunch(configuration, mode, new SubProgressMonitor(buildMonitor, 7))) {
buildMonitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.PerformingIncrementalBuild")); //$NON-NLS-1$
ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new SubProgressMonitor(buildMonitor, 3));
}
else {
buildMonitor.worked(3); /* No incremental build required */
}
}
}
boolean continueLaunch = true;
if(orderedProjects == null) {
return continueLaunch;
@ -770,6 +808,8 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
monitor = new NullProgressMonitor();
}
workspaceBuildBeforeLaunch = false;
int scale = 1000;
int totalWork = 2 * scale;

View file

@ -30,6 +30,9 @@ AbstractCLaunchDelegate.searching_for_errors=Searching for compile errors
AbstractCLaunchDelegate.searching_for_errors_in=Searching for compile errors in
AbstractCLaunchDelegate.20=Building prerequisite project list
AbstractCLaunchDelegate.Program_is_not_a_recongnized_executable=Program is not a recognized executable.
AbstractCLaunchDelegate.BuildBeforeLaunch=Build before launch -
AbstractCLaunchDelegate.PerformingBuild=Performing required build...
AbstractCLaunchDelegate.PerformingIncrementalBuild=Performing incremental workspace build...
LocalRunLaunchDelegate.Launching_Local_C_Application=Launching Local C/C++ Application
LocalRunLaunchDelegate.Failed_setting_runtime_option_though_debugger=Failed to set program arguments, environment or working directory.
@ -82,10 +85,19 @@ CMainTab.Choose_program_to_run_from_NAME=Choose a program to run from {0}:
CMainTab.UseTerminal=Connect process input & output to a terminal.
CMainTab.Program_is_not_a_recongnized_executable=Program is not a recognized executable.
CMainTab.Program_invalid_proj_path=Program specification is not a valid project-relative path.
CMainTab.Build_Config=Build Configuration
CMainTab.Build_Config=Build configuration:
CMainTab.Use_Active=Use Active
#For CMainTab.Configuration_name: {0} - project name; {1} - configuration name
CMainTab.Configuration_name={0} {1}
CMainTab.Build_options=Build (if required) before launching
CMainTab.Disable_build_button_label=Disable auto build
CMainTab.Disable_build_button_tooltip=Requires manually building project before launching (this may improve launch performance)
CMainTab.Enable_build_button_label=Enable auto build
CMainTab.Enable_build_button_tooltip=Always build project before launching (this may impact launch performance)
CMainTab.Workspace_settings_button_label=Use workspace settings
CMainTab.Workspace_settings_button_tooltip=Use workspace settings
CMainTab.Workspace_settings_link_label=<a>Configure Workspace Settings...</a>
CMainTab.Workspace_settings_page_id=org.eclipse.debug.ui.LaunchingPreferencePage
CDebuggerTab.Advanced_Options_Dialog_Title=Advanced Options
CDebuggerTab.Stop_at_main_on_startup=Stop on startup at:

View file

@ -66,9 +66,12 @@ import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.ui.dialogs.TwoPaneElementSelector;
/**
@ -114,6 +117,15 @@ public class CMainTab extends CLaunchConfigurationTab {
* @since 6.0
*/
protected Combo fBuildConfigCombo;
// Build option UI widgets
/** @since 6.1 */
protected Button fDisableBuildButton;
/** @since 6.1 */
protected Button fEnableBuildButton;
/** @since 6.1 */
protected Button fWorkspaceSettingsButton;
/** @since 6.1 */
protected Link fWorkpsaceSettingsLink;
private final boolean fWantsTerminalOption;
protected Button fTerminalButton;
@ -162,9 +174,9 @@ public class CMainTab extends CLaunchConfigurationTab {
comp.setLayout(topLayout);
createVerticalSpacer(comp, 1);
createProjectGroup(comp, 1);
createBuildConfigCombo(comp, 1);
createExeFileGroup(comp, 1);
createProjectGroup(comp, 1);
createBuildOptionGroup(comp, 1);
createVerticalSpacer(comp, 1);
if (fSpecifyCoreFile) {
createCoreFileGroup(comp, 1);
@ -320,6 +332,65 @@ public class CMainTab extends CLaunchConfigurationTab {
});
}
/** @since 6.1 */
protected void createBuildOptionGroup(final Composite parent, int colSpan) {
Group buildGroup = new Group(parent, SWT.NONE);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = colSpan;
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
gridLayout.marginHeight = 5;
gridLayout.marginWidth = 5;
gridLayout.makeColumnsEqualWidth= true;
buildGroup.setLayoutData(gridData);
buildGroup.setLayout(gridLayout);
buildGroup.setText(LaunchMessages.getString("CMainTab.Build_options")); //$NON-NLS-1$
createBuildConfigCombo(buildGroup, 2);
fEnableBuildButton = new Button(buildGroup, SWT.RADIO);
fEnableBuildButton.setText(LaunchMessages.getString("CMainTab.Enable_build_button_label")); //$NON-NLS-1$
fEnableBuildButton.setToolTipText(LaunchMessages.getString("CMainTab.Enable_build_button_tooltip")); //$NON-NLS-1$
fEnableBuildButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
updateLaunchConfigurationDialog();
}
});
fDisableBuildButton = new Button(buildGroup, SWT.RADIO);
fDisableBuildButton.setText(LaunchMessages.getString("CMainTab.Disable_build_button_label")); //$NON-NLS-1$
fDisableBuildButton.setToolTipText(LaunchMessages.getString("CMainTab.Disable_build_button_tooltip")); //$NON-NLS-1$
fDisableBuildButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
updateLaunchConfigurationDialog();
}
});
fWorkspaceSettingsButton = new Button(buildGroup, SWT.RADIO);
fWorkspaceSettingsButton.setText(LaunchMessages.getString("CMainTab.Workspace_settings_button_label")); //$NON-NLS-1$
fWorkspaceSettingsButton.setToolTipText(LaunchMessages.getString("CMainTab.Workspace_settings_button_tooltip")); //$NON-NLS-1$
fWorkspaceSettingsButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
updateLaunchConfigurationDialog();
}
});
fWorkpsaceSettingsLink = new Link(buildGroup, SWT.NONE); //$NON-NLS-1$
fWorkpsaceSettingsLink.setText(LaunchMessages.getString("CMainTab.Workspace_settings_link_label")); //$NON-NLS-1$
fWorkpsaceSettingsLink.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
PreferencesUtil.createPreferenceDialogOn(
parent.getShell(),
LaunchMessages.getString("CMainTab.Workspace_settings_page_id"), //$NON-NLS-1$
null,
null).open();
}
});
}
/** @since 6.0 */
protected void createCoreFileGroup(Composite parent, int colSpan) {
Composite coreComp = new Composite(parent, SWT.NONE);
@ -395,6 +466,7 @@ public class CMainTab extends CLaunchConfigurationTab {
updateProjectFromConfig(config);
updateProgramFromConfig(config);
updateCoreFromConfig(config);
updateBuildOptionFromConfig(config);
updateTerminalFromConfig(config);
}
@ -424,13 +496,16 @@ public class CMainTab extends CLaunchConfigurationTab {
}
protected void updateProgramFromConfig(ILaunchConfiguration config) {
String programName = EMPTY_STRING;
try {
programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EMPTY_STRING);
} catch (CoreException ce) {
LaunchUIPlugin.log(ce);
if (fProgText != null)
{
String programName = EMPTY_STRING;
try {
programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EMPTY_STRING);
} catch (CoreException ce) {
LaunchUIPlugin.log(ce);
}
fProgText.setText(programName);
}
fProgText.setText(programName);
}
/** @since 6.0 */
@ -445,7 +520,21 @@ public class CMainTab extends CLaunchConfigurationTab {
fCoreText.setText(coreName);
}
}
/** @since 6.1 */
protected void updateBuildOptionFromConfig(ILaunchConfiguration config) {
int buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING;
try {
buildBeforeLaunchValue = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, buildBeforeLaunchValue);
} catch (CoreException e) {
LaunchUIPlugin.log(e);
}
fDisableBuildButton.setSelection(buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED);
fEnableBuildButton.setSelection(buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED);
fWorkspaceSettingsButton.setSelection(buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING);
}
/*
* (non-Javadoc)
*
@ -464,14 +553,28 @@ public class CMainTab extends CLaunchConfigurationTab {
config.setMappedResources(null);
}
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, fProjText.getText());
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, (String)fBuildConfigCombo.getData(Integer.toString(fBuildConfigCombo.getSelectionIndex())));
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, fProgText.getText());
if (fBuildConfigCombo != null) {
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, (String)fBuildConfigCombo.getData(Integer.toString(fBuildConfigCombo.getSelectionIndex())));
}
if (fProgText != null) {
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, fProgText.getText());
}
if (fCoreText != null) {
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, fCoreText.getText());
}
if (fTerminalButton != null) {
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, fTerminalButton.getSelection());
}
if (fDisableBuildButton != null) {
int buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING;
if (fDisableBuildButton.getSelection()) {
buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED;
} else if (fEnableBuildButton.getSelection()) {
buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED;
}
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, buildBeforeLaunchValue);
}
}
/**