コード例 #1
0
        private static bool StripAssembliesTo(string[] assemblies, string[] searchDirs, string outputFolder, string workingDirectory, out string output, out string error, string linkerPath, IIl2CppPlatformProvider platformProvider, IEnumerable <string> additionalBlacklist, bool developmentBuild)
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            AssemblyStripper.\u003CStripAssembliesTo\u003Ec__AnonStorey65 assembliesToCAnonStorey65 = new AssemblyStripper.\u003CStripAssembliesTo\u003Ec__AnonStorey65();
            // ISSUE: reference to a compiler-generated field
            assembliesToCAnonStorey65.workingDirectory = workingDirectory;
            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }
            // ISSUE: reference to a compiler-generated method
            additionalBlacklist = additionalBlacklist.Select <string, string>(new Func <string, string>(assembliesToCAnonStorey65.\u003C\u003Em__D4)).Where <string>(new Func <string, bool>(File.Exists));
            IEnumerable <string> userBlacklistFiles = AssemblyStripper.GetUserBlacklistFiles();

            foreach (string str in userBlacklistFiles)
            {
                Console.WriteLine("UserBlackList: " + str);
            }
            additionalBlacklist = additionalBlacklist.Concat <string>(userBlacklistFiles);
            List <string> stringList = new List <string>()
            {
                "-out \"" + outputFolder + "\"", "-l none", "-c link", "-b " + (object)developmentBuild, "-x \"" + AssemblyStripper.GetModuleWhitelist("Core", platformProvider.moduleStrippingInformationFolder) + "\"", "-f \"" + Path.Combine(platformProvider.il2CppFolder, "LinkerDescriptors") + "\""
            };

            stringList.AddRange(additionalBlacklist.Select <string, string>((Func <string, string>)(path => "-x \"" + path + "\"")));
            stringList.AddRange(((IEnumerable <string>)searchDirs).Select <string, string>((Func <string, string>)(d => "-d \"" + d + "\"")));
            stringList.AddRange(((IEnumerable <string>)assemblies).Select <string, string>((Func <string, string>)(assembly => "-a  \"" + Path.GetFullPath(assembly) + "\"")));
            // ISSUE: reference to a compiler-generated field
            return(AssemblyStripper.RunAssemblyLinker((IEnumerable <string>)stringList, out output, out error, linkerPath, assembliesToCAnonStorey65.workingDirectory));
        }
コード例 #2
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);
        }
コード例 #3
0
        private static string WriteMethodsToPreserveBlackList(RuntimeClassRegistry rcr, BuildTarget target)
        {
            string tempFileName = Path.GetTempFileName();

            File.WriteAllText(tempFileName, AssemblyStripper.GetMethodPreserveBlacklistContents(rcr, target));
            return(tempFileName);
        }
コード例 #4
0
        public LinkXmlReader()
        {
            IEnumerator <string> enumerator = AssemblyStripper.GetUserBlacklistFiles().GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    string         current   = enumerator.Current;
                    XPathNavigator navigator = new XPathDocument(current).CreateNavigator();
                    navigator.MoveToFirstChild();
                    XPathNodeIterator iterator = navigator.SelectChildren("assembly", string.Empty);
                    while (iterator.MoveNext())
                    {
                        this._assembliesInALinkXmlFile.Add(iterator.Current.GetAttribute("fullname", string.Empty));
                    }
                }
            }
            finally
            {
                if (enumerator == null)
                {
                }
                enumerator.Dispose();
            }
        }
コード例 #5
0
        public void Run()
        {
            string cppOutputDirectoryInStagingArea = this.GetCppOutputDirectoryInStagingArea();
            string fullPath = Path.GetFullPath(Path.Combine(this.m_StagingAreaData, "Managed"));

            string[] files = Directory.GetFiles(fullPath);
            for (int i = 0; i < files.Length; i++)
            {
                string   fileName = files[i];
                FileInfo fileInfo = new FileInfo(fileName);
                fileInfo.IsReadOnly = false;
            }
            AssemblyStripper.StripAssemblies(this.m_StagingAreaData, this.m_PlatformProvider, this.m_RuntimeClassRegistry);
            FileUtil.CreateOrCleanDirectory(cppOutputDirectoryInStagingArea);
            if (this.m_ModifyOutputBeforeCompile != null)
            {
                this.m_ModifyOutputBeforeCompile(cppOutputDirectoryInStagingArea);
            }
            this.ConvertPlayerDlltoCpp(this.GetUserAssembliesToConvert(fullPath), cppOutputDirectoryInStagingArea, fullPath);
            INativeCompiler nativeCompiler = this.m_PlatformProvider.CreateNativeCompiler();

            if (nativeCompiler != null && this.m_PlatformProvider.CreateIl2CppNativeCodeBuilder() == null)
            {
                string        outFile = this.OutputFileRelativePath();
                List <string> list    = new List <string>(this.m_PlatformProvider.includePaths);
                list.Add(cppOutputDirectoryInStagingArea);
                this.m_PlatformProvider.CreateNativeCompiler().CompileDynamicLibrary(outFile, NativeCompiler.AllSourceFilesIn(cppOutputDirectoryInStagingArea), list, this.m_PlatformProvider.libraryPaths, new string[0]);
            }
        }
