示例#1
0
        /// <summary>
        /// Classpathes & classes cache initialisation
        /// </summary>
        public override void BuildClassPath()
        {
            ReleaseClasspath();
            started = true;
            if (as3settings == null)
            {
                throw new Exception("BuildClassPath() must be overridden");
            }
            if (contextSetup == null)
            {
                contextSetup          = new ContextSetupInfos();
                contextSetup.Lang     = settings.LanguageId;
                contextSetup.Platform = "Flash Player";
                contextSetup.Version  = as3settings.DefaultFlashVersion;
            }

            // external version definition
            platform     = contextSetup.Platform;
            majorVersion = 10;
            minorVersion = 0;
            ParseVersion(contextSetup.Version, ref majorVersion, ref minorVersion);
            hasAIRSupport    = platform == "AIR" || platform == "AIR Mobile";
            hasMobileSupport = platform == "AIR Mobile";

            string cpCheck = contextSetup.Classpath != null?
                             String.Join(";", contextSetup.Classpath).Replace('\\', '/') : "";

            // check if CP contains a custom playerglobal.swc
            bool hasCustomAPI = re_customAPI.IsMatch(cpCheck);

            //
            // Class pathes
            //
            classPath = new List <PathModel>();
            MxmlFilter.ClearCatalogs();
            MxmlFilter.AddProjectManifests();

            // SDK
            string compiler = PluginBase.CurrentProject != null
                ? PluginBase.CurrentProject.CurrentSDK
                : as3settings.GetDefaultSDK().Path;

            char S = Path.DirectorySeparatorChar;

            if (compiler == null)
            {
                compiler = Path.Combine(PathHelper.ToolDir, "flexlibs");
            }
            string        frameworks     = compiler + S + "frameworks";
            string        sdkLibs        = frameworks + S + "libs";
            string        sdkLocales     = frameworks + S + "locale" + S + PluginBase.MainForm.Settings.LocaleVersion;
            string        fallbackLibs   = PathHelper.ResolvePath(PathHelper.ToolDir + S + "flexlibs" + S + "frameworks" + S + "libs");
            string        fallbackLocale = PathHelper.ResolvePath(PathHelper.ToolDir + S + "flexlibs" + S + "frameworks" + S + "locale" + S + "en_US");
            List <string> addLibs        = new List <string>();
            List <string> addLocales     = new List <string>();

            if (!Directory.Exists(sdkLibs) && !sdkLibs.StartsWith("$")) // fallback
            {
                sdkLibs = PathHelper.ResolvePath(PathHelper.ToolDir + S + "flexlibs" + S + "frameworks" + S + "libs" + S + "player");
            }

            if (majorVersion > 0 && !String.IsNullOrEmpty(sdkLibs) && Directory.Exists(sdkLibs))
            {
                // core API SWC
                if (!hasCustomAPI)
                {
                    if (hasAIRSupport)
                    {
                        addLibs.Add("air" + S + "airglobal.swc");
                        addLibs.Add("air" + S + "aircore.swc");
                        addLibs.Add("air" + S + "applicationupdater.swc");
                    }
                    else
                    {
                        bool   swcPresent   = false;
                        string playerglobal = MatchPlayerGlobalExact(majorVersion, minorVersion, sdkLibs);
                        if (playerglobal != null)
                        {
                            swcPresent = true;
                        }
                        else
                        {
                            playerglobal = MatchPlayerGlobalExact(majorVersion, minorVersion, fallbackLibs);
                        }
                        if (playerglobal == null)
                        {
                            playerglobal = MatchPlayerGlobalAny(ref majorVersion, ref minorVersion, fallbackLibs);
                        }
                        if (playerglobal == null)
                        {
                            playerglobal = MatchPlayerGlobalAny(ref majorVersion, ref minorVersion, sdkLibs);
                        }
                        if (playerglobal != null)
                        {
                            // add missing SWC in new SDKs
                            if (!swcPresent && sdkLibs.IndexOf(S + "flexlibs") < 0 && Directory.Exists(compiler))
                            {
                                string swcDir = sdkLibs + S + "player" + S;
                                if (!Directory.Exists(swcDir + "9") && !Directory.Exists(swcDir + "10"))
                                {
                                    swcDir += majorVersion + "." + minorVersion;
                                }
                                else
                                {
                                    swcDir += majorVersion;
                                }
                                try
                                {
                                    if (!File.Exists(swcDir + S + "playerglobal.swc"))
                                    {
                                        Directory.CreateDirectory(swcDir);
                                        File.Copy(playerglobal, swcDir + S + "playerglobal.swc");
                                        File.WriteAllText(swcDir + S + "FlashDevelopNotice.txt",
                                                          "This 'playerglobal.swc' was copied here automatically by FlashDevelop from:\r\n" + playerglobal);
                                    }
                                    playerglobal = swcDir + S + "playerglobal.swc";
                                }
                                catch { }
                            }
                            addLibs.Add(playerglobal);
                        }
                    }
                }
                addLocales.Add("playerglobal_rb.swc");

                // framework SWCs
                string as3Fmk = PathHelper.ResolvePath("Library" + S + "AS3" + S + "frameworks");

                // Flex core - ie. (Bitmap|Font|ByteArray|...)Asset / Flex(Sprite|MobieClip|Loader...)
                addLibs.Add("flex.swc");
                addLibs.Add("core.swc");

                // Flex framework
                if (cpCheck.IndexOf("Library/AS3/frameworks/Flex", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    addLibs.Add("framework.swc");
                    addLibs.Add("mx/mx.swc");
                    addLibs.Add("rpc.swc");
                    addLibs.Add("datavisualization.swc");
                    addLibs.Add("flash-integration.swc");
                    addLocales.Add("framework_rb.swc");
                    addLocales.Add("mx_rb.swc");
                    addLocales.Add("rpc_rb.swc");
                    addLocales.Add("datavisualization_rb.swc");
                    addLocales.Add("flash-integration_rb.swc");

                    if (hasAIRSupport)
                    {
                        addLibs.Add("air" + S + "airframework.swc");
                        addLocales.Add("airframework_rb.swc");
                    }

                    if (cpCheck.IndexOf("Library/AS3/frameworks/Flex4", StringComparison.OrdinalIgnoreCase) >= 0)
                    {
                        addLibs.Add("spark.swc");
                        addLibs.Add("spark_dmv.swc");
                        addLibs.Add("sparkskins.swc");
                        //addLibs.Add("textLayout.swc");
                        addLibs.Add("osmf.swc");
                        addLocales.Add("spark_rb.swc");
                        //addLocales.Add("textLayout_rb.swc");
                        addLocales.Add("osmf_rb.swc");

                        if (hasAIRSupport)
                        {
                            addLibs.Add("air" + S + "airspark.swc");
                            addLocales.Add("airspark_rb.swc");

                            if (hasMobileSupport)
                            {
                                addLibs.Add("mobile" + S + "mobilecomponents.swc");
                                addLocales.Add("mobilecomponents_rb.swc");
                            }
                        }

                        MxmlFilter.AddManifest("http://ns.adobe.com/mxml/2009", as3Fmk + S + "Flex4" + S + "manifest.xml");
                    }
                    else
                    {
                        MxmlFilter.AddManifest(MxmlFilter.OLD_MX, as3Fmk + S + "Flex3" + S + "manifest.xml");
                    }
                }
            }

            foreach (string file in addLocales)
            {
                string swcItem = sdkLocales + S + file;
                if (!File.Exists(swcItem))
                {
                    swcItem = fallbackLocale + S + file;
                }
                AddPath(swcItem);
            }
            foreach (string file in addLibs)
            {
                if (File.Exists(file))
                {
                    AddPath(file);
                }
                else
                {
                    AddPath(sdkLibs + S + file);
                }
            }

            // intrinsics (deprecated, excepted for FP10 Vector.<T>)
            string fp9cp = as3settings.AS3ClassPath + S + "FP9";

            AddPath(PathHelper.ResolvePath(fp9cp));
            if (majorVersion > 9)
            {
                string fp10cp = as3settings.AS3ClassPath + S + "FP" + majorVersion;
                AddPath(PathHelper.ResolvePath(fp10cp));
                string fp101cp = as3settings.AS3ClassPath + S + "FP" + majorVersion + "." + minorVersion;
                AddPath(PathHelper.ResolvePath(fp101cp));
            }

            // add external pathes
            List <PathModel> initCP = classPath;

            classPath = new List <PathModel>();
            if (contextSetup.Classpath != null)
            {
                foreach (string cpath in contextSetup.Classpath)
                {
                    AddPath(cpath.Trim());
                }
            }

            // add library
            AddPath(PathHelper.LibraryDir + S + "AS3" + S + "classes");
            // add user pathes from settings
            if (settings.UserClasspath != null && settings.UserClasspath.Length > 0)
            {
                foreach (string cpath in settings.UserClasspath)
                {
                    AddPath(cpath.Trim());
                }
            }

            // add initial pathes
            foreach (PathModel mpath in initCP)
            {
                AddPath(mpath);
            }

            // parse top-level elements
            InitTopLevelElements();
            if (cFile != null)
            {
                UpdateTopLevelElements();
            }

            // add current temporaty path
            if (temporaryPath != null)
            {
                string tempPath = temporaryPath;
                temporaryPath = null;
                SetTemporaryPath(tempPath);
            }
            FinalizeClasspath();
        }
示例#2
0
        /// <summary>
        /// Classpathes & classes cache initialisation
        /// </summary>
        public override void BuildClassPath()
        {
            ReleaseClasspath();
            started = true;
            if (as3settings == null)
            {
                throw new Exception("BuildClassPath() must be overridden");
            }

            // external version definition
            // expected from project manager: "9;path;path..."
            flashVersion = as3settings.DefaultFlashVersion;
            string exPath = externalClassPath ?? "";

            if (exPath.Length > 0)
            {
                try
                {
                    int p = exPath.IndexOf(';');
                    flashVersion = Convert.ToInt16(exPath.Substring(0, p));
                    exPath       = exPath.Substring(p + 1).Trim();
                }
                catch { }
            }

            // special features
            if (exPath.Length > 0 && exPath.StartsWith("AIR;"))
            {
                exPath        = exPath.Substring(4);
                hasAIRSupport = true;
            }
            else
            {
                hasAIRSupport = false;
            }

            //
            // Class pathes
            //
            classPath = new List <PathModel>();
            MxmlFilter.ClearCatalogs();
            MxmlFilter.AddProjectManifests();

            // SDK
            string compiler = MainForm.ProcessArgString("$(CompilerPath)");

            if (compiler == "$(CompilerPath)")
            {
                compiler = Regex.Replace(as3settings.FlexSDK ?? "", @"[\\/]bin[\\/]?$", "");
            }
            ;
            char          S               = Path.DirectorySeparatorChar;
            string        frameworks      = compiler + S + "frameworks";
            string        sdkLibs         = frameworks + S + "libs";
            string        sdkLocales      = frameworks + S + "locale" + S + PluginBase.MainForm.Settings.LocaleVersion;
            string        fallbackLocales = PathHelper.ResolvePath(PathHelper.LibraryDir + S + "AS3" + S + "intrinsic" + S + "locale" + S + "en_US");
            List <string> addLibs         = new List <string>();
            List <string> addLocales      = new List <string>();

            if (!Directory.Exists(sdkLibs) && !sdkLibs.StartsWith("$")) // fallback
            {
                sdkLibs = PathHelper.ResolvePath(PathHelper.LibraryDir + S + "AS3" + S + "intrinsic" + S + "libs");
            }

            if (!String.IsNullOrEmpty(sdkLibs) && Directory.Exists(sdkLibs))
            {
                string libPlayer = sdkLibs + S + "player";
                if (hasAIRSupport)
                {
                    addLibs.Add("air" + S + "airglobal.swc");
                    addLibs.Add("air" + S + "aircore.swc");
                    addLibs.Add("air" + S + "applicationupdater.swc");
                }
                else
                {
                    if (flashVersion < 10 && Directory.Exists(libPlayer + S + "9"))
                    {
                        addLibs.Add("player" + S + "9" + S + "playerglobal.swc");
                    }
                    else if (flashVersion > 10 && Directory.Exists(libPlayer + S + "10.1"))
                    {
                        addLibs.Add("player" + S + "10.1" + S + "playerglobal.swc");
                    }
                    else if (Directory.Exists(libPlayer + S + "10.0"))
                    {
                        addLibs.Add("player" + S + "10.0" + S + "playerglobal.swc");
                    }
                    else if (Directory.Exists(libPlayer + S + "10"))
                    {
                        addLibs.Add("player" + S + "10" + S + "playerglobal.swc");
                    }
                    string p = libPlayer + S + "10";
                }
                addLocales.Add("playerglobal_rb.swc");

                string test   = exPath.Replace('\\', '/');
                string as3Fmk = PathHelper.ResolvePath("Library" + S + "AS3" + S + "frameworks");

                if (test.IndexOf("Library/AS3/frameworks/Flex", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    addLibs.Add("framework.swc");
                    addLibs.Add("mx/mx.swc");
                    addLibs.Add("rpc.swc");
                    addLibs.Add("datavisualization.swc");
                    addLibs.Add("flash-integration.swc");
                    addLocales.Add("framework_rb.swc");
                    addLocales.Add("mx_rb.swc");
                    addLocales.Add("rpc_rb.swc");
                    addLocales.Add("datavisualization_rb.swc");
                    addLocales.Add("flash-integration_rb.swc");
                    if (hasAIRSupport)
                    {
                        addLibs.Add("air" + S + "airframework.swc");
                        addLocales.Add("airframework_rb.swc");
                    }

                    if (test.IndexOf("Library/AS3/frameworks/Flex4", StringComparison.OrdinalIgnoreCase) >= 0)
                    {
                        addLibs.Add("spark.swc");
                        addLibs.Add("sparkskins.swc");
                        addLibs.Add("textLayout.swc");
                        addLibs.Add("osmf.swc");
                        addLocales.Add("spark_rb.swc");
                        addLocales.Add("textLayout_rb.swc");
                        addLocales.Add("osmf_rb.swc");
                        if (hasAIRSupport)
                        {
                            addLibs.Add("air" + S + "airspark.swc");
                            addLocales.Add("airspark_rb.swc");
                        }

                        MxmlFilter.AddManifest("http://ns.adobe.com/mxml/2009", as3Fmk + S + "Flex4" + S + "manifest.xml");
                    }
                    else
                    {
                        MxmlFilter.AddManifest(MxmlFilter.OLD_MX, as3Fmk + S + "Flex3" + S + "manifest.xml");
                    }
                }
            }

            foreach (string file in addLocales)
            {
                string swcItem = sdkLocales + S + file;
                if (!File.Exists(swcItem))
                {
                    swcItem = fallbackLocales + S + file;
                }
                AddPath(swcItem);
            }
            foreach (string file in addLibs)
            {
                AddPath(sdkLibs + S + file);
            }

            // intrinsics (deprecated, excepted for FP10 Vector.<T>)
            string fp9cp = as3settings.AS3ClassPath + S + "FP9";

            AddPath(PathHelper.ResolvePath(fp9cp));
            if (flashVersion > 9)
            {
                string fp10cp = as3settings.AS3ClassPath + S + "FP10";
                AddPath(PathHelper.ResolvePath(fp10cp));
            }
            else if (flashVersion > 10)
            {
                string fp101cp = as3settings.AS3ClassPath + S + "FP10.1";
                AddPath(PathHelper.ResolvePath(fp101cp));
            }

            // add external pathes
            List <PathModel> initCP = classPath;

            classPath = new List <PathModel>();
            string[] cpathes;
            if (exPath.Length > 0)
            {
                cpathes = exPath.Split(';');
                foreach (string cpath in cpathes)
                {
                    AddPath(cpath.Trim());
                }
            }

            // add library
            AddPath(PathHelper.LibraryDir + S + "AS3" + S + "classes");
            // add user pathes from settings
            if (settings.UserClasspath != null && settings.UserClasspath.Length > 0)
            {
                foreach (string cpath in settings.UserClasspath)
                {
                    AddPath(cpath.Trim());
                }
            }

            // add initial pathes
            foreach (PathModel mpath in initCP)
            {
                AddPath(mpath);
            }

            // parse top-level elements
            InitTopLevelElements();
            if (cFile != null)
            {
                UpdateTopLevelElements();
            }

            // add current temporaty path
            if (temporaryPath != null)
            {
                string tempPath = temporaryPath;
                temporaryPath = null;
                SetTemporaryPath(tempPath);
            }
            FinalizeClasspath();
        }