mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
Bug 464078 - Support project-less Run
Change-Id: I69e655a65533e4cb835df59c9ff6ffa8152b92ff Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
parent
bd66f35865
commit
acda777315
2 changed files with 55 additions and 2 deletions
|
@ -34,6 +34,7 @@ import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
|||
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
||||
import org.eclipse.core.resources.ICommand;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -642,6 +643,45 @@ public abstract class AbstractCLaunchDelegate2 extends LaunchConfigurationDelega
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the program name of the configuration can be found as a file.
|
||||
* This method supports a program name without a corresponding project,
|
||||
* as long as the program name is specified with an absolute path.
|
||||
*
|
||||
* @return Absolute path of the program location
|
||||
* @since 7.3
|
||||
*/
|
||||
protected IPath verifyProgramPath(ILaunchConfiguration configuration, ICProject cproject) throws CoreException {
|
||||
String programName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null);
|
||||
if (programName == null) {
|
||||
abort(LaunchMessages.AbstractCLaunchDelegate_Program_file_not_specified, null,
|
||||
ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM);
|
||||
}
|
||||
programName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programName);
|
||||
|
||||
IPath programPath = new Path(programName);
|
||||
if (programPath.isEmpty()) {
|
||||
abort(LaunchMessages.AbstractCLaunchDelegate_Program_file_does_not_exist, null,
|
||||
ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST);
|
||||
}
|
||||
|
||||
if (!programPath.isAbsolute() && cproject != null) {
|
||||
// Find the specified program within the specified project
|
||||
IFile wsProgramPath = cproject.getProject().getFile(programPath);
|
||||
programPath = wsProgramPath.getLocation();
|
||||
}
|
||||
|
||||
if (!programPath.toFile().exists()) {
|
||||
abort(LaunchMessages.AbstractCLaunchDelegate_Program_file_does_not_exist,
|
||||
new FileNotFoundException(
|
||||
NLS.bind(LaunchMessages.AbstractCLaunchDelegate_PROGRAM_PATH_not_found,
|
||||
programPath.toOSString())),
|
||||
ICDTLaunchConfigurationConstants.ERR_PROGRAM_NOT_EXIST);
|
||||
}
|
||||
|
||||
return programPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the plugin hosting the launch delegate. It's used to
|
||||
* create {@link IStatus} objects.
|
||||
|
|
|
@ -17,7 +17,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDebugUtils;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.launch.AbstractCLaunchDelegate2;
|
||||
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
||||
|
@ -43,6 +43,7 @@ import com.ibm.icu.text.DateFormat;
|
|||
public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate2
|
||||
{
|
||||
public LocalRunLaunchDelegate() {
|
||||
// We support project-less run
|
||||
super(false);
|
||||
}
|
||||
|
||||
|
@ -66,7 +67,7 @@ public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate2
|
|||
}
|
||||
monitor.worked(1);
|
||||
try {
|
||||
IPath exePath = CDebugUtils.verifyProgramPath(config);
|
||||
IPath exePath = checkBinaryDetails(config);
|
||||
|
||||
File wd = verifyWorkingDirectory(config);
|
||||
if (wd == null) {
|
||||
|
@ -97,6 +98,18 @@ public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate2
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to check that the project and program are correct.
|
||||
* Can be overridden to avoid checking certain things.
|
||||
*/
|
||||
protected IPath checkBinaryDetails(final ILaunchConfiguration config) throws CoreException {
|
||||
// First verify we are dealing with a proper project.
|
||||
ICProject project = verifyCProject(config);
|
||||
// Now verify we know the program to run.
|
||||
IPath exePath = verifyProgramPath(config, project);
|
||||
return exePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a runtime exec on the given command line in the context of the
|
||||
* specified working directory, and returns the resulting process.
|
||||
|
|
Loading…
Add table
Reference in a new issue