Beispiel #1
0
        private static bool AddWhiteListsForModules(IEnumerable <string> nativeModules, ref IEnumerable <string> blacklists, string moduleStrippingInformationFolder, BuildReport buildReport)
        {
            StrippingInfo buildReportData = StrippingInfo.GetBuildReportData(buildReport);
            bool          flag            = false;

            foreach (string current in nativeModules)
            {
                string moduleWhitelist = AssemblyStripper.GetModuleWhitelist(current, moduleStrippingInformationFolder);
                if (File.Exists(moduleWhitelist))
                {
                    if (!blacklists.Contains(moduleWhitelist))
                    {
                        blacklists = blacklists.Concat(new string[]
                        {
                            moduleWhitelist
                        });
                        flag = true;
                    }
                    List <string> dependentModules = AssemblyStripper.GetDependentModules(moduleWhitelist);
                    if (buildReportData != null)
                    {
                        foreach (string current2 in dependentModules)
                        {
                            buildReportData.RegisterDependency(current2, current);
                        }
                    }
                    flag = (flag || AssemblyStripper.AddWhiteListsForModules(dependentModules, ref blacklists, moduleStrippingInformationFolder, buildReport));
                }
            }
            return(flag);
        }
Beispiel #2
0
        private static bool AddWhiteListsForModules(IEnumerable <string> nativeModules, ref IEnumerable <string> blacklists, string moduleStrippingInformationFolder)
        {
            bool flag = false;

            foreach (string nativeModule in nativeModules)
            {
                string moduleWhitelist = AssemblyStripper.GetModuleWhitelist(nativeModule, moduleStrippingInformationFolder);
                if (File.Exists(moduleWhitelist))
                {
                    if (!blacklists.Contains <string>(moduleWhitelist))
                    {
                        blacklists = blacklists.Concat <string>((IEnumerable <string>) new string[1]
                        {
                            moduleWhitelist
                        });
                        flag = true;
                    }
                    flag = flag || AssemblyStripper.AddWhiteListsForModules((IEnumerable <string>)AssemblyStripper.GetDependentModules(moduleWhitelist), ref blacklists, moduleStrippingInformationFolder);
                }
            }
            return(flag);
        }
