Пример #1
0
        private void AddTargetPlayer(MxmlcOptions options)
        {
            int majorVersion = project.MovieOptions.MajorVersion;
            int minorVersion = project.MovieOptions.MinorVersion;

            if (project.MovieOptions.Platform == AS3MovieOptions.AIR_PLATFORM ||
                project.MovieOptions.Platform == AS3MovieOptions.AIR_MOBILE_PLATFORM)
            {
                AS3Project.GuessFlashPlayerForAIR(ref majorVersion, ref minorVersion);
            }

            string version;

            if (options.MinorVersion.Length > 0)
            {
                version = majorVersion + "." + options.MinorVersion;
            }
            else
            {
                version = majorVersion + "." + minorVersion;
            }

            WriteElementString("target-player", version);
        }
Пример #2
0
        public string[] BuildHXML(string[] paths, string outfile, bool release)
        {
            List <String> pr = new List <String>();

            if (rawHXML != null)
            {
                pr.AddRange(rawHXML);
            }
            else
            {
                // 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)
                    {
                        AS3Project.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.Add("-debug");
                if (IsFlashOutput && MovieOptions.DebuggerSupported && CompilerOptions.EnableDebug)
                {
                    pr.Add("--no-inline");
                    pr.Add("-D fdb");
                }
            }
            return(pr.ToArray());
        }
Пример #3
0
        public void UpdateASCompletion(IMainForm mainForm, Project project)
        {
            List <string> classPaths   = new List <string>();
            List <string> hiddenPaths  = new List <string>();
            int           majorVersion = 0;
            int           minorVersion = 0;
            string        platform     = "";

            if (project != null)
            {
                BuildActions.GetCompilerPath(project); // refresh project's SDK
                project.UpdateVars(true);

                // platform/version
                platform     = project.MovieOptions.Platform;
                majorVersion = project.MovieOptions.MajorVersion;
                minorVersion = project.MovieOptions.MinorVersion;
                if (project.MovieOptions.Platform == AS3MovieOptions.AIR_PLATFORM ||
                    project.MovieOptions.Platform == AS3MovieOptions.AIR_MOBILE_PLATFORM)
                {
                    AS3Project.GuessFlashPlayerForAIR(ref majorVersion, ref minorVersion);
                }

                // add project classpaths
                foreach (string cp in project.AbsoluteClasspaths)
                {
                    if (Directory.Exists(cp))
                    {
                        classPaths.Add(cp);
                    }
                }

                // add AS3 libraries
                string absPath;
                if (project is AS3Project)
                {
                    MxmlcOptions options = (project as AS3Project).CompilerOptions;
                    foreach (string relPath in options.IntrinsicPaths)
                    {
                        absPath = PathHelper.ResolvePath(relPath);
                        if (absPath == null)
                        {
                            absPath = project.GetAbsolutePath(relPath);
                        }
                        if (absPath == null)
                        {
                            continue;
                        }
                        if (Directory.Exists(absPath))
                        {
                            classPaths.Add(absPath);
                        }
                    }
                    foreach (string relPath in options.LibraryPaths)
                    {
                        absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null)
                        {
                            continue;
                        }
                        if (File.Exists(absPath))
                        {
                            classPaths.Add(absPath);
                        }
                        else if (Directory.Exists(absPath))
                        {
                            string[] libs = Directory.GetFiles(absPath, "*.swc");
                            foreach (string lib in libs)
                            {
                                classPaths.Add(lib);
                            }
                        }
                    }
                    foreach (string relPath in options.IncludeLibraries)
                    {
                        absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null)
                        {
                            continue;
                        }
                        if (Directory.Exists(absPath) || File.Exists(absPath))
                        {
                            classPaths.Add(absPath);
                        }
                    }
                    foreach (string relPath in options.ExternalLibraryPaths)
                    {
                        absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null)
                        {
                            continue;
                        }
                        if (Directory.Exists(absPath) || File.Exists(absPath))
                        {
                            classPaths.Add(absPath);
                        }
                    }
                    foreach (string relPath in options.RSLPaths)
                    {
                        string[] parts = relPath.Split(',');
                        if (parts.Length < 2)
                        {
                            continue;
                        }
                        absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null)
                        {
                            continue;
                        }
                        if (File.Exists(absPath))
                        {
                            classPaths.Add(absPath);
                        }
                    }
                }

                string dir = project.Directory;
                foreach (string hidPath in project.HiddenPaths)
                {
                    absPath = Path.Combine(dir, hidPath);
                    foreach (string cp in classPaths)
                    {
                        if (absPath.StartsWith(cp))
                        {
                            hiddenPaths.Add(absPath);
                            break;
                        }
                    }
                }
            }

            DataEvent de;
            Hashtable info = new Hashtable();

            // release old classpath
            if (currentLang != null && project == null)
            {
                info["lang"]        = currentLang;
                info["platform"]    = "";
                info["targetBuild"] = "";
                info["version"]     = "0.0";
                info["classpath"]   = null;
                info["hidden"]      = null;

                de = new DataEvent(EventType.Command, "ASCompletion.ClassPath", info);
                EventManager.DispatchEvent(this, de);
            }

            // set new classpath
            if (project != null)
            {
                currentLang = project.Language;

                info["platform"]    = platform;
                info["version"]     = majorVersion + "." + minorVersion;
                info["targetBuild"] = project.TargetBuild;
                info["lang"]        = currentLang;
                info["classpath"]   = classPaths.ToArray();
                info["hidden"]      = hiddenPaths.ToArray();

                de = new DataEvent(EventType.Command, "ASCompletion.ClassPath", info);
                EventManager.DispatchEvent(this, de);

                project.AdditionalPaths = info.ContainsKey("additional") ? info["additional"] as string[] : null;
            }
            else
            {
                currentLang = null;
            }
        }
