Example #1
0
        public string[] BuildHXML(string[] paths, string outfile, bool release)
        {
            List <String> pr = new List <String>();

            if (rawHXML != null)
            {
                pr.AddRange(rawHXML);
            }
            else
            {
                // SWC libraries
                if (IsFlashOutput)
                {
                    foreach (LibraryAsset asset in LibraryAssets)
                    {
                        if (asset.IsSwc)
                        {
                            pr.Add("-swf-lib " + asset.Path);
                        }
                    }
                }

                // libraries
                foreach (string lib in CompilerOptions.Libraries)
                {
                    if (lib.Length > 0)
                    {
                        if (lib.Trim().StartsWith("-lib"))
                        {
                            pr.Add(lib);
                        }
                        else
                        {
                            pr.Add("-lib " + lib);
                        }
                    }
                }

                // class paths
                List <String> classPaths = new List <String>();
                foreach (string cp in paths)
                {
                    classPaths.Add(cp);
                }
                foreach (string cp in this.Classpaths)
                {
                    classPaths.Add(cp);
                }
                foreach (string cp in classPaths)
                {
                    String ccp = String.Join("/", cp.Split('\\'));
                    pr.Add("-cp " + Quote(ccp));
                }

                // compilation mode
                string mode = null;
                if (IsFlashOutput)
                {
                    mode = "swf";
                }
                else if (IsJavacriptOutput)
                {
                    mode = "js";
                }
                else if (IsNekoOutput)
                {
                    mode = "neko";
                }
                else if (IsPhpOutput)
                {
                    mode = "php";
                }
                else if (IsCppOutput)
                {
                    mode = "cpp";
                }
                else if (IsCSharpOutput)
                {
                    mode = "cs";
                }
                else if (IsJavaOutput)
                {
                    mode = "java";
                }
                //else throw new SystemException("Unknown mode");

                if (mode != null)
                {
                    outfile = String.Join("/", outfile.Split('\\'));
                    pr.Add("-" + mode + " " + Quote(outfile));
                }

                // nme options

                /*if (IsNmeOutput)
                 * {
                 *  pr.Add("--remap flash:nme");
                 * }*/

                // flash options
                if (IsFlashOutput)
                {
                    string htmlColor = this.MovieOptions.Background.Substring(1);

                    if (htmlColor.Length > 0)
                    {
                        htmlColor = ":" + htmlColor;
                    }

                    pr.Add("-swf-header " + string.Format("{0}:{1}:{2}{3}", MovieOptions.Width, MovieOptions.Height, MovieOptions.Fps, htmlColor));

                    if (!UsesInjection && LibraryAssets.Count > 0)
                    {
                        pr.Add("-swf-lib " + Quote(LibrarySWFPath));
                    }

                    if (CompilerOptions.FlashStrict)
                    {
                        pr.Add("--flash-strict");
                    }

                    // convert Flash version to haxe supported parameter
                    string param        = null;
                    int    majorVersion = MovieOptions.MajorVersion;
                    int    minorVersion = MovieOptions.MinorVersion;

                    if (MovieOptions.Platform == HaxeMovieOptions.AIR_PLATFORM ||
                        MovieOptions.Platform == HaxeMovieOptions.AIR_MOBILE_PLATFORM)
                    {
                        PlatformData.GuessFlashPlayerForAIR(ref majorVersion, ref minorVersion);
                    }
                    if (movieOptions.Platform == HaxeMovieOptions.NME_PLATFORM)
                    {
                        HaxeProject.GuessFlashPlayerForNME(ref majorVersion, ref minorVersion);
                    }

                    if (majorVersion >= 10)
                    {
                        if (minorVersion > 0)
                        {
                            param = majorVersion + "." + minorVersion;
                        }
                        else
                        {
                            param = "" + majorVersion;
                        }
                    }
                    else
                    {
                        param = "" + majorVersion;
                    }
                    if (param != null)
                    {
                        pr.Add("-swf-version " + param);
                    }
                }

                // defines
                foreach (string def in CompilerOptions.Directives)
                {
                    pr.Add("-D " + Quote(def));
                }

                // add project files marked as "always compile"
                foreach (string relTarget in CompileTargets)
                {
                    string absTarget = GetAbsolutePath(relTarget);
                    // guess the class name from the file name
                    foreach (string cp in classPaths)
                    {
                        if (absTarget.StartsWith(cp, StringComparison.OrdinalIgnoreCase))
                        {
                            string className = GetClassName(absTarget, cp);
                            if (CompilerOptions.MainClass != className)
                            {
                                pr.Add(className);
                            }
                        }
                    }
                }

                // add main class
                if (CompilerOptions.MainClass != null && CompilerOptions.MainClass.Length > 0)
                {
                    pr.Add("-main " + CompilerOptions.MainClass);
                }

                // extra options
                foreach (string opt in CompilerOptions.Additional)
                {
                    String p = opt.Trim();
                    if (p == "" || p[0] == '#')
                    {
                        continue;
                    }
                    char[]   space = { ' ' };
                    string[] parts = p.Split(space, 2);
                    if (parts.Length == 1)
                    {
                        pr.Add(p);
                    }
                    else
                    {
                        pr.Add(parts[0] + ' ' + Quote(parts[1]));
                    }
                }
            }

            // debug
            if (!release)
            {
                pr.Insert(0, "-debug");
                if (CurrentSDK == null || CurrentSDK.IndexOf("Motion-Twin") < 0)
                {
                    pr.Insert(1, "--each");
                }
                if (IsFlashOutput && MovieOptions.DebuggerSupported && CompilerOptions.EnableDebug)
                {
                    pr.Insert(1, "-D fdb");
                    if (CompilerOptions.NoInlineOnDebug)
                    {
                        pr.Insert(2, "--no-inline");
                    }
                }
            }
            return(pr.ToArray());
        }
