1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Eclipse Public License, Version 1.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.eclipse.org/org/documents/epl-v10.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ide.eclipse.adt.ndk.internal.build; 18 19 import com.android.ide.eclipse.adt.ndk.internal.NdkManager; 20 21 import org.eclipse.cdt.core.CommandLauncher; 22 import org.eclipse.core.runtime.CoreException; 23 import org.eclipse.core.runtime.IPath; 24 import org.eclipse.core.runtime.IProgressMonitor; 25 import org.eclipse.core.runtime.Path; 26 import org.eclipse.core.runtime.Platform; 27 28 public class NdkCommandLauncher extends CommandLauncher { 29 30 @Override 31 public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory, 32 IProgressMonitor monitor) 33 throws CoreException { 34 if (!commandPath.isAbsolute()) 35 commandPath = new Path(NdkManager.getNdkLocation()).append(commandPath); 36 37 if (Platform.getOS().equals(Platform.OS_WIN32)) { 38 String[] newargs = new String[args.length + 1]; 39 newargs[0] = commandPath.toOSString(); 40 System.arraycopy(args, 0, newargs, 1, args.length); 41 commandPath = new Path("sh"); //$NON-NLS-1$ 42 args = newargs; 43 } 44 45 return super.execute(commandPath, args, env, changeToDirectory, monitor); 46 } 47 48 } 49