Пример #4
0
        public void AddOptions(bool releaseMode, bool incremental)
        {
            if (!releaseMode)
            {
                AddEq("-debug", true);
            }
            if (!asc2 && incremental)
            {
                AddEq("-incremental", true);
            }

            MxmlcOptions options = project.CompilerOptions;

            if (asc2 && options.AdvancedTelemetry)
            {
                AddEq("-advanced-telemetry", true);
                if (!string.IsNullOrEmpty(options.AdvancedTelemetryPassword))
                {
                    AddEq("-advanced-telemetry-password", options.AdvancedTelemetryPassword);
                }
            }
            if (asc2 && options.InlineFunctions)
            {
                AddEq("-inline", true);
            }
            if (options.LinkReport.Length > 0)
            {
                Add("-link-report", options.LinkReport);
            }
            if (options.LoadExterns.Length > 0)
            {
                Add("-load-externs", options.LoadExterns);
            }

            bool hasConfig  = false;
            bool hasVersion = false;

            if (options.Additional != null)
            {
                string all = String.Join(" ", options.Additional);
                if (all.IndexOf("configname") > 0)
                {
                    hasConfig = true;
                }
                if (all.IndexOf("swf-version") > 0)
                {
                    hasVersion = true;
                }
            }

            bool isAIR = false;

            if (!hasConfig)
            {
                if (project.MovieOptions.Platform == "AIR")
                {
                    isAIR = true;
                    AddEq("+configname", "air");
                }
                else if (project.MovieOptions.Platform == "AIR Mobile")
                {
                    isAIR = true;
                    AddEq("+configname", "airmobile");
                }
            }
            if ((asc2 || flex45) && !hasVersion)
            {
                string version = project.MovieOptions.Version;
                if (isAIR)
                {
                    version = AS3Project.GuessFlashPlayerForAIR(version);
                }
                string swfVersion = (project.MovieOptions as AS3MovieOptions).GetSWFVersion(version);
                if (swfVersion != null)
                {
                    AddEq("-swf-version", swfVersion);
                }
            }

            if (options.Additional != null)
            {
                Add(options.Additional, releaseMode);
            }
        }