Exemplo n.º 1
0
        private void ParseHXML(string[] raw)
        {
            if (raw != null && (raw.Length == 0 || raw[0] == null))
            {
                raw = null;
            }
            rawHXML = raw;

            List <string> libs       = new List <string>();
            List <string> defs       = new List <string>();
            List <string> cps        = new List <string>();
            List <string> add        = new List <string>();
            string        target     = PlatformData.JAVASCRIPT_PLATFORM;
            string        haxeTarget = "js";
            string        output     = "";

            if (raw != null)
            {
                ParseHxmlEntries(raw, defs, cps, libs, add, ref target, ref haxeTarget, ref output);
            }

            CompilerOptions.Directives = defs.ToArray();
            CompilerOptions.Libraries  = libs.ToArray();
            CompilerOptions.Additional = add.ToArray();
            if (cps.Count == 0)
            {
                cps.Add(".");
            }
            Classpaths.Clear();
            Classpaths.AddRange(cps);

            if (MovieOptions.HasPlatformSupport)
            {
                var platform = MovieOptions.PlatformSupport;
                MovieOptions.TargetBuildTypes = platform.Targets;

                if (platform.Name == "hxml" && string.IsNullOrEmpty(TargetBuild))
                {
                    TargetBuild = haxeTarget ?? "";
                }
            }
            else
            {
                MovieOptions.TargetBuildTypes = null;
            }

            if (MovieOptions.TargetBuildTypes == null)
            {
                OutputPath            = output;
                OutputType            = OutputType.Application;
                MovieOptions.Platform = target;
            }
        }
Exemplo n.º 2
0
        private void ParseHXML(string[] raw)
        {
            if (raw != null && (raw.Length == 0 || raw[0] == null))
            {
                raw = null;
            }
            rawHXML = raw;

            Regex         reHxOp = new Regex("-([a-z0-9-]+)\\s*(.*)", RegexOptions.IgnoreCase);
            List <string> libs   = new List <string>();
            List <string> defs   = new List <string>();
            List <string> cps    = new List <string>();
            List <string> add    = new List <string>();
            string        target = HaxeMovieOptions.FLASHPLAYER_PLATFORM;
            string        output = "";

            if (raw != null)
            {
                foreach (string line in raw)
                {
                    if (line == null)
                    {
                        break;
                    }
                    Match m = reHxOp.Match(line.Trim());
                    if (m.Success)
                    {
                        string op    = m.Groups[1].Value;
                        string value = m.Groups[2].Value.Trim();
                        switch (op)
                        {
                        case "D": defs.Add(value); break;

                        case "cp": cps.Add(CleanPath(value)); break;

                        case "lib": libs.Add(value); break;

                        case "main": CompilerOptions.MainClass = value; break;

                        case "swf":
                        case "swf9": target = HaxeMovieOptions.FLASHPLAYER_PLATFORM; output = value; break;

                        case "swf-header":
                            var header = value.Split(':');
                            int.TryParse(header[0], out MovieOptions.Width);
                            int.TryParse(header[1], out MovieOptions.Height);
                            int.TryParse(header[2], out MovieOptions.Fps);
                            MovieOptions.Background = header[3];
                            break;

                        case "cpp": target = HaxeMovieOptions.CPP_PLATFORM; output = value; break;

                        case "js": target = HaxeMovieOptions.JAVASCRIPT_PLATFORM; output = value; break;

                        case "php": target = HaxeMovieOptions.PHP_PLATFORM; output = value; break;

                        case "neko": target = HaxeMovieOptions.NEKO_PLATFORM; output = value; break;

                        case "cs": target = HaxeMovieOptions.CSHARP_PLATFORM; output = value; break;

                        case "java": target = HaxeMovieOptions.JAVA_PLATFORM; output = value; break;

                        case "--connect": break; // ignore

                        default: add.Add(line); break;
                        }
                    }
                }
            }
            CompilerOptions.Directives = defs.ToArray();
            CompilerOptions.Libraries  = libs.ToArray();
            CompilerOptions.Additional = add.ToArray();
            if (cps.Count == 0)
            {
                cps.Add(".");
            }
            Classpaths.Clear();
            Classpaths.AddRange(cps);

            if (MovieOptions.Platform == HaxeMovieOptions.NME_PLATFORM)
            {
                MovieOptions.TargetBuildTypes = PlatformData.NME_TARGETS;
                if (TestMovieBehavior == TestMovieBehavior.Unknown)
                {
                    TestMovieBehavior = TestMovieBehavior.Custom;
                }
            }
            else if (MovieOptions.TargetBuildTypes == null)
            {
                OutputPath            = output;
                OutputType            = OutputType.Application;
                MovieOptions.Platform = target;
            }
        }
