public void RunCompileAndLink() { Il2CppNativeCodeBuilder il2CppNativeCodeBuilder = this.m_PlatformProvider.CreateIl2CppNativeCodeBuilder(); if (il2CppNativeCodeBuilder != null) { Il2CppNativeCodeBuilderUtils.ClearAndPrepareCacheDirectory(il2CppNativeCodeBuilder); BuildTargetGroup buildTargetGroup = BuildPipeline.GetBuildTargetGroup(this.m_PlatformProvider.target); bool debugBuild = PlayerSettings.GetIl2CppCompilerConfiguration(buildTargetGroup) == Il2CppCompilerConfiguration.Debug; List <string> list = Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, this.OutputFileRelativePath(), this.m_PlatformProvider.includePaths, debugBuild).ToList <string>(); list.Add(string.Format("--map-file-parser=\"{0}\"", IL2CPPBuilder.GetMapFileParserPath())); list.Add(string.Format("--generatedcppdir=\"{0}\"", Path.GetFullPath(this.GetCppOutputDirectoryInStagingArea()))); if (PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup) == ApiCompatibilityLevel.NET_4_6) { list.Add("--dotnetprofile=\"net45\""); } if (PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup) == ApiCompatibilityLevel.NET_Standard_2_0) { list.Add("--dotnetprofile=\"unityaot\""); } Action <ProcessStartInfo> setupStartInfo = new Action <ProcessStartInfo>(il2CppNativeCodeBuilder.SetupStartInfo); string fullPath = Path.GetFullPath(Path.Combine(this.m_StagingAreaData, "Managed")); this.RunIl2CppWithArguments(list, setupStartInfo, fullPath); } }
public static void ClearAndPrepareCacheDirectory(Il2CppNativeCodeBuilder builder) { string fullUnityVersion = InternalEditorUtility.GetFullUnityVersion(); ClearCacheIfEditorVersionDiffers(builder, fullUnityVersion); PrepareCacheDirectory(builder, fullUnityVersion); }
public static IEnumerable <string> AddBuilderArguments(Il2CppNativeCodeBuilder builder, string outputRelativePath, IEnumerable <string> includeRelativePaths) { List <string> list = new List <string>(); list.Add("--compile-cpp"); list.Add("--libil2cpp-static"); list.Add(Il2CppNativeCodeBuilderUtils.FormatArgument("platform", builder.CompilerPlatform)); list.Add(Il2CppNativeCodeBuilderUtils.FormatArgument("architecture", builder.CompilerArchitecture)); list.Add(Il2CppNativeCodeBuilderUtils.FormatArgument("configuration", "Release")); list.Add(Il2CppNativeCodeBuilderUtils.FormatArgument("outputpath", builder.ConvertOutputFileToFullPath(outputRelativePath))); if (!string.IsNullOrEmpty(builder.CacheDirectory)) { list.Add(Il2CppNativeCodeBuilderUtils.FormatArgument("cachedirectory", Il2CppNativeCodeBuilderUtils.CacheDirectoryPathFor(builder.CacheDirectory))); } if (!string.IsNullOrEmpty(builder.CompilerFlags)) { list.Add(Il2CppNativeCodeBuilderUtils.FormatArgument("compiler-flags", builder.CompilerFlags)); } if (!string.IsNullOrEmpty(builder.LinkerFlags)) { list.Add(Il2CppNativeCodeBuilderUtils.FormatArgument("linker-flags", builder.LinkerFlags)); } if (!string.IsNullOrEmpty(builder.PluginPath)) { list.Add(Il2CppNativeCodeBuilderUtils.FormatArgument("plugin", builder.PluginPath)); } foreach (string current in builder.ConvertIncludesToFullPaths(includeRelativePaths)) { list.Add(Il2CppNativeCodeBuilderUtils.FormatArgument("additional-include-directories", current)); } list.AddRange(builder.AdditionalIl2CPPArguments); return(list); }
public static IEnumerable <string> AddBuilderArguments(Il2CppNativeCodeBuilder builder, string outputRelativePath, IEnumerable <string> includeRelativePaths, IEnumerable <string> additionalLibs, Il2CppCompilerConfiguration compilerConfiguration) { var arguments = new List <string>(); arguments.Add("--compile-cpp"); if (builder.LinkLibIl2CppStatically) { arguments.Add("--libil2cpp-static"); } arguments.Add(FormatArgument("platform", builder.CompilerPlatform)); arguments.Add(FormatArgument("architecture", builder.CompilerArchitecture)); // In IL2CPP, Master config is called "ReleasePlus" string configurationName = compilerConfiguration != Il2CppCompilerConfiguration.Master ? compilerConfiguration.ToString() : "ReleasePlus"; arguments.Add(FormatArgument("configuration", configurationName)); arguments.Add(FormatArgument("outputpath", builder.ConvertOutputFileToFullPath(outputRelativePath))); if (!string.IsNullOrEmpty(builder.CacheDirectory) && !builder.OverriddenCacheDirectory) { arguments.Add(FormatArgument("cachedirectory", CacheDirectoryPathFor(builder.CacheDirectory))); } if (!string.IsNullOrEmpty(builder.CompilerFlags)) { arguments.Add(FormatArgument("compiler-flags", builder.CompilerFlags)); } if (!string.IsNullOrEmpty(builder.LinkerFlags)) { arguments.Add(FormatArgument("linker-flags", builder.LinkerFlags)); } if (!string.IsNullOrEmpty(builder.PluginPath)) { arguments.Add(FormatArgument("plugin", builder.PluginPath)); } foreach (var includePath in builder.ConvertIncludesToFullPaths(includeRelativePaths)) { arguments.Add(FormatArgument("additional-include-directories", includePath)); } foreach (var library in additionalLibs) { arguments.Add(FormatArgument("additional-libraries", library)); } if (!string.IsNullOrEmpty(builder.BaselibLibraryDirectory)) { arguments.Add(FormatArgument("baselib-directory", builder.BaselibLibraryDirectory)); } arguments.Add("--avoid-dynamic-library-copy"); arguments.AddRange(builder.AdditionalIl2CPPArguments); return(arguments); }
public static void ClearCacheIfEditorVersionDiffers(Il2CppNativeCodeBuilder builder, string currentEditorVersion) { string path = CacheDirectoryPathFor(builder.CacheDirectory); if (Directory.Exists(path) && !File.Exists(Path.Combine(builder.CacheDirectory, EditorVersionFilenameFor(currentEditorVersion)))) { Directory.Delete(path, true); } }
public static void ClearCacheIfEditorVersionDiffers(Il2CppNativeCodeBuilder builder, string currentEditorVersion) { string text = Il2CppNativeCodeBuilderUtils.CacheDirectoryPathFor(builder.CacheDirectory); if (Directory.Exists(text) && !File.Exists(Path.Combine(text, currentEditorVersion))) { Directory.Delete(text, true); } }
public static void PrepareCacheDirectory(Il2CppNativeCodeBuilder builder, string currentEditorVersion) { string path = Il2CppNativeCodeBuilderUtils.CacheDirectoryPathFor(builder.CacheDirectory); Directory.CreateDirectory(path); string path2 = Path.Combine(builder.CacheDirectory, Il2CppNativeCodeBuilderUtils.EditorVersionFilenameFor(currentEditorVersion)); if (!File.Exists(path2)) { File.Create(path2).Dispose(); } }
public static void PrepareCacheDirectory(Il2CppNativeCodeBuilder builder, string currentEditorVersion) { var cacheDirectoryPath = CacheDirectoryPathFor(builder.CacheDirectory); Directory.CreateDirectory(cacheDirectoryPath); var versionFilePath = Path.Combine(builder.CacheDirectory, EditorVersionFilenameFor(currentEditorVersion)); if (!File.Exists(versionFilePath)) { File.Create(versionFilePath).Dispose(); } }
public static void PrepareCacheDirectory(Il2CppNativeCodeBuilder builder, string currentEditorVersion) { string text = Il2CppNativeCodeBuilderUtils.CacheDirectoryPathFor(builder.CacheDirectory); Directory.CreateDirectory(text); string path = Path.Combine(text, currentEditorVersion); if (!File.Exists(path)) { File.Create(path).Dispose(); } }
public static IEnumerable <string> AddBuilderArguments(Il2CppNativeCodeBuilder builder, string outputRelativePath, IEnumerable <string> includeRelativePaths, bool debugBuild) { var arguments = new List <string>(); arguments.Add("--compile-cpp"); if (builder.LinkLibIl2CppStatically) { arguments.Add("--libil2cpp-static"); } arguments.Add(FormatArgument("platform", builder.CompilerPlatform)); arguments.Add(FormatArgument("architecture", builder.CompilerArchitecture)); if (debugBuild) { arguments.Add(FormatArgument("configuration", "Debug")); } else { arguments.Add(FormatArgument("configuration", "Release")); } arguments.Add(FormatArgument("outputpath", builder.ConvertOutputFileToFullPath(outputRelativePath))); if (!string.IsNullOrEmpty(builder.CacheDirectory)) { arguments.Add(FormatArgument("cachedirectory", CacheDirectoryPathFor(builder.CacheDirectory))); } if (!string.IsNullOrEmpty(builder.CompilerFlags)) { arguments.Add(FormatArgument("compiler-flags", builder.CompilerFlags)); } if (!string.IsNullOrEmpty(builder.LinkerFlags)) { arguments.Add(FormatArgument("linker-flags", builder.LinkerFlags)); } if (!string.IsNullOrEmpty(builder.PluginPath)) { arguments.Add(FormatArgument("plugin", builder.PluginPath)); } foreach (var includePath in builder.ConvertIncludesToFullPaths(includeRelativePaths)) { arguments.Add(FormatArgument("additional-include-directories", includePath)); } arguments.AddRange(builder.AdditionalIl2CPPArguments); return(arguments); }
public void RunCompileAndLink() { Il2CppNativeCodeBuilder il2CppNativeCodeBuilder = this.m_PlatformProvider.CreateIl2CppNativeCodeBuilder(); if (il2CppNativeCodeBuilder != null) { Il2CppNativeCodeBuilderUtils.ClearAndPrepareCacheDirectory(il2CppNativeCodeBuilder); List <string> list = Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, this.OutputFileRelativePath(), this.m_PlatformProvider.includePaths).ToList <string>(); list.Add(string.Format("--generatedcppdir=\"{0}\"", Path.GetFullPath(this.GetCppOutputDirectoryInStagingArea()))); Action <ProcessStartInfo> setupStartInfo = new Action <ProcessStartInfo>(il2CppNativeCodeBuilder.SetupStartInfo); string fullPath = Path.GetFullPath(Path.Combine(this.m_StagingAreaData, "Managed")); this.RunIl2CppWithArguments(list, setupStartInfo, fullPath); } }
public static void PrepareCacheDirectory(Il2CppNativeCodeBuilder builder, string currentEditorVersion) { var cacheDirectoryPath = CacheDirectoryPathFor(builder.CacheDirectory); Directory.CreateDirectory(cacheDirectoryPath); foreach (var previousEditorVersionFile in Directory.GetFiles(builder.CacheDirectory, EditorVersionFilenameFor("*"))) { File.Delete(previousEditorVersionFile); } var versionFilePath = Path.Combine(builder.CacheDirectory, EditorVersionFilenameFor(currentEditorVersion)); if (!File.Exists(versionFilePath)) { File.Create(versionFilePath).Dispose(); } }
public static IEnumerable <string> AddBuilderArguments(Il2CppNativeCodeBuilder builder, string outputRelativePath, IEnumerable <string> includeRelativePaths, IEnumerable <string> additionalLibs, Il2CppCompilerConfiguration compilerConfiguration) { var arguments = new List <string>(); arguments.Add("--compile-cpp"); if (builder.LinkLibIl2CppStatically) { arguments.Add("--libil2cpp-static"); } arguments.Add(FormatArgument("platform", builder.CompilerPlatform)); arguments.Add(FormatArgument("architecture", builder.CompilerArchitecture)); arguments.Add(FormatArgument("configuration", GetConfigurationName(compilerConfiguration))); arguments.Add(FormatArgument("outputpath", builder.ConvertOutputFileToFullPath(outputRelativePath))); string cacheDirectory = null; if (!string.IsNullOrEmpty(builder.CacheDirectory) && !builder.OverriddenCacheDirectory) { cacheDirectory = IL2CPPBuilder.GetShortPathName(CacheDirectoryPathFor(builder.CacheDirectory)); arguments.Add(FormatArgument("cachedirectory", cacheDirectory)); } if (!string.IsNullOrEmpty(builder.CompilerFlags)) { arguments.Add(FormatArgument("compiler-flags", builder.CompilerFlags)); } if (!string.IsNullOrEmpty(builder.LinkerFlags)) { if (cacheDirectory == null) { throw new ArgumentException("If you pass linkerflags, a cachedirectory also needs to be passed."); } NPath templinkerflagsTxt = $"{cacheDirectory}/linkerflags/linkerflags.txt"; templinkerflagsTxt.WriteAllText(builder.LinkerFlags); arguments.Add(FormatArgument("linker-flags-file", templinkerflagsTxt.ToString())); } if (!string.IsNullOrEmpty(builder.PluginPath)) { arguments.Add(FormatArgument("plugin", builder.PluginPath)); } foreach (var includePath in builder.ConvertIncludesToFullPaths(includeRelativePaths)) { arguments.Add(FormatArgument("additional-include-directories", includePath)); } foreach (var library in additionalLibs) { arguments.Add(FormatArgument("additional-libraries", library)); } if (!string.IsNullOrEmpty(builder.BaselibLibraryDirectory)) { arguments.Add(FormatArgument("baselib-directory", builder.BaselibLibraryDirectory)); } arguments.Add("--avoid-dynamic-library-copy"); arguments.AddRange(builder.AdditionalIl2CPPArguments); return(arguments); }
private void ConvertPlayerDlltoCpp(ICollection <string> userAssemblies, string outputDirectory, string workingDirectory) { if (userAssemblies.Count != 0) { string[] array = (from s in Directory.GetFiles("Assets", "il2cpp_extra_types.txt", SearchOption.AllDirectories) select Path.Combine(Directory.GetCurrentDirectory(), s)).ToArray <string>(); List <string> list = new List <string>(); list.Add("--convert-to-cpp"); 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.enableDivideByZeroCheck) { list.Add("--enable-divide-by-zero-check"); } if (this.m_PlatformProvider.loadSymbols) { list.Add("--enable-symbol-loading"); } if (this.m_PlatformProvider.developmentMode) { list.Add("--development-mode"); } Il2CppNativeCodeBuilder il2CppNativeCodeBuilder = this.m_PlatformProvider.CreateIl2CppNativeCodeBuilder(); if (il2CppNativeCodeBuilder != null) { Il2CppNativeCodeBuilderUtils.ClearAndPrepareCacheDirectory(il2CppNativeCodeBuilder); list.AddRange(Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, this.OutputFileRelativePath(), this.m_PlatformProvider.includePaths, this.m_DebugBuild)); } list.Add(string.Format("--map-file-parser=\"{0}\"", IL2CPPBuilder.GetMapFileParserPath())); 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 = PlayerSettings.GetAdditionalIl2CppArgs(); if (!string.IsNullOrEmpty(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))); if (EditorUtility.DisplayCancelableProgressBar("Building Player", "Converting managed assemblies to C++", 0.3f)) { throw new OperationCanceledException(); } Action <ProcessStartInfo> setupStartInfo = null; if (il2CppNativeCodeBuilder != null) { setupStartInfo = new Action <ProcessStartInfo>(il2CppNativeCodeBuilder.SetupStartInfo); } this.RunIl2CppWithArguments(list, setupStartInfo, workingDirectory); } }
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, BuildTargetGroup buildTargetGroup, ManagedStrippingLevel managedStrippingLevel, bool stripEngineCode, string editorToLinkerDataPath) { if (!Directory.Exists(outputFolder)) { Directory.CreateDirectory(outputFolder); } additionalBlacklist = additionalBlacklist.Select(s => Path.IsPathRooted(s) ? s : Path.Combine(workingDirectory, s)).Where(File.Exists); var userBlackLists = GetUserBlacklistFiles(); foreach (var ub in userBlackLists) { Console.WriteLine("UserBlackList: " + ub); } additionalBlacklist = additionalBlacklist.Concat(userBlackLists); var args = new List <string> { $"-out={CommandLineFormatter.PrepareFileName(outputFolder)}", }; if (!UseUnityLinkerEngineModuleStripping) { args.Add($"-x={CommandLineFormatter.PrepareFileName(GetModuleWhitelist("Core", platformProvider.moduleStrippingInformationFolder))}"); } args.AddRange(additionalBlacklist.Select(path => $"-x={CommandLineFormatter.PrepareFileName(path)}")); args.AddRange(searchDirs.Select(d => $"-d={CommandLineFormatter.PrepareFileName(d)}")); args.AddRange(assemblies.Select(assembly => $"--include-unity-root-assembly={CommandLineFormatter.PrepareFileName(Path.GetFullPath(assembly))}")); args.Add($"--dotnetruntime={GetRuntimeArgumentValueForLinker(buildTargetGroup)}"); args.Add($"--dotnetprofile={GetProfileArgumentValueForLinker(buildTargetGroup)}"); args.Add("--use-editor-options"); args.Add($"--include-directory={CommandLineFormatter.PrepareFileName(workingDirectory)}"); if (EditorUserBuildSettings.allowDebugging) { args.Add("--editor-settings-flag=AllowDebugging"); } if (EditorUserBuildSettings.development) { args.Add("--editor-settings-flag=Development"); } args.Add($"--rule-set={GetRuleSetForStrippingLevel(managedStrippingLevel)}"); args.Add($"--editor-data-file={CommandLineFormatter.PrepareFileName(editorToLinkerDataPath)}"); var compilerPlatform = ""; var compilerArchitecture = ""; Il2CppNativeCodeBuilder il2cppNativeCodeBuilder = platformProvider.CreateIl2CppNativeCodeBuilder(); if (il2cppNativeCodeBuilder != null) { compilerPlatform = il2cppNativeCodeBuilder.CompilerPlatform; compilerArchitecture = il2cppNativeCodeBuilder.CompilerArchitecture; } else { // When the scripting backend is not IL2CPP, we have to map those strings and use a utility function to figure out proper strings. GetUnityLinkerPlatformStringsFromBuildTarget(platformProvider.target, out compilerPlatform, out compilerArchitecture); } args.Add($"--platform={compilerPlatform}"); if (!string.IsNullOrEmpty(compilerArchitecture)) { args.Add($"--architecture={compilerArchitecture}"); } if (!UseUnityLinkerEngineModuleStripping) { args.Add("--disable-engine-module-support"); } if (stripEngineCode) { args.Add("--enable-engine-module-stripping"); if (UnityEngine.Connect.UnityConnectSettings.enabled) { args.Add("--engine-stripping-flag=EnableUnityConnect"); } if (UnityEngine.Analytics.PerformanceReporting.enabled) { args.Add("--engine-stripping-flag=EnablePerformanceReporting"); } if (UnityEngine.Analytics.Analytics.enabled) { args.Add("--engine-stripping-flag=EnableAnalytics"); } if (UnityEditor.CrashReporting.CrashReportingSettings.enabled) { args.Add("--engine-stripping-flag=EnableCrashReporting"); } if (UnityEditorInternal.VR.VRModule.ShouldInjectVRDependenciesForBuildTarget(platformProvider.target)) { args.Add("--engine-stripping-flag=EnableVR"); } } var modulesAssetPath = Path.Combine(platformProvider.moduleStrippingInformationFolder, "../modules.asset"); if (File.Exists(modulesAssetPath)) { args.Add($"--engine-modules-asset-file={CommandLineFormatter.PrepareFileName(modulesAssetPath)}"); } var additionalArgs = System.Environment.GetEnvironmentVariable("UNITYLINKER_ADDITIONAL_ARGS"); if (!string.IsNullOrEmpty(additionalArgs)) { args.Add(additionalArgs); } additionalArgs = Debug.GetDiagnosticSwitch("VMUnityLinkerAdditionalArgs") as string; if (!string.IsNullOrEmpty(additionalArgs)) { args.Add(additionalArgs.Trim('\'')); } return(RunAssemblyLinker(args, out output, out error, linkerPath, workingDirectory)); }
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, BuildTargetGroup buildTargetGroup, ManagedStrippingLevel managedStrippingLevel) { if (!Directory.Exists(outputFolder)) { Directory.CreateDirectory(outputFolder); } additionalBlacklist = additionalBlacklist.Select(s => Path.IsPathRooted(s) ? s : Path.Combine(workingDirectory, s)).Where(File.Exists); var userBlackLists = GetUserBlacklistFiles(); foreach (var ub in userBlackLists) { Console.WriteLine("UserBlackList: " + ub); } additionalBlacklist = additionalBlacklist.Concat(userBlackLists); var args = new List <string> { "-out=\"" + outputFolder + "\"", "-x=\"" + GetModuleWhitelist("Core", platformProvider.moduleStrippingInformationFolder) + "\"", }; args.AddRange(additionalBlacklist.Select(path => "-x \"" + path + "\"")); args.AddRange(searchDirs.Select(d => "-d \"" + d + "\"")); args.AddRange(assemblies.Select(assembly => "--include-unity-root-assembly=\"" + Path.GetFullPath(assembly) + "\"")); args.Add($"--dotnetruntime={GetRuntimeArgumentValueForLinker(buildTargetGroup)}"); args.Add($"--dotnetprofile={GetProfileArgumentValueForLinker(buildTargetGroup)}"); args.Add("--use-editor-options"); args.Add($"--include-directory={CommandLineFormatter.PrepareFileName(workingDirectory)}"); if (EditorUserBuildSettings.allowDebugging) { args.Add("--editor-settings-flag=AllowDebugging"); } if (EditorUserBuildSettings.development) { args.Add("--editor-settings-flag=Development"); } args.Add($"--rule-set={GetRuleSetForStrippingLevel(managedStrippingLevel)}"); // One final check to make sure we only run high on latest runtime. if ((managedStrippingLevel == ManagedStrippingLevel.High) && (PlayerSettingsEditor.IsLatestApiCompatibility(PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup)))) { // Prepare the arguments to run the UnityLinker. When in high mode, need to also // supply the IL2CPP compiler platform and compiler architecture. When the scripting backend // is not IL2CPP, we have to map those strings and use a utility function to figure out proper strings. // Currently only need to do this on the non aot platforms of Android, Windows, Mac, Linux. var compilerPlatform = ""; var compilerArchitecture = ""; Il2CppNativeCodeBuilder il2cppNativeCodeBuilder = platformProvider.CreateIl2CppNativeCodeBuilder(); if (il2cppNativeCodeBuilder != null) { compilerPlatform = il2cppNativeCodeBuilder.CompilerPlatform; compilerArchitecture = il2cppNativeCodeBuilder.CompilerArchitecture; } else { GetUnityLinkerPlatformStringsFromBuildTarget(platformProvider.target, out compilerPlatform, out compilerArchitecture); } args.Add($"--platform={compilerPlatform}"); if (platformProvider.target != BuildTarget.Android) { args.Add($"--architecture={compilerArchitecture}"); } } var additionalArgs = System.Environment.GetEnvironmentVariable("UNITYLINKER_ADDITIONAL_ARGS"); if (!string.IsNullOrEmpty(additionalArgs)) { args.Add(additionalArgs); } additionalArgs = Debug.GetDiagnosticSwitch("VMUnityLinkerAdditionalArgs") as string; if (!string.IsNullOrEmpty(additionalArgs)) { args.Add(additionalArgs.Trim('\'')); } return(RunAssemblyLinker(args, out output, out error, linkerPath, workingDirectory)); }
private void ConvertPlayerDlltoCpp(ICollection <string> userAssemblies, string outputDirectory, string workingDirectory) { if (userAssemblies.Count != 0) { List <string> list = new List <string>(); list.Add("--convert-to-cpp"); 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.enableDivideByZeroCheck) { list.Add("--enable-divide-by-zero-check"); } if (this.m_PlatformProvider.developmentMode) { list.Add("--development-mode"); } BuildTargetGroup buildTargetGroup = BuildPipeline.GetBuildTargetGroup(this.m_PlatformProvider.target); if (PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup) == ApiCompatibilityLevel.NET_4_6) { list.Add("--dotnetprofile=\"net45\""); } Il2CppNativeCodeBuilder il2CppNativeCodeBuilder = this.m_PlatformProvider.CreateIl2CppNativeCodeBuilder(); if (il2CppNativeCodeBuilder != null) { Il2CppNativeCodeBuilderUtils.ClearAndPrepareCacheDirectory(il2CppNativeCodeBuilder); list.AddRange(Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, this.OutputFileRelativePath(), this.m_PlatformProvider.includePaths, this.m_DebugBuild)); } list.Add(string.Format("--map-file-parser=\"{0}\"", IL2CPPBuilder.GetMapFileParserPath())); string text = PlayerSettings.GetAdditionalIl2CppArgs(); if (!string.IsNullOrEmpty(text)) { list.Add(text); } text = Environment.GetEnvironmentVariable("IL2CPP_ADDITIONAL_ARGS"); if (!string.IsNullOrEmpty(text)) { list.Add(text); } 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 info = "Converting managed assemblies to C++"; if (il2CppNativeCodeBuilder != null) { info = "Building native binary with IL2CPP..."; } if (EditorUtility.DisplayCancelableProgressBar("Building Player", info, 0.3f)) { throw new OperationCanceledException(); } Action <ProcessStartInfo> setupStartInfo = null; if (il2CppNativeCodeBuilder != null) { setupStartInfo = new Action <ProcessStartInfo>(il2CppNativeCodeBuilder.SetupStartInfo); } this.RunIl2CppWithArguments(list, setupStartInfo, workingDirectory); } }
private void ConvertPlayerDlltoCpp(ICollection <string> userAssemblies, string outputDirectory, string workingDirectory) { 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"); 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.enableDivideByZeroCheck) { list.Add("--enable-divide-by-zero-check"); } if (this.m_PlatformProvider.loadSymbols) { list.Add("--enable-symbol-loading"); } if (this.m_PlatformProvider.developmentMode) { list.Add("--development-mode"); } Il2CppNativeCodeBuilder il2CppNativeCodeBuilder = this.m_PlatformProvider.CreateIl2CppNativeCodeBuilder(); if (il2CppNativeCodeBuilder != null) { string fullUnityVersion = InternalEditorUtility.GetFullUnityVersion(); Il2CppNativeCodeBuilderUtils.ClearCacheIfEditorVersionDiffers(il2CppNativeCodeBuilder, fullUnityVersion); Il2CppNativeCodeBuilderUtils.PrepareCacheDirectory(il2CppNativeCodeBuilder, fullUnityVersion); list.AddRange(Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, this.OutputFileRelativePath(), this.m_PlatformProvider.includePaths)); } 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(); } Action <ProcessStartInfo> setupStartInfo = null; if (il2CppNativeCodeBuilder != null) { setupStartInfo = new Action <ProcessStartInfo>(il2CppNativeCodeBuilder.SetupStartInfo); } Runner.RunManagedProgram(il2CppExe, text3, workingDirectory, new Il2CppOutputParser(), setupStartInfo); }