Example #2
0
        public string[] BuildHXML(string[] paths, string outfile, bool release)
        {
            List <String> pr      = new List <String>();
            var           isFlash = IsFlashOutput;

            if (rawHXML != null)
            {
                pr.AddRange(rawHXML);
            }
            else
            {
                // SWC libraries
                if (isFlash)
                {
                    foreach (LibraryAsset asset in LibraryAssets)
                    {
                        if (asset.IsSwc)
                        {
                            pr.Add("-swf-lib " + asset.Path);
                        }
                    }
                }

                // libraries
                foreach (string lib in CompilerOptions.Libraries)
                {
                    if (lib.Length > 0)
                    {
                        if (lib.Trim().StartsWith("-lib", StringComparison.Ordinal))
                        {
                            pr.Add(lib);
                        }
                        else
                        {
                            pr.Add("-lib " + lib);
                        }
                    }
                }

                // class paths
                List <String> classPaths = new List <String>();
                foreach (string cp in paths)
                {
                    classPaths.Add(cp);
                }
                foreach (string cp in this.Classpaths)
                {
                    classPaths.Add(cp);
                }
                foreach (string cp in classPaths)
                {
                    String ccp = String.Join("/", cp.Split('\\'));
                    pr.Add("-cp " + Quote(ccp));
                }

                // compilation mode
                string mode = HaxeTarget;
                //throw new SystemException("Unknown mode");

                if (mode != null)
                {
                    outfile = String.Join("/", outfile.Split('\\'));
                    pr.Add("-" + mode + " " + Quote(outfile));
                }

                // flash options
                if (isFlash)
                {
                    string htmlColor = this.MovieOptions.Background.Substring(1);

                    if (htmlColor.Length > 0)
                    {
                        htmlColor = ":" + htmlColor;
                    }

                    pr.Add("-swf-header " + string.Format("{0}:{1}:{2}{3}", MovieOptions.Width, MovieOptions.Height, MovieOptions.Fps, htmlColor));

                    if (!UsesInjection && LibraryAssets.Count > 0)
                    {
                        pr.Add("-swf-lib " + Quote(LibrarySWFPath));
                    }

                    if (CompilerOptions.FlashStrict)
                    {
                        pr.Add("--flash-strict");
                    }

                    // haxe compiler uses Flash version directly
                    string version = MovieOptions.Version;
                    if (version != null)
                    {
                        pr.Add("-swf-version " + version);
                    }
                }

                // defines
                foreach (string def in CompilerOptions.Directives)
                {
                    pr.Add("-D " + Quote(def));
                }

                // add project files marked as "always compile"
                foreach (string relTarget in CompileTargets)
                {
                    string absTarget = GetAbsolutePath(relTarget);
                    // guess the class name from the file name
                    foreach (string cp in classPaths)
                    {
                        if (absTarget.StartsWith(cp, StringComparison.OrdinalIgnoreCase))
                        {
                            string className = GetClassName(absTarget, cp);
                            if (CompilerOptions.MainClass != className)
                            {
                                pr.Add(className);
                            }
                        }
                    }
                }

                // add main class
                if (!string.IsNullOrEmpty(CompilerOptions.MainClass))
                {
                    pr.Add("-main " + CompilerOptions.MainClass);
                }

                // extra options
                foreach (string opt in CompilerOptions.Additional)
                {
                    String p = opt.Trim();
                    if (p == "" || p[0] == '#')
                    {
                        continue;
                    }
                    char[]   space = { ' ' };
                    string[] parts = p.Split(space, 2);
                    if (parts.Length == 1)
                    {
                        pr.Add(p);
                    }
                    else
                    {
                        pr.Add(parts[0] + ' ' + Quote(parts[1]));
                    }
                }
            }

            // debug
            if (!release)
            {
                pr.Insert(0, "-debug");
                if (CurrentSDK == null || CurrentSDK.IndexOf("Motion-Twin", StringComparison.Ordinal) < 0) // Haxe 3+
                {
                    pr.Insert(1, "--each");
                }
                if (isFlash && EnableInteractiveDebugger && CompilerOptions.EnableDebug)
                {
                    pr.Insert(1, "-D fdb");
                    if (CompilerOptions.NoInlineOnDebug)
                    {
                        pr.Insert(2, "--no-inline");
                    }
                }
            }
            return(pr.ToArray());
        }