private static ExecutionCommand CreateExecutionCommand(HaxeProject project, HaxeProjectConfiguration configuration)
        {
            string hxmlPath = Path.GetFullPath(project.TargetHXMLFile);

            if (!File.Exists(hxmlPath))
            {
                hxmlPath = Path.Combine(project.BaseDirectory, project.TargetHXMLFile);
            }

            string hxml = File.ReadAllText(hxmlPath);

            hxml = hxml.Replace(Environment.NewLine, " ");
            string[] hxmlArgs = hxml.Split(' ');

            List <string> platforms       = new List <string> ();
            List <string> platformOutputs = new List <string> ();

            bool   addNext    = false;
            bool   nextIsMain = false;
            string main       = "";

            foreach (string hxmlArg in hxmlArgs)
            {
                if (addNext)
                {
                    if (!hxmlArg.StartsWith("-"))
                    {
                        if (nextIsMain)
                        {
                            main       = hxmlArg;
                            nextIsMain = false;
                        }
                        else
                        {
                            platformOutputs.Add(hxmlArg);
                        }
                    }
                    else
                    {
                        if (!nextIsMain)
                        {
                            platforms.RemoveAt(platforms.Count - 1);
                        }
                    }
                }

                addNext = true;

                switch (hxmlArg)
                {
                case "-cpp":
                    platforms.Add("cpp");
                    break;

                case "-swf":
                case "-swf9":
                    platforms.Add("flash");
                    break;

                case "-js":
                    platforms.Add("js");
                    break;

                case "-neko":
                    platforms.Add("neko");
                    break;

                case "-php":
                    platforms.Add("php");
                    break;

                case "-main":
                    nextIsMain = true;
                    break;

                default:
                    addNext = false;
                    break;
                }
            }


            int i = 0;

            //for (int i = 0; i < platforms.Count; i++)
            //{
            string platform = platforms[i];
            string output   = platformOutputs[i];

            if (platform == "cpp" || platform == "neko")
            {
                if (platform == "cpp")
                {
                    output = Path.Combine(output, main);
                    if (configuration.DebugMode)
                    {
                        output += "-debug";
                    }
                }

                if (!File.Exists(Path.GetFullPath(output)))
                {
                    output = Path.Combine(project.BaseDirectory, output);
                }

                string exe  = "";
                string args = "";

                if (platform == "cpp")
                {
                    exe = output;
                }
                else
                {
                    exe  = "neko";
                    args = "\"" + output + "\"";
                }

                //NativeExecutionCommand cmd = new NativeExecutionCommand (exe);
                HaxeExecutionCommand cmd = new HaxeExecutionCommand(exe);
                cmd.Arguments        = args;
                cmd.WorkingDirectory = Path.GetDirectoryName(output);

                if (configuration.DebugMode)
                {
                    //	cmd.EnvironmentVariables.Add ("HXCPP_DEBUG_HOST", "gdb");
                    cmd.EnvironmentVariables.Add("HXCPP_DEBUG", "1");
                }
                //cmd.WorkingDirectory = project.BaseDirectory.FullPath;

                //MonoDevelop.Ide.MessageService.ShowMessage (cmd.Command);
                //MonoDevelop.Ide.MessageService.ShowMessage (cmd.Arguments);
                //MonoDevelop.Ide.MessageService.ShowMessage (cmd.WorkingDirectory);

                return(cmd);
            }
            else if (platform == "flash" || platform == "js")
            {
                if (!File.Exists(Path.GetFullPath(output)))
                {
                    output = Path.Combine(project.BaseDirectory, output);
                }

                if (platform == "js")
                {
                    output = Path.Combine(Path.GetDirectoryName(output), "index.html");
                }

                //string target = output;

                switch (Environment.OSVersion.Platform)
                {
                case PlatformID.MacOSX:
                    //target = "open \"" + output + "\"";
                    break;

                case PlatformID.Unix:
                    //target = "xdg-open \"" + output + "\"";
                    break;
                }

                ProcessExecutionCommand cmd = new ProcessExecutionCommand();
                cmd.Command = output;
                return(cmd);
            }
            //}

            return(null);
        }
        private static ExecutionCommand CreateExecutionCommand(HaxeProject project, HaxeProjectConfiguration configuration)
        {
            string hxmlPath = Path.GetFullPath (project.TargetHXMLFile);

            if (!File.Exists (hxmlPath))
            {
                hxmlPath = Path.Combine (project.BaseDirectory, project.TargetHXMLFile);
            }

            string hxml = File.ReadAllText (hxmlPath);
            hxml = hxml.Replace (Environment.NewLine, " ");
            string[] hxmlArgs = hxml.Split (' ');

            List<string> platforms = new List<string> ();
            List<string> platformOutputs = new List<string> ();

            bool addNext = false;
            bool nextIsMain = false;
            string main = "";

            foreach (string hxmlArg in hxmlArgs)
            {
                if (addNext)
                {
                    if (!hxmlArg.StartsWith ("-"))
                    {
                        if (nextIsMain)
                        {
                            main = hxmlArg;
                            nextIsMain = false;
                        }
                        else
                        {
                            platformOutputs.Add (hxmlArg);
                        }
                    }
                    else
                    {
                        if (!nextIsMain)
                        {
                            platforms.RemoveAt (platforms.Count - 1);
                        }
                    }
                }

                addNext = true;

                switch (hxmlArg)
                {
                    case "-cpp":
                        platforms.Add ("cpp");
                        break;

                    case "-swf":
                    case "-swf9":
                        platforms.Add ("flash");
                        break;

                    case "-js":
                        platforms.Add ("js");
                        break;

                    case "-neko":
                        platforms.Add ("neko");
                        break;

                    case "-php":
                        platforms.Add ("php");
                        break;

                    case "-main":
                        nextIsMain = true;
                        break;

                    default:
                        addNext = false;
                        break;
                }
            }

            int i = 0;

            //for (int i = 0; i < platforms.Count; i++)
            //{
                string platform = platforms[i];
                string output = platformOutputs[i];

                if (platform == "cpp" || platform == "neko")
                {
                    if (platform == "cpp")
                    {
                        output = Path.Combine (output, main);
                        if (configuration.DebugMode)
                        {
                            output += "-debug";
                        }
                    }

                    if (!File.Exists (Path.GetFullPath (output)))
                    {
                        output = Path.Combine (project.BaseDirectory, output);
                    }

                    string exe = "";
                    string args = "";

                    if (platform == "cpp")
                    {
                        exe = output;
                    }
                    else
                    {
                        exe = "neko";
                        args = "\"" + output + "\"";
                    }

                    //NativeExecutionCommand cmd = new NativeExecutionCommand (exe);
                    HaxeExecutionCommand cmd = new HaxeExecutionCommand (exe);
                    cmd.Arguments = args;
                    cmd.WorkingDirectory = Path.GetDirectoryName (output);

                    if (configuration.DebugMode)
                    {
                    //	cmd.EnvironmentVariables.Add ("HXCPP_DEBUG_HOST", "gdb");
                        cmd.EnvironmentVariables.Add ("HXCPP_DEBUG", "1");
                    }
                    //cmd.WorkingDirectory = project.BaseDirectory.FullPath;

                    //MonoDevelop.Ide.MessageService.ShowMessage (cmd.Command);
                    //MonoDevelop.Ide.MessageService.ShowMessage (cmd.Arguments);
                    //MonoDevelop.Ide.MessageService.ShowMessage (cmd.WorkingDirectory);

                    return cmd;
                }
                else if (platform == "flash" || platform == "js")
                {
                    if (!File.Exists (Path.GetFullPath (output)))
                    {
                        output = Path.Combine (project.BaseDirectory, output);
                    }

                    if (platform == "js")
                    {
                        output = Path.Combine (Path.GetDirectoryName (output), "index.html");
                    }

                    //string target = output;

                    switch (Environment.OSVersion.Platform)
                    {
                        case PlatformID.MacOSX:
                            //target = "open \"" + output + "\"";
                            break;

                        case PlatformID.Unix:
                            //target = "xdg-open \"" + output + "\"";
                            break;
                    }

                    ProcessExecutionCommand cmd = new ProcessExecutionCommand ();
                    cmd.Command = output;
                    return cmd;
                }
            //}

            return null;
        }