From b280f247ae3d523fbcfd60ab2d883dd860711958 Mon Sep 17 00:00:00 2001 From: Marc-Andre Laperle Date: Thu, 3 Jul 2014 20:29:53 -0400 Subject: Bug 438476 - Fix autotools MinGW and Cygwin build Change-Id: I10bfb868718bf564dc74d53be6ff7453f1349dc5 Signed-off-by: Marc-Andre Laperle Reviewed-on: https://git.eclipse.org/r/29435 Tested-by: Hudson CI --- .../cdt/remote/core/RemoteCommandLauncher.java | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'remote') 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; -- cgit v1.2.3