internal static void GenerateInternalCallSummaryFile(string icallSummaryPath, string managedAssemblyFolderPath, string strippedDLLPath) { string exe = Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Tools/InternalCallRegistrationWriter/InternalCallRegistrationWriter.exe"); string args = string.Format("-assembly=\"{0}\" -output=\"{1}\" -summary=\"{2}\"", Path.Combine(strippedDLLPath, "UnityEngine.dll"), Path.Combine(managedAssemblyFolderPath, "UnityICallRegistration.cpp"), icallSummaryPath); Runner.RunManagedProgram(exe, args); }
private static string AssemblySearchPathArgument() { string[] textArray1 = new string[] { Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Managed"), ",+", Path.Combine(EditorApplication.applicationContentsPath, "UnityExtensions/Unity"), ",+", Application.dataPath }; string str = string.Concat(textArray1); return(" -s \"" + str + "\""); }
public static void UpdateScripts(string responseFile, string sourceExtension, string pathMappingsFilePath) { if (!APIUpdaterManager.WaitForVCSServerConnection(true)) { return; } var tempOutputPath = "Library/Temp/ScriptUpdater/" + new System.Random().Next() + "/"; try { RunUpdatingProgram( "ScriptUpdater.exe", sourceExtension + " " + CommandLineFormatter.PrepareFileName(MonoInstallationFinder.GetFrameWorksFolder()) + " " + tempOutputPath + " " + APIUpdaterManager.ConfigurationSourcesFilter + " " + pathMappingsFilePath + " " + responseFile, tempOutputPath); } catch (Exception ex) when(!(ex is StackOverflowException) && !(ex is ExecutionEngineException)) { Debug.LogError("[API Updater] ScriptUpdater threw an exception. Check the following message in the log."); Debug.LogException(ex); APIUpdaterManager.ReportExpectedUpdateFailure(); } }
public override void CompileDynamicLibrary(string outputFile, IEnumerable <string> sources, IEnumerable <string> includePaths, IEnumerable <string> libraries, IEnumerable <string> libraryPaths) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type MSVCCompiler.\u003CCompileDynamicLibrary\u003Ec__AnonStorey75 libraryCAnonStorey75 = new MSVCCompiler.\u003CCompileDynamicLibrary\u003Ec__AnonStorey75(); // ISSUE: reference to a compiler-generated field libraryCAnonStorey75.\u003C\u003Ef__this = this; string[] array = sources.ToArray <string>(); string str1 = NativeCompiler.Aggregate(((IEnumerable <string>)array).Select <string, string>(new Func <string, string>(((NativeCompiler)this).ObjectFileFor)), " \"", "\" " + Environment.NewLine); // ISSUE: reference to a compiler-generated field libraryCAnonStorey75.includePathsString = NativeCompiler.Aggregate(includePaths.Union <string>((IEnumerable <string>) this.m_IncludePaths), "/I \"", "\" "); string str2 = NativeCompiler.Aggregate(libraries.Union <string>((IEnumerable <string>) this.m_Libraries), " ", " "); string str3 = NativeCompiler.Aggregate(libraryPaths.Union <string>((IEnumerable <string>) this.m_Settings.LibPaths), "/LIBPATH:\"", "\" "); this.GenerateEmptyPdbFile(outputFile); // ISSUE: reference to a compiler-generated method NativeCompiler.ParallelFor <string>(array, new Action <string>(libraryCAnonStorey75.\u003C\u003Em__108)); string contents = string.Format(" {0} {1} {2} /DEBUG /INCREMENTAL:NO /MACHINE:{4} /DLL /out:\"{3}\" /MAP /DEF:\"{5}\" ", (object)str1, (object)str2, (object)str3, (object)outputFile, (object)this.m_Settings.MachineSpecification, (object)this.m_DefFile); string tempFileName = Path.GetTempFileName(); File.WriteAllText(tempFileName, contents); this.Execute(string.Format("@{0}", (object)tempFileName), "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\bin\\link.exe"); this.ExecuteCommand(Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Tools/MapFileParser/MapFileParser.exe"), "-format=MSVC", "\"" + Path.GetFullPath(Path.Combine(Path.GetDirectoryName(outputFile), Path.GetFileNameWithoutExtension(outputFile) + ".map")) + "\"", "\"" + Path.GetFullPath(Path.Combine(Path.GetDirectoryName(outputFile), "SymbolMap")) + "\""); }
private static string AssemblySearchPathArgument() { var searchPath = Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Managed") + "," + "+" + Path.Combine(EditorApplication.applicationContentsPath, "UnityExtensions/Unity") + "," + "+" + Application.dataPath; return(" -s \"" + searchPath + "\""); }
internal static void GenerateInternalCallSummaryFile(string icallSummaryPath, string managedAssemblyFolderPath, string strippedDLLPath) { string exe = Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Tools/InternalCallRegistrationWriter/InternalCallRegistrationWriter.exe"); IEnumerable <string> source = Directory.GetFiles(strippedDLLPath, "UnityEngine.*Module.dll").Concat(new string[] { Path.Combine(strippedDLLPath, "UnityEngine.dll") }); string args = string.Format("-output=\"{0}\" -summary=\"{1}\" -assembly=\"{2}\"", Path.Combine(managedAssemblyFolderPath, "UnityICallRegistration.cpp"), icallSummaryPath, source.Aggregate((string dllArg, string next) => dllArg + ";" + next)); Runner.RunManagedProgram(exe, args); }
public static string ArgumentsForScriptUpdater(string sourceExtension, string tempOutputPath, string pathMappingsFilePath, string responseFile) { return(sourceExtension + " " + CommandLineFormatter.PrepareFileName(MonoInstallationFinder.GetFrameWorksFolder()) + " " + CommandLineFormatter.PrepareFileName(tempOutputPath) + " \"" + APIUpdaterManager.ConfigurationSourcesFilter + "\" " // Quote the filter (regex) to avoid issues when passing through command line arg.) + CommandLineFormatter.PrepareFileName(pathMappingsFilePath) + " " + responseFile); // Response file is always relative and without spaces, no need to quote. }
public static void UpdateScripts(string responseFile, string sourceExtension, string[] sourceFiles) { if (!APIUpdaterManager.WaitForVCSServerConnection(true)) { return; } var pathMappingsFilePath = Path.GetTempFileName(); var filePathMappings = new List <string>(sourceFiles.Length); foreach (var source in sourceFiles) { var f = CommandLineFormatter.PrepareFileName(source); f = Paths.UnifyDirectorySeparator(f); if (f != source) { filePathMappings.Add(f + " => " + source); } } File.WriteAllLines(pathMappingsFilePath, filePathMappings.ToArray()); var tempOutputPath = "Library/Temp/ScriptUpdater/" + new System.Random().Next() + "/"; try { RunUpdatingProgram( "ScriptUpdater.exe", sourceExtension + " " + CommandLineFormatter.PrepareFileName(MonoInstallationFinder.GetFrameWorksFolder()) + " " + tempOutputPath + " \"" // Quote the filer (regex) to avoid issues when passing through command line arg. + APIUpdaterManager.ConfigurationSourcesFilter + "\" " + pathMappingsFilePath + " " + responseFile, tempOutputPath); } #pragma warning disable CS0618 // Type or member is obsolete catch (Exception ex) when(!(ex is StackOverflowException) && !(ex is ExecutionEngineException)) #pragma warning restore CS0618 // Type or member is obsolete { Debug.LogError("[API Updater] ScriptUpdater threw an exception. Check the following message in the log."); Debug.LogException(ex); APIUpdaterManager.ReportExpectedUpdateFailure(); } }
private static string AssemblySearchPathArgument(IEnumerable <string> configurationSourceDirectories = null) { var searchPath = Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Managed") + "," + "+" + Application.dataPath; if (configurationSourceDirectories != null) { var searchPathFromConfigSources = configurationSourceDirectories.Aggregate("", (acc, curr) => acc + ",+" + curr); searchPath += searchPathFromConfigSources; } return(" -s \"" + searchPath + "\""); }
public static void UpdateScripts(string responseFile, string sourceExtension) { if (ScriptUpdatingManager.WaitForVCSServerConnection(true)) { string text = (!Provider.enabled) ? "." : "Temp/ScriptUpdater/"; APIUpdaterHelper.RunUpdatingProgram("ScriptUpdater.exe", string.Concat(new string[] { sourceExtension, " ", CommandLineFormatter.PrepareFileName(MonoInstallationFinder.GetFrameWorksFolder()), " ", text, " ", responseFile })); } }
public static void UpdateScripts(string responseFile, string sourceExtension) { if (!ScriptUpdatingManager.WaitForVCSServerConnection(true)) { return; } var outputPath = Provider.enabled ? tempOutputPath : "."; RunUpdatingProgram( "ScriptUpdater.exe", sourceExtension + " " + CommandLineFormatter.PrepareFileName(MonoInstallationFinder.GetFrameWorksFolder()) + " " + outputPath + " " + responseFile); }
public override void CompileDynamicLibrary(string outFile, IEnumerable <string> sources, IEnumerable <string> includePaths, IEnumerable <string> libraries, IEnumerable <string> libraryPaths) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type ClangCompiler.\u003CCompileDynamicLibrary\u003Ec__AnonStorey71 libraryCAnonStorey71 = new ClangCompiler.\u003CCompileDynamicLibrary\u003Ec__AnonStorey71(); // ISSUE: reference to a compiler-generated field libraryCAnonStorey71.\u003C\u003Ef__this = this; string[] array = sources.ToArray <string>(); // ISSUE: reference to a compiler-generated field libraryCAnonStorey71.includeDirs = includePaths.Aggregate <string, string>(string.Empty, (Func <string, string, string>)((current, sourceDir) => current + "-I" + sourceDir + " ")); string str1 = NativeCompiler.Aggregate(libraries, "-force_load ", " "); string str2 = NativeCompiler.Aggregate(libraryPaths.Union <string>((IEnumerable <string>) this.m_Settings.LibPaths), "-L", " "); // ISSUE: reference to a compiler-generated method NativeCompiler.ParallelFor <string>(array, new Action <string>(libraryCAnonStorey71.\u003C\u003Em__F8)); string str3 = "\"" + Path.GetFullPath(Path.Combine(Path.GetDirectoryName(outFile), Path.GetFileNameWithoutExtension(outFile) + ".map")) + "\""; this.ExecuteCommand("ld", "-dylib", "-arch " + this.m_Settings.MachineSpecification, "-macosx_version_min 10.6", "-lSystem", "-lstdc++", "-map", str3, "-o " + outFile, ((IEnumerable <string>)array).Select <string, string>(new Func <string, string>(((NativeCompiler)this).ObjectFileFor)).Aggregate <string>((Func <string, string, string>)((buff, s) => buff + " " + s)), str2, str1); string command = Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Tools/MapFileParser/MapFileParser"); string str4 = "\"" + Path.GetFullPath(Path.Combine(Path.GetDirectoryName(outFile), "SymbolMap")) + "\""; this.ExecuteCommand(command, "-format=Clang", str3, str4); }
public override void CompileDynamicLibrary(string outFile, IEnumerable <string> sources, IEnumerable <string> includePaths, IEnumerable <string> libraries, IEnumerable <string> libraryPaths) { string[] array = sources.ToArray <string>(); string includeDirs = includePaths.Aggregate(string.Empty, (string current, string sourceDir) => current + "-I" + sourceDir + " "); string text = NativeCompiler.Aggregate(libraries, "-force_load ", " "); string text2 = NativeCompiler.Aggregate(libraryPaths.Union(this.m_Settings.LibPaths), "-L", " "); NativeCompiler.ParallelFor <string>(array, delegate(string file) { this.Compile(file, includeDirs); }); string text3 = "\"" + Path.GetFullPath(Path.Combine(Path.GetDirectoryName(outFile), Path.GetFileNameWithoutExtension(outFile) + ".map")) + "\""; string arg_15C_1 = "ld"; string[] expr_C9 = new string[11]; expr_C9[0] = "-dylib"; expr_C9[1] = "-arch " + this.m_Settings.MachineSpecification; expr_C9[2] = "-macosx_version_min 10.6"; expr_C9[3] = "-lSystem"; expr_C9[4] = "-lstdc++"; expr_C9[5] = "-map"; expr_C9[6] = text3; expr_C9[7] = "-o " + outFile; expr_C9[8] = array.Select(new Func <string, string>(base.ObjectFileFor)).Aggregate((string buff, string s) => buff + " " + s); expr_C9[9] = text2; expr_C9[10] = text; base.ExecuteCommand(arg_15C_1, expr_C9); string command = Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Tools/MapFileParser/MapFileParser"); string text4 = "\"" + Path.GetFullPath(Path.Combine(Path.GetDirectoryName(outFile), "SymbolMap")) + "\""; base.ExecuteCommand(command, new string[] { "-format=Clang", text3, text4 }); }
public override void CompileDynamicLibrary(string outputFile, IEnumerable <string> sources, IEnumerable <string> includePaths, IEnumerable <string> libraries, IEnumerable <string> libraryPaths) { string[] array = sources.ToArray <string>(); string text = NativeCompiler.Aggregate(array.Select(new Func <string, string>(base.ObjectFileFor)), " \"", "\" " + Environment.NewLine); string includePathsString = NativeCompiler.Aggregate(includePaths.Union(this.m_IncludePaths), "/I \"", "\" "); string text2 = NativeCompiler.Aggregate(libraries.Union(this.m_Libraries), " ", " "); string text3 = NativeCompiler.Aggregate(libraryPaths.Union(this.m_Settings.LibPaths), "/LIBPATH:\"", "\" "); this.GenerateEmptyPdbFile(outputFile); NativeCompiler.ParallelFor <string>(array, delegate(string file) { this.Compile(file, includePathsString); }); string contents = string.Format(" {0} {1} {2} /DEBUG /INCREMENTAL:NO /MACHINE:{4} /DLL /out:\"{3}\" /MAP /DEF:\"{5}\" ", new object[] { text, text2, text3, outputFile, this.m_Settings.MachineSpecification, this.m_DefFile }); string tempFileName = Path.GetTempFileName(); File.WriteAllText(tempFileName, contents); base.Execute(string.Format("@{0}", tempFileName), MSVCCompiler.VisualStudioDir() + "\\bin\\link.exe"); string command = Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Tools/MapFileParser/MapFileParser.exe"); string text4 = "\"" + Path.GetFullPath(Path.Combine(Path.GetDirectoryName(outputFile), Path.GetFileNameWithoutExtension(outputFile) + ".map")) + "\""; string text5 = "\"" + Path.GetFullPath(Path.Combine(Path.GetDirectoryName(outputFile), "SymbolMap")) + "\""; base.ExecuteCommand(command, new string[] { "-format=MSVC", text4, text5 }); }
private static string GetNetCoreRoot() { return(Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "NetCore")); }
private static string GetUnityEditorManagedPath() { return(Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Managed")); }
public static void UpdateScripts(string responseFile, string sourceExtension) { if (!ScriptUpdatingManager.WaitForVCSServerConnection(true)) { return; } string str = !Provider.enabled ? "." : "Temp/ScriptUpdater/"; APIUpdaterHelper.RunUpdatingProgram("ScriptUpdater.exe", sourceExtension + " " + CommandLineFormatter.PrepareFileName(MonoInstallationFinder.GetFrameWorksFolder()) + " " + str + " " + responseFile); }
private static string GetUnityReferenceProfileDirectory() { return(Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "UnityReferenceAssemblies", "unity-4.8-api")); }
public static void MonoLink(BuildTarget buildTarget, string managedLibrariesDirectory, string[] input, string[] allAssemblies, RuntimeClassRegistry usedClasses) { Process process = MonoProcessUtility.PrepareMonoProcess(buildTarget, managedLibrariesDirectory); string buildToolsDirectory = BuildPipeline.GetBuildToolsDirectory(buildTarget); string str2 = null; string path = Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), StripperExe()); string str5 = Path.Combine(Path.GetDirectoryName(path), "link.xml"); string str6 = Path.Combine(managedLibrariesDirectory, "output"); Directory.CreateDirectory(str6); process.StartInfo.Arguments = "\"" + path + "\" -l none -c link"; foreach (string str7 in input) { ProcessStartInfo info1 = process.StartInfo; info1.Arguments = info1.Arguments + " -a \"" + str7 + "\""; } ProcessStartInfo startInfo = process.StartInfo; string arguments = startInfo.Arguments; string[] textArray1 = new string[] { arguments, " -out output -x \"", str5, "\" -d \"", managedLibrariesDirectory, "\"" }; startInfo.Arguments = string.Concat(textArray1); string str8 = Path.Combine(buildToolsDirectory, "link.xml"); if (File.Exists(str8)) { ProcessStartInfo info3 = process.StartInfo; info3.Arguments = info3.Arguments + " -x \"" + str8 + "\""; } string str9 = Path.Combine(Path.GetDirectoryName(path), "Core.xml"); if (File.Exists(str9)) { ProcessStartInfo info4 = process.StartInfo; info4.Arguments = info4.Arguments + " -x \"" + str9 + "\""; } foreach (string str10 in Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "Assets"), "link.xml", SearchOption.AllDirectories)) { ProcessStartInfo info5 = process.StartInfo; info5.Arguments = info5.Arguments + " -x \"" + str10 + "\""; } if (usedClasses != null) { str2 = GenerateBlackList(managedLibrariesDirectory, usedClasses, allAssemblies); ProcessStartInfo info6 = process.StartInfo; info6.Arguments = info6.Arguments + " -x \"" + str2 + "\""; } MonoProcessUtility.RunMonoProcess(process, "assemblies stripper", Path.Combine(str6, "mscorlib.dll")); DeleteAllDllsFrom(managedLibrariesDirectory); CopyAllDlls(managedLibrariesDirectory, str6); foreach (string str11 in Directory.GetFiles(managedLibrariesDirectory)) { if (str11.Contains(".mdb") && !File.Exists(str11.Replace(".mdb", string.Empty))) { FileUtil.DeleteFileOrDirectory(str11); } } if (str2 != null) { FileUtil.DeleteFileOrDirectory(Path.Combine(managedLibrariesDirectory, str2)); } FileUtil.DeleteFileOrDirectory(str6); }
static public void WriteCPlusPlusFileForStaticAOTModuleRegistration(BuildTarget buildTarget, string file, CrossCompileOptions crossCompileOptions, bool advancedLic, string targetDevice, bool stripping, RuntimeClassRegistry usedClassRegistry, AssemblyReferenceChecker checker, string stagingAreaDataManaged, IIl2CppPlatformProvider platformProvider) { // generate the Interal Call Summary file var icallSummaryPath = Path.Combine(stagingAreaDataManaged, "ICallSummary.txt"); var dlls = Directory.GetFiles(stagingAreaDataManaged, "UnityEngine.*Module.dll").Concat(new[] { Path.Combine(stagingAreaDataManaged, "UnityEngine.dll") }); var exe = Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Tools/InternalCallRegistrationWriter/InternalCallRegistrationWriter.exe"); var args = string.Format("-assembly=\"{0}\" -summary=\"{1}\"", dlls.Aggregate((dllArg, next) => dllArg + ";" + next), icallSummaryPath ); Runner.RunManagedProgram(exe, args); HashSet <UnityType> nativeClasses; HashSet <string> nativeModules; CodeStrippingUtils.GenerateDependencies(Path.GetDirectoryName(stagingAreaDataManaged), icallSummaryPath, usedClassRegistry, stripping, out nativeClasses, out nativeModules, platformProvider); using (TextWriter w = new StreamWriter(file)) { string[] fileNames = checker.GetAssemblyFileNames(); AssemblyDefinition[] assemblies = checker.GetAssemblyDefinitions(); bool fastICall = (crossCompileOptions & CrossCompileOptions.FastICall) != 0; ArrayList nativeMethods = BuildNativeMethodList(assemblies); if (buildTarget == BuildTarget.iOS) { w.WriteLine("#include \"RegisterMonoModules.h\""); w.WriteLine("#include <stdio.h>"); } w.WriteLine(""); w.WriteLine("#if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR"); w.WriteLine(" #define DECL_USER_FUNC(f) void f() __attribute__((weak_import))"); w.WriteLine(" #define REGISTER_USER_FUNC(f)\\"); w.WriteLine(" do {\\"); w.WriteLine(" if(f != NULL)\\"); w.WriteLine(" mono_dl_register_symbol(#f, (void*)f);\\"); w.WriteLine(" else\\"); w.WriteLine(" ::printf_console(\"Symbol \'%s\' not found. Maybe missing implementation for Simulator?\\n\", #f);\\"); w.WriteLine(" }while(0)"); w.WriteLine("#else"); w.WriteLine(" #define DECL_USER_FUNC(f) void f() "); w.WriteLine(" #if !defined(__arm64__)"); w.WriteLine(" #define REGISTER_USER_FUNC(f) mono_dl_register_symbol(#f, (void*)&f)"); w.WriteLine(" #else"); w.WriteLine(" #define REGISTER_USER_FUNC(f)"); w.WriteLine(" #endif"); w.WriteLine("#endif"); w.WriteLine("extern \"C\"\n{"); w.WriteLine(" typedef void* gpointer;"); w.WriteLine(" typedef int gboolean;"); if (buildTarget == BuildTarget.iOS) { w.WriteLine(" const char* UnityIPhoneRuntimeVersion = \"{0}\";", Application.unityVersion); w.WriteLine(" void mono_dl_register_symbol (const char* name, void *addr);"); w.WriteLine("#if !defined(__arm64__)"); w.WriteLine(" extern int mono_ficall_flag;"); w.WriteLine("#endif"); } w.WriteLine(" void mono_aot_register_module(gpointer *aot_info);"); w.WriteLine("#if __ORBIS__ || SN_TARGET_PSP2"); w.WriteLine("#define DLL_EXPORT __declspec(dllexport)"); // ps4 and psp2 need dllexport. w.WriteLine("#else"); w.WriteLine("#define DLL_EXPORT"); w.WriteLine("#endif"); w.WriteLine("#if !(TARGET_IPHONE_SIMULATOR)"); w.WriteLine(" extern gboolean mono_aot_only;"); for (int q = 0; q < fileNames.Length; ++q) { string fileName = fileNames[q]; string assemblyName = assemblies[q].Name.Name; assemblyName = assemblyName.Replace(".", "_"); assemblyName = assemblyName.Replace("-", "_"); assemblyName = assemblyName.Replace(" ", "_"); w.WriteLine(" extern gpointer* mono_aot_module_{0}_info; // {1}", assemblyName, fileName); } w.WriteLine("#endif // !(TARGET_IPHONE_SIMULATOR)"); foreach (string nmethod in nativeMethods) { w.WriteLine(" DECL_USER_FUNC({0});", nmethod); } w.WriteLine("}"); w.WriteLine("DLL_EXPORT void RegisterMonoModules()"); w.WriteLine("{"); w.WriteLine("#if !(TARGET_IPHONE_SIMULATOR) && !defined(__arm64__)"); w.WriteLine(" mono_aot_only = true;"); if (buildTarget == BuildTarget.iOS) { w.WriteLine(" mono_ficall_flag = {0};", fastICall ? "true" : "false"); } foreach (AssemblyDefinition definition in assemblies) { string assemblyName = definition.Name.Name; assemblyName = assemblyName.Replace(".", "_"); assemblyName = assemblyName.Replace("-", "_"); assemblyName = assemblyName.Replace(" ", "_"); w.WriteLine(" mono_aot_register_module(mono_aot_module_{0}_info);", assemblyName); } w.WriteLine("#endif // !(TARGET_IPHONE_SIMULATOR) && !defined(__arm64__)"); w.WriteLine(""); if (buildTarget == BuildTarget.iOS) { foreach (string nmethod in nativeMethods) { w.WriteLine(" REGISTER_USER_FUNC({0});", nmethod); } } w.WriteLine("}"); w.WriteLine(""); if (buildTarget == BuildTarget.iOS) { var inputAssemblies = new List <AssemblyDefinition>(); for (int i = 0; i < assemblies.Length; i++) { if (AssemblyHelper.IsUnityEngineModule(assemblies[i])) { inputAssemblies.Add(assemblies[i]); } } GenerateRegisterInternalCalls(inputAssemblies.ToArray(), w); GenerateRegisterModules(nativeClasses, nativeModules, w, stripping); if (stripping && usedClassRegistry != null) { GenerateRegisterClassesForStripping(nativeClasses, w); } else { GenerateRegisterClasses(nativeClasses, w); } } w.Close(); } }
private static string AssemblySearchPathArgument() { string[] textArray1 = new string[] { " -s ", CommandLineFormatter.PrepareFileName(Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Managed")), ",+", CommandLineFormatter.PrepareFileName(Path.Combine(EditorApplication.applicationContentsPath, "UnityExtensions/Unity")), ",+", CommandLineFormatter.PrepareFileName(Application.dataPath) }; return(string.Concat(textArray1)); }
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); }
public static void WriteCPlusPlusFileForStaticAOTModuleRegistration(BuildTarget buildTarget, string file, CrossCompileOptions crossCompileOptions, bool advancedLic, string targetDevice, bool stripping, RuntimeClassRegistry usedClassRegistry, AssemblyReferenceChecker checker, string stagingAreaDataManaged) { HashSet <UnityType> set; HashSet <string> set2; string str = Path.Combine(stagingAreaDataManaged, "ICallSummary.txt"); string exe = Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Tools/InternalCallRegistrationWriter/InternalCallRegistrationWriter.exe"); string args = $"-assembly=" { Path.Combine(stagingAreaDataManaged, "UnityEngine.dll") } " -summary=" { str } ""; Runner.RunManagedProgram(exe, args); CodeStrippingUtils.GenerateDependencies(Path.GetFullPath(stagingAreaDataManaged), str, usedClassRegistry, stripping, out set, out set2, null); using (TextWriter writer = new StreamWriter(file)) { string[] assemblyFileNames = checker.GetAssemblyFileNames(); AssemblyDefinition[] assemblyDefinitions = checker.GetAssemblyDefinitions(); bool flag = (crossCompileOptions & CrossCompileOptions.FastICall) != CrossCompileOptions.Dynamic; ArrayList list = BuildNativeMethodList(assemblyDefinitions); if (buildTarget == BuildTarget.iOS) { writer.WriteLine("#include \"RegisterMonoModules.h\""); writer.WriteLine("#include <stdio.h>"); } writer.WriteLine(""); writer.WriteLine("#if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR"); writer.WriteLine(" #define DECL_USER_FUNC(f) void f() __attribute__((weak_import))"); writer.WriteLine(@" #define REGISTER_USER_FUNC(f)\"); writer.WriteLine(@" do {\"); writer.WriteLine(@" if(f != NULL)\"); writer.WriteLine(@" mono_dl_register_symbol(#f, (void*)f);\"); writer.WriteLine(@" else\"); writer.WriteLine(" ::printf_console(\"Symbol '%s' not found. Maybe missing implementation for Simulator?\\n\", #f);\\"); writer.WriteLine(" }while(0)"); writer.WriteLine("#else"); writer.WriteLine(" #define DECL_USER_FUNC(f) void f() "); writer.WriteLine(" #if !defined(__arm64__)"); writer.WriteLine(" #define REGISTER_USER_FUNC(f) mono_dl_register_symbol(#f, (void*)&f)"); writer.WriteLine(" #else"); writer.WriteLine(" #define REGISTER_USER_FUNC(f)"); writer.WriteLine(" #endif"); writer.WriteLine("#endif"); writer.WriteLine("extern \"C\"\n{"); writer.WriteLine(" typedef void* gpointer;"); writer.WriteLine(" typedef int gboolean;"); if (buildTarget == BuildTarget.iOS) { writer.WriteLine(" const char* UnityIPhoneRuntimeVersion = \"{0}\";", Application.unityVersion); writer.WriteLine(" void mono_dl_register_symbol (const char* name, void *addr);"); writer.WriteLine("#if !defined(__arm64__)"); writer.WriteLine(" extern int mono_ficall_flag;"); writer.WriteLine("#endif"); } writer.WriteLine(" void mono_aot_register_module(gpointer *aot_info);"); writer.WriteLine("#if __ORBIS__ || SN_TARGET_PSP2"); writer.WriteLine("#define DLL_EXPORT __declspec(dllexport)"); writer.WriteLine("#else"); writer.WriteLine("#define DLL_EXPORT"); writer.WriteLine("#endif"); writer.WriteLine("#if !(TARGET_IPHONE_SIMULATOR)"); writer.WriteLine(" extern gboolean mono_aot_only;"); for (int i = 0; i < assemblyFileNames.Length; i++) { string str4 = assemblyFileNames[i]; string str5 = assemblyDefinitions[i].Name.Name.Replace(".", "_").Replace("-", "_").Replace(" ", "_"); writer.WriteLine(" extern gpointer* mono_aot_module_{0}_info; // {1}", str5, str4); } writer.WriteLine("#endif // !(TARGET_IPHONE_SIMULATOR)"); IEnumerator enumerator = list.GetEnumerator(); try { while (enumerator.MoveNext()) { string current = (string)enumerator.Current; writer.WriteLine(" DECL_USER_FUNC({0});", current); } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } writer.WriteLine("}"); writer.WriteLine("DLL_EXPORT void RegisterMonoModules()"); writer.WriteLine("{"); writer.WriteLine("#if !(TARGET_IPHONE_SIMULATOR) && !defined(__arm64__)"); writer.WriteLine(" mono_aot_only = true;"); if (buildTarget == BuildTarget.iOS) { writer.WriteLine(" mono_ficall_flag = {0};", !flag ? "false" : "true"); } foreach (AssemblyDefinition definition in assemblyDefinitions) { string str7 = definition.Name.Name.Replace(".", "_").Replace("-", "_").Replace(" ", "_"); writer.WriteLine(" mono_aot_register_module(mono_aot_module_{0}_info);", str7); } writer.WriteLine("#endif // !(TARGET_IPHONE_SIMULATOR) && !defined(__arm64__)"); writer.WriteLine(""); if (buildTarget == BuildTarget.iOS) { IEnumerator enumerator2 = list.GetEnumerator(); try { while (enumerator2.MoveNext()) { string str8 = (string)enumerator2.Current; writer.WriteLine(" REGISTER_USER_FUNC({0});", str8); } } finally { IDisposable disposable2 = enumerator2 as IDisposable; if (disposable2 != null) { disposable2.Dispose(); } } } writer.WriteLine("}"); writer.WriteLine(""); AssemblyDefinition unityEngine = null; for (int j = 0; j < assemblyFileNames.Length; j++) { if (assemblyFileNames[j] == "UnityEngine.dll") { unityEngine = assemblyDefinitions[j]; } } if (buildTarget == BuildTarget.iOS) { AssemblyDefinition[] assemblies = new AssemblyDefinition[] { unityEngine }; GenerateRegisterInternalCalls(assemblies, writer); ResolveDefinedNativeClassesFromMono(assemblies, usedClassRegistry); ResolveReferencedUnityEngineClassesFromMono(assemblyDefinitions, unityEngine, usedClassRegistry); GenerateRegisterModules(set, set2, writer, stripping); if (stripping && (usedClassRegistry != null)) { GenerateRegisterClassesForStripping(set, writer); } else { GenerateRegisterClasses(set, writer); } } writer.Close(); } }
public static void WriteCPlusPlusFileForStaticAOTModuleRegistration(BuildTarget buildTarget, string file, CrossCompileOptions crossCompileOptions, bool advancedLic, string targetDevice, bool stripping, RuntimeClassRegistry usedClassRegistry, AssemblyReferenceChecker checker, string stagingAreaDataManaged, IIl2CppPlatformProvider platformProvider) { string text = Path.Combine(stagingAreaDataManaged, "ICallSummary.txt"); string exe = Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Tools/InternalCallRegistrationWriter/InternalCallRegistrationWriter.exe"); string args = string.Format("-assembly=\"{0}\" -summary=\"{1}\"", Path.Combine(stagingAreaDataManaged, "UnityEngine.dll"), text); Runner.RunManagedProgram(exe, args); HashSet <UnityType> hashSet; HashSet <string> nativeModules; CodeStrippingUtils.GenerateDependencies(Path.GetDirectoryName(stagingAreaDataManaged), text, usedClassRegistry, stripping, out hashSet, out nativeModules, platformProvider); using (TextWriter textWriter = new StreamWriter(file)) { string[] assemblyFileNames = checker.GetAssemblyFileNames(); AssemblyDefinition[] assemblyDefinitions = checker.GetAssemblyDefinitions(); bool flag = (crossCompileOptions & CrossCompileOptions.FastICall) != CrossCompileOptions.Dynamic; ArrayList arrayList = MonoAOTRegistration.BuildNativeMethodList(assemblyDefinitions); if (buildTarget == BuildTarget.iOS) { textWriter.WriteLine("#include \"RegisterMonoModules.h\""); textWriter.WriteLine("#include <stdio.h>"); } textWriter.WriteLine(""); textWriter.WriteLine("#if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR"); textWriter.WriteLine(" #define DECL_USER_FUNC(f) void f() __attribute__((weak_import))"); textWriter.WriteLine(" #define REGISTER_USER_FUNC(f)\\"); textWriter.WriteLine(" do {\\"); textWriter.WriteLine(" if(f != NULL)\\"); textWriter.WriteLine(" mono_dl_register_symbol(#f, (void*)f);\\"); textWriter.WriteLine(" else\\"); textWriter.WriteLine(" ::printf_console(\"Symbol '%s' not found. Maybe missing implementation for Simulator?\\n\", #f);\\"); textWriter.WriteLine(" }while(0)"); textWriter.WriteLine("#else"); textWriter.WriteLine(" #define DECL_USER_FUNC(f) void f() "); textWriter.WriteLine(" #if !defined(__arm64__)"); textWriter.WriteLine(" #define REGISTER_USER_FUNC(f) mono_dl_register_symbol(#f, (void*)&f)"); textWriter.WriteLine(" #else"); textWriter.WriteLine(" #define REGISTER_USER_FUNC(f)"); textWriter.WriteLine(" #endif"); textWriter.WriteLine("#endif"); textWriter.WriteLine("extern \"C\"\n{"); textWriter.WriteLine(" typedef void* gpointer;"); textWriter.WriteLine(" typedef int gboolean;"); if (buildTarget == BuildTarget.iOS) { textWriter.WriteLine(" const char* UnityIPhoneRuntimeVersion = \"{0}\";", Application.unityVersion); textWriter.WriteLine(" void mono_dl_register_symbol (const char* name, void *addr);"); textWriter.WriteLine("#if !defined(__arm64__)"); textWriter.WriteLine(" extern int mono_ficall_flag;"); textWriter.WriteLine("#endif"); } textWriter.WriteLine(" void mono_aot_register_module(gpointer *aot_info);"); textWriter.WriteLine("#if __ORBIS__ || SN_TARGET_PSP2"); textWriter.WriteLine("#define DLL_EXPORT __declspec(dllexport)"); textWriter.WriteLine("#else"); textWriter.WriteLine("#define DLL_EXPORT"); textWriter.WriteLine("#endif"); textWriter.WriteLine("#if !(TARGET_IPHONE_SIMULATOR)"); textWriter.WriteLine(" extern gboolean mono_aot_only;"); for (int i = 0; i < assemblyFileNames.Length; i++) { string arg = assemblyFileNames[i]; string text2 = assemblyDefinitions[i].Name.Name; text2 = text2.Replace(".", "_"); text2 = text2.Replace("-", "_"); text2 = text2.Replace(" ", "_"); textWriter.WriteLine(" extern gpointer* mono_aot_module_{0}_info; // {1}", text2, arg); } textWriter.WriteLine("#endif // !(TARGET_IPHONE_SIMULATOR)"); IEnumerator enumerator = arrayList.GetEnumerator(); try { while (enumerator.MoveNext()) { string arg2 = (string)enumerator.Current; textWriter.WriteLine(" DECL_USER_FUNC({0});", arg2); } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } textWriter.WriteLine("}"); textWriter.WriteLine("DLL_EXPORT void RegisterMonoModules()"); textWriter.WriteLine("{"); textWriter.WriteLine("#if !(TARGET_IPHONE_SIMULATOR) && !defined(__arm64__)"); textWriter.WriteLine(" mono_aot_only = true;"); if (buildTarget == BuildTarget.iOS) { textWriter.WriteLine(" mono_ficall_flag = {0};", (!flag) ? "false" : "true"); } AssemblyDefinition[] array = assemblyDefinitions; for (int j = 0; j < array.Length; j++) { AssemblyDefinition assemblyDefinition = array[j]; string text3 = assemblyDefinition.Name.Name; text3 = text3.Replace(".", "_"); text3 = text3.Replace("-", "_"); text3 = text3.Replace(" ", "_"); textWriter.WriteLine(" mono_aot_register_module(mono_aot_module_{0}_info);", text3); } textWriter.WriteLine("#endif // !(TARGET_IPHONE_SIMULATOR) && !defined(__arm64__)"); textWriter.WriteLine(""); if (buildTarget == BuildTarget.iOS) { IEnumerator enumerator2 = arrayList.GetEnumerator(); try { while (enumerator2.MoveNext()) { string arg3 = (string)enumerator2.Current; textWriter.WriteLine(" REGISTER_USER_FUNC({0});", arg3); } } finally { IDisposable disposable2; if ((disposable2 = (enumerator2 as IDisposable)) != null) { disposable2.Dispose(); } } } textWriter.WriteLine("}"); textWriter.WriteLine(""); AssemblyDefinition assemblyDefinition2 = null; for (int k = 0; k < assemblyFileNames.Length; k++) { if (assemblyFileNames[k] == "UnityEngine.dll") { assemblyDefinition2 = assemblyDefinitions[k]; } } if (buildTarget == BuildTarget.iOS) { AssemblyDefinition[] assemblies = new AssemblyDefinition[] { assemblyDefinition2 }; MonoAOTRegistration.GenerateRegisterInternalCalls(assemblies, textWriter); MonoAOTRegistration.GenerateRegisterModules(hashSet, nativeModules, textWriter, stripping); if (stripping && usedClassRegistry != null) { MonoAOTRegistration.GenerateRegisterClassesForStripping(hashSet, textWriter); } else { MonoAOTRegistration.GenerateRegisterClasses(hashSet, textWriter); } } textWriter.Close(); } }
protected override Program StartCompiler() { var compilerPath = GetUniversalCompilerPath(); if (compilerPath != null) { if (assembly.GeneratedResponseFile == null) { assembly.GeneratedResponseFile = GenerateResponseFileEdited(assembly, options, tempOutputDirectory); } Program StartCompilerLocal(string compiler) { var p = new Program(CreateOSDependentStartInfo( isWindows: Application.platform == RuntimePlatform.WindowsEditor, processPath: compiler, // Arguments = "/noconfig @" + this.assembly.GeneratedResponseFile, processArguments: $"@{assembly.GeneratedResponseFile}", unityEditorDataDir: MonoInstallationFinder.GetFrameWorksFolder() )); p.Start(); return(p); } var program = StartCompilerLocal(compilerPath); if (!CompilationFlags.checkIfBuildCompiles) { return(program); } var compiledDllName = assembly.Filename.Split('/').Last(); if (compiledDllName != "Assembly-CSharp.dll") { return(program); } program.WaitForExit(); if (program.ExitCode != 0) { return(program); } // message contents are used in CI script, so this shouldnt be changed Debug.Log("Scripts successfully compile in Build mode"); // CI script expects to find log from above if process was killed // sometimes process.Kill() happens faster than Debug.Log() logs our message // sleeping the thread ensures that message was logged before we kill the process Thread.Sleep(5000); Process.GetCurrentProcess().Kill(); throw new Exception("unreachable code"); } else { // fallback to the default compiler. Debug.LogWarning($"Universal C# compiler not found in project directory. Use the default compiler"); return(base.StartCompiler()); } }
public static void MonoLink(BuildTarget buildTarget, string managedLibrariesDirectory, string[] input, string[] allAssemblies, RuntimeClassRegistry usedClasses) { Process process = MonoProcessUtility.PrepareMonoProcess(buildTarget, managedLibrariesDirectory); string buildToolsDirectory = BuildPipeline.GetBuildToolsDirectory(buildTarget); string text = null; string frameWorksFolder = MonoInstallationFinder.GetFrameWorksFolder(); string text2 = Path.Combine(frameWorksFolder, MonoAssemblyStripping.StripperExe()); string text3 = Path.Combine(Path.GetDirectoryName(text2), "link.xml"); string text4 = Path.Combine(managedLibrariesDirectory, "output"); Directory.CreateDirectory(text4); process.StartInfo.Arguments = "\"" + text2 + "\" -l none -c link"; for (int i = 0; i < input.Length; i++) { string str = input[i]; ProcessStartInfo expr_80 = process.StartInfo; expr_80.Arguments = expr_80.Arguments + " -a \"" + str + "\""; } ProcessStartInfo expr_B3 = process.StartInfo; string arguments = expr_B3.Arguments; expr_B3.Arguments = string.Concat(new string[] { arguments, " -out output -x \"", text3, "\" -d \"", managedLibrariesDirectory, "\"" }); string text5 = Path.Combine(buildToolsDirectory, "link.xml"); if (File.Exists(text5)) { ProcessStartInfo expr_110 = process.StartInfo; expr_110.Arguments = expr_110.Arguments + " -x \"" + text5 + "\""; } string text6 = Path.Combine(Path.GetDirectoryName(text2), "Core.xml"); if (File.Exists(text6)) { ProcessStartInfo expr_151 = process.StartInfo; expr_151.Arguments = expr_151.Arguments + " -x \"" + text6 + "\""; } string[] files = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "Assets"), "link.xml", SearchOption.AllDirectories); string[] array = files; for (int j = 0; j < array.Length; j++) { string str2 = array[j]; ProcessStartInfo expr_1A2 = process.StartInfo; expr_1A2.Arguments = expr_1A2.Arguments + " -x \"" + str2 + "\""; } if (usedClasses != null) { text = MonoAssemblyStripping.GenerateBlackList(managedLibrariesDirectory, usedClasses, allAssemblies); ProcessStartInfo expr_1E6 = process.StartInfo; expr_1E6.Arguments = expr_1E6.Arguments + " -x \"" + text + "\""; } MonoProcessUtility.RunMonoProcess(process, "assemblies stripper", Path.Combine(text4, "mscorlib.dll")); MonoAssemblyStripping.DeleteAllDllsFrom(managedLibrariesDirectory); MonoAssemblyStripping.CopyAllDlls(managedLibrariesDirectory, text4); string[] files2 = Directory.GetFiles(managedLibrariesDirectory); for (int k = 0; k < files2.Length; k++) { string text7 = files2[k]; if (text7.Contains(".mdb")) { string path = text7.Replace(".mdb", string.Empty); if (!File.Exists(path)) { FileUtil.DeleteFileOrDirectory(text7); } } } if (text != null) { FileUtil.DeleteFileOrDirectory(Path.Combine(managedLibrariesDirectory, text)); } FileUtil.DeleteFileOrDirectory(text4); }
// Copy of MonoCSharpCompiler.StartCompiler() // The only reason it exists is to call the new implementation // of GetCompilerPath(...) which is non-virtual unfortunately. protected override Program StartCompiler() { var arguments = new List <string> { "-debug", "-target:library", "-nowarn:0169", "-out:" + PrepareFileName(island._output), "-unsafe" }; arguments.Add("-define:" + COMPILER_DEFINE); var unity5References = GetAdditionalReferences(); if (unity5References != null) { foreach (string path in unity5References) { var text = Path.Combine(GetProfileDirectoryViaReflection(), path); if (File.Exists(text)) { arguments.Add("-r:" + PrepareFileName(text)); } } } foreach (var define in island._defines.Distinct()) { arguments.Add("-define:" + define); } foreach (var file in island._files) { arguments.Add(PrepareFileName(file)); } foreach (string fileName in island._references) { arguments.Add("-r:" + PrepareFileName(fileName)); } if (!island._development_player && (!buildingForEditor() || !EditorPrefs.GetBool("AllowAttachedDebuggingOfEditor", true))) { arguments.Add("-optimize+"); } else { arguments.Add("-optimize-"); } var universalCompilerPath = GetUniversalCompilerPath(); if (universalCompilerPath != null) { // use universal compiler. arguments.Add("-define:__UNITY_PROCESSID__" + System.Diagnostics.Process.GetCurrentProcess().Id); // this function should be run because it adds an item to arguments //var compilerPath = GetCompilerPath(arguments); var rspFileName = "Assets/mcs.rsp"; if (File.Exists(rspFileName)) { arguments.Add("@" + rspFileName); } //else //{ // var defaultCompilerName = Path.GetFileNameWithoutExtension(compilerPath); // rspFileName = "Assets/" + defaultCompilerName + ".rsp"; // if (File.Exists(rspFileName)) // arguments.Add("@" + rspFileName); //} // Replaced following line to use newer mono runtime for compiler // var program = StartCompiler(island._target, universalCompilerPath, arguments); // Side effect: API updater is disabled // Disabled API updater Program StartCompilerLocal(BuildTarget target, string compiler, List <string> arguments_) { AddCustomResponseFileIfPresent(arguments, Path.GetFileNameWithoutExtension(compiler) + ".rsp"); var responseFile = CommandLineFormatter.GenerateResponseFile(arguments_); var p = new Program(CreateOSDependentStartInfo( isWindows: Application.platform == RuntimePlatform.WindowsEditor, processPath: compiler, processArguments: " @" + responseFile, unityEditorDataDir: MonoInstallationFinder.GetFrameWorksFolder() )); p.Start(); return(p); } var program = StartCompilerLocal(island._target, universalCompilerPath, arguments); if (!CompilationFlags.checkIfBuildCompiles) { return(program); } var compiledDllName = island._output.Split('/').Last(); if (compiledDllName != "Assembly-CSharp.dll") { return(program); } program.WaitForExit(); if (program.ExitCode != 0) { return(program); } // message contents are used in CI script, so this shouldnt be changed Debug.Log("Scripts successfully compile in Build mode"); // CI script expects to find log from above if process was killed // sometimes process.Kill() happens faster than Debug.Log() logs our message // sleeping the thread ensures that message was logged before we kill the process Thread.Sleep(5000); Process.GetCurrentProcess().Kill(); throw new Exception("unreachable code"); } else { // fallback to the default compiler. Debug.LogWarning($"Universal C# compiler not found in project directory. Use the default compiler"); return(base.StartCompiler()); } }
public static bool WeaveUNetInto(string assemblyPath, string destPath, string unityEngine, string unityUNet) { string text = Weaver.CommandLineArgsFor(assemblyPath, destPath, unityEngine); text = text + " -unity-unet=" + unityUNet; string frameWorksFolder = MonoInstallationFinder.GetFrameWorksFolder(); Console.Write(string.Concat(new string[] { "WeaveUNetInto ", assemblyPath, " using ", frameWorksFolder, "/UNetWeaver/UNetWeaver.exe ", text })); bool result; using (ManagedProgram managedProgram = Weaver.UNetWeaverProgramWith(text, frameWorksFolder)) { try { managedProgram.Start(); } catch { managedProgram.LogProcessStartInfo(); throw new Exception("Could not start UNetWeaver.exe"); } managedProgram.WaitForExit(); Console.Write(managedProgram.GetAllOutput()); if (managedProgram.ExitCode == 0) { string allOutput = managedProgram.GetAllOutput(); string text2 = "COMPILE_WARNING "; string[] array = allOutput.Split(new char[] { '\n' }); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text3 = array2[i]; if (text3.Length >= text2.Length) { if (text3.Substring(0, text2.Length) == text2) { string msg = text3.Substring(text2.Length); EditorApplication.ReportUNetWeaver("file", msg, false); } } } result = true; } else { string allOutput2 = managedProgram.GetAllOutput(); string text4 = "COMPILE_ERROR "; string text5 = "COMPILE_WARNING "; string[] array3 = allOutput2.Split(new char[] { '\n' }); string[] array4 = array3; for (int j = 0; j < array4.Length; j++) { string text6 = array4[j]; if (text6.Length >= text5.Length) { if (text6.Substring(0, text4.Length) == text4) { string msg2 = text6.Substring(text4.Length); EditorApplication.ReportUNetWeaver("file", msg2, true); } if (text6.Substring(0, text5.Length) == text5) { string msg3 = text6.Substring(text5.Length); EditorApplication.ReportUNetWeaver("file", msg3, false); } } } result = false; } } return(result); }
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); }
public static void MonoLink(BuildTarget buildTarget, string managedLibrariesDirectory, string[] input, string[] allAssemblies, RuntimeClassRegistry usedClasses) { Process process = MonoProcessUtility.PrepareMonoProcess(buildTarget, managedLibrariesDirectory); string buildToolsDirectory = BuildPipeline.GetBuildToolsDirectory(buildTarget); string path2 = (string)null; string path1 = Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), MonoAssemblyStripping.StripperExe()); string str1 = Path.Combine(Path.GetDirectoryName(path1), "link.xml"); string str2 = Path.Combine(managedLibrariesDirectory, "output"); Directory.CreateDirectory(str2); process.StartInfo.Arguments = "\"" + path1 + "\" -l none -c link"; foreach (string str3 in input) { ProcessStartInfo startInfo = process.StartInfo; string str4 = startInfo.Arguments + " -a \"" + str3 + "\""; startInfo.Arguments = str4; } ProcessStartInfo startInfo1 = process.StartInfo; string str5 = startInfo1.Arguments + " -out output -x \"" + str1 + "\" -d \"" + managedLibrariesDirectory + "\""; startInfo1.Arguments = str5; string path3 = Path.Combine(buildToolsDirectory, "link.xml"); if (File.Exists(path3)) { ProcessStartInfo startInfo2 = process.StartInfo; string str3 = startInfo2.Arguments + " -x \"" + path3 + "\""; startInfo2.Arguments = str3; } string path4 = Path.Combine(Path.GetDirectoryName(path1), "Core.xml"); if (File.Exists(path4)) { ProcessStartInfo startInfo2 = process.StartInfo; string str3 = startInfo2.Arguments + " -x \"" + path4 + "\""; startInfo2.Arguments = str3; } foreach (string file in Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "Assets"), "link.xml", SearchOption.AllDirectories)) { ProcessStartInfo startInfo2 = process.StartInfo; string str3 = startInfo2.Arguments + " -x \"" + file + "\""; startInfo2.Arguments = str3; } if (usedClasses != null) { path2 = MonoAssemblyStripping.GenerateBlackList(managedLibrariesDirectory, usedClasses, allAssemblies); ProcessStartInfo startInfo2 = process.StartInfo; string str3 = startInfo2.Arguments + " -x \"" + path2 + "\""; startInfo2.Arguments = str3; } foreach (string file in Directory.GetFiles(Path.Combine(BuildPipeline.GetPlaybackEngineDirectory(EditorUserBuildSettings.activeBuildTarget, BuildOptions.None), "Whitelists"), "*.xml")) { ProcessStartInfo startInfo2 = process.StartInfo; string str3 = startInfo2.Arguments + " -x \"" + file + "\""; startInfo2.Arguments = str3; } MonoProcessUtility.RunMonoProcess(process, "assemblies stripper", Path.Combine(str2, "mscorlib.dll")); MonoAssemblyStripping.DeleteAllDllsFrom(managedLibrariesDirectory); MonoAssemblyStripping.CopyAllDlls(managedLibrariesDirectory, str2); foreach (string file in Directory.GetFiles(managedLibrariesDirectory)) { if (file.Contains(".mdb") && !File.Exists(file.Replace(".mdb", string.Empty))) { FileUtil.DeleteFileOrDirectory(file); } } if (path2 != null) { FileUtil.DeleteFileOrDirectory(Path.Combine(managedLibrariesDirectory, path2)); } FileUtil.DeleteFileOrDirectory(str2); }