diff options
author | Marc-Andre Laperle | 2014-07-04 00:29:53 +0000 |
---|---|---|
committer | Marc-Andre Laperle | 2014-07-16 01:06:31 +0000 |
commit | b280f247ae3d523fbcfd60ab2d883dd860711958 (patch) | |
tree | 2ddf2d2b3935b48a78fdc38bde078239c323eb26 /remote | |
parent | 29b783155fd3acec6c0b5b65237a70fb0e219260 (diff) | |
download | org.eclipse.cdt-b280f247ae3d523fbcfd60ab2d883dd860711958.tar.gz org.eclipse.cdt-b280f247ae3d523fbcfd60ab2d883dd860711958.tar.xz org.eclipse.cdt-b280f247ae3d523fbcfd60ab2d883dd860711958.zip |
Bug 438476 - Fix autotools MinGW and Cygwin build
Change-Id: I10bfb868718bf564dc74d53be6ff7453f1349dc5
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/29435
Tested-by: Hudson CI
Diffstat (limited to 'remote')
-rw-r--r-- | remote/org.eclipse.cdt.remote.core/src/org/eclipse/cdt/remote/core/RemoteCommandLauncher.java | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/remote/org.eclipse.cdt.remote.core/src/org/eclipse/cdt/remote/core/RemoteCommandLauncher.java b/remote/org.eclipse.cdt.remote.core/src/org/eclipse/cdt/remote/core/RemoteCommandLauncher.java index b8b85e35655..412ac59d4d4 100644 --- a/remote/org.eclipse.cdt.remote.core/src/org/eclipse/cdt/remote/core/RemoteCommandLauncher.java +++ b/remote/org.eclipse.cdt.remote.core/src/org/eclipse/cdt/remote/core/RemoteCommandLauncher.java @@ -7,12 +7,12 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Marc-Andre Laperle (Ericsson) - Fix MinGW and Cygwin build (Bug 438476) *******************************************************************************/ package org.eclipse.cdt.remote.core; import java.io.IOException; import java.io.OutputStream; -import java.net.MalformedURLException; import java.net.URI; import java.util.Map; import java.util.Properties; @@ -36,6 +36,8 @@ import org.eclipse.remote.core.RemoteServices; public class RemoteCommandLauncher implements ICommandLauncher { + private static final String CYGWIN_PREFIX = "cygdrive"; //$NON-NLS-1$ + /** * Convert a local (workspace) path into the remote equivalent. If the local path is not * absolute, then do nothing. @@ -68,14 +70,35 @@ public class RemoteCommandLauncher implements ICommandLauncher { if (!localPath.isAbsolute()) { return localPath; } - IPath relativePath = localPath.makeRelativeTo(remote.getResource().getLocation()); + + IPath remoteLocation = remote.getResource().getLocation(); IPath remotePath = new Path(remote.getActiveLocationURI().getPath()); + + // Device mismatch, we might be in the presence of Cygwin or MinGW + if (remoteLocation.getDevice() != null && localPath.getDevice() == null) { + boolean isCygwin = localPath.segment(0).equals(CYGWIN_PREFIX); + remoteLocation = new Path(getPathString(remoteLocation, isCygwin)); + remotePath = new Path(getPathString(remotePath, isCygwin)); + } + + IPath relativePath = localPath.makeRelativeTo(remoteLocation); if (!relativePath.isEmpty()) { remotePath = remotePath.append(relativePath); } return remotePath; } + private static String getPathString(IPath path, boolean isCygwin) { + String s = path.toString(); + if (isCygwin) { + s = s.replaceAll("^([a-zA-Z]):", "/" + CYGWIN_PREFIX + "/$1"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ + } else { + s = s.replaceAll("^([a-zA-Z]):", "/$1"); //$NON-NLS-1$ //$NON-NLS-2$ + } + + return s; + } + private final ICommandLauncher fLocalLauncher = new CommandLauncher(); private boolean fShowCommand; private String[] fCommandArgs; |