From 509ee1af2018660c87486b4df167e1a2fcbca35c Mon Sep 17 00:00:00 2001 From: Leo Treggiari Date: Mon, 9 May 2005 23:51:39 +0000 Subject: [PATCH] UI for Discrete custom build steps Filter configs based upon OS list and Arch list --- .../managedbuilder/core/IConfiguration.java | 16 +- .../internal/core/Configuration.java | 26 +- .../core/GeneratedMakefileBuilder.java | 25 +- .../internal/core/PluginResources.properties | 1 + .../makegen/gnu/GnuMakefileGenerator.java | 43 ++- .../internal/ui/BuildSettingsBlock.java | 20 +- .../internal/ui/BuildStepSettingsBlock.java | 337 ++++++++++++++++++ .../internal/ui/ManagedBuildOptionBlock.java | 25 ++ .../internal/ui/PluginResources.properties | 14 + .../ui/wizards/CProjectPlatformPage.java | 85 ++++- 10 files changed, 527 insertions(+), 65 deletions(-) create mode 100644 build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildStepSettingsBlock.java diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java index 06507056869..8cfd99aa511 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java @@ -29,10 +29,10 @@ import org.eclipse.core.resources.IResource; public interface IConfiguration extends IBuildObject { public static final String ARTIFACT_NAME = "artifactName"; //$NON-NLS-1$ public static final String CLEAN_COMMAND = "cleanCommand"; //$NON-NLS-1$ - public static final String PREBUILD_STEP = "prebuildStep"; //$NON-NLS-1$ - public static final String POSTBUILD_STEP = "postbuildStep"; //$NON-NLS-1$ - public static final String PREANNOUNCEBUILD_STEP = "preannouncebuildStep"; //$NON-NLS-1$ - public static final String POSTANNOUNCEBUILD_STEP = "postannouncebuildStep"; //$NON-NLS-1$ + public static final String PREBUILD_STEP = "prebuildStep"; //$NON-NLS-1$ + public static final String POSTBUILD_STEP = "postbuildStep"; //$NON-NLS-1$ + public static final String PREANNOUNCEBUILD_STEP = "preannouncebuildStep"; //$NON-NLS-1$ + public static final String POSTANNOUNCEBUILD_STEP = "postannouncebuildStep"; //$NON-NLS-1$ // Schema element names public static final String CONFIGURATION_ELEMENT_NAME = "configuration"; //$NON-NLS-1$ public static final String ERROR_PARSERS = "errorParsers"; //$NON-NLS-1$ @@ -106,28 +106,28 @@ public interface IConfiguration extends IBuildObject { public String getBuildCommand(); /** - * Returns the prebuild step from this configuration's builder + * Returns the prebuild step command * * @return String */ public String getPrebuildStep(); /** - * Returns the postbuild step from this configuration's builder + * Returns the postbuild step command * * @return String */ public String getPostbuildStep(); /** - * Returns the display string associated with the prebuild step from this configuration's builder + * Returns the display string associated with the prebuild step * * @return String */ public String getPreannouncebuildStep(); /** - * Returns the display string associated with the postbuild step from this configuration's builder + * Returns the display string associated with the postbuild step * * @return String */ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java index 8b8a8a8d311..565e58227c6 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java @@ -271,7 +271,7 @@ public class Configuration extends BuildObject implements IConfiguration { preannouncebuildStep = new String(cloneConfig.preannouncebuildStep); } if (cloneConfig.postannouncebuildStep != null) { - postannouncebuildStep = new String( cloneConfig.postannouncebuildStep); + postannouncebuildStep = new String(cloneConfig.postannouncebuildStep); } // Clone the configuration's children @@ -1140,9 +1140,9 @@ public class Configuration extends BuildObject implements IConfiguration { public void setPrebuildStep(String step) { if (step == null && prebuildStep == null) return; if (prebuildStep == null || step == null || !prebuildStep.equals(step)) { - prebuildStep = step; - setRebuildState(true); - isDirty = true; + prebuildStep = step; + setRebuildState(true); + isDirty = true; } } @@ -1153,9 +1153,9 @@ public class Configuration extends BuildObject implements IConfiguration { public void setPostbuildStep(String step) { if (step == null && postbuildStep == null) return; if (postbuildStep == null || step == null || !postbuildStep.equals(step)) { - postbuildStep = step; - setRebuildState(true); - isDirty = true; + postbuildStep = step; + setRebuildState(true); + isDirty = true; } } @@ -1165,9 +1165,9 @@ public class Configuration extends BuildObject implements IConfiguration { public void setPreannouncebuildStep(String announceStep) { if (announceStep == null && preannouncebuildStep == null) return; if (preannouncebuildStep == null || announceStep == null || !preannouncebuildStep.equals(announceStep)) { - preannouncebuildStep = announceStep; - setRebuildState(true); - isDirty = true; + preannouncebuildStep = announceStep; + setRebuildState(true); + isDirty = true; } } @@ -1177,9 +1177,9 @@ public class Configuration extends BuildObject implements IConfiguration { public void setPostannouncebuildStep(String announceStep) { if (announceStep == null && postannouncebuildStep == null) return; if (postannouncebuildStep == null || announceStep == null || !postannouncebuildStep.equals(announceStep)) { - postannouncebuildStep = announceStep; - setRebuildState(true); - isDirty = true; + postannouncebuildStep = announceStep; + setRebuildState(true); + isDirty = true; } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java index 0608e430c99..1006ac31fe1 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java @@ -655,10 +655,8 @@ public class GeneratedMakefileBuilder extends ACBuilder { boolean quit = false; premakeArgs.add("-q"); //$NON-NLS-1$ premakeArgs.add("main-build"); //$NON-NLS-1$ - premakeTargets = (String[]) premakeArgs - .toArray(new String[premakeArgs.size()]); - proc = launcher.execute(makeCommand, premakeTargets, - env, workingDirectory); + premakeTargets = (String[]) premakeArgs.toArray(new String[premakeArgs.size()]); + proc = launcher.execute(makeCommand, premakeTargets, env, workingDirectory); if (proc != null) { try { // Close the input of the process since we will never write to it @@ -674,8 +672,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { errMsg = launcher.getErrorMessage(); } - if ((errMsg != null && errMsg.length() > 0) - || proc == null) { + if ((errMsg != null && errMsg.length() > 0) || proc == null) { // Can't tell if the build is needed, so assume it is, and let any errors be triggered // when the "real" build is invoked below makeArgs.add("pre-build"); //$NON-NLS-1$ @@ -687,14 +684,13 @@ public class GeneratedMakefileBuilder extends ACBuilder { isuptodate = true; // Report that the build was up to date, and thus nothing needs to be built String uptodateMsg = ManagedMakeMessages - .getFormattedString(NOTHING_BUILT, - currentProject.getName()); + .getFormattedString(NOTHING_BUILT, currentProject.getName()); + buf = new StringBuffer(); + buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$ buf.append(uptodateMsg); - buf.append(System.getProperty( - "line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$ + buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$ // Write message on the console - consoleOutStream.write(buf.toString() - .getBytes()); + consoleOutStream.write(buf.toString().getBytes()); consoleOutStream.flush(); consoleOutStream.close(); stdout.close(); @@ -725,13 +721,12 @@ public class GeneratedMakefileBuilder extends ACBuilder { makeArgs.addAll(Arrays.asList(getMakeTargets(buildType))); } - makeTargets = (String[]) makeArgs.toArray(new String[makeArgs - .size()]); + makeTargets = (String[]) makeArgs.toArray(new String[makeArgs.size()]); // Launch make - main invocation if (!isuptodate) { proc = launcher.execute(makeCommand, makeTargets, env, - workingDirectory); + workingDirectory); if (proc != null) { try { // Close the input of the process since we will never write to it diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties index 762c99fe167..4fef4b4ba0e 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties @@ -63,6 +63,7 @@ MakefileGenerator.comment.source.list = All of the sources participating in the MakefileGenerator.comment.build.rule = Each subdirectory must supply rules for building sources it contributes MakefileGenerator.comment.build.toprules = Tool invocations MakefileGenerator.comment.build.alltarget = All Target +MakefileGenerator.comment.build.mainbuildtarget = Main-build Target MakefileGenerator.comment.build.toptargets = Other Targets MakefileGenerator.comment.module.make.includes = Include the makefiles for each source subdirectory MakefileGenerator.comment.module.dep.includes = Include automatically-generated dependency list: diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java index e6147f0de67..dff92a74e59 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java @@ -232,6 +232,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { private static final String MOD_RULES = COMMENT + ".build.rule"; //$NON-NLS-1$ private static final String BUILD_TOP = COMMENT + ".build.toprules"; //$NON-NLS-1$ private static final String ALL_TARGET = COMMENT + ".build.alltarget"; //$NON-NLS-1$ + private static final String MAINBUILD_TARGET = COMMENT + ".build.mainbuildtarget"; //$NON-NLS-1$ private static final String BUILD_TARGETS = COMMENT + ".build.toptargets"; //$NON-NLS-1$ private static final String SRC_LISTS = COMMENT + ".source.list"; //$NON-NLS-1$ @@ -1119,6 +1120,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { String defaultTarget = "all:"; //$NON-NLS-1$ if (prebuildStep.length() > 0) { + // Add the comment for the "All" target + buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(ALL_TARGET) + NEWLINE); + buffer.append(defaultTarget + WHITESPACE); buffer.append(PREBUILD + WHITESPACE); @@ -1130,13 +1134,16 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { // needed below defaultTarget = defaultTarget.concat(COLON); buffer.append(NEWLINE + NEWLINE); + + // Add the comment for the "main-build" target + buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(MAINBUILD_TARGET) + NEWLINE); } + else + // Add the comment for the "All" target + buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(ALL_TARGET) + NEWLINE); // Write out the all target first in case someone just runs make // all: or mainbuild: - - // Add the comment - buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(ALL_TARGET) + NEWLINE); String outputPrefix = EMPTY_STRING; if (targetTool != null) { @@ -1279,20 +1286,13 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { // Get the target tool and generate the rule if (targetTool != null) { if (addRuleForTool(targetTool, buffer, true, buildTargetName, buildTargetExt, - outputVarsAdditionsList, managedProjectOutputs)) { + outputVarsAdditionsList, managedProjectOutputs, postbuildStep)) { // Mark the target tool as processed for (int i=0; inull * @param outputVarsAdditionsList list to add needed build output variables to * @param managedProjectOutputs Other projects in the workspace that this project depends upon + * @param bPostBuildStep Emit post-build step invocation */ protected boolean addRuleForTool(ITool tool, StringBuffer buffer, boolean bTargetTool, String targetName, String targetExt, - List outputVarsAdditionsList, Vector managedProjectOutputs) { + List outputVarsAdditionsList, Vector managedProjectOutputs, boolean bEmitPostBuildStepCall) { // Get the tool's inputs and outputs Vector inputs = new Vector(); @@ -1454,7 +1455,18 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { } else { buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + MESSAGE_FINISH_FILE + WHITESPACE + OUT_MACRO + SINGLE_QUOTE + NEWLINE); } - buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + WHITESPACE + SINGLE_QUOTE + NEWLINE + NEWLINE); + buffer.append(TAB + AT + ECHO + WHITESPACE + SINGLE_QUOTE + WHITESPACE + SINGLE_QUOTE + NEWLINE); + + // If there is a post build step, then add a recursive invocation of MAKE to invoke it after the main build + // Note that $(MAKE) will instantiate in the recusive invocation to the make command that was used to invoke + // the makefile originally + if (bEmitPostBuildStepCall) { + buffer.append(TAB + MAKE + WHITESPACE + NO_PRINT_DIR + WHITESPACE + POSTBUILD + NEWLINE + NEWLINE); + } + else { + // Just emit a blank line + buffer.append(NEWLINE); + } // If we have secondary outputs, output dependency rules without commands if (enumeratedSecondaryOutputs.size() > 0) { @@ -1465,7 +1477,6 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { } buffer.append(NEWLINE); } - return true; } @@ -1491,7 +1502,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator { (outVariable != null && inVariable != null && outVariable.equals(inVariable))) { if (addRuleForTool(buildTools[k], buffer, false, null, null, - outputVarsAdditionsList, null)) { + outputVarsAdditionsList, null, false)) { buildToolsUsed[k] = true; // Look for tools that consume the output generateRulesForConsumers(buildTools[k], outputVarsAdditionsList, buffer); diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java index c56976a4295..6b8055d45d0 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildSettingsBlock.java @@ -23,6 +23,7 @@ import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.swt.SWT; import org.eclipse.swt.accessibility.AccessibleAdapter; @@ -30,6 +31,7 @@ import org.eclipse.swt.accessibility.AccessibleEvent; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; @@ -250,6 +252,16 @@ public class BuildSettingsBlock extends AbstractCOptionPage { * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults() */ public void performDefaults() { + + // Display a "Confirm" dialog box, since: + // 1. The defaults are immediately applied + // 2. The action cannot be undone + Shell shell = ManagedBuilderUIPlugin.getDefault().getShell(); + boolean shouldDefault = MessageDialog.openConfirm(shell, + ManagedBuilderUIMessages.getResourceString("BuildSettingsBlock.defaults.title"), //$NON-NLS-1$ + ManagedBuilderUIMessages.getResourceString("BuildSettingsBlock.defaults.message")); //$NON-NLS-1$ + if (!shouldDefault) return; + IConfiguration config = parent.getSelectedConfiguration(); config.setArtifactName(config.getManagedProject().getDefaultArtifactName()); config.setArtifactExtension(null); @@ -257,9 +269,15 @@ public class BuildSettingsBlock extends AbstractCOptionPage { if (!builder.isExtensionElement()) { config.getToolChain().removeLocalBuilder(); } + + // Save the information that was reset + ManagedBuildManager.setDefaultConfiguration(parent.getProject(), parent.getSelectedConfiguration()); + ManagedBuildManager.saveBuildInfo(parent.getProject(), false); + setValues(); + makeCommandDefault.setSelection(true); - makeCommandEntry.setEditable(false); + makeCommandEntry.setEditable(false); setDirty(false); } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildStepSettingsBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildStepSettingsBlock.java new file mode 100644 index 00000000000..791fb8950d1 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/BuildStepSettingsBlock.java @@ -0,0 +1,337 @@ +/******************************************************************************* + * Copyright (c) 2005 Intel Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.internal.ui; + +import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.accessibility.AccessibleAdapter; +import org.eclipse.swt.accessibility.AccessibleEvent; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + +public class BuildStepSettingsBlock extends AbstractCOptionPage { + + /* + * String constants + */ + private static final String PREFIX = "BuildStepSettingsBlock"; //$NON-NLS-1$ + private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$ + private static final String SETTINGS_LABEL = LABEL + ".Settings"; //$NON-NLS-1$ + private static final String PREBUILD_GROUP = LABEL + ".prebuildstep.group"; //$NON-NLS-1$ + private static final String PREBUILD_CMD = LABEL + ".prebuildstep.cmd"; //$NON-NLS-1$ + private static final String PREBUILD_DESC = LABEL + ".prebuildstep.desc"; //$NON-NLS-1$ + private static final String POSTBUILD_GROUP = LABEL + ".postbuildstep.group"; //$NON-NLS-1$ + private static final String POSTBUILD_CMD = LABEL + ".postbuildstep.cmd"; //$NON-NLS-1$ + private static final String POSTBUILD_DESC = LABEL + ".postbuildstep.desc"; //$NON-NLS-1$ + private static final String EMPTY_STRING = new String(); + + /* + * Dialog widgets + */ + protected Text preBuildCmd; + protected Text preBuildAnnc; + protected Text postBuildCmd; + protected Text postBuildAnnc; + + /* + * Bookeeping variables + */ + private BuildPropertyPage parent; + private String preBuildCommand; + private String preBuildAnnounce; + private String postBuildCommand; + private String postBuildAnnounce; + + // Has the page been changed? + private boolean dirty = false; + + private ModifyListener widgetModified = new ModifyListener() { + public void modifyText(ModifyEvent e) { + setDirty(true); + } + }; + + /* + * Constructor + */ + public BuildStepSettingsBlock(BuildPropertyPage parent) + { + super(ManagedBuilderUIMessages.getResourceString(SETTINGS_LABEL)); + super.setContainer(parent); + this.parent = parent; + } + + public void createControl(Composite parent) { + Composite comp = new Composite(parent, SWT.NULL); + comp.setFont(parent.getFont()); + comp.setLayout(new GridLayout(1, true)); + comp.setLayoutData(new GridData(GridData.FILL_BOTH)); + setControl(comp); + + // Create a group for the prebuild step + createPreBuildStepGroup(comp); + + // Create a group for the postbuild step + createPostBuildStepGroup(comp); + } + + /* (non-Javadoc) + * Creates the group that contains the pre-build step controls. + */ + private void createPreBuildStepGroup(Composite parent) { + final Group preBuildStepGroup = new Group(parent, SWT.NONE); + preBuildStepGroup.setFont(parent.getFont()); + preBuildStepGroup.setText(ManagedBuilderUIMessages.getResourceString(PREBUILD_GROUP)); + preBuildStepGroup.setLayout(new GridLayout(1, true)); + preBuildStepGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // Pre-build command label + final Label cmdLabel = new Label(preBuildStepGroup, SWT.LEFT); + cmdLabel.setFont(preBuildStepGroup.getFont()); + cmdLabel.setText(ManagedBuilderUIMessages.getResourceString(PREBUILD_CMD)); + cmdLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // Text widget for pre-build command + preBuildCmd = new Text(preBuildStepGroup, SWT.SINGLE | SWT.BORDER); + preBuildCmd.setFont(preBuildStepGroup.getFont()); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; + preBuildCmd.setLayoutData(data); + preBuildCmd.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent event) { + preBuildCmd = null; + } + }); + preBuildCmd.getAccessible().addAccessibleListener(new AccessibleAdapter(){ + public void getName(AccessibleEvent e) { + e.result = ManagedBuilderUIMessages.getResourceString(PREBUILD_CMD); + } + }); + preBuildCmd.addModifyListener(widgetModified); + + final Label descLabel = new Label(preBuildStepGroup, SWT.LEFT); + descLabel.setFont(preBuildStepGroup.getFont()); + descLabel.setText(ManagedBuilderUIMessages.getResourceString(PREBUILD_DESC)); + descLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // Text widget for the pre-build description + preBuildAnnc = new Text(preBuildStepGroup, SWT.SINGLE | SWT.BORDER); + preBuildAnnc.setFont(preBuildStepGroup.getFont()); + data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = (IDialogConstants.ENTRY_FIELD_WIDTH); + preBuildAnnc.setLayoutData(data); + preBuildAnnc.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + preBuildAnnc = null; + } + }); + preBuildAnnc.getAccessible().addAccessibleListener(new AccessibleAdapter() { + public void getName(AccessibleEvent e) { + e.result = ManagedBuilderUIMessages.getResourceString(PREBUILD_DESC); + } + }); + preBuildAnnc.addModifyListener(widgetModified); + } + + /* (non-Javadoc) + * Creates the group that contains the post-build step controls. + */ + private void createPostBuildStepGroup(Composite parent) { + final Group postBuildStepGroup = new Group(parent, SWT.NONE); + postBuildStepGroup.setFont(parent.getFont()); + postBuildStepGroup.setText(ManagedBuilderUIMessages.getResourceString(POSTBUILD_GROUP)); + postBuildStepGroup.setLayout(new GridLayout(1, true)); + postBuildStepGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // Post-build command label + final Label cmdLabel = new Label(postBuildStepGroup, SWT.LEFT); + cmdLabel.setFont(postBuildStepGroup.getFont()); + cmdLabel.setText(ManagedBuilderUIMessages.getResourceString(POSTBUILD_CMD)); + cmdLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // Text widget for the post-build command + postBuildCmd = new Text(postBuildStepGroup, SWT.SINGLE | SWT.BORDER); + postBuildCmd.setFont(postBuildStepGroup.getFont()); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; + postBuildCmd.setLayoutData(data); + postBuildCmd.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent event) { + postBuildCmd = null; + } + }); + postBuildCmd.getAccessible().addAccessibleListener(new AccessibleAdapter(){ + public void getName(AccessibleEvent e) { + e.result = ManagedBuilderUIMessages.getResourceString(POSTBUILD_CMD); + } + }); + postBuildCmd.addModifyListener(widgetModified); + + // Post-build description label + final Label descLabel = new Label(postBuildStepGroup, SWT.LEFT); + descLabel.setFont(postBuildStepGroup.getFont()); + descLabel.setText(ManagedBuilderUIMessages.getResourceString(POSTBUILD_DESC)); + descLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + // Text widget for the post-build description + postBuildAnnc = new Text(postBuildStepGroup, SWT.SINGLE | SWT.BORDER); + postBuildAnnc.setFont(postBuildStepGroup.getFont()); + data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = (IDialogConstants.ENTRY_FIELD_WIDTH); + postBuildAnnc.setLayoutData(data); + postBuildAnnc.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + postBuildAnnc = null; + } + }); + postBuildAnnc.getAccessible().addAccessibleListener(new AccessibleAdapter() { + public void getName(AccessibleEvent e) { + e.result = ManagedBuilderUIMessages.getResourceString(POSTBUILD_DESC); + } + }); + postBuildAnnc.addModifyListener(widgetModified); + } + + protected void initializeValues() { + setValues(); + } + + public void updateValues() { + setValues(); + } + + protected void setValues() { + // Fetch values from the current configuration and set in the UI + preBuildCommand = parent.getSelectedConfiguration().getPrebuildStep(); + preBuildCmd.setText(preBuildCommand); + preBuildAnnounce = parent.getSelectedConfiguration().getPreannouncebuildStep(); + preBuildAnnc.setText(preBuildAnnounce); + postBuildCommand = parent.getSelectedConfiguration().getPostbuildStep(); + postBuildCmd.setText(postBuildCommand); + postBuildAnnounce = parent.getSelectedConfiguration().getPostannouncebuildStep(); + postBuildAnnc.setText(postBuildAnnounce); + setDirty(false); //Indicate that the UI state is consistent with internal state + } + + public void removeValues(String id) { + // Nothing to do... + } + + /* + * (non-Javadoc) + * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults() + */ + public void performDefaults() { + IConfiguration config = parent.getSelectedConfiguration(); + boolean mustSetValue = false; + + // Display a "Confirm" dialog box, since: + // 1. The defaults are immediately applied + // 2. The action cannot be undone + Shell shell = ManagedBuilderUIPlugin.getDefault().getShell(); + boolean shouldDefault = MessageDialog.openConfirm(shell, + ManagedBuilderUIMessages.getResourceString("BuildStepsSettingsBlock.defaults.title"), //$NON-NLS-1$ + ManagedBuilderUIMessages.getResourceString("BuildStepsSettingsBlock.defaults.message")); //$NON-NLS-1$ + if (!shouldDefault) return; + + // Set the build step entries to null; this will force the next fetch of the entries to get the + // values from the parent of this configuration, which should be the values from the .xml manifest + // file + config.setPrebuildStep(null); + config.setPreannouncebuildStep(null); + config.setPostbuildStep(null); + config.setPostannouncebuildStep(null); + + // Save the information that was reset + ManagedBuildManager.setDefaultConfiguration(parent.getProject(), parent.getSelectedConfiguration()); + ManagedBuildManager.saveBuildInfo(parent.getProject(), false); + + // Fetch and set the default values to be displayed in the UI + setValues(); + + } + + /* + * (non-Javadoc) + * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(IProgressMonitor) + */ + public void performApply(IProgressMonitor monitor) throws CoreException { + + // Fetch the build step values from the UI and store + preBuildCommand = preBuildCmd.getText().trim(); + preBuildAnnounce = preBuildAnnc.getText().trim(); + postBuildCommand = postBuildCmd.getText().trim(); + postBuildAnnounce = postBuildAnnc.getText().trim(); + + IConfiguration selectedConfiguration = parent.getSelectedConfiguration(); + boolean mustSetValue = false; + + if (!selectedConfiguration.getPrebuildStep().equals(preBuildCommand)) { + mustSetValue = true; + } + else if (!selectedConfiguration.getPreannouncebuildStep().equals(preBuildAnnounce)) { + mustSetValue = true; + } + else if (!selectedConfiguration.getPostbuildStep().equals(postBuildCommand)) { + mustSetValue = true; + } + else if (!selectedConfiguration.getPostannouncebuildStep().equals(postBuildAnnounce)) { + mustSetValue = true; + } + + if (mustSetValue) { + // Set all the build step values in the current configuration + selectedConfiguration.setPrebuildStep(preBuildCommand); + selectedConfiguration.setPreannouncebuildStep(preBuildAnnounce); + selectedConfiguration.setPostbuildStep(postBuildCommand); + selectedConfiguration.setPostannouncebuildStep(postBuildAnnounce); + } + + setDirty(false); //Indicate that the UI state is consistent with internal state + } + + public IPreferenceStore getPreferenceStore() { + return null; + } + + /** + * Sets the "dirty" state, which indicates whether or not the state of the build step UI is consistent + * with its corresponding internal state + */ + public void setDirty(boolean b) { + dirty = b; + } + + /** + * Returns the "dirty" state, which indicates whether or not the state of the build step UI is consistent + * with its corresponding internal state + */ + public boolean isDirty() { + return dirty; + } +} diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuildOptionBlock.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuildOptionBlock.java index 798785f9e98..30256324edc 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuildOptionBlock.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/ManagedBuildOptionBlock.java @@ -32,6 +32,7 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock { private ToolsSettingsBlock toolsSettingsBlock; private BuildSettingsBlock buildSettingsBlock; + private BuildStepSettingsBlock buildStepSettingsBlock; private ErrorParserBlock errParserBlock; private BinaryParserBlock binaryParserBlock; private EnvironmentSetBlock environmentBlock; @@ -72,6 +73,7 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock { if (element instanceof IProject) { addTab(toolsSettingsBlock = new ToolsSettingsBlock((BuildPropertyPage) fParent, element)); addTab(buildSettingsBlock = new BuildSettingsBlock((BuildPropertyPage) fParent)); + addTab(buildStepSettingsBlock = new BuildStepSettingsBlock((BuildPropertyPage) fParent)); addTab(errParserBlock = new ErrorParserBlock()); addTab(binaryParserBlock = new BinaryParserBlock()); addTab(environmentBlock = new EnvironmentSetBlock((BuildPropertyPage) fParent)); @@ -89,6 +91,10 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock { public BuildSettingsBlock getBuildSettingsBlock() { return buildSettingsBlock; } + + public BuildStepSettingsBlock getBuildStepSettingsBlock() { + return buildStepSettingsBlock; + } public BinaryParserBlock getBinaryParserBlock() { return binaryParserBlock; @@ -125,6 +131,9 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock { if (getBuildSettingsBlock()!= null) { getBuildSettingsBlock().initializeValues(); } + if (getBuildStepSettingsBlock()!= null) { + getBuildStepSettingsBlock().initializeValues(); + } if (getErrorParserBlock()!= null) { // TODO //getErrorParserBlock().initializeValues(); @@ -145,6 +154,9 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock { if (getBuildSettingsBlock() != null) { getBuildSettingsBlock().updateValues(); } + if (getBuildStepSettingsBlock() != null) { + getBuildStepSettingsBlock().updateValues(); + } if (getErrorParserBlock() != null) { getErrorParserBlock().updateValues(); } @@ -174,6 +186,9 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock { if (getBuildSettingsBlock() != null) { getBuildSettingsBlock().setValues(); } + if (getBuildStepSettingsBlock() != null) { + getBuildStepSettingsBlock().setValues(); + } if (getErrorParserBlock() != null) { // TODO //getErrorParserBlock().setValues(); @@ -204,6 +219,9 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock { if (getBuildSettingsBlock() != null) { getBuildSettingsBlock().removeValues(id); } + if (getBuildStepSettingsBlock() != null) { + getBuildStepSettingsBlock().removeValues(id); + } if (getErrorParserBlock() != null) { // TODO //getErrorParserBlock().removeValues(id); @@ -233,6 +251,9 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock { if (getCurrentPage() instanceof BuildSettingsBlock) { return buildSettingsBlock.getPreferenceStore(); } + if (getCurrentPage() instanceof BuildStepSettingsBlock) { + return buildStepSettingsBlock.getPreferenceStore(); + } if (getCurrentPage() instanceof ErrorParserBlock) { return errParserBlock.getPreferenceStore(); } @@ -292,6 +313,8 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock { ((BuildSettingsBlock)tab).setDirty(b); } else if (tab instanceof ToolsSettingsBlock) { ((ToolsSettingsBlock)tab).setDirty(b); + } else if (tab instanceof BuildStepSettingsBlock) { + ((BuildStepSettingsBlock)tab).setDirty(b); } else if (tab instanceof ErrorParserBlock) { ((ErrorParserBlock)tab).setDirty(b); } else if (tab instanceof BinaryParserBlock) { @@ -314,6 +337,8 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock { if (((BuildSettingsBlock)tab).isDirty()) return true; } else if (tab instanceof ToolsSettingsBlock) { if (((ToolsSettingsBlock)tab).isDirty()) return true; + } else if (tab instanceof BuildStepSettingsBlock) { + if (((BuildStepSettingsBlock)tab).isDirty()) return true; } else if (tab instanceof ErrorParserBlock) { if (((ErrorParserBlock)tab).isDirty()) return true; } else if (tab instanceof BinaryParserBlock) { diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties index 970ad899e6c..ea0ba152205 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties @@ -32,6 +32,7 @@ MngCCWizardSettings.description=Define the Managed Make C++ build settings. MngMakeProjectWizard.config.title=Select a type of project MngMakeProjectWizard.config.desc=Select the platform and configurations you wish to deploy on PlatformBlock.tip.platform=Select the type of project for the build goal +PlatformBlock.tip.forcedconfigs=There are no buildable configurations on this platform for this project type.\n By default, all configurations selected. PlatformBlock.label.platform=Project Type: PlatformBlock.label.configs=Configurations: PlatformBlock.label.showall=Show All Project Types @@ -86,6 +87,19 @@ BuildSettingsBlock.label.makecmddef=Use default command BuildSettingsBlock.label.output.group=Build output BuildSettingsBlock.label.output.name=Artifact name: BuildSettingsBlock.label.output.extension=Artifact extension: +BuildSettingsBlock.defaults.title=Reset Build Settings +BuildSettingsBlock.defaults.message=This action will reset the build settings to their default settings.\n\nDo you want to proceed? + +# ----------- Build Steps Block ----------- +BuildStepSettingsBlock.label.Settings=Build Steps +BuildStepSettingsBlock.label.prebuildstep.group=Pre-build step: +BuildStepSettingsBlock.label.prebuildstep.cmd=Command: +BuildStepSettingsBlock.label.prebuildstep.desc=Description: +BuildStepSettingsBlock.label.postbuildstep.group=Post-build step: +BuildStepSettingsBlock.label.postbuildstep.cmd=Command: +BuildStepSettingsBlock.label.postbuildstep.desc=Description: +BuildStepsSettingsBlock.defaults.title=Reset Build Steps +BuildStepsSettingsBlock.defaults.message=This action will reset the pre-build and post-build steps to their default settings.\n\nDo you want to proceed? # ----------- Environment Set Block ----------- EnvironmentSetBlock.label.environment=Environment diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java index b91a0236969..8ed99368d06 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/CProjectPlatformPage.java @@ -62,6 +62,8 @@ public class CProjectPlatformPage extends WizardPage { private static final String SHOWALL_CONFIG_LABEL = LABEL + ".showall.config"; //$NON-NLS-1$ private static final String TARGET_LABEL = LABEL + ".platform"; //$NON-NLS-1$ private static final String TARGET_TIP = TIP + ".platform"; //$NON-NLS-1$ + private static final String FORCEDCONFIG_TIP = TIP + ".forcedconfigs"; //$NON-NLS-1$ + protected NewManagedProjectWizard parentWizard; protected Combo platformSelection; @@ -69,6 +71,7 @@ public class CProjectPlatformPage extends WizardPage { protected IProjectType selectedProjectType; protected Button showAllProjTypes; protected Button showAllConfigs; + protected boolean showAllConfigsForced; protected CheckboxTableViewer tableViewer; protected String[] projectTypeNames; protected ArrayList projectTypes; @@ -85,6 +88,7 @@ public class CProjectPlatformPage extends WizardPage { selectedProjectType = null; selectedConfigurations = new ArrayList(0); this.parentWizard = parentWizard; + showAllConfigsForced = false; } /** @@ -187,7 +191,7 @@ public class CProjectPlatformPage extends WizardPage { showAllConfigs.setText(ManagedBuilderUIMessages.getResourceString(SHOWALL_CONFIG_LABEL)); showAllConfigs.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { - populateConfigurations(); + populateConfigurations(true); } }); showAllConfigs.addDisposeListener(new DisposeListener() { @@ -279,30 +283,73 @@ public class CProjectPlatformPage extends WizardPage { parentWizard.updateProjectTypeProperties(); } } - populateConfigurations(); + populateConfigurations(false); setPageComplete(validatePage()); } /** * Populate the table viewer with either all known configurations * or only with the supported configurations depending on whether a user - * has chosen to diaplay unsupported configurations or not + * has chosen to display unsupported configurations or not * By default, only supported configurations are selected. */ - private void populateConfigurations() { - if(selectedProjectType == null) + private void populateConfigurations(boolean showallconfigsevent) { + if (selectedProjectType == null) return; boolean showAll = showAllConfigs != null ? showAllConfigs.getSelection() : false; IConfiguration selected[] = null; - if(showAll){ + if (showAll) { configurations = selectedProjectType.getConfigurations(); selected = filterSupportedConfigurations(configurations); } - else{ + else { configurations = filterSupportedConfigurations(selectedProjectType.getConfigurations()); selected = configurations; } + + // Check for buildable configs on this platform + if (selected.length == 0) { + // No buildable configs on this platform + if (showallconfigsevent) { + // "Show All Configurations" button pressed by user + if (showAll) { + // "Show All Configurations" check box "checked" by user + // For a project with no buildable configs, all available + // configs should be displayed and checked + configurations = selectedProjectType.getConfigurations(); + selected = configurations; + } + if (showAllConfigsForced) { + // The previous setting of this check box was done automatically when a project type + // with no buildable configs was encountered; undo this state now and honor the + // user's button click + setMessage(null, NONE); + showAllConfigsForced = false; + } + } + else { + configurations = selectedProjectType.getConfigurations(); + selected = configurations; + if (!showAll) { + showAllConfigsForced = true; + showAllConfigs.setSelection(true); + } + } + // Indicate that there are no buildable configurations on this platform for this project + // type and that all configurations will be selected + setMessage(ManagedBuilderUIMessages.getResourceString(FORCEDCONFIG_TIP), WARNING); + } + else { + setMessage(null, NONE); + if (showAllConfigsForced) { + showAllConfigsForced = false; + showAllConfigs.setSelection(false); + // Redo filtering in light of reset of "show all configs" to false + configurations = filterSupportedConfigurations(selectedProjectType.getConfigurations()); + selected = configurations; + } + } tableViewer.setInput(configurations); tableViewer.setCheckedElements(selected); @@ -310,14 +357,28 @@ public class CProjectPlatformPage extends WizardPage { } /** - * Returns the array of supported configurations found in the configuurations - * passes to this method + * Returns the array of supported configurations found in the configurations + * passed to this method */ IConfiguration[] filterSupportedConfigurations(IConfiguration cfgs[]){ ArrayList supported = new ArrayList(); - for(int i = 0; i < cfgs.length; i++){ - if(cfgs[i].isSupported()) - supported.add(cfgs[i]); + String os = Platform.getOS(); + String arch = Platform.getOSArch(); + + for (int i = 0; i < cfgs.length; i++) { + // First, filter on supported state + if (cfgs[i].isSupported()) { + // Now, apply the OS and ARCH filters to determine if the configuration should be shown + // Determine if the configuration's tool-chain supports this OS & Architecture. + IToolChain tc = cfgs[i].getToolChain(); + List osList = Arrays.asList(tc.getOSList()); + if (osList.contains("all") || osList.contains(os)) { //$NON-NLS-1$ + List archList = Arrays.asList(tc.getArchList()); + if (archList.contains("all") || archList.contains(arch)) { //$NON-NLS-1$ + supported.add(cfgs[i]); + } + } + } } return (IConfiguration[])supported.toArray(new IConfiguration[supported.size()]); }