コード例 #6
0
        private static string WriteMethodsToPreserveBlackList(string stagingAreaData, RuntimeClassRegistry rcr)
        {
            string path = (!Path.IsPathRooted(stagingAreaData) ? Directory.GetCurrentDirectory() + "/" : string.Empty) + stagingAreaData + "/methods_pointedto_by_uievents.xml";

            File.WriteAllText(path, AssemblyStripper.GetMethodPreserveBlacklistContents(rcr));
            return(path);
        }
コード例 #7
0
        private void RunAssemblyStripper(IEnumerable assemblies, string managedAssemblyFolderPath, string[] assembliesToStrip, string[] searchDirs, string monoLinkerPath)
        {
            IEnumerable <string> enumerable = this.Il2CppBlacklistPaths;

            if (this.m_RuntimeClassRegistry != null)
            {
                enumerable = enumerable.Concat(new string[]
                {
                    this.WriteMethodsToPreserveBlackList()
                });
            }
            string text;
            string text2;

            if (AssemblyStripper.Strip(assembliesToStrip, searchDirs, managedAssemblyFolderPath, managedAssemblyFolderPath, out text, out text2, monoLinkerPath, Path.Combine(this.m_PlatformProvider.il2CppFolder, "LinkerDescriptors"), enumerable))
            {
                return;
            }
            throw new Exception(string.Concat(new object[]
            {
                "Error in stripping assemblies: ",
                assemblies,
                ", ",
                text2
            }));
        }
コード例 #8
0
        public void Run()
        {
            string directoryInStagingArea = this.GetCppOutputDirectoryInStagingArea();
            string fullPath = Path.GetFullPath(Path.Combine(this.m_StagingAreaData, "Managed"));

            foreach (string file in Directory.GetFiles(fullPath))
            {
                new FileInfo(file).IsReadOnly = false;
            }
            AssemblyStripper.StripAssemblies(this.m_StagingAreaData, this.m_PlatformProvider, this.m_RuntimeClassRegistry, this.m_DevelopmentBuild);
            this.ConvertPlayerDlltoCpp((ICollection <string>) this.GetUserAssembliesToConvert(fullPath), directoryInStagingArea, fullPath);
            if (this.m_ModifyOutputBeforeCompile != null)
            {
                this.m_ModifyOutputBeforeCompile(directoryInStagingArea);
            }
            if (this.m_PlatformProvider.CreateNativeCompiler() == null)
            {
                return;
            }
            string str = Path.Combine(this.m_StagingAreaData, "Native");

            Directory.CreateDirectory(str);
            this.m_PlatformProvider.CreateNativeCompiler().CompileDynamicLibrary(Path.Combine(str, this.m_PlatformProvider.nativeLibraryFileName), NativeCompiler.AllSourceFilesIn(directoryInStagingArea), (IEnumerable <string>) new List <string>((IEnumerable <string>) this.m_PlatformProvider.includePaths)
            {
                directoryInStagingArea
            }, (IEnumerable <string>) this.m_PlatformProvider.libraryPaths, (IEnumerable <string>) new string[0]);
        }
