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 = IL2CPPUtils.GetAdditionalArguments(); 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); }
private void ConvertPlayerDlltoCpp(Il2CppBuildPipelineData data, string outputDirectory, string workingDirectory, bool platformSupportsManagedDebugging) { ProcessBuildPipelineOnBeforeConvertRun(m_PlatformProvider.buildReport, data); 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.development && m_PlatformProvider.enableDeepProfilingSupport) { arguments.Add("--enable-deep-profiler"); } if (m_BuildForMonoRuntime) { arguments.Add("--mono-runtime"); } var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(m_PlatformProvider.target); var apiCompatibilityLevel = PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup); arguments.Add(string.Format("--dotnetprofile=\"{0}\"", IL2CPPUtils.ApiCompatibilityLevelToDotNetProfileArgument(apiCompatibilityLevel))); 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.AddRange(IL2CPPUtils.GetDebuggerIL2CPPArguments(m_PlatformProvider, buildTargetGroup)); arguments.AddRange(IL2CPPUtils.GetBuildingIL2CPPArguments(m_PlatformProvider, buildTargetGroup)); arguments.Add($"--map-file-parser={CommandLineFormatter.PrepareFileName(GetMapFileParserPath())}"); var additionalArgs = IL2CPPUtils.GetAdditionalArguments(); if (!string.IsNullOrEmpty(additionalArgs)) { arguments.Add(additionalArgs); } arguments.Add($"--directory={CommandLineFormatter.PrepareFileName(Path.GetFullPath(data.inputDirectory))}"); arguments.Add($"--generatedcppdir={CommandLineFormatter.PrepareFileName(Path.GetFullPath(outputDirectory))}"); // NOTE: any arguments added here that affect how generated code is built need // to also be added to PlatformDependent\Win\Extensions\Managed\VisualStudioProjectHelpers.cs // as that file generated project files that invoke back into IL2CPP in order to build // generated code 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($"--extra-types-file={CommandLineFormatter.PrepareFileName(tempFile)}"); } RunIl2CppWithArguments(arguments, setupStartInfo, workingDirectory); }
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(Il2CppBuildPipelineData data) { 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.development && m_PlatformProvider.enableDeepProfilingSupport) { arguments.Add("--enable-deep-profiler"); } if (m_BuildForMonoRuntime) { arguments.Add("--mono-runtime"); } var apiCompatibilityLevel = PlayerSettings.GetApiCompatibilityLevel(m_PlatformProvider.namedBuildTarget); arguments.Add(string.Format("--dotnetprofile=\"{0}\"", IL2CPPUtils.ApiCompatibilityLevelToDotNetProfileArgument(apiCompatibilityLevel, m_PlatformProvider.target))); var il2cppCodeGeneration = PlayerSettings.GetIl2CppCodeGeneration(m_PlatformProvider.namedBuildTarget); if (il2cppCodeGeneration == Il2CppCodeGeneration.OptimizeSize) { arguments.Add("--generics-option=EnableFullSharing"); } var il2CppNativeCodeBuilder = m_PlatformProvider.CreateIl2CppNativeCodeBuilder(); if (il2CppNativeCodeBuilder != null) { var buildCacheNativeOutputFile = Path.Combine(GetNativeOutputRelativeDirectory(m_PlatformProvider.il2cppBuildCacheDirectory), m_PlatformProvider.nativeLibraryFileName); var compilerConfiguration = PlayerSettings.GetIl2CppCompilerConfiguration(m_PlatformProvider.namedBuildTarget); Il2CppNativeCodeBuilderUtils.ClearAndPrepareCacheDirectory(il2CppNativeCodeBuilder); arguments.AddRange(Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, buildCacheNativeOutputFile, m_PlatformProvider.includePaths, m_PlatformProvider.libraryPaths, compilerConfiguration)); } else { arguments.Add($"--cachedirectory={CommandLineFormatter.PrepareFileName(GetShortPathName(Path.GetFullPath(m_PlatformProvider.il2cppBuildCacheDirectory)))}"); } // Additional files can take any form, depending on platform, so pass anything in the additional files directory foreach (var additionalCppFile in Directory.GetFiles(GetAdditionalCppFilesDirectory(m_PlatformProvider.il2cppBuildCacheDirectory))) { arguments.Add($"--additional-cpp={CommandLineFormatter.PrepareFileName(GetShortPathName(Path.GetFullPath(additionalCppFile)))}"); } arguments.AddRange(IL2CPPUtils.GetDebuggerIL2CPPArguments(m_PlatformProvider)); foreach (var buildingArgument in IL2CPPUtils.GetBuildingIL2CPPArguments(m_PlatformProvider)) { if (!arguments.Contains(buildingArgument)) { arguments.Add(buildingArgument); } } if (CrashReportingSettings.enabled) { arguments.Add($"--emit-source-mapping"); } var additionalArgs = IL2CPPUtils.GetAdditionalArguments(); if (!string.IsNullOrEmpty(additionalArgs)) { arguments.Add(additionalArgs); } arguments.Add($"--directory={CommandLineFormatter.PrepareFileName(GetShortPathName(Path.GetFullPath(data.inputDirectory)))}"); arguments.Add($"--generatedcppdir={CommandLineFormatter.PrepareFileName(GetCppOutputDirectory(m_PlatformProvider.il2cppBuildCacheDirectory))}"); // NOTE: any arguments added here that affect how generated code is built need // to also be added to PlatformDependent\Win\Extensions\Managed\VisualStudioProjectHelpers.cs // as that file generated project files that invoke back into IL2CPP in order to build // generated code 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($"--extra-types-file={CommandLineFormatter.PrepareFileName(tempFile)}"); } RunIl2CppWithArguments(arguments, setupStartInfo); }