mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
Stop launch on error. Fix up set/get make commands.
We were missing the dialog to ask if you wanted to continue after build errors in a project. We were missing the method that provided the list of projects to do that check. Also while testing that noticed the handling of the build and clean command UI was broken with make projects. Change-Id: I698e151672a114bb22c815f49d362b6413b9c315
This commit is contained in:
parent
0ed7b10dea
commit
6db1357b1a
7 changed files with 94 additions and 28 deletions
|
@ -54,31 +54,31 @@ public class MakeBuildSettingsTab extends CommonBuildTab {
|
||||||
|
|
||||||
// Build Output Group
|
// Build Output Group
|
||||||
Group outputGroup = new Group(comp, SWT.NONE);
|
Group outputGroup = new Group(comp, SWT.NONE);
|
||||||
outputGroup.setText("Build Output Location");
|
outputGroup.setText(Messages.MakeBuildSettingsTab_BuildOutputLocation);
|
||||||
outputGroup.setLayout(new GridLayout());
|
outputGroup.setLayout(new GridLayout());
|
||||||
outputGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
outputGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||||
|
|
||||||
projectButton = new Button(outputGroup, SWT.RADIO);
|
projectButton = new Button(outputGroup, SWT.RADIO);
|
||||||
projectButton.setText("Build in project directory");
|
projectButton.setText(Messages.MakeBuildSettingsTab_BuildInProjectDir);
|
||||||
projectButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
projectButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
||||||
|
|
||||||
configButton = new Button(outputGroup, SWT.RADIO);
|
configButton = new Button(outputGroup, SWT.RADIO);
|
||||||
configButton.setText("Build in configuration specific folder");
|
configButton.setText(Messages.MakeBuildSettingsTab_BuildInConfigDir);
|
||||||
configButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
configButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
||||||
|
|
||||||
Group cmdGroup = new Group(comp, SWT.NONE);
|
Group cmdGroup = new Group(comp, SWT.NONE);
|
||||||
cmdGroup.setText("Build Commands");
|
cmdGroup.setText(Messages.MakeBuildSettingsTab_BuildCommands);
|
||||||
cmdGroup.setLayout(new GridLayout(2, false));
|
cmdGroup.setLayout(new GridLayout(2, false));
|
||||||
cmdGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
cmdGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||||
|
|
||||||
Label label = new Label(cmdGroup, SWT.NONE);
|
Label label = new Label(cmdGroup, SWT.NONE);
|
||||||
label.setText("Build:");
|
label.setText(Messages.MakeBuildSettingsTab_Build);
|
||||||
|
|
||||||
buildCmdText = new Text(cmdGroup, SWT.BORDER);
|
buildCmdText = new Text(cmdGroup, SWT.BORDER);
|
||||||
buildCmdText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
buildCmdText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
||||||
|
|
||||||
label = new Label(cmdGroup, SWT.NONE);
|
label = new Label(cmdGroup, SWT.NONE);
|
||||||
label.setText("Clean:");
|
label.setText(Messages.MakeBuildSettingsTab_Clean);
|
||||||
|
|
||||||
cleanCmdText = new Text(cmdGroup, SWT.BORDER);
|
cleanCmdText = new Text(cmdGroup, SWT.BORDER);
|
||||||
cleanCmdText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
cleanCmdText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
||||||
|
@ -86,7 +86,7 @@ public class MakeBuildSettingsTab extends CommonBuildTab {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Makefile";
|
return Messages.MakeBuildSettingsTab_Makefile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -195,11 +195,15 @@ public class MakeBuildSettingsTab extends CommonBuildTab {
|
||||||
String buildCommand = buildCmdText.getText().trim();
|
String buildCommand = buildCmdText.getText().trim();
|
||||||
if (!buildCommand.isEmpty()) {
|
if (!buildCommand.isEmpty()) {
|
||||||
stdConfig.setBuildCommand(buildCommand.split(" ")); //$NON-NLS-1$
|
stdConfig.setBuildCommand(buildCommand.split(" ")); //$NON-NLS-1$
|
||||||
|
} else {
|
||||||
|
stdConfig.setBuildCommand(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
String cleanCommand = cleanCmdText.getText().trim();
|
String cleanCommand = cleanCmdText.getText().trim();
|
||||||
if (!cleanCommand.isEmpty()) {
|
if (!cleanCommand.isEmpty()) {
|
||||||
stdConfig.setCleanCommand(cleanCommand.split(" ")); //$NON-NLS-1$
|
stdConfig.setCleanCommand(cleanCommand.split(" ")); //$NON-NLS-1$
|
||||||
|
} else {
|
||||||
|
stdConfig.setCleanCommand(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.eclipse.cdt.make.internal.ui;
|
||||||
|
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
|
public class Messages extends NLS {
|
||||||
|
private static final String BUNDLE_NAME = "org.eclipse.cdt.make.internal.ui.messages"; //$NON-NLS-1$
|
||||||
|
public static String MakeBuildSettingsTab_Build;
|
||||||
|
public static String MakeBuildSettingsTab_BuildCommands;
|
||||||
|
public static String MakeBuildSettingsTab_BuildInConfigDir;
|
||||||
|
public static String MakeBuildSettingsTab_BuildInProjectDir;
|
||||||
|
public static String MakeBuildSettingsTab_BuildOutputLocation;
|
||||||
|
public static String MakeBuildSettingsTab_Clean;
|
||||||
|
public static String MakeBuildSettingsTab_Makefile;
|
||||||
|
static {
|
||||||
|
// initialize resource bundle
|
||||||
|
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Messages() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
MakeBuildSettingsTab_Build=Build:
|
||||||
|
MakeBuildSettingsTab_BuildCommands=Build Commands
|
||||||
|
MakeBuildSettingsTab_BuildInConfigDir=Build in configuration specific directory
|
||||||
|
MakeBuildSettingsTab_BuildInProjectDir=Build in project directory
|
||||||
|
MakeBuildSettingsTab_BuildOutputLocation=Build Output Location
|
||||||
|
MakeBuildSettingsTab_Clean=Clean:
|
||||||
|
MakeBuildSettingsTab_Makefile=Makefile
|
|
@ -60,8 +60,11 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
|
||||||
*/
|
*/
|
||||||
public static final String CLEAN_COMMAND = "stdbuild.clean.command"; //$NON-NLS-1$
|
public static final String CLEAN_COMMAND = "stdbuild.clean.command"; //$NON-NLS-1$
|
||||||
|
|
||||||
private String[] buildCommand;
|
private static final String[] DEFAULT_BUILD_COMMAND = new String[] { "make" }; //$NON-NLS-1$
|
||||||
private String[] cleanCommand;
|
private static final String[] DEFAULT_CLEAN_COMMAND = new String[] { "make", "clean" }; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
|
private String[] buildCommand = DEFAULT_BUILD_COMMAND;
|
||||||
|
private String[] cleanCommand = DEFAULT_CLEAN_COMMAND;
|
||||||
private IContainer buildContainer;
|
private IContainer buildContainer;
|
||||||
private IEnvironmentVariable[] envVars;
|
private IEnvironmentVariable[] envVars;
|
||||||
|
|
||||||
|
@ -91,11 +94,15 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
|
||||||
String buildCmd = getProperty(BUILD_COMMAND);
|
String buildCmd = getProperty(BUILD_COMMAND);
|
||||||
if (buildCmd != null && !buildCmd.trim().isEmpty()) {
|
if (buildCmd != null && !buildCmd.trim().isEmpty()) {
|
||||||
buildCommand = buildCmd.split(" "); //$NON-NLS-1$
|
buildCommand = buildCmd.split(" "); //$NON-NLS-1$
|
||||||
|
} else {
|
||||||
|
buildCommand = DEFAULT_BUILD_COMMAND;
|
||||||
}
|
}
|
||||||
|
|
||||||
String cleanCmd = getProperty(CLEAN_COMMAND);
|
String cleanCmd = getProperty(CLEAN_COMMAND);
|
||||||
if (cleanCmd != null && !cleanCmd.trim().isEmpty()) {
|
if (cleanCmd != null && !cleanCmd.trim().isEmpty()) {
|
||||||
cleanCommand = cleanCmd.split(" "); //$NON-NLS-1$
|
cleanCommand = cleanCmd.split(" "); //$NON-NLS-1$
|
||||||
|
} else {
|
||||||
|
cleanCommand = DEFAULT_CLEAN_COMMAND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,12 +139,23 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBuildCommand(String[] buildCommand) {
|
public void setBuildCommand(String[] buildCommand) {
|
||||||
|
if (buildCommand != null) {
|
||||||
this.buildCommand = buildCommand;
|
this.buildCommand = buildCommand;
|
||||||
setProperty(BUILD_COMMAND, String.join(" ", buildCommand)); //$NON-NLS-1$
|
setProperty(BUILD_COMMAND, String.join(" ", buildCommand)); //$NON-NLS-1$
|
||||||
|
} else {
|
||||||
|
this.buildCommand = DEFAULT_BUILD_COMMAND;
|
||||||
|
removeProperty(BUILD_COMMAND);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCleanCommand(String[] cleanCommand) {
|
public void setCleanCommand(String[] cleanCommand) {
|
||||||
|
if (cleanCommand != null) {
|
||||||
this.cleanCommand = cleanCommand;
|
this.cleanCommand = cleanCommand;
|
||||||
|
setProperty(CLEAN_COMMAND, String.join(" ", cleanCommand)); //$NON-NLS-1$
|
||||||
|
} else {
|
||||||
|
this.cleanCommand = DEFAULT_CLEAN_COMMAND;
|
||||||
|
removeProperty(CLEAN_COMMAND);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createBuildContainer(IContainer container, IProgressMonitor monitor) throws CoreException {
|
private void createBuildContainer(IContainer container, IProgressMonitor monitor) throws CoreException {
|
||||||
|
@ -183,7 +201,12 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
|
||||||
return getBuildContainer().getFullPath().toString();
|
return getBuildContainer().getFullPath().toString();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e.getStatus());
|
CCorePlugin.log(e.getStatus());
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
case BUILD_COMMAND:
|
||||||
|
return String.join(" ", buildCommand); //$NON-NLS-1$
|
||||||
|
case CLEAN_COMMAND:
|
||||||
|
return String.join(" ", cleanCommand); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -211,21 +234,23 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
|
||||||
|
|
||||||
outStream.write(String.format(Messages.StandardBuildConfiguration_0, buildDir.toString()));
|
outStream.write(String.format(Messages.StandardBuildConfiguration_0, buildDir.toString()));
|
||||||
|
|
||||||
List<String> command;
|
|
||||||
if (buildCommand != null) {
|
|
||||||
command = Arrays.asList(buildCommand);
|
|
||||||
Path make = findCommand(buildCommand[0]);
|
Path make = findCommand(buildCommand[0]);
|
||||||
command.set(0, make.toString());
|
if (make == null) {
|
||||||
} else {
|
console.getErrorStream()
|
||||||
command = new ArrayList<>();
|
.write(String.format(Messages.StandardBuildConfiguration_CommandNotFound, buildCommand[0]));
|
||||||
command.add(findCommand("make").toString()); //$NON-NLS-1$
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> command = new ArrayList<>();
|
||||||
|
command.add(make.toString());
|
||||||
if (!getBuildContainer().equals(getProject())) {
|
if (!getBuildContainer().equals(getProject())) {
|
||||||
Path makefile = Paths.get(getProject().getFile("Makefile").getLocationURI()); //$NON-NLS-1$
|
Path makefile = Paths.get(getProject().getFile("Makefile").getLocationURI()); //$NON-NLS-1$
|
||||||
Path relative = getBuildDirectory().relativize(makefile);
|
Path relative = getBuildDirectory().relativize(makefile);
|
||||||
command.add("-f"); //$NON-NLS-1$
|
command.add("-f"); //$NON-NLS-1$
|
||||||
command.add(relative.toString());
|
command.add(relative.toString());
|
||||||
}
|
}
|
||||||
command.add("all"); //$NON-NLS-1$
|
for (int i = 1; i < buildCommand.length; i++) {
|
||||||
|
command.add(buildCommand[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
try (ErrorParserManager epm = new ErrorParserManager(project, getProject().getLocationURI(), this,
|
try (ErrorParserManager epm = new ErrorParserManager(project, getProject().getLocationURI(), this,
|
||||||
|
|
|
@ -10,7 +10,7 @@ package org.eclipse.cdt.internal.core.build;
|
||||||
import org.eclipse.osgi.util.NLS;
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
public class Messages extends NLS {
|
public class Messages extends NLS {
|
||||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.build.Messages"; //$NON-NLS-1$
|
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.build.messages"; //$NON-NLS-1$
|
||||||
public static String CBuildConfiguration_CreateJob;
|
public static String CBuildConfiguration_CreateJob;
|
||||||
public static String CBuildConfiguration_ToolchainMissing;
|
public static String CBuildConfiguration_ToolchainMissing;
|
||||||
public static String CBuildConfiguration_Location;
|
public static String CBuildConfiguration_Location;
|
||||||
|
@ -20,6 +20,7 @@ public class Messages extends NLS {
|
||||||
public static String CBuilder_NotConfiguredCorrectly2;
|
public static String CBuilder_NotConfiguredCorrectly2;
|
||||||
public static String StandardBuildConfiguration_0;
|
public static String StandardBuildConfiguration_0;
|
||||||
public static String StandardBuildConfiguration_1;
|
public static String StandardBuildConfiguration_1;
|
||||||
|
public static String StandardBuildConfiguration_CommandNotFound;
|
||||||
static {
|
static {
|
||||||
// initialize resource bundle
|
// initialize resource bundle
|
||||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||||
|
|
|
@ -11,6 +11,7 @@ CBuilder_NotConfiguredCorrectly=Build not configured correctly\n
|
||||||
CBuilder_NotConfiguredCorrectly2=Build not configured correctly\n
|
CBuilder_NotConfiguredCorrectly2=Build not configured correctly\n
|
||||||
StandardBuildConfiguration_0=Building in: %s\n
|
StandardBuildConfiguration_0=Building in: %s\n
|
||||||
StandardBuildConfiguration_1=Build complete: %s\n
|
StandardBuildConfiguration_1=Build complete: %s\n
|
||||||
|
StandardBuildConfiguration_CommandNotFound=Error: build command '%s' not found
|
||||||
CBuildConfiguration_CreateJob=Create Build Folder
|
CBuildConfiguration_CreateJob=Create Build Folder
|
||||||
CBuildConfiguration_Location=line %d, external location: %s
|
CBuildConfiguration_Location=line %d, external location: %s
|
||||||
CBuildConfiguration_ToolchainMissing=Toolchain is missing for build configuration
|
CBuildConfiguration_ToolchainMissing=Toolchain is missing for build configuration
|
||||||
|
|
|
@ -44,6 +44,13 @@ public abstract class CoreBuildLaunchConfigDelegate extends LaunchConfigurationT
|
||||||
return configuration.getMappedResources()[0].getProject();
|
return configuration.getMappedResources()[0].getProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected IProject[] getProjectsForProblemSearch(ILaunchConfiguration configuration, String mode)
|
||||||
|
throws CoreException {
|
||||||
|
IProject project = getProject(configuration);
|
||||||
|
return project != null ? new IProject[] { project } : new IProject[0];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use the version that takes the launch config so we can see if it
|
* @deprecated Use the version that takes the launch config so we can see if it
|
||||||
* know what toolchain to use.
|
* know what toolchain to use.
|
||||||
|
|
Loading…
Add table
Reference in a new issue