コード例 #9
0
        private static bool StripAssembliesTo(string[] assemblies, string[] searchDirs, string outputFolder, string workingDirectory, out string output, out string error, string linkerPath, IIl2CppPlatformProvider platformProvider, IEnumerable <string> additionalBlacklist, bool developmentBuild)
        {
            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }
            additionalBlacklist = (from s in additionalBlacklist
                                   select(!Path.IsPathRooted(s)) ? Path.Combine(workingDirectory, s) : s).Where(new Func <string, bool>(File.Exists));
            IEnumerable <string> userBlacklistFiles = AssemblyStripper.GetUserBlacklistFiles();

            foreach (string current in userBlacklistFiles)
            {
                Console.WriteLine("UserBlackList: " + current);
            }
            additionalBlacklist = additionalBlacklist.Concat(userBlacklistFiles);
            List <string> list = new List <string>
            {
                "-out \"" + outputFolder + "\"",
                "-l none",
                "-c link",
                "-b " + developmentBuild,
                "-x \"" + AssemblyStripper.GetModuleWhitelist("Core", platformProvider.moduleStrippingInformationFolder) + "\"",
                "-f \"" + Path.Combine(platformProvider.il2CppFolder, "LinkerDescriptors") + "\""
            };

            list.AddRange(from path in additionalBlacklist
                          select "-x \"" + path + "\"");
            list.AddRange(from d in searchDirs
                          select "-d \"" + d + "\"");
            list.AddRange(from assembly in assemblies
                          select "-a  \"" + Path.GetFullPath(assembly) + "\"");
            return(AssemblyStripper.RunAssemblyLinker(list, out output, out error, linkerPath, workingDirectory));
        }
コード例 #10
0
        static public void InvokeFromBuildPlayer(BuildTarget buildTarget, RuntimeClassRegistry usedClasses, ManagedStrippingLevel managedStrippingLevel, BuildReport report)
        {
            var stagingAreaData = Paths.Combine("Temp", "StagingArea", "Data");

            var platformProvider = new BaseIl2CppPlatformProvider(buildTarget, Path.Combine(stagingAreaData, "Libraries"), report);

            var managedAssemblyFolderPath = Path.GetFullPath(Path.Combine(stagingAreaData, "Managed"));

            AssemblyStripper.StripAssemblies(managedAssemblyFolderPath, platformProvider, usedClasses, managedStrippingLevel);
        }
コード例 #11
0
        internal static void StripAssemblies(string stagingAreaData, IIl2CppPlatformProvider platformProvider, RuntimeClassRegistry rcr, bool developmentBuild)
        {
            string        fullPath       = Path.GetFullPath(Path.Combine(stagingAreaData, "Managed"));
            List <string> userAssemblies = AssemblyStripper.GetUserAssemblies(rcr, fullPath);

            string[] array      = userAssemblies.ToArray();
            string[] searchDirs = new string[1] {
                fullPath
            };
            AssemblyStripper.RunAssemblyStripper(stagingAreaData, (IEnumerable)userAssemblies, fullPath, array, searchDirs, AssemblyStripper.MonoLinker2Path, platformProvider, rcr, developmentBuild);
        }
コード例 #12
0
        internal static void StripAssemblies(string managedAssemblyFolderPath, IIl2CppPlatformProvider platformProvider, RuntimeClassRegistry rcr)
        {
            List <string> userAssemblies = AssemblyStripper.GetUserAssemblies(rcr, managedAssemblyFolderPath);

            userAssemblies.AddRange(Directory.GetFiles(managedAssemblyFolderPath, "I18N*.dll", SearchOption.TopDirectoryOnly));
            string[] assembliesToStrip = userAssemblies.ToArray();
            string[] searchDirs        = new string[]
            {
                managedAssemblyFolderPath
            };
            AssemblyStripper.RunAssemblyStripper(userAssemblies, managedAssemblyFolderPath, assembliesToStrip, searchDirs, AssemblyStripper.MonoLinker2Path, platformProvider, rcr);
        }
コード例 #13
0
        public static void InvokeFromBuildPlayer(BuildTarget buildTarget, RuntimeClassRegistry usedClasses)
        {
            string text = Paths.Combine(new string[]
            {
                "Temp",
                "StagingArea",
                "Data"
            });
            BaseIl2CppPlatformProvider platformProvider = new BaseIl2CppPlatformProvider(buildTarget, Path.Combine(text, "Libraries"));

            AssemblyStripper.StripAssemblies(text, platformProvider, usedClasses);
        }
