diff options
author | Siva Velusamy <vsiva@google.com> | 2012-07-02 16:44:10 -0700 |
---|---|---|
committer | android code review <noreply-gerritcodereview@google.com> | 2012-07-02 16:44:11 -0700 |
commit | 33352d827e5bc3a91442ebee80931fc1f77b052b (patch) | |
tree | 919f30dbb77109884d16ae41e55bebe41b6168e1 | |
parent | 0ea2ea9094c7786c381aa6c3206c601b7458109d (diff) | |
parent | cd1f0ebda9d518ab0e491b4c97c1c3d7c625eb62 (diff) | |
download | sdk-33352d827e5bc3a91442ebee80931fc1f77b052b.zip sdk-33352d827e5bc3a91442ebee80931fc1f77b052b.tar.gz sdk-33352d827e5bc3a91442ebee80931fc1f77b052b.tar.bz2 |
Merge "NdkCommandLauncher: find the correct executable extension"
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.ndk/src/com/android/ide/eclipse/ndk/internal/build/NdkCommandLauncher.java | 50 |
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); + } } |