public static void CleanIl2CppArgs() { const string Il2CppCommand_AdditionalCpp = "--additional-cpp"; string arguments = PlayerSettings.GetAdditionalIl2CppArgs(); string newArguments = arguments; foreach (string path in AdditionalIl2CppFiles()) { // Match on basename only in case the temp file location has moved string basename = Regex.Escape(Path.GetFileName(path)); Regex regex = new Regex(Il2CppCommand_AdditionalCpp + "=\"[^\"]*" + basename + "\""); for (int startIndex = 0; startIndex < newArguments.Length;) { Match match = regex.Match(newArguments, startIndex); if (!match.Success) { break; } RuntimeUtils.DebugLogFormat("FMOD: Removing Il2CPP argument '{0}'", match.Value); int matchStart = match.Index; int matchEnd = match.Index + match.Length; // Consume an adjacent space if there is one if (matchStart > 0 && newArguments[matchStart - 1] == ' ') { --matchStart; } else if (matchEnd < newArguments.Length && newArguments[matchEnd] == ' ') { ++matchEnd; } newArguments = newArguments.Substring(0, matchStart) + newArguments.Substring(matchEnd); startIndex = matchStart; } } if (newArguments != arguments) { PlayerSettings.SetAdditionalIl2CppArgs(newArguments); } }
internal static string GetAdditionalArguments() { var arguments = new List <string>(); var additionalArgs = PlayerSettings.GetAdditionalIl2CppArgs(); if (!string.IsNullOrEmpty(additionalArgs)) { arguments.Add(additionalArgs); } additionalArgs = System.Environment.GetEnvironmentVariable("IL2CPP_ADDITIONAL_ARGS"); if (!string.IsNullOrEmpty(additionalArgs)) { arguments.Add(additionalArgs); } additionalArgs = Debug.GetDiagnosticSwitch("VMIl2CppAdditionalArgs") as string; if (!string.IsNullOrEmpty(additionalArgs)) { arguments.Add(additionalArgs); } return(arguments.Aggregate(String.Empty, (current, arg) => current + arg + " ")); }
private static void UpdateIl2CppArgs() { string[] filePaths = { RegisterStaticPluginsTempFilePath, Application.dataPath + "/Plugins/FMOD/src/Runtime/" + StaticPluginsSupportHeader, }; string arguments = PlayerSettings.GetAdditionalIl2CppArgs(); string newArguments = arguments; foreach (string path in filePaths) { // Match on basename only in case the temp file location has moved string basename = Path.GetFileName(path); Regex regex = new Regex(Il2CppCommand_AdditionalCpp + "=\"([^\"]*" + basename + ")\""); bool pathFound = false; for (int startIndex = 0; startIndex < newArguments.Length;) { Match match = regex.Match(newArguments, startIndex); if (!match.Success) { break; } int matchEnd = match.Index + match.Length; if (!pathFound && match.Groups[1].Value == path) { pathFound = true; startIndex = matchEnd; } else { Debug.LogFormat("FMOD: Removing Il2CPP argument '{0}'", match.Value); int matchStart = match.Index; // Consume an adjacent space if there is one if (matchStart > 0 && newArguments[matchStart - 1] == ' ') { --matchStart; } else if (matchEnd < newArguments.Length && newArguments[matchEnd] == ' ') { ++matchEnd; } newArguments = newArguments.Substring(0, matchStart) + newArguments.Substring(matchEnd); startIndex = matchStart; } } if (!pathFound) { string newArgument = string.Format("{0}=\"{1}\"", Il2CppCommand_AdditionalCpp, path); Debug.LogFormat("FMOD: Adding Il2CPP argument '{0}'", newArgument); if (string.IsNullOrEmpty(newArguments)) { newArguments = newArgument; } else { newArguments += " " + newArgument; } } } if (newArguments != arguments) { PlayerSettings.SetAdditionalIl2CppArgs(newArguments); } }
private void ConvertPlayerDlltoCpp(ICollection <string> userAssemblies, string outputDirectory, string workingDirectory, bool platformSupportsManagedDebugging) { if (userAssemblies.Count == 0) { return; } var arguments = new List <string>(); arguments.Add("--convert-to-cpp"); if (m_PlatformProvider.emitNullChecks) { arguments.Add("--emit-null-checks"); } if (m_PlatformProvider.enableStackTraces) { arguments.Add("--enable-stacktrace"); } if (m_PlatformProvider.enableArrayBoundsCheck) { arguments.Add("--enable-array-bounds-check"); } if (m_PlatformProvider.enableDivideByZeroCheck) { arguments.Add("--enable-divide-by-zero-check"); } if (m_PlatformProvider.developmentMode) { arguments.Add("--development-mode"); } if (m_BuildForMonoRuntime) { arguments.Add("--mono-runtime"); } var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(m_PlatformProvider.target); if (PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup) == ApiCompatibilityLevel.NET_4_6) { arguments.Add("--dotnetprofile=\"unityjit\""); } if (PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup) == ApiCompatibilityLevel.NET_Standard_2_0) { arguments.Add("--dotnetprofile=\"unityaot\""); } if (EditorUserBuildSettings.allowDebugging && platformSupportsManagedDebugging && EditorApplication.scriptingRuntimeVersion == ScriptingRuntimeVersion.Latest) { arguments.Add("--enable-debugger"); } var il2CppNativeCodeBuilder = m_PlatformProvider.CreateIl2CppNativeCodeBuilder(); if (il2CppNativeCodeBuilder != null) { var useDebugBuild = PlayerSettings.GetIl2CppCompilerConfiguration(buildTargetGroup) == Il2CppCompilerConfiguration.Debug; Il2CppNativeCodeBuilderUtils.ClearAndPrepareCacheDirectory(il2CppNativeCodeBuilder); arguments.AddRange(Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, OutputFileRelativePath(), m_PlatformProvider.includePaths, useDebugBuild)); } arguments.Add(string.Format("--map-file-parser=\"{0}\"", GetMapFileParserPath())); var additionalArgs = PlayerSettings.GetAdditionalIl2CppArgs(); if (!string.IsNullOrEmpty(additionalArgs)) { arguments.Add(additionalArgs); } additionalArgs = System.Environment.GetEnvironmentVariable("IL2CPP_ADDITIONAL_ARGS"); if (!string.IsNullOrEmpty(additionalArgs)) { arguments.Add(additionalArgs); } var pathArguments = new List <string>(userAssemblies); arguments.AddRange(pathArguments.Select(arg => "--assembly=\"" + Path.GetFullPath(arg) + "\"")); arguments.Add(string.Format("--generatedcppdir=\"{0}\"", Path.GetFullPath(outputDirectory))); string progressMessage = "Converting managed assemblies to C++"; if (il2CppNativeCodeBuilder != null) { progressMessage = "Building native binary with IL2CPP..."; } if (EditorUtility.DisplayCancelableProgressBar("Building Player", progressMessage, 0.3f)) { throw new OperationCanceledException(); } Action <ProcessStartInfo> setupStartInfo = null; if (il2CppNativeCodeBuilder != null) { setupStartInfo = il2CppNativeCodeBuilder.SetupStartInfo; } if (PlayerBuildInterface.ExtraTypesProvider != null) { var extraTypes = new HashSet <string>(); foreach (var extraType in PlayerBuildInterface.ExtraTypesProvider()) { extraTypes.Add(extraType); } var tempFile = Path.GetFullPath(Path.Combine(m_TempFolder, "extra-types.txt")); File.WriteAllLines(tempFile, extraTypes.ToArray()); arguments.Add(string.Format("--extra-types-file=\"{0}\"", tempFile)); } RunIl2CppWithArguments(arguments, setupStartInfo, 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(string inputDirectory, string outputDirectory, string workingDirectory, bool platformSupportsManagedDebugging) { var arguments = new List <string>(); arguments.Add("--convert-to-cpp"); if (m_PlatformProvider.emitNullChecks) { arguments.Add("--emit-null-checks"); } if (m_PlatformProvider.enableStackTraces) { arguments.Add("--enable-stacktrace"); } if (m_PlatformProvider.enableArrayBoundsCheck) { arguments.Add("--enable-array-bounds-check"); } if (m_PlatformProvider.enableDivideByZeroCheck) { arguments.Add("--enable-divide-by-zero-check"); } if (m_BuildForMonoRuntime) { arguments.Add("--mono-runtime"); } var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(m_PlatformProvider.target); arguments.Add(string.Format("--dotnetprofile=\"{0}\"", IL2CPPUtils.ApiCompatibilityLevelToDotNetProfileArgument(PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup)))); if (IL2CPPUtils.EnableIL2CPPDebugger(m_PlatformProvider, buildTargetGroup) && platformSupportsManagedDebugging) { arguments.Add("--enable-debugger"); } var il2CppNativeCodeBuilder = m_PlatformProvider.CreateIl2CppNativeCodeBuilder(); if (il2CppNativeCodeBuilder != null) { var compilerConfiguration = PlayerSettings.GetIl2CppCompilerConfiguration(buildTargetGroup); Il2CppNativeCodeBuilderUtils.ClearAndPrepareCacheDirectory(il2CppNativeCodeBuilder); arguments.AddRange(Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, OutputFileRelativePath(), m_PlatformProvider.includePaths, m_PlatformProvider.libraryPaths, compilerConfiguration)); } arguments.Add(string.Format("--map-file-parser=\"{0}\"", GetMapFileParserPath())); var additionalArgs = PlayerSettings.GetAdditionalIl2CppArgs(); if (!string.IsNullOrEmpty(additionalArgs)) { arguments.Add(additionalArgs); } additionalArgs = System.Environment.GetEnvironmentVariable("IL2CPP_ADDITIONAL_ARGS"); if (!string.IsNullOrEmpty(additionalArgs)) { arguments.Add(additionalArgs); } additionalArgs = Debug.GetDiagnosticSwitch("VMIl2CppAdditionalArgs") as string; if (!string.IsNullOrEmpty(additionalArgs)) { arguments.Add(additionalArgs); } arguments.Add("--directory=\"" + Path.GetFullPath(inputDirectory) + "\""); arguments.Add(string.Format("--generatedcppdir=\"{0}\"", Path.GetFullPath(outputDirectory))); string progressMessage = "Converting managed assemblies to C++"; if (il2CppNativeCodeBuilder != null) { progressMessage = "Building native binary with IL2CPP..."; } if (EditorUtility.DisplayCancelableProgressBar("Building Player", progressMessage, 0.3f)) { throw new OperationCanceledException(); } Action <ProcessStartInfo> setupStartInfo = null; if (il2CppNativeCodeBuilder != null) { setupStartInfo = il2CppNativeCodeBuilder.SetupStartInfo; } if (PlayerBuildInterface.ExtraTypesProvider != null) { var extraTypes = new HashSet <string>(); foreach (var extraType in PlayerBuildInterface.ExtraTypesProvider()) { extraTypes.Add(extraType); } var tempFile = Path.GetFullPath(Path.Combine(m_TempFolder, "extra-types.txt")); File.WriteAllLines(tempFile, extraTypes.ToArray()); arguments.Add(string.Format("--extra-types-file=\"{0}\"", tempFile)); } RunIl2CppWithArguments(arguments, setupStartInfo, workingDirectory); }
public static void BuildTo(BuildConfiguration buildConfiguration, string path) { var buildTarget = EditorUserBuildSettings.activeBuildTarget; var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget); /* * Debug * Develop * Release */ void ProfileConfiguration(ClassicBuildProfile profile, string s) => profile.Configuration = (BuildType)Enum.Parse(typeof(BuildType), s, true); SetBuildComponentValue <ClassicBuildProfile>(buildConfiguration, "-BUILD_PROFILE_CONFIGURATION", ProfileConfiguration); /* * Mono2x * IL2CPP * WinRTDotNET */ void ScriptingBackend(ClassicScriptingSettings profile, string s) => profile.ScriptingBackend = (ScriptingImplementation)Enum.Parse(typeof(ScriptingImplementation), s, true); SetBuildComponentValue <ClassicScriptingSettings>(buildConfiguration, "-BUILD_SCRIPTING_BACKEND", ScriptingBackend); /* * Debug * Release * Master */ void Il2CppCompilerConfiguration(ClassicScriptingSettings profile, string s) => profile.Il2CppCompilerConfiguration = (Il2CppCompilerConfiguration)Enum.Parse(typeof(Il2CppCompilerConfiguration), s, true);; SetBuildComponentValue <ClassicScriptingSettings>(buildConfiguration, "-BUILD_SCRIPTING_IL2CPP_CONFIGURATION", Il2CppCompilerConfiguration); var graphicsJobs = PlayerSettings.graphicsJobs; try { PlayerSettings.graphicsJobs = bool.Parse(CommandLineArguments.ReadArgValue("-GRAPHICS_JOBS")); Debug.Log($"[{typeof(ScriptableBuildPipeline)}] PlayerSettings.graphicsJobs = {PlayerSettings.graphicsJobs}"); } catch (CommandLineArguments.CommandLineArgumentNotFoundException) { /*Ignore*/ } try { var version = CommandLineArguments.ReadArgValue("-BUILD_NUMBER"); PlayerSettings.bundleVersion = version; if (buildTarget == BuildTarget.iOS || Application.platform == RuntimePlatform.OSXPlayer) { PlayerSettings.iOS.buildNumber = version; } if (buildTarget == BuildTarget.Android) { var match = new Regex(@"^(\d{1})\.(\d{1})\.(\d{1,3})$").Match(version); if (!match.Success) { throw new InvalidOperationException($"BUILD_NUMBER {version} is not in the format #{{1}}.#{{1}}.#{{1-3}} for conversion to Android bundleVersionCode"); } int bundleVersionCode = 0; bundleVersionCode += int.Parse(match.Groups[1].Value) * 10000; bundleVersionCode += int.Parse(match.Groups[2].Value) * 1000; bundleVersionCode += int.Parse(match.Groups[3].Value); PlayerSettings.Android.bundleVersionCode = bundleVersionCode; } } catch (CommandLineArguments.CommandLineArgumentNotFoundException) { /*Ignore*/ } var additionalil2CppArgs = PlayerSettings.GetAdditionalIl2CppArgs(); try { if (CommandLineArguments.IsArgumentPresent("-BUILD_SCRIPTING_IL2CPP_DISABLE_JUMP_THREADING_OPTIMISER")) { PlayerSettings.SetAdditionalIl2CppArgs(additionalil2CppArgs + " --compiler-flags=-d2ssa-cfg-jt-"); Debug.Log($"[{typeof(ScriptableBuildPipeline)}] PlayerSettings.additionalIl2CppArgs = {PlayerSettings.GetAdditionalIl2CppArgs()}"); } } catch (CommandLineArguments.CommandLineArgumentNotFoundException) { /*Ignore*/ } var applicationIdentifier = PlayerSettings.applicationIdentifier; try { PlayerSettings.SetApplicationIdentifier(buildTargetGroup, CommandLineArguments.ReadArgValue("-APPLICATION_IDENTIFIER")); Debug.Log($"[{typeof(ScriptableBuildPipeline)}] PlayerSettings.applicationIdentifier = {PlayerSettings.GetApplicationIdentifier(buildTargetGroup)}"); } catch (CommandLineArguments.CommandLineArgumentNotFoundException) { /*Ignore*/ } var outputBuildDirectory = buildConfiguration.GetComponentOrDefault <OutputBuildDirectory>(); outputBuildDirectory.OutputDirectory = path; buildConfiguration.RemoveComponent <OutputBuildDirectory>(); buildConfiguration.SetComponent(outputBuildDirectory); Debug.Log($"[{typeof(ScriptableBuildPipeline)}] {typeof(OutputBuildDirectory)} OutputBuildDirectory = {path}"); try { Debug.Log($"[{nameof(ScriptableBuildPipeline)}] Building to {buildConfiguration.GetOutputBuildDirectory()}"); buildConfiguration.Build(); Debug.Log($"[{nameof(ScriptableBuildPipeline)}] Completed building to {buildConfiguration.GetOutputBuildDirectory()}"); buildConfiguration.RestoreAsset(); } finally { // Restore settings PlayerSettings.graphicsJobs = graphicsJobs; PlayerSettings.SetAdditionalIl2CppArgs(additionalil2CppArgs); PlayerSettings.SetApplicationIdentifier(buildTargetGroup, applicationIdentifier); } }
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); } }
public static void AdditionalIl2CppArgs() { //PlayerSettings.SetAdditionalIl2CppArgs(""); //PlayerSettings.SetAdditionalIl2CppArgs("-O3 -g0 -DUNITY_WEBGL=1 -s PRECISE_F32=2 -s NO_EXIT_RUNTIME=1 -s USE_WEBGL2=1 -s FULL_ES3=1 -s DISABLE_EXCEPTION_CATCHING=0 -s TOTAL_MEMORY=268435456 --memory-init-file 1 --emit-symbol-map --separate-asm --output_eol linux"); Debug.Log(PlayerSettings.GetAdditionalIl2CppArgs()); }