コード例 #14
0
        public void Run()
        {
            var outputDirectory = GetCppOutputDirectoryInStagingArea();
            var managedDir      = Path.GetFullPath(Path.Combine(m_StagingAreaData, "Managed"));

            // Make all assemblies in Staging/Managed writable for stripping.
            foreach (var file in Directory.GetFiles(managedDir))
            {
                var fileInfo = new FileInfo(file);
                fileInfo.IsReadOnly = false;
            }

            var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(m_PlatformProvider.target);

            var managedStrippingLevel = PlayerSettings.GetManagedStrippingLevel(buildTargetGroup);

            // IL2CPP does not support a managed stripping level of disabled. If the player settings
            // do try this (which should not be possible from the editor), use Low instead.
            if (managedStrippingLevel == ManagedStrippingLevel.Disabled)
            {
                managedStrippingLevel = ManagedStrippingLevel.Low;
            }
            AssemblyStripper.StripAssemblies(managedDir, m_PlatformProvider.CreateUnityLinkerPlatformProvider(), m_PlatformProvider, m_RuntimeClassRegistry, managedStrippingLevel);

            // The IL2CPP editor integration here is responsible to give il2cpp.exe an empty directory to use.
            FileUtil.CreateOrCleanDirectory(outputDirectory);

            if (m_ModifyOutputBeforeCompile != null)
            {
                m_ModifyOutputBeforeCompile(outputDirectory);
            }

            var pipelineData = new Il2CppBuildPipelineData(m_PlatformProvider.target, managedDir);

            ConvertPlayerDlltoCpp(pipelineData, outputDirectory, managedDir, m_PlatformProvider.supportsManagedDebugging);

            var compiler = m_PlatformProvider.CreateNativeCompiler();

            if (compiler != null && m_PlatformProvider.CreateIl2CppNativeCodeBuilder() == null)
            {
                var nativeLibPath = OutputFileRelativePath();

                var includePaths = new List <string>(m_PlatformProvider.includePaths);
                includePaths.Add(outputDirectory);

                m_PlatformProvider.CreateNativeCompiler().CompileDynamicLibrary(
                    nativeLibPath,
                    NativeCompiler.AllSourceFilesIn(outputDirectory),
                    includePaths,
                    m_PlatformProvider.libraryPaths,
                    new string[0]);
            }
        }
コード例 #15
0
        internal static void StripAssemblies(string stagingAreaData, IIl2CppPlatformProvider platformProvider, RuntimeClassRegistry rcr)
        {
            string        fullPath       = Path.GetFullPath(Path.Combine(stagingAreaData, "Managed"));
            List <string> userAssemblies = AssemblyStripper.GetUserAssemblies(rcr, fullPath);

            string[] assembliesToStrip = userAssemblies.ToArray();
            string[] searchDirs        = new string[]
            {
                fullPath
            };
            AssemblyStripper.RunAssemblyStripper(stagingAreaData, userAssemblies, fullPath, assembliesToStrip, searchDirs, AssemblyStripper.MonoLinker2Path, platformProvider, rcr);
        }
コード例 #16
0
 public LinkXmlReader()
 {
     foreach (string userBlacklistFile in AssemblyStripper.GetUserBlacklistFiles())
     {
         XPathNavigator navigator = new XPathDocument(userBlacklistFile).CreateNavigator();
         navigator.MoveToFirstChild();
         XPathNodeIterator xpathNodeIterator = navigator.SelectChildren("assembly", string.Empty);
         while (xpathNodeIterator.MoveNext())
         {
             this._assembliesInALinkXmlFile.Add(xpathNodeIterator.Current.GetAttribute("fullname", string.Empty));
         }
     }
 }
コード例 #17
0
        public LinkXmlReader()
        {
            foreach (var linkXmlFile in AssemblyStripper.GetUserBlacklistFiles())
            {
                XPathDocument linkXml   = new XPathDocument(linkXmlFile);
                var           navigator = linkXml.CreateNavigator();
                navigator.MoveToFirstChild();
                var iterator = navigator.SelectChildren("assembly", string.Empty);

                while (iterator.MoveNext())
                {
                    _assembliesInALinkXmlFile.Add(iterator.Current.GetAttribute("fullname", string.Empty));
                }
            }
        }
コード例 #18
0
        static public void StripForMonoBackend(BuildTarget buildTarget, RuntimeClassRegistry usedClasses, ManagedStrippingLevel managedStrippingLevel, BuildReport report)
        {
            if (managedStrippingLevel == ManagedStrippingLevel.Disabled)
            {
                return;
            }

            var stagingAreaData = Paths.Combine("Temp", "StagingArea", "Data");

            var il2cppPlatformProvider = new MonoBackendIl2CppPlatformProvider(buildTarget, Path.Combine(stagingAreaData, "Libraries"), report);
            var platformProvider       = new MonoBackendUnityLinkerPlatformProvider(buildTarget);

            var managedAssemblyFolderPath = Path.GetFullPath(Path.Combine(stagingAreaData, "Managed"));

            AssemblyStripper.StripAssemblies(managedAssemblyFolderPath, platformProvider, il2cppPlatformProvider, usedClasses, managedStrippingLevel);
        }
