Ejemplo n.º 1
0
        public void Load(HaxeProjectConfiguration configuration)
        {
            mConfiguration = configuration;

            wOutputFileNameEntry.Text = configuration.OutputFileName;
            wOutputDirectoryEntry.Text = configuration.OutputDirectory;
            wParametersEntry.Text = configuration.CompilerParameters;
        }
Ejemplo n.º 2
0
        public static void Run(HaxeProject project, HaxeProjectConfiguration configuration, IProgressMonitor monitor, ExecutionContext context)
        {
            ExecutionCommand cmd = CreateExecutionCommand(project, configuration);

            if (cmd is HaxeExecutionCommand)
            {
                IConsole console;
                if (configuration.ExternalConsole)
                {
                    console = context.ExternalConsoleFactory.CreateConsole(false);
                }
                else
                {
                    console = context.ConsoleFactory.CreateConsole(false);
                }

                AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor(monitor);

                try
                {
                    if (!context.ExecutionHandler.CanExecute(cmd))
                    {
                        monitor.ReportError(String.Format("Cannot execute '{0}'.", cmd.Target), null);
                        return;
                    }

                    IProcessAsyncOperation operation = context.ExecutionHandler.Execute(cmd, console);

                    operationMonitor.AddOperation(operation);
                    operation.WaitForCompleted();

                    monitor.Log.WriteLine("Player exited with code {0}.", operation.ExitCode);
                }
                catch (Exception)
                {
                    monitor.ReportError(String.Format("Error while executing '{0}'.", cmd.Target), null);
                }
                finally
                {
                    operationMonitor.Dispose();
                    console.Dispose();
                }
            }
            //else
            //{
            //	Process.Start (cmd);
            //}
        }
Ejemplo n.º 3
0
        public static bool CanRun(HaxeProject project, HaxeProjectConfiguration configuration, ExecutionContext context)
        {
            // need to optimize so this caches the result

            ExecutionCommand cmd = CreateExecutionCommand(project, configuration);

            if (cmd == null)
            {
                return(false);
            }
            else if (cmd is HaxeExecutionCommand)
            {
                return(context.ExecutionHandler.CanExecute(cmd));
            }
            else
            {
                return(true);
            }
        }
        public void Load(HaxeProjectConfiguration configuration)
        {
            mConfiguration = configuration;

            AdditionalArgumentsEntry.Text = configuration.AdditionalArguments;
        }
		public void Load (HaxeProjectConfiguration configuration)
		{
			mConfiguration = configuration;
			
			AdditionalArgumentsEntry.Text = configuration.AdditionalArguments;
		}