Beispiel #3
0
        private static void RunAssemblyStripper(string stagingAreaData, IEnumerable assemblies, string managedAssemblyFolderPath, string[] assembliesToStrip, string[] searchDirs, string monoLinkerPath, IIl2CppPlatformProvider platformProvider, RuntimeClassRegistry rcr, bool developmentBuild)
        {
            bool flag1 = rcr != null && PlayerSettings.stripEngineCode && platformProvider.supportsEngineStripping;
            IEnumerable <string> blacklists = (IEnumerable <string>)AssemblyStripper.Il2CppBlacklistPaths;

            if (rcr != null)
            {
                blacklists = blacklists.Concat <string>((IEnumerable <string>) new string[2]
                {
                    AssemblyStripper.WriteMethodsToPreserveBlackList(stagingAreaData, rcr),
                    MonoAssemblyStripping.GenerateLinkXmlToPreserveDerivedTypes(stagingAreaData, managedAssemblyFolderPath, rcr)
                });
            }
            if (!flag1)
            {
                foreach (string file in Directory.GetFiles(platformProvider.moduleStrippingInformationFolder, "*.xml"))
                {
                    blacklists = blacklists.Concat <string>((IEnumerable <string>) new string[1] {
                        file
                    });
                }
            }
            string fullPath1 = Path.GetFullPath(Path.Combine(managedAssemblyFolderPath, "tempStrip"));
            bool   flag2;

            do
            {
                flag2 = false;
                if (EditorUtility.DisplayCancelableProgressBar("Building Player", "Stripping assemblies", 0.0f))
                {
                    throw new OperationCanceledException();
                }
                string output;
                string error;
                if (!AssemblyStripper.StripAssembliesTo(assembliesToStrip, searchDirs, fullPath1, managedAssemblyFolderPath, out output, out error, monoLinkerPath, platformProvider, blacklists, developmentBuild))
                {
                    throw new Exception("Error in stripping assemblies: " + (object)assemblies + ", " + error);
                }
                string icallsListFile = Path.Combine(managedAssemblyFolderPath, "ICallSummary.txt");
                Runner.RunManagedProgram(Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Tools/InternalCallRegistrationWriter/InternalCallRegistrationWriter.exe"), string.Format("-assembly=\"{0}\" -output=\"{1}\" -summary=\"{2}\"", (object)Path.Combine(fullPath1, "UnityEngine.dll"), (object)Path.Combine(managedAssemblyFolderPath, "UnityICallRegistration.cpp"), (object)icallsListFile));
                if (flag1)
                {
                    HashSet <string> nativeClasses;
                    HashSet <string> nativeModules;
                    CodeStrippingUtils.GenerateDependencies(fullPath1, icallsListFile, rcr, out nativeClasses, out nativeModules);
                    flag2 = AssemblyStripper.AddWhiteListsForModules((IEnumerable <string>)nativeModules, ref blacklists, platformProvider.moduleStrippingInformationFolder);
                }
            }while (flag2);
            string fullPath2 = Path.GetFullPath(Path.Combine(managedAssemblyFolderPath, "tempUnstripped"));

            Directory.CreateDirectory(fullPath2);
            foreach (string file in Directory.GetFiles(managedAssemblyFolderPath))
            {
                string extension = Path.GetExtension(file);
                if (string.Equals(extension, ".dll", StringComparison.InvariantCultureIgnoreCase) || string.Equals(extension, ".mdb", StringComparison.InvariantCultureIgnoreCase))
                {
                    File.Move(file, Path.Combine(fullPath2, Path.GetFileName(file)));
                }
            }
            foreach (string file in Directory.GetFiles(fullPath1))
            {
                File.Move(file, Path.Combine(managedAssemblyFolderPath, Path.GetFileName(file)));
            }
            Directory.Delete(fullPath1);
        }
        private static void RunAssemblyStripper(string stagingAreaData, IEnumerable assemblies, string managedAssemblyFolderPath, string[] assembliesToStrip, string[] searchDirs, string monoLinkerPath, IIl2CppPlatformProvider platformProvider, RuntimeClassRegistry rcr)
        {
            bool flag = rcr != null && PlayerSettings.stripEngineCode && platformProvider.supportsEngineStripping;
            IEnumerable <string> enumerable = AssemblyStripper.Il2CppBlacklistPaths;

            if (rcr != null)
            {
                enumerable = enumerable.Concat(new string[]
                {
                    AssemblyStripper.WriteMethodsToPreserveBlackList(stagingAreaData, rcr),
                    MonoAssemblyStripping.GenerateLinkXmlToPreserveDerivedTypes(stagingAreaData, managedAssemblyFolderPath, rcr)
                });
            }
            BuildTargetGroup buildTargetGroup = BuildPipeline.GetBuildTargetGroup(platformProvider.target);

            if (PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup) == ApiCompatibilityLevel.NET_4_6)
            {
                string path = Path.Combine(platformProvider.il2CppFolder, "LinkerDescriptors");
                enumerable = enumerable.Concat(Directory.GetFiles(path, "*45.xml"));
            }
            if (!flag)
            {
                string[] files = Directory.GetFiles(platformProvider.moduleStrippingInformationFolder, "*.xml");
                for (int i = 0; i < files.Length; i++)
                {
                    string text = files[i];
                    enumerable = enumerable.Concat(new string[]
                    {
                        text
                    });
                }
            }
            string fullPath = Path.GetFullPath(Path.Combine(managedAssemblyFolderPath, "tempStrip"));
            string text3;

            while (true)
            {
                bool flag2 = false;
                if (EditorUtility.DisplayCancelableProgressBar("Building Player", "Stripping assemblies", 0f))
                {
                    break;
                }
                string text2;
                if (!AssemblyStripper.StripAssembliesTo(assembliesToStrip, searchDirs, fullPath, managedAssemblyFolderPath, out text2, out text3, monoLinkerPath, platformProvider, enumerable))
                {
                    goto Block_7;
                }
                if (platformProvider.supportsEngineStripping)
                {
                    string text4 = Path.Combine(managedAssemblyFolderPath, "ICallSummary.txt");
                    AssemblyStripper.GenerateInternalCallSummaryFile(text4, managedAssemblyFolderPath, fullPath);
                    if (flag)
                    {
                        HashSet <UnityType> hashSet;
                        HashSet <string>    nativeModules;
                        CodeStrippingUtils.GenerateDependencies(fullPath, text4, rcr, flag, out hashSet, out nativeModules, platformProvider);
                        flag2 = AssemblyStripper.AddWhiteListsForModules(nativeModules, ref enumerable, platformProvider.moduleStrippingInformationFolder);
                    }
                }
                if (!flag2)
                {
                    goto Block_10;
                }
            }
            throw new OperationCanceledException();
Block_7:
            throw new Exception(string.Concat(new object[]
            {
                "Error in stripping assemblies: ",
                assemblies,
                ", ",
                text3
            }));