コード例 #19
0
ファイル: IL2CPPUtils.cs プロジェクト: Mu-L/UnityCsReference
        public void Run()
        {
            var generatedCppDir             = GetCppOutputDirectory(m_PlatformProvider.il2cppBuildCacheDirectory);
            var additionalCppFilesDirectory = GetAdditionalCppFilesDirectory(m_PlatformProvider.il2cppBuildCacheDirectory);
            var managedDir = Path.GetFullPath(Path.Combine(m_StagingAreaData, "Managed"));

            // Make all assemblies in Staging/Managed writable for stripping.
            ClearReadOnlyFlagOnAllFilesNonRecursively(managedDir);

            var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(m_PlatformProvider.target);

            var managedStrippingLevel = PlayerSettings.GetManagedStrippingLevel(buildTargetGroup);

            // IL2CPP does not support a managed stripping level of disabled. If the player settings
            // do try this (which should not be possible from the editor), use Low instead.
            if (managedStrippingLevel == ManagedStrippingLevel.Disabled)
            {
                managedStrippingLevel = ManagedStrippingLevel.Minimal;
            }
            AssemblyStripper.StripAssemblies(managedDir, m_PlatformProvider.CreateUnityLinkerPlatformProvider(), m_PlatformProvider, m_RuntimeClassRegistry, managedStrippingLevel);

            Directory.CreateDirectory(m_TempFolder);
            Directory.CreateDirectory(generatedCppDir);
            ClearReadOnlyFlagOnAllFilesNonRecursively(generatedCppDir);

            // Need to clean out the AdditionalCppFiles directory because a platform could do pretty much anything
            // in a "modifyOutputBeforeCompile" callback method, and so we need to provide a fresh directory. Bee will
            // still check the hash of these files before doing a build, so writing them again won't cause a recompile.
            if (Directory.Exists(additionalCppFilesDirectory))
            {
                ClearReadOnlyFlagOnAllFilesNonRecursively(additionalCppFilesDirectory);
                Directory.Delete(additionalCppFilesDirectory, true);
            }

            Directory.CreateDirectory(additionalCppFilesDirectory);

            if (m_ModifyOutputBeforeCompile != null)
            {
                m_ModifyOutputBeforeCompile(additionalCppFilesDirectory);
            }

            var pipelineData = new Il2CppBuildPipelineData(m_PlatformProvider.target, managedDir);

            ConvertPlayerDlltoCpp(pipelineData);
        }
コード例 #20
0
        private void BackupInputFolderIfNeeded(string outputFolder)
        {
            string fullOutput = AssemblyStripper.FullPathOf(outputFolder);

            if ((
                    from a in this._assemblies
                    select AssemblyStripper.FullPathOf(Path.GetDirectoryName(a))).All((string p) => string.Compare(p, fullOutput) != 0))
            {
                return;
            }
            string text = Path.Combine(outputFolder, "not-stripped");

            FileUtil.CreateOrCleanDirectory(text);
            string[] files = Directory.GetFiles(outputFolder);
            for (int i = 0; i < files.Length; i++)
            {
                string text2 = files[i];
                File.Copy(text2, Path.Combine(text, Path.GetFileName(text2)));
            }
        }
コード例 #21
0
        public void Run()
        {
            var outputDirectory = GetCppOutputDirectoryInStagingArea();
            var managedDir      = Path.GetFullPath(Path.Combine(m_StagingAreaData, "Managed"));

            // Make all assemblies in Staging/Managed writable for stripping.
            foreach (var file in Directory.GetFiles(managedDir))
            {
                var fileInfo = new FileInfo(file);
                fileInfo.IsReadOnly = false;
            }

            AssemblyStripper.StripAssemblies(managedDir, m_PlatformProvider, m_RuntimeClassRegistry);

            // The IL2CPP editor integration here is responsible to give il2cpp.exe an empty directory to use.
            FileUtil.CreateOrCleanDirectory(outputDirectory);

            if (m_ModifyOutputBeforeCompile != null)
            {
                m_ModifyOutputBeforeCompile(outputDirectory);
            }

            ConvertPlayerDlltoCpp(GetUserAssembliesToConvert(managedDir), outputDirectory, managedDir, m_PlatformProvider.supportsManagedDebugging);

            var compiler = m_PlatformProvider.CreateNativeCompiler();

            if (compiler != null && m_PlatformProvider.CreateIl2CppNativeCodeBuilder() == null)
            {
                var nativeLibPath = OutputFileRelativePath();

                var includePaths = new List <string>(m_PlatformProvider.includePaths);
                includePaths.Add(outputDirectory);

                m_PlatformProvider.CreateNativeCompiler().CompileDynamicLibrary(
                    nativeLibPath,
                    NativeCompiler.AllSourceFilesIn(outputDirectory),
                    includePaths,
                    m_PlatformProvider.libraryPaths,
                    new string[0]);
            }
        }
