aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2012-07-02 16:33:36 -0700
committerSiva Velusamy <vsiva@google.com>2012-07-02 16:41:17 -0700
commitcd1f0ebda9d518ab0e491b4c97c1c3d7c625eb62 (patch)
tree69003feec33dc7292f2440d8c0a18249cd42d8e3
parent4c6c45a81807c33cd52bf6782e52a676a2ac940a (diff)
downloadsdk-cd1f0ebda9d518ab0e491b4c97c1c3d7c625eb62.zip
sdk-cd1f0ebda9d518ab0e491b4c97c1c3d7c625eb62.tar.gz
sdk-cd1f0ebda9d518ab0e491b4c97c1c3d7c625eb62.tar.bz2
NdkCommandLauncher: find the correct executable extension
Assume that extensions .exe, .bat and .cmd all refer to native Windows executables. For such executables, do not use "sh" (Cygwin shell) to launch them. Change-Id: Ia04f69e85d8b7d7f4fc2421ae4c9839a3df914a0
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ndk/src/com/android/ide/eclipse/ndk/internal/build/NdkCommandLauncher.java50
1 files changed, 42 insertions, 8 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.ndk/src/com/android/ide/eclipse/ndk/internal/build/NdkCommandLauncher.java b/eclipse/plugins/com.android.ide.eclipse.ndk/src/com/android/ide/eclipse/ndk/internal/build/NdkCommandLauncher.java
index 71c635a..0a1f7dc 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ndk/src/com/android/ide/eclipse/ndk/internal/build/NdkCommandLauncher.java
+++ b/eclipse/plugins/com.android.ide.eclipse.ndk/src/com/android/ide/eclipse/ndk/internal/build/NdkCommandLauncher.java
@@ -29,11 +29,18 @@ import org.eclipse.core.runtime.Platform;
import java.io.File;
import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
@SuppressWarnings("restriction") // for AdtPlugin internal classes
public class NdkCommandLauncher extends CommandLauncher {
private static CygPath sCygPath = null;
- private static final String WINDOWS_EXE = "exe"; //$NON-NLS-1$
+
+ private static final List<String> WINDOWS_NATIVE_EXECUTABLES = Arrays.asList(
+ "exe", //$NON-NLS-1$
+ "cmd", //$NON-NLS-1$
+ "bat" //$NON-NLS-1$
+ );
static {
if (Platform.OS_WIN32.equals(Platform.getOS())) {
@@ -66,10 +73,8 @@ public class NdkCommandLauncher extends CommandLauncher {
}
if (isWindowsExecutable(commandPath)) {
- // Make sure it has the full file name extension
- if (!WINDOWS_EXE.equalsIgnoreCase(commandPath.getFileExtension())) {
- commandPath = commandPath.addFileExtension(WINDOWS_EXE);
- }
+ // append necessary extension
+ commandPath = appendExecutableExtension(commandPath);
} else {
// Invoke using Cygwin shell if this is not a native windows executable
String[] newargs = new String[args.length + 1];
@@ -85,15 +90,44 @@ public class NdkCommandLauncher extends CommandLauncher {
}
private boolean isWindowsExecutable(IPath commandPath) {
- if (WINDOWS_EXE.equalsIgnoreCase(commandPath.getFileExtension())) {
+ String ext = commandPath.getFileExtension();
+ if (isWindowsExecutableExtension(ext)) {
return true;
}
- File exeFile = commandPath.addFileExtension(WINDOWS_EXE).toFile();
- if (exeFile.exists()) {
+ ext = findWindowsExecutableExtension(commandPath);
+ if (ext != null) {
return true;
}
return false;
}
+
+ private IPath appendExecutableExtension(IPath commandPath) {
+ if (isWindowsExecutableExtension(commandPath.getFileExtension())) {
+ return commandPath;
+ }
+
+ String ext = findWindowsExecutableExtension(commandPath);
+ if (ext != null) {
+ return commandPath.addFileExtension(ext);
+ }
+
+ return commandPath;
+ }
+
+ private String findWindowsExecutableExtension(IPath command) {
+ for (String e: WINDOWS_NATIVE_EXECUTABLES) {
+ File exeFile = command.addFileExtension(e).toFile();
+ if (exeFile.exists()) {
+ return e;
+ }
+ }
+
+ return null;
+ }
+
+ private boolean isWindowsExecutableExtension(String extension) {
+ return extension != null && WINDOWS_NATIVE_EXECUTABLES.contains(extension);
+ }
}