Block_10:
            string fullPath2 = Path.GetFullPath(Path.Combine(managedAssemblyFolderPath, "tempUnstripped"));

            Directory.CreateDirectory(fullPath2);
            string[] files2 = Directory.GetFiles(managedAssemblyFolderPath);
            for (int j = 0; j < files2.Length; j++)
            {
                string text5     = files2[j];
                string extension = Path.GetExtension(text5);
                if (string.Equals(extension, ".dll", StringComparison.InvariantCultureIgnoreCase) || string.Equals(extension, ".winmd", StringComparison.InvariantCultureIgnoreCase) || string.Equals(extension, ".mdb", StringComparison.InvariantCultureIgnoreCase) || string.Equals(extension, ".pdb", StringComparison.InvariantCultureIgnoreCase))
                {
                    File.Move(text5, Path.Combine(fullPath2, Path.GetFileName(text5)));
                }
            }
            string[] files3 = Directory.GetFiles(fullPath);
            for (int k = 0; k < files3.Length; k++)
            {
                string text6 = files3[k];
                File.Move(text6, Path.Combine(managedAssemblyFolderPath, Path.GetFileName(text6)));
            }
            Directory.Delete(fullPath);
        }
        private static void RunAssemblyStripper(string stagingAreaData, IEnumerable assemblies, string managedAssemblyFolderPath, string[] assembliesToStrip, string[] searchDirs, string monoLinkerPath, IIl2CppPlatformProvider platformProvider, RuntimeClassRegistry rcr, bool developmentBuild)
        {
            bool flag = rcr != null && PlayerSettings.stripEngineCode && platformProvider.supportsEngineStripping;
            IEnumerable <string> enumerable = AssemblyStripper.Il2CppBlacklistPaths;

            if (rcr != null)
            {
                enumerable = enumerable.Concat(new string[]
                {
                    AssemblyStripper.WriteMethodsToPreserveBlackList(stagingAreaData, rcr)
                });
            }
            if (!flag)
            {
                string[] files = Directory.GetFiles(platformProvider.moduleStrippingInformationFolder, "*.xml");
                for (int i = 0; i < files.Length; i++)
                {
                    string text = files[i];
                    enumerable = enumerable.Concat(new string[]
                    {
                        text
                    });
                }
            }
            string fullPath = Path.GetFullPath(Path.Combine(managedAssemblyFolderPath, "tempStrip"));
            string text3;

            while (true)
            {
                bool flag2 = false;
                if (EditorUtility.DisplayCancelableProgressBar("Building Player", "Stripping assemblies", 0f))
                {
                    break;
                }
                string text2;
                if (!AssemblyStripper.StripAssembliesTo(assembliesToStrip, searchDirs, fullPath, managedAssemblyFolderPath, out text2, out text3, monoLinkerPath, platformProvider, enumerable, developmentBuild))
                {
                    goto Block_6;
                }
                string text4 = Path.Combine(managedAssemblyFolderPath, "ICallSummary.txt");
                string exe   = Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Tools/InternalCallRegistrationWriter/InternalCallRegistrationWriter.exe");
                string args  = string.Format("-assembly=\"{0}\" -output=\"{1}\" -summary=\"{2}\"", Path.Combine(fullPath, "UnityEngine.dll"), Path.Combine(managedAssemblyFolderPath, "UnityICallRegistration.cpp"), text4);
                Runner.RunManagedProgram(exe, args);
                if (flag)
                {
                    HashSet <string> hashSet;
                    HashSet <string> nativeModules;
                    CodeStrippingUtils.GenerateDependencies(fullPath, text4, rcr, out hashSet, out nativeModules);
                    flag2 = AssemblyStripper.AddWhiteListsForModules(nativeModules, ref enumerable, platformProvider.moduleStrippingInformationFolder);
                }
                if (!flag2)
                {
                    goto Block_8;
                }
            }
            throw new OperationCanceledException();
Block_6:
            throw new Exception(string.Concat(new object[]
            {
                "Error in stripping assemblies: ",
                assemblies,
                ", ",
                text3
            }));
Block_8:
            string fullPath2 = Path.GetFullPath(Path.Combine(managedAssemblyFolderPath, "tempUnstripped"));

            Directory.CreateDirectory(fullPath2);
            string[] files2 = Directory.GetFiles(managedAssemblyFolderPath);
            for (int j = 0; j < files2.Length; j++)
            {
                string text5     = files2[j];
                string extension = Path.GetExtension(text5);
                if (string.Equals(extension, ".dll", StringComparison.InvariantCultureIgnoreCase) || string.Equals(extension, ".mdb", StringComparison.InvariantCultureIgnoreCase))
                {
                    File.Move(text5, Path.Combine(fullPath2, Path.GetFileName(text5)));
                }
            }
            string[] files3 = Directory.GetFiles(fullPath);
            for (int k = 0; k < files3.Length; k++)
            {
                string text6 = files3[k];
                File.Move(text6, Path.Combine(managedAssemblyFolderPath, Path.GetFileName(text6)));
            }
            Directory.Delete(fullPath);
        }