Exemplo n.º 3
0
        private void ParseHXML(string[] raw)
        {
            if (raw != null && (raw.Length == 0 || raw[0] == null))
            {
                raw = null;
            }
            rawHXML = raw;

            Regex         reHxOp     = new Regex("-([a-z0-9-]+)\\s*(.*)", RegexOptions.IgnoreCase);
            List <string> libs       = new List <string>();
            List <string> defs       = new List <string>();
            List <string> cps        = new List <string>();
            List <string> add        = new List <string>();
            string        target     = PlatformData.JAVASCRIPT_PLATFORM;
            string        haxeTarget = "js";
            string        output     = "";

            if (raw != null)
            {
                foreach (string line in raw)
                {
                    if (line == null)
                    {
                        break;
                    }
                    Match m = reHxOp.Match(line.Trim());
                    if (m.Success)
                    {
                        string op = m.Groups[1].Value;
                        if (op == "-next")
                        {
                            break; // ignore the rest
                        }
                        string value = m.Groups[2].Value.Trim();
                        switch (op)
                        {
                        case "D": defs.Add(value); break;

                        case "cp": cps.Add(CleanPath(value)); break;

                        case "lib": libs.Add(value); break;

                        case "main": CompilerOptions.MainClass = value; break;

                        case "swf":
                        case "swf9":
                            target     = PlatformData.FLASHPLAYER_PLATFORM;
                            haxeTarget = "flash";
                            output     = value;
                            break;

                        case "swf-header":
                            var header = value.Split(':');
                            int.TryParse(header[0], out MovieOptions.Width);
                            int.TryParse(header[1], out MovieOptions.Height);
                            int.TryParse(header[2], out MovieOptions.Fps);
                            MovieOptions.Background = header[3];
                            break;

                        case "-connect": break; // ignore

                        case "-each": break;    // ignore

                        default:
                            // detect platform (-cpp output, -js output, ...)
                            var targetPlatform = FindPlatform(op);
                            if (targetPlatform != null)
                            {
                                target     = targetPlatform.Name;
                                haxeTarget = targetPlatform.HaxeTarget;
                                output     = value;
                            }
                            else
                            {
                                add.Add(line);
                            }
                            break;
                        }
                    }
                }
            }
            CompilerOptions.Directives = defs.ToArray();
            CompilerOptions.Libraries  = libs.ToArray();
            CompilerOptions.Additional = add.ToArray();
            if (cps.Count == 0)
            {
                cps.Add(".");
            }
            Classpaths.Clear();
            Classpaths.AddRange(cps);

            if (MovieOptions.HasPlatformSupport)
            {
                var platform = MovieOptions.PlatformSupport;
                MovieOptions.TargetBuildTypes = platform.Targets;

                if (platform.Name == "hxml" && string.IsNullOrEmpty(TargetBuild))
                {
                    TargetBuild = haxeTarget ?? "";
                }
            }
            else
            {
                MovieOptions.TargetBuildTypes = null;
            }

            if (MovieOptions.TargetBuildTypes == null)
            {
                OutputPath            = output;
                OutputType            = OutputType.Application;
                MovieOptions.Platform = target;
            }
        }