mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
This commit is contained in:
parent
2c822f988a
commit
ea46f60dc2
5 changed files with 122 additions and 53 deletions
|
@ -32,7 +32,9 @@ public interface IMakeTarget {
|
|||
void setBuildCommand(IPath command) throws CoreException;
|
||||
String getBuildArguments();
|
||||
void setBuildArguments(String arguments) throws CoreException;
|
||||
|
||||
|
||||
void setRunAllBuilders(boolean runAllBuilders);
|
||||
boolean runAllBuilders();
|
||||
|
||||
/**
|
||||
* Get the target build container.
|
||||
|
|
|
@ -7,10 +7,10 @@ MakeBuilder.Creating_Markers=Generating markers...
|
|||
|
||||
BuildInfoFactory.Missing_Builder=Missing Builder:
|
||||
|
||||
MakeTargetManager.add_to_workspace_root=Cannot add build targets to workspace root
|
||||
MakeTargetManager.add_to_workspace_root=Cannot add make targets to workspace root
|
||||
MakeTargetManager.add_temporary_target=Cannot add temporart Target to manager.
|
||||
MakeTargetManager.target_exists=Target exists
|
||||
MakeTargetManager.failed_initializing_targets=Failed initializing build targets
|
||||
MakeTargetManager.failed_initializing_targets=Failed initializing make targets
|
||||
MakeTargetManager.error_writing_file=Error writing target file
|
||||
|
||||
ProjectTargets.error_reading_project_targets=Error reading project targets.
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/*
|
||||
/*******************************************************************************
|
||||
* Created on 19-Aug-2003
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2002,2003 QNX Software Systems Ltd.
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
***********************************************************************/
|
||||
* Contributors: QNX Software Systems - Initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.make.internal.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -13,13 +12,17 @@ import java.util.HashMap;
|
|||
import org.eclipse.cdt.make.core.IMakeBuilderInfo;
|
||||
import org.eclipse.cdt.make.core.IMakeTarget;
|
||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||
import org.eclipse.core.resources.ICommand;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
|
||||
public class MakeTarget implements IMakeTarget {
|
||||
|
||||
|
@ -30,9 +33,10 @@ public class MakeTarget implements IMakeTarget {
|
|||
private IPath buildCommand;
|
||||
private boolean isDefaultBuildCmd;
|
||||
private boolean isStopOnError;
|
||||
private boolean runAllBuidlers = true;
|
||||
private String targetBuilderID;
|
||||
private IContainer container;
|
||||
|
||||
|
||||
MakeTarget(MakeTargetManager manager, IProject project, String targetBuilderID, String name) throws CoreException {
|
||||
this.manager = manager;
|
||||
this.targetBuilderID = targetBuilderID;
|
||||
|
@ -79,7 +83,7 @@ public class MakeTarget implements IMakeTarget {
|
|||
}
|
||||
|
||||
public IPath getBuildCommand() {
|
||||
return buildCommand != null ? buildCommand: new Path(""); //$NON-NLS-1$
|
||||
return buildCommand != null ? buildCommand : new Path(""); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void setBuildCommand(IPath command) throws CoreException {
|
||||
|
@ -104,7 +108,7 @@ public class MakeTarget implements IMakeTarget {
|
|||
if (obj == this)
|
||||
return true;
|
||||
if (obj instanceof MakeTarget) {
|
||||
MakeTarget other = (MakeTarget) obj;
|
||||
MakeTarget other = (MakeTarget)obj;
|
||||
return container.equals(other.getContainer()) && name.equals(other.getName());
|
||||
}
|
||||
return false;
|
||||
|
@ -115,26 +119,56 @@ public class MakeTarget implements IMakeTarget {
|
|||
}
|
||||
|
||||
public void build(IProgressMonitor monitor) throws CoreException {
|
||||
IProject project = container.getProject();
|
||||
String builderID = manager.getBuilderID(targetBuilderID);
|
||||
HashMap infoMap = new HashMap();
|
||||
final IProject project = container.getProject();
|
||||
final String builderID = manager.getBuilderID(targetBuilderID);
|
||||
final HashMap infoMap = new HashMap();
|
||||
|
||||
IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(infoMap, builderID);
|
||||
if ( buildArguments != null) {
|
||||
if (buildArguments != null) {
|
||||
info.setBuildArguments(buildArguments);
|
||||
}
|
||||
if ( buildCommand != null ) {
|
||||
if (buildCommand != null) {
|
||||
info.setBuildCommand(buildCommand);
|
||||
}
|
||||
info.setUseDefaultBuildCmd(isDefaultBuildCmd);
|
||||
info.setStopOnError(isStopOnError);
|
||||
info.setFullBuildEnable(true);
|
||||
info.setFullBuildTarget(target);
|
||||
if ( container != null) {
|
||||
if (container != null) {
|
||||
info.setBuildLocation(container.getFullPath());
|
||||
}
|
||||
IMakeBuilderInfo projectInfo = MakeCorePlugin.createBuildInfo(project, builderID);
|
||||
info.setErrorParsers(projectInfo.getErrorParsers());
|
||||
project.build(IncrementalProjectBuilder.FULL_BUILD, builderID, infoMap, monitor);
|
||||
IWorkspaceRunnable op = new IWorkspaceRunnable() {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.core.resources.IWorkspaceRunnable#run(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
if (runAllBuidlers) {
|
||||
ICommand[] commands = project.getDescription().getBuildSpec();
|
||||
monitor.beginTask("", commands.length); //$NON-NLS-1$
|
||||
for (int i = 0; i < commands.length; i++) {
|
||||
if (commands[i].getBuilderName().equals(builderID)) {
|
||||
project.build(IncrementalProjectBuilder.FULL_BUILD, builderID, infoMap, monitor);
|
||||
} else {
|
||||
project.build(IncrementalProjectBuilder.FULL_BUILD, commands[i].getBuilderName(),
|
||||
commands[i].getArguments(), new SubProgressMonitor(monitor, 1));
|
||||
}
|
||||
}
|
||||
monitor.done();
|
||||
} else {
|
||||
project.build(IncrementalProjectBuilder.FULL_BUILD, builderID, infoMap, monitor);
|
||||
}
|
||||
}
|
||||
};
|
||||
try {
|
||||
ResourcesPlugin.getWorkspace().run(op, monitor);
|
||||
} finally {
|
||||
monitor.done();
|
||||
}
|
||||
}
|
||||
|
||||
public void setBuildTarget(String target) throws CoreException {
|
||||
|
@ -145,4 +179,22 @@ public class MakeTarget implements IMakeTarget {
|
|||
public String getBuildTarget() {
|
||||
return target != null ? target : ""; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.make.core.IMakeTarget#setRunAllBuilders(boolean)
|
||||
*/
|
||||
public void setRunAllBuilders(boolean runAllBuilders) {
|
||||
this.runAllBuidlers = runAllBuilders;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.make.core.IMakeTarget#runAllBuilders()
|
||||
*/
|
||||
public boolean runAllBuilders() {
|
||||
return runAllBuidlers;
|
||||
}
|
||||
}
|
|
@ -32,6 +32,7 @@ SettingsBlock.label=Make Builder
|
|||
SettingsBlock.message=Make builder settings.
|
||||
SettingsBlock.makeSetting.group_label=Build Setting
|
||||
SettingsBlock.makeSetting.stopOnError=Stop on first build error.
|
||||
SettingsBlock.makeSetting.runAllBuilders=Run all project builders.
|
||||
SettingsBlock.makeCmd.group_label=Build command
|
||||
SettingsBlock.makeCmd.use_default=Use default
|
||||
SettingsBlock.makeCmd.label=Build command:
|
||||
|
@ -49,8 +50,8 @@ SettingsBlock.makeWorkbench.clean=Clean
|
|||
TargetBlock.target.group_label=Target
|
||||
TargetBlock.target.label=Target Name:
|
||||
|
||||
BuildTarget.target.group_label=Build Target
|
||||
BuildTarget.target.label=Build Target:
|
||||
BuildTarget.target.group_label=Make Target
|
||||
BuildTarget.target.label=Make Target:
|
||||
|
||||
|
||||
# String constants for the build include path and preprocessor symbols
|
||||
|
@ -84,9 +85,9 @@ MakeTargetsPreferencePage.buildTargetInBackground.label=Build make targets in ba
|
|||
|
||||
MakeDocumentProvider.exception.createElementInfo=Error creating element.
|
||||
|
||||
AddBuildTargetAction.title=Add To Build Target
|
||||
AddBuildTargetAction.description=Add To Build Target
|
||||
AddBuildTargetAction.tooltip= Add To Build Target
|
||||
AddBuildTargetAction.title=Add make Target
|
||||
AddBuildTargetAction.description=Add make Target
|
||||
AddBuildTargetAction.tooltip= Add make Target
|
||||
AddBuildTargetAction.exception.internal=Internal Error
|
||||
|
||||
TargetBuild.execption.message=Target Build Error
|
||||
|
@ -110,7 +111,7 @@ BuildPathInfoBlock.button.browse=Browse...
|
|||
BuildPathInfoBlock.description=Set the include paths and preprocessor symbols for this project
|
||||
BuildPathInfoBlock.monitor.settingScannerInfo=Setting Scanner Info
|
||||
|
||||
BuildTargetDialog.title.buildTarget=Build Targets
|
||||
BuildTargetDialog.title.buildTarget=Make Targets
|
||||
BuildTargetDialog.button.build=Build
|
||||
BuildTargetDialog.title.makeTargetsFor=Make Targets for:
|
||||
|
||||
|
@ -130,25 +131,25 @@ SettingsBlock.label.missingBuilderInformation=Missing builder information on pro
|
|||
SettingsBlock.monitor.applyingSettings=Applying Settings...
|
||||
SettingsBlock.message.mustEnterBuildCommand=Must enter a build command
|
||||
|
||||
DeleteTargetAction.label=Delete Build Target
|
||||
DeleteTargetAction.tooltip=Delete Build Target
|
||||
DeleteTargetAction.label=Delete Make Target
|
||||
DeleteTargetAction.tooltip=Delete Make Target
|
||||
DeleteTargetAction.title.confirmDeletion=Confirm Target Deletion
|
||||
DeleteTargetAction.message.confirmDeleteion=Are you sure you want to delete ''{0}''?
|
||||
DeleteTargetAction.title.confirmMultipleDeletion=Confirm Multiple Target Deletion
|
||||
DeleteTargetAction.message.confirmMultipleDeletion=Are you sure you want to delete these {0} targets?
|
||||
DeleteTargetAction.exception.removeError=Target Remove Error
|
||||
DeleteTargetAction.exception.errorDeletingBuildTarget=Error deleting build target
|
||||
DeleteTargetAction.exception.removeError=Make Target Remove Error
|
||||
DeleteTargetAction.exception.errorDeletingBuildTarget=Error deleting Make target
|
||||
|
||||
BuildTargetAction.label=Build Target
|
||||
BuildTargetAction.tooltip=Build Target
|
||||
BuildTargetAction.label=Build Make Target
|
||||
BuildTargetAction.tooltip=Build Make Target
|
||||
|
||||
EditTargetAction.label=Edit Build Target
|
||||
EditTargetAction.tooltip=Edit Build Target
|
||||
EditTargetAction.label=Edit Make Target
|
||||
EditTargetAction.tooltip=Edit Make Target
|
||||
EditTargetAction.exception.internalError=Internal Error
|
||||
EditTargetAction.exception.errorEditingTarget=Error editing target.
|
||||
|
||||
AddTargetAction.label=Add Build Target
|
||||
AddTargetAction.tooltip=Add Build Target
|
||||
AddTargetAction.label=Add Make Target
|
||||
AddTargetAction.tooltip=Add Make Target
|
||||
AddTargetAction.exception.internalError=Internal Error
|
||||
AddTargetAction.=Internal Error
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ public class MakeTargetDialog extends Dialog {
|
|||
|
||||
Text targetNameText;
|
||||
Button stopOnErrorButton;
|
||||
Button runAllBuildersButton;
|
||||
Text commandText;
|
||||
Button defButton;
|
||||
Text targetText;
|
||||
|
@ -68,6 +69,7 @@ public class MakeTargetDialog extends Dialog {
|
|||
private IPath buildCommand;
|
||||
private boolean isDefaultCommand;
|
||||
private boolean isStopOnError;
|
||||
private boolean runAllBuilders = true;
|
||||
private String buildArguments;
|
||||
private String targetString;
|
||||
private String targetName;
|
||||
|
@ -87,6 +89,7 @@ public class MakeTargetDialog extends Dialog {
|
|||
targetName = target.getName();
|
||||
targetString = target.getBuildTarget();
|
||||
targetBuildID = target.getTargetBuilderID();
|
||||
runAllBuilders = target.runAllBuilders();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,12 +101,12 @@ public class MakeTargetDialog extends Dialog {
|
|||
fTargetManager = MakeCorePlugin.getDefault().getTargetManager();
|
||||
String[] id = fTargetManager.getTargetBuilders(container.getProject());
|
||||
if (id.length == 0) {
|
||||
throw new CoreException(
|
||||
new Status(IStatus.ERROR, MakeUIPlugin.getUniqueIdentifier(), -1, MakeUIPlugin.getResourceString("MakeTargetDialog.exception.noTargetBuilderOnProject"), null)); //$NON-NLS-1$
|
||||
throw new CoreException(new Status(IStatus.ERROR, MakeUIPlugin.getUniqueIdentifier(), -1,
|
||||
MakeUIPlugin.getResourceString("MakeTargetDialog.exception.noTargetBuilderOnProject"), null)); //$NON-NLS-1$
|
||||
}
|
||||
targetBuildID = id[0];
|
||||
IMakeBuilderInfo buildInfo =
|
||||
MakeCorePlugin.createBuildInfo(container.getProject(), fTargetManager.getBuilderID(targetBuildID));
|
||||
IMakeBuilderInfo buildInfo = MakeCorePlugin.createBuildInfo(container.getProject(),
|
||||
fTargetManager.getBuilderID(targetBuildID));
|
||||
isStopOnError = buildInfo.isStopOnError();
|
||||
isDefaultCommand = buildInfo.isDefaultBuildCmd();
|
||||
buildCommand = buildInfo.getBuildCommand();
|
||||
|
@ -134,25 +137,23 @@ public class MakeTargetDialog extends Dialog {
|
|||
Composite composite = (Composite)super.createDialogArea(parent);
|
||||
initializeDialogUnits(composite);
|
||||
|
||||
createNameControl(composite);
|
||||
createTargetControl(composite);
|
||||
createBuildCmdControls(composite);
|
||||
createSettingControls(composite);
|
||||
|
||||
fStatusLine = new MessageLine(composite);
|
||||
fStatusLine.setAlignment(SWT.LEFT);
|
||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
gd.widthHint = convertWidthInCharsToPixels(50);
|
||||
fStatusLine.setLayoutData(gd);
|
||||
fStatusLine.setMessage(getTitle());
|
||||
|
||||
createNameControl(composite);
|
||||
createTargetControl(composite);
|
||||
createBuildCmdControls(composite);
|
||||
createSettingControls(composite);
|
||||
return composite;
|
||||
}
|
||||
|
||||
protected void createNameControl(Composite parent) {
|
||||
Composite composite = ControlFactory.createComposite(parent, 2);
|
||||
((GridLayout)composite.getLayout()).makeColumnsEqualWidth = false;
|
||||
((GridLayout)composite.getLayout()).horizontalSpacing = 0;
|
||||
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
Label label = ControlFactory.createLabel(composite, MakeUIPlugin.getResourceString(TARGET_NAME_LABEL));
|
||||
((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING;
|
||||
|
@ -161,6 +162,7 @@ public class MakeTargetDialog extends Dialog {
|
|||
((GridData) (targetNameText.getLayoutData())).horizontalAlignment = GridData.FILL;
|
||||
((GridData) (targetNameText.getLayoutData())).grabExcessHorizontalSpace = true;
|
||||
targetNameText.addListener(SWT.Modify, new Listener() {
|
||||
|
||||
public void handleEvent(Event e) {
|
||||
String newName = targetNameText.getText().trim();
|
||||
if (newName.equals("")) { //$NON-NLS-1$
|
||||
|
@ -168,9 +170,8 @@ public class MakeTargetDialog extends Dialog {
|
|||
getButton(IDialogConstants.OK_ID).setEnabled(false);
|
||||
} else
|
||||
try {
|
||||
if (fTarget != null
|
||||
&& fTarget.getName().equals(newName)
|
||||
|| fTargetManager.findTarget(fContainer, newName) == null) {
|
||||
if (fTarget != null && fTarget.getName().equals(newName)
|
||||
|| fTargetManager.findTarget(fContainer, newName) == null) {
|
||||
fStatusLine.setErrorMessage(null);
|
||||
getButton(IDialogConstants.OK_ID).setEnabled(true);
|
||||
} else {
|
||||
|
@ -197,18 +198,23 @@ public class MakeTargetDialog extends Dialog {
|
|||
} else {
|
||||
stopOnErrorButton.setEnabled(false);
|
||||
}
|
||||
runAllBuildersButton = new Button(group, SWT.CHECK);
|
||||
runAllBuildersButton.setText(MakeUIPlugin.getResourceString("SettingsBlock.makeSetting.runAllBuilders")); //$NON-NLS-1$
|
||||
if (runAllBuilders) {
|
||||
runAllBuildersButton.setSelection(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected void createBuildCmdControls(Composite parent) {
|
||||
Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_CMD_GROUP), 1);
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = 2;
|
||||
layout.horizontalSpacing = 0;
|
||||
layout.makeColumnsEqualWidth = false;
|
||||
group.setLayout(layout);
|
||||
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
defButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_CMD_USE_DEFAULT));
|
||||
defButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
if (defButton.getSelection() == true) {
|
||||
commandText.setEnabled(false);
|
||||
|
@ -229,6 +235,7 @@ public class MakeTargetDialog extends Dialog {
|
|||
((GridData) (commandText.getLayoutData())).horizontalAlignment = GridData.FILL;
|
||||
((GridData) (commandText.getLayoutData())).grabExcessHorizontalSpace = true;
|
||||
commandText.addListener(SWT.Modify, new Listener() {
|
||||
|
||||
public void handleEvent(Event e) {
|
||||
if (commandText.getText().equals("")) { //$NON-NLS-1$
|
||||
fStatusLine.setErrorMessage(MakeUIPlugin.getResourceString("MakeTargetDialog.message.mustSpecifyBuildCommand")); //$NON-NLS-1$
|
||||
|
@ -277,7 +284,8 @@ public class MakeTargetDialog extends Dialog {
|
|||
createButton(parent, IDialogConstants.OK_ID, MakeUIPlugin.getResourceString("MakeTargetDialog.button.create"), true); //$NON-NLS-1$
|
||||
}
|
||||
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
|
||||
//do this here because setting the text will set enablement on the ok button
|
||||
//do this here because setting the text will set enablement on the ok
|
||||
// button
|
||||
targetNameText.setFocus();
|
||||
if (targetName != null) {
|
||||
targetNameText.setText(targetName);
|
||||
|
@ -304,6 +312,10 @@ public class MakeTargetDialog extends Dialog {
|
|||
return stopOnErrorButton.getSelection();
|
||||
}
|
||||
|
||||
private boolean runAllBuilders() {
|
||||
return runAllBuildersButton.getSelection();
|
||||
}
|
||||
|
||||
private boolean useDefaultBuildCmd() {
|
||||
return defButton.getSelection();
|
||||
}
|
||||
|
@ -323,8 +335,8 @@ public class MakeTargetDialog extends Dialog {
|
|||
if (fTarget == null) {
|
||||
target = fTargetManager.createTarget(fContainer.getProject(), targetNameText.getText().trim(), targetBuildID);
|
||||
}
|
||||
|
||||
target.setStopOnError(isStopOnError());
|
||||
target.setRunAllBuilders(runAllBuilders());
|
||||
target.setUseDefaultBuildCmd(useDefaultBuildCmd());
|
||||
if (!useDefaultBuildCmd()) {
|
||||
String bldLine = getBuildLine();
|
||||
|
@ -359,8 +371,10 @@ public class MakeTargetDialog extends Dialog {
|
|||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
MakeUIPlugin.errorDialog(getShell(), MakeUIPlugin.getResourceString("MakeTargetDialog.exception.makeTargetError"), MakeUIPlugin.getResourceString("MakeTargetDialog.exception.errorAddingTarget"), e); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
MakeUIPlugin.errorDialog(
|
||||
getShell(),
|
||||
MakeUIPlugin.getResourceString("MakeTargetDialog.exception.makeTargetError"), MakeUIPlugin.getResourceString("MakeTargetDialog.exception.errorAddingTarget"), e); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
super.okPressed();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue