From b9f5b7a7d48ea4a8c02958538d24602f58e975de Mon Sep 17 00:00:00 2001 From: John Cortell Date: Wed, 20 Aug 2008 20:50:17 +0000 Subject: [PATCH] Support specifying the program as a relative path pointing outside the project directory. This is currently blocked merely because of shortcomings in the validation logic. There is no hard requirement otherwise for the executable to be in the project directory. In fact, the code I'm tweaking already supports the program being specified as an absolute path. Not allowing a relative path to the same location (or any other valid location) doesn't make sense. --- .../cdt/launch/AbstractCLaunchDelegate.java | 6 ++++-- .../org/eclipse/cdt/launch/ui/CMainTab.java | 19 ++++++++----------- 2 files changed, 12 insertions(+), 13 deletions(-) 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 852e3004be9..1cf563ad51a 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 @@ -374,8 +374,10 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat ICDTLaunchConfigurationConstants.ERR_UNSPECIFIED_PROGRAM); } if (!programPath.isAbsolute()) { - IFile wsProgramPath = cproject.getProject().getFile(programPath); - programPath = wsProgramPath.getLocation(); + IPath location = project.getLocation(); + if (location != null) { + programPath = location.append(programPath); + } } if (!programPath.toFile().exists()) { abort( 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 a9edcf14cf5..93515a6d554 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 @@ -552,20 +552,17 @@ public class CMainTab extends CLaunchConfigurationTab { } IPath exePath = new Path(name); if (!exePath.isAbsolute()) { - IFile projFile = null; - try { - projFile = project.getFile(name); - } - catch (Exception exc) { - // throws an exception if it's a relative path pointing outside project - setErrorMessage(LaunchMessages.getString("CMainTab.Program_invalid_proj_path")); //$NON-NLS-1$ - return false; - } - if (projFile == null || !projFile.exists()) { + IPath location = project.getLocation(); + if (location == null) { + setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$ + return false; + } + + exePath = location.append(name); + if (!exePath.toFile().exists()) { setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$ return false; } - exePath = projFile.getLocation(); } else { if (!exePath.toFile().exists()) { setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$