Exemplo n.º 1
0
        public override SolutionItemConfiguration CreateConfiguration(string name)
        {
            HaxeProjectConfiguration conf = new HaxeProjectConfiguration();

            conf.Name = name;
            return(conf);
        }
Exemplo n.º 2
0
        public override void CopyFrom(ItemConfiguration configuration)
        {
            base.CopyFrom(configuration);

            HaxeProjectConfiguration other = (HaxeProjectConfiguration)configuration;

            mAdditionalArguments = other.mAdditionalArguments;
        }
Exemplo 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 NativeExecutionCommand)
            {
                return context.ExecutionHandler.CanExecute (cmd);
            }
            else
            {
                return true;
            }
        }
Exemplo n.º 4
0
        public static BuildResult Compile(HaxeProject project, HaxeProjectConfiguration configuration, IProgressMonitor monitor)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat(" -output \"{0}/{1}\" ", configuration.OutputDirectory, configuration.OutputFileName);

            if (configuration.DebugMode)
                sb.Append("-compiler.debug=true ");

            if (!String.IsNullOrEmpty(configuration.CompilerParameters)) {
                sb.Append(configuration.CompilerParameters);
                sb.Append(" ");
            }

            sb.Append(project.MainSource);

            string output = "";
            string error  = "";

            string cmd = Path.Combine(Path.Combine(PropertyService.Get<string>("CBinding.FlexSdkPath"), "bin"), project.Compiler);
            string args = sb.ToString();
            monitor.Log.WriteLine(cmd+" "+args);

            int exitCode = DoCompilation(cmd, args, project.BaseDirectory, ref output, ref error);

            BuildResult result = ParseOutput(output, error);
            if (result.CompilerOutput.Trim().Length != 0)
                monitor.Log.WriteLine(result.CompilerOutput);

            // If compiler crashes, output entire error string.

            if (result.ErrorCount == 0 && exitCode != 0) {
                if (!string.IsNullOrEmpty(error))
                    result.AddError(error);
                else
                    result.AddError("The compiler appears to have crashed without any error output.");
            }

            FileService.DeleteFile(output);
            FileService.DeleteFile(error);
            return result;
        }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
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);
                    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;
        }
Exemplo n.º 7
0
        public static void Run(HaxeProject project, HaxeProjectConfiguration configuration, IProgressMonitor monitor, ExecutionContext context)
        {
            ExecutionCommand cmd = CreateExecutionCommand (project, configuration);

            if (cmd is NativeExecutionCommand)
            {
                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.CommandString), 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.CommandString), null);
                }
                finally
                {
                    operationMonitor.Dispose ();
                    console.Dispose ();
                }
            }
            else
            {
                Process.Start (cmd.CommandString);
            }
        }
Exemplo n.º 8
0
 public override SolutionItemConfiguration CreateConfiguration(string name)
 {
     HaxeProjectConfiguration conf = new HaxeProjectConfiguration ();
     conf.Name = name;
     return conf;
 }
Exemplo n.º 9
0
        protected override BuildResult DoBuild(IProgressMonitor monitor, ConfigurationSelector configurationSelector)
        {
            HaxeProjectConfiguration haxeConfig = (HaxeProjectConfiguration)GetConfiguration(configurationSelector);

            return(HaxeCompilerManager.Compile(this, haxeConfig, monitor));
        }
Exemplo n.º 10
0
        protected override bool OnGetCanExecute(ExecutionContext context, ConfigurationSelector configurationSelector)
        {
            HaxeProjectConfiguration haxeConfig = (HaxeProjectConfiguration)GetConfiguration(configurationSelector);

            return(HaxeCompilerManager.CanRun(this, haxeConfig, context));
        }
Exemplo n.º 11
0
        protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configurationSelector)
        {
            HaxeProjectConfiguration haxeConfig = (HaxeProjectConfiguration)GetConfiguration(configurationSelector);

            HaxeCompilerManager.Run(this, haxeConfig, monitor, context);
        }
Exemplo n.º 12
0
        /*protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, string configurationName)
        {
            FlexProjectConfiguration configuration = (FlexProjectConfiguration)GetConfiguration(configurationName);

            switch (mRunMode)
            {
                case RunMode.SystemPlugin:
                    DoExecuteWithSystemPlugin(monitor, context, configuration);
                    break;

                case RunMode.CustomPlugin:
                    DoExecuteWithExe(monitor, context, PropertyService.Get<string>("CBinding.FlexBrowserPath"), configuration);
                    break;

                case RunMode.StandalonePlayer:
                    DoExecuteWithExe(monitor, context, PropertyService.Get<string>("CBinding.FlexPlayerPath"), configuration);
                    break;
            }
        }*/
        void DoExecuteWithSystemPlugin(IProgressMonitor monitor, ExecutionContext context, HaxeProjectConfiguration configuration)
        {
            monitor.Log.WriteLine("Invoking system default browser...");

            String args = "file://"+Path.GetFullPath(Path.Combine(configuration.OutputDirectory, configuration.OutputFileName));

            Process.Start(args);
        }
Exemplo n.º 13
0
        void DoExecuteWithExe(IProgressMonitor monitor, ExecutionContext context, string exe, HaxeProjectConfiguration configuration)
        {
            monitor.Log.WriteLine("Running project using '{0}' ...", exe);

            if (string.IsNullOrEmpty(exe)) {
                monitor.ReportError(String.Format("No custom player or browser configured."), null);
                return;
            }

            string[] parts = exe.Split(' ');
            string args = "file://"+Path.GetFullPath(Path.Combine(configuration.OutputDirectory, configuration.OutputFileName));
            if (parts.Length > 1)
                args = string.Join(" ", parts, 1, parts.Length-1) + " " + args;
            exe = parts[0];

            IConsole console;
            if (configuration.ExternalConsole)
                console = context.ExternalConsoleFactory.CreateConsole(false);
            else
                console = context.ConsoleFactory.CreateConsole(false);

            AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor(monitor);

            try {
                NativeExecutionCommand cmd = new NativeExecutionCommand(exe);
                cmd.Arguments = args;
                cmd.WorkingDirectory = Path.GetFullPath(configuration.OutputDirectory);

                if (!context.ExecutionHandler.CanExecute(cmd)) {
                    monitor.ReportError(String.Format("Cannot execute '{0} {1}'.", exe, args), 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} {1}'.", exe, args), null);
            }
            finally {
                operationMonitor.Dispose();
                console.Dispose();
            }
        }
Exemplo n.º 14
0
 public string GetDefaultOutputFileName(HaxeProjectConfiguration configuration)
 {
     return Path.GetFileNameWithoutExtension(MainSource) + "." + TargetFormat.ToString().ToLower();
 }