1 package net.sourceforge.phpdt.internal.launching;
 
   4 import java.io.IOException;
 
   6 import org.eclipse.core.boot.BootLoader;
 
   7 import org.eclipse.debug.core.DebugPlugin;
 
   8 import org.eclipse.debug.core.ILaunch;
 
   9 import org.eclipse.debug.core.model.IProcess;
 
  11 public class InterpreterRunner {
 
  13         public InterpreterRunner() {
 
  16         public IProcess run(InterpreterRunnerConfiguration configuration, ILaunch launch) {
 
  17                 String commandLine = renderCommandLine(configuration);
 
  18                 File workingDirectory = configuration.getAbsoluteWorkingDirectory();
 
  20                 Process nativePHPProcess = null;
 
  22                         nativePHPProcess = configuration.getInterpreter().exec(commandLine, workingDirectory);
 
  23                 } catch (IOException e) {
 
  24                         throw new RuntimeException("Unable to execute interpreter: " + commandLine + workingDirectory);
 
  27                 IProcess process = DebugPlugin.newProcess(launch, nativePHPProcess, renderLabel(configuration));
 
  28                 process.setAttribute(PHPLaunchingPlugin.PLUGIN_ID + ".launcher.cmdline", commandLine);
 
  32         protected String renderLabel(InterpreterRunnerConfiguration configuration) {
 
  33                 StringBuffer buffer = new StringBuffer();
 
  35                 PHPInterpreter interpreter = configuration.getInterpreter();
 
  36                 buffer.append("PHP ");
 
  37                 buffer.append(interpreter.getCommand());
 
  39                 buffer.append(configuration.getFileName());
 
  41                 return buffer.toString();
 
  44         protected String renderCommandLine(InterpreterRunnerConfiguration configuration) {
 
  45                 PHPInterpreter interpreter = configuration.getInterpreter();
 
  47                 StringBuffer buffer = new StringBuffer();
 
  48                 buffer.append(this.getDebugCommandLineArgument());
 
  49         //      buffer.append(renderLoadPath(configuration));
 
  50                 buffer.append(" " + configuration.getInterpreterArguments());
 
  51         //      buffer.append(interpreter.endOfOptionsDelimeter);
 
  52                 buffer.append(" " + osDependentPath(configuration.getAbsoluteFileName()));
 
  53                 buffer.append(" " + configuration.getProgramArguments());
 
  55                 return buffer.toString();
 
  58 //      protected String renderLoadPath(InterpreterRunnerConfiguration configuration) {
 
  59 //              StringBuffer loadPath = new StringBuffer();
 
  61 //              PHPProject project = configuration.getProject();
 
  62 //              addToLoadPath(loadPath, project.getProject());
 
  64 //              Iterator referencedProjects = project.getReferencedProjects().iterator();
 
  65 //              while (referencedProjects.hasNext())
 
  66 //                      addToLoadPath(loadPath, (IProject) referencedProjects.next());
 
  68 //              return loadPath.toString();
 
  71 //      protected void addToLoadPath(StringBuffer loadPath, IProject project) {
 
  73 //              loadPath.append(" -I " + osDependentPath(project.getLocation().toOSString()));
 
  76         protected String osDependentPath(String aPath) {
 
  77                 if (BootLoader.getOS().equals(BootLoader.OS_WIN32))
 
  78                         aPath = "\"" + aPath + "\"";
 
  83         protected String getDebugCommandLineArgument() {