コード例 #22
0
        private static bool AddWhiteListsForModules(IEnumerable <string> nativeModules, ref IEnumerable <string> blacklists, string moduleStrippingInformationFolder)
        {
            bool result = 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
                        });
                        result = true;
                    }
                }
            }
            return(result);
        }
コード例 #23
0
        private static bool StripAssembliesTo(string[] assemblies, string[] searchDirs, string outputFolder, string workingDirectory, out string output, out string error, string linkerPath, IIl2CppPlatformProvider platformProvider, IEnumerable <string> additionalBlacklist)
        {
            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }
            IEnumerable <string> arg_50_0 = from s in additionalBlacklist
                                            select(!Path.IsPathRooted(s)) ? Path.Combine(workingDirectory, s) : s;

            if (AssemblyStripper.< > f__mg$cache0 == null)
            {
                AssemblyStripper.< > f__mg$cache0 = new Func <string, bool>(File.Exists);
            }
            additionalBlacklist = arg_50_0.Where(AssemblyStripper.< > f__mg$cache0);
            IEnumerable <string> userBlacklistFiles = AssemblyStripper.GetUserBlacklistFiles();

            foreach (string current in userBlacklistFiles)
            {
                Console.WriteLine("UserBlackList: " + current);
            }
            additionalBlacklist = additionalBlacklist.Concat(userBlacklistFiles);
            List <string> list = new List <string>
            {
                "--api " + PlayerSettings.GetApiCompatibilityLevel(EditorUserBuildSettings.activeBuildTargetGroup).ToString(),
                "-out \"" + outputFolder + "\"",
                "-l none",
                "-c link",
                "-b true",
                "-x \"" + AssemblyStripper.GetModuleWhitelist("Core", platformProvider.moduleStrippingInformationFolder) + "\"",
                "-f \"" + Path.Combine(platformProvider.il2CppFolder, "LinkerDescriptors") + "\""
            };

            list.AddRange(from path in additionalBlacklist
                          select "-x \"" + path + "\"");
            list.AddRange(from d in searchDirs
                          select "-d \"" + d + "\"");
            list.AddRange(from assembly in assemblies
                          select "-a  \"" + Path.GetFullPath(assembly) + "\"");
            return(AssemblyStripper.RunAssemblyLinker(list, out output, out error, linkerPath, workingDirectory));
        }
コード例 #24
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);
        }
コード例 #25
0
        private bool StripAssembliesTo(string outputFolder, string workingDirectory, out string output, out string error, string linkerPath, string descriptorsFolder, IEnumerable <string> additionalBlacklist)
        {
            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }
            additionalBlacklist = (
                from s in additionalBlacklist
                select(!Path.IsPathRooted(s)) ? Path.Combine(workingDirectory, s) : s).Where(new Func <string, bool>(File.Exists));
            IEnumerable <string> enumerable =
                from s in Directory.GetFiles("Assets", "link.xml", SearchOption.AllDirectories)
                select Path.Combine(Directory.GetCurrentDirectory(), s);

            foreach (string current in enumerable)
            {
                Console.WriteLine("UserBlackList: " + current);
            }
            additionalBlacklist = additionalBlacklist.Concat(enumerable);
            List <string> list = new List <string>
            {
                "-out \"" + outputFolder + "\"",
                "-l none",
                "-c link",
                "-x \"" + AssemblyStripper.BlacklistPath + "\"",
                "-f \"" + descriptorsFolder + "\""
            };

            list.AddRange(
                from path in additionalBlacklist
                select "-x \"" + path + "\"");
            list.AddRange(
                from d in this._searchDirs
                select "-d \"" + d + "\"");
            list.AddRange(
                from assembly in this._assemblies
                select "-a  \"" + Path.GetFullPath(assembly) + "\"");
            return(AssemblyStripper.RunAssemblyLinker(list, out output, out error, linkerPath, workingDirectory));
        }
コード例 #26
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);
        }
コード例 #27
0
        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);
        }
コード例 #28
0
        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);
        }