Ejemplo n.º 6
0
        public static BuildResult Compile(HaxeProject project, HaxeProjectConfiguration configuration, IProgressMonitor monitor)
        {
            string exe = "haxe";
            //string args = project.TargetHXMLFile;

            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(' ');

            bool createNext = false;

            foreach (string hxmlArg in hxmlArgs)
            {
                if (createNext)
                {
                    if (!hxmlArg.StartsWith("-"))
                    {
                        string path = Path.GetFullPath(Path.GetDirectoryName(hxmlArg));
                        if (!Directory.Exists(path))
                        {
                            path = Path.Combine(project.BaseDirectory, hxmlArg);
                            if (!Directory.Exists(Path.GetDirectoryName(path)))
                            {
                                Directory.CreateDirectory(Path.GetDirectoryName(path));
                            }
                        }
                    }
                    createNext = false;
                }

                if (hxmlArg == "-js" || hxmlArg == "-swf" || hxmlArg == "-swf9" || hxmlArg == "-neko")
                {
                    createNext = true;
                }
            }

            string args = String.Join(" ", hxmlArgs);

            if (configuration.DebugMode)
            {
                args += " -debug";
            }

            if (project.AdditionalArguments != "")
            {
                args += " " + project.AdditionalArguments;
            }

            if (configuration.AdditionalArguments != "")
            {
                args += " " + configuration.AdditionalArguments;
            }

            string error    = "";
            int    exitCode = DoCompilation(exe, args, project.BaseDirectory, monitor, ref error);

            BuildResult result = ParseOutput(project, error);

            if (result.CompilerOutput.Trim().Length != 0)
            {
                monitor.Log.WriteLine(result.CompilerOutput);
            }

            if (result.ErrorCount == 0 && exitCode != 0)
            {
                string errorMessage = File.ReadAllText(error);
                if (!string.IsNullOrEmpty(errorMessage))
                {
                    result.AddError(errorMessage);
                }
                else
                {
                    result.AddError("Build failed. Go to \"Build Output\" for more information");
                }
            }

            FileService.DeleteFile(error);
            return(result);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        public static string GetCompletionData(Project project, string classPath, string fileName, int position)
        {
            if (!PropertyService.HasValue("HaxeBinding.EnableCompilationServer"))
            {
                PropertyService.Set("HaxeBinding.EnableCompilationServer", true);
                PropertyService.Set("HaxeBinding.CompilationServerPort", 6000);
                PropertyService.SaveProperties();
            }

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

            if (project is OpenFLProject)
            {
                OpenFLProjectConfiguration configuration = project.GetConfiguration(MonoDevelop.Ide.IdeApp.Workspace.ActiveConfiguration) as OpenFLProjectConfiguration;

                string platform = configuration.Platform.ToLower();
                string path     = ((OpenFLProject)project).TargetProjectXMLFile;

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

                DateTime time = File.GetLastWriteTime(Path.GetFullPath(path));

                if (!time.Equals(cacheNMMLTime) || platform != cachePlatform || configuration.AdditionalArguments != cacheArgumentsPlatform || ((OpenFLProject)project).AdditionalArguments != cacheArgumentsGlobal)
                {
                    cacheHXML              = OpenFLCommandLineToolsManager.GetHXMLData((OpenFLProject)project, configuration).Replace(Environment.NewLine, " ");
                    cacheNMMLTime          = time;
                    cachePlatform          = platform;
                    cacheArgumentsGlobal   = ((OpenFLProject)project).AdditionalArguments;
                    cacheArgumentsPlatform = configuration.AdditionalArguments;
                }

                args = cacheHXML + " -D code_completion";
            }
            else if (project is HaxeProject)
            {
                HaxeProjectConfiguration configuration = project.GetConfiguration(MonoDevelop.Ide.IdeApp.Workspace.ActiveConfiguration) as HaxeProjectConfiguration;

                args = "\"" + ((HaxeProject)project).TargetHXMLFile + "\" " + ((HaxeProject)project).AdditionalArguments + " " + configuration.AdditionalArguments;
            }
            else
            {
                return("");
            }

            args += " -cp \"" + classPath + "\" --display \"" + fileName + "\"@" + position + " -D use_rtti_doc";

            if (PropertyService.Get <bool> ("HaxeBinding.EnableCompilationServer"))
            {
                var port = PropertyService.Get <int> ("HaxeBinding.CompilationServerPort");

                if (compilationServer == null || compilationServer.HasExited || port != compilationServerPort)
                {
                    StartServer();
                }

                try
                {
                    if (!compilationServer.HasExited)
                    {
                        var client = new TcpClient("127.0.0.1", port);
                        var writer = new StreamWriter(client.GetStream());
                        writer.WriteLine("--cwd " + project.BaseDirectory);

                        // Instead of replacing spaces with newlines, replace only
                        // if the space is followed by a dash.
                        // TODO: Even more intelligent replacement so you can use folders
                        //       that contain the string sequence " -".
                        writer.Write(args.Replace(" -", "\n-"));

                        //writer.WriteLine("--connect " + port);
                        writer.Write("\0");
                        writer.Flush();
                        var reader = new StreamReader(client.GetStream());
                        var lines  = reader.ReadToEnd().Split('\n');
                        client.Close();
                        return(String.Join("\n", lines));
                    }
                }
                catch (Exception)
                {
                    //MonoDevelop.Ide.MessageService.ShowError (ex.ToString ());
                    //TraceManager.AddAsync(ex.Message);
                    //if (!failure && FallbackNeeded != null)
                    // FallbackNeeded(false);
                    //failure = true;
                    //return "";
                }
            }

            //MonoDevelop.Ide.MessageService.ShowError ("Falling back to standard completion");

            Process process = new Process();

            process.StartInfo.FileName              = exe;
            process.StartInfo.Arguments             = args;
            process.StartInfo.UseShellExecute       = false;
            process.StartInfo.CreateNoWindow        = true;
            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.WorkingDirectory      = project.BaseDirectory;
            process.Start();

            string result = process.StandardError.ReadToEnd();

            process.WaitForExit();

            return(result);
        }