Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Ryall2009-08-18 14:46:54 +0000
committerKen Ryall2009-08-18 14:46:54 +0000
commit6d989371448d305d1fccc4b707f554127f7f5c22 (patch)
tree9cbee3648e9e3f9be30aa28f13b5c669f4558489 /launch/org.eclipse.cdt.launch
parentc10f971d21e3cf467293e2fa9a3f6f26c6f51602 (diff)
downloadorg.eclipse.cdt-6d989371448d305d1fccc4b707f554127f7f5c22.tar.gz
org.eclipse.cdt-6d989371448d305d1fccc4b707f554127f7f5c22.tar.xz
org.eclipse.cdt-6d989371448d305d1fccc4b707f554127f7f5c22.zip
[Bug 285904] Control build-before-launch activity per launch configuation
Diffstat (limited to 'launch/org.eclipse.cdt.launch')
-rw-r--r--launch/org.eclipse.cdt.launch/META-INF/MANIFEST.MF2
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java44
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties14
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java125
4 files changed, 170 insertions, 15 deletions
diff --git a/launch/org.eclipse.cdt.launch/META-INF/MANIFEST.MF b/launch/org.eclipse.cdt.launch/META-INF/MANIFEST.MF
index 0070c40d53..a66ba7e0e1 100644
--- a/launch/org.eclipse.cdt.launch/META-INF/MANIFEST.MF
+++ b/launch/org.eclipse.cdt.launch/META-INF/MANIFEST.MF
@@ -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
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java
index 54538effee..9b0aa73f27 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java
@@ -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;
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties
index 9434a42a1f..0ad147467c 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties
@@ -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:
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java
index 82dec0564f..ce58517e7c 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java
@@ -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);
+ }
}
/**

Back to the top