private void ConvertPlayerDlltoCpp(ICollection <string> userAssemblies, string outputDirectory, string workingDirectory) { FileUtil.CreateOrCleanDirectory(outputDirectory); if (userAssemblies.Count == 0) { return; } string[] array = (from s in Directory.GetFiles("Assets", "il2cpp_extra_types.txt", SearchOption.AllDirectories) select Path.Combine(Directory.GetCurrentDirectory(), s)).ToArray <string>(); string il2CppExe = this.GetIl2CppExe(); List <string> list = new List <string>(); list.Add("--convert-to-cpp"); list.Add("--copy-level=None"); if (this.m_PlatformProvider.emitNullChecks) { list.Add("--emit-null-checks"); } if (this.m_PlatformProvider.enableStackTraces) { list.Add("--enable-stacktrace"); } if (this.m_PlatformProvider.enableArrayBoundsCheck) { list.Add("--enable-array-bounds-check"); } if (this.m_PlatformProvider.compactMode) { list.Add("--output-format=Compact"); } if (this.m_PlatformProvider.loadSymbols) { list.Add("--enable-symbol-loading"); } if (this.m_PlatformProvider.developmentMode) { list.Add("--development-mode"); } if (array.Length > 0) { string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string arg2 = array2[i]; list.Add(string.Format("--extra-types.file=\"{0}\"", arg2)); } } string text = Path.Combine(this.m_PlatformProvider.il2CppFolder, "il2cpp_default_extra_types.txt"); if (File.Exists(text)) { list.Add(string.Format("--extra-types.file=\"{0}\"", text)); } string text2 = string.Empty; if (PlayerSettings.GetPropertyOptionalString("additionalIl2CppArgs", ref text2)) { list.Add(text2); } text2 = Environment.GetEnvironmentVariable("IL2CPP_ADDITIONAL_ARGS"); if (!string.IsNullOrEmpty(text2)) { list.Add(text2); } List <string> source = new List <string>(userAssemblies); list.AddRange(from arg in source select "--assembly=\"" + Path.GetFullPath(arg) + "\""); list.Add(string.Format("--generatedcppdir=\"{0}\"", Path.GetFullPath(outputDirectory))); string text3 = list.Aggregate(string.Empty, (string current, string arg) => current + arg + " "); Console.WriteLine("Invoking il2cpp with arguments: " + text3); if (EditorUtility.DisplayCancelableProgressBar("Building Player", "Converting managed assemblies to C++", 0.3f)) { throw new OperationCanceledException(); } Runner.RunManagedProgram(il2CppExe, text3, workingDirectory, new Il2CppOutputParser()); }
private void ConvertPlayerDlltoCpp(ICollection <string> userAssemblies, string outputDirectory, string workingDirectory) { FileUtil.CreateOrCleanDirectory(outputDirectory); if (userAssemblies.Count == 0) { return; } string[] array = ((IEnumerable <string>)Directory.GetFiles("Assets", "il2cpp_extra_types.txt", SearchOption.AllDirectories)).Select <string, string>((Func <string, string>)(s => Path.Combine(Directory.GetCurrentDirectory(), s))).ToArray <string>(); string il2CppExe = this.GetIl2CppExe(); List <string> source1 = new List <string>(); source1.Add("--convert-to-cpp"); if (this.m_PlatformProvider.emitNullChecks) { source1.Add("--emit-null-checks"); } if (this.m_PlatformProvider.enableStackTraces) { source1.Add("--enable-stacktrace"); } if (this.m_PlatformProvider.enableArrayBoundsCheck) { source1.Add("--enable-array-bounds-check"); } if (this.m_PlatformProvider.loadSymbols) { source1.Add("--enable-symbol-loading"); } if (this.m_PlatformProvider.developmentMode) { source1.Add("--development-mode"); } if (array.Length > 0) { foreach (string str in array) { source1.Add(string.Format("--extra-types.file=\"{0}\"", (object)str)); } } string path = Path.Combine(this.m_PlatformProvider.il2CppFolder, "il2cpp_default_extra_types.txt"); if (File.Exists(path)) { source1.Add(string.Format("--extra-types.file=\"{0}\"", (object)path)); } string empty = string.Empty; if (PlayerSettings.GetPropertyOptionalString("additionalIl2CppArgs", ref empty)) { source1.Add(empty); } string environmentVariable = Environment.GetEnvironmentVariable("IL2CPP_ADDITIONAL_ARGS"); if (!string.IsNullOrEmpty(environmentVariable)) { source1.Add(environmentVariable); } List <string> source2 = new List <string>((IEnumerable <string>)userAssemblies); source1.AddRange(source2.Select <string, string>((Func <string, string>)(arg => "--assembly=\"" + Path.GetFullPath(arg) + "\""))); source1.Add(string.Format("--generatedcppdir=\"{0}\"", (object)Path.GetFullPath(outputDirectory))); string args = source1.Aggregate <string, string>(string.Empty, (Func <string, string, string>)((current, arg) => current + arg + " ")); Console.WriteLine("Invoking il2cpp with arguments: " + args); if (EditorUtility.DisplayCancelableProgressBar("Building Player", "Converting managed assemblies to C++", 0.3f)) { throw new OperationCanceledException(); } Runner.RunManagedProgram(il2CppExe, args, workingDirectory, (CompilerOutputParserBase) new Il2CppOutputParser()); }
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), MonoAssemblyStripping.GenerateLinkXmlToPreserveDerivedTypes(stagingAreaData, managedAssemblyFolderPath, 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, platformProvider.buildReport); flag2 = AssemblyStripper.AddWhiteListsForModules(nativeModules, ref enumerable, platformProvider.moduleStrippingInformationFolder, platformProvider.buildReport); } 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); }