AddBuilderArguments() публичный статический Метод

public static AddBuilderArguments ( Il2CppNativeCodeBuilder builder, string outputRelativePath, IEnumerable includeRelativePaths ) : IEnumerable
builder Il2CppNativeCodeBuilder
outputRelativePath string
includeRelativePaths IEnumerable
Результат IEnumerable
Пример #1
0
        public void RunCompileAndLink()
        {
            var il2CppNativeCodeBuilder = m_PlatformProvider.CreateIl2CppNativeCodeBuilder();

            if (il2CppNativeCodeBuilder != null)
            {
                Il2CppNativeCodeBuilderUtils.ClearAndPrepareCacheDirectory(il2CppNativeCodeBuilder);

                var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(m_PlatformProvider.target);
                var useDebugBuild    = PlayerSettings.GetIl2CppCompilerConfiguration(buildTargetGroup) == Il2CppCompilerConfiguration.Debug;
                var arguments        = Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, OutputFileRelativePath(), m_PlatformProvider.includePaths, useDebugBuild).ToList();

                arguments.Add(string.Format("--map-file-parser=\"{0}\"", GetMapFileParserPath()));
                arguments.Add(string.Format("--generatedcppdir=\"{0}\"", Path.GetFullPath(GetCppOutputDirectoryInStagingArea())));
                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\"");
                }
                Action <ProcessStartInfo> setupStartInfo = il2CppNativeCodeBuilder.SetupStartInfo;
                var managedDir = Path.GetFullPath(Path.Combine(m_StagingAreaData, "Managed"));

                RunIl2CppWithArguments(arguments, setupStartInfo, managedDir);
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        public void RunCompileAndLink()
        {
            var il2CppNativeCodeBuilder = m_PlatformProvider.CreateIl2CppNativeCodeBuilder();

            if (il2CppNativeCodeBuilder != null)
            {
                Il2CppNativeCodeBuilderUtils.ClearAndPrepareCacheDirectory(il2CppNativeCodeBuilder);

                var buildTargetGroup      = BuildPipeline.GetBuildTargetGroup(m_PlatformProvider.target);
                var compilerConfiguration = PlayerSettings.GetIl2CppCompilerConfiguration(buildTargetGroup);
                var arguments             = Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, OutputFileRelativePath(), m_PlatformProvider.includePaths, m_PlatformProvider.libraryPaths, compilerConfiguration).ToList();

                var additionalArgs = IL2CPPUtils.GetAdditionalArguments();
                if (!string.IsNullOrEmpty(additionalArgs))
                {
                    arguments.Add(additionalArgs);
                }

                arguments.Add($"--map-file-parser={CommandLineFormatter.PrepareFileName(GetMapFileParserPath())}");
                arguments.Add($"--generatedcppdir={CommandLineFormatter.PrepareFileName(GetShortPathName(Path.GetFullPath(GetCppOutputDirectoryInStagingArea())))}");
                arguments.Add(string.Format("--dotnetprofile=\"{0}\"", IL2CPPUtils.ApiCompatibilityLevelToDotNetProfileArgument(PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup))));
                arguments.AddRange(IL2CPPUtils.GetDebuggerIL2CPPArguments(m_PlatformProvider, buildTargetGroup));
                Action <ProcessStartInfo> setupStartInfo = il2CppNativeCodeBuilder.SetupStartInfo;
                var managedDir = Path.GetFullPath(Path.Combine(m_StagingAreaData, "Managed"));

                RunIl2CppWithArguments(arguments, setupStartInfo, managedDir);
            }
        }
Пример #4
0
        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);
            }
        }
Пример #5
0
        public void RunCompileAndLink(string il2cppBuildCacheSource)
        {
            if (string.Equals(Path.GetFullPath(il2cppBuildCacheSource), Path.GetFullPath(m_PlatformProvider.il2cppBuildCacheDirectory), StringComparison.OrdinalIgnoreCase))
            {
                throw new ArgumentException("IIl2CppPlatformProvider.il2cppBuildCacheDirectory cannot be the same as il2cppBuildCacheDirectory. You probably forgot to override il2cppBuildCacheDirectory on your IIl2CppPlatformProvider.");
            }

            var il2CppNativeCodeBuilder = m_PlatformProvider.CreateIl2CppNativeCodeBuilder();

            if (il2CppNativeCodeBuilder != null)
            {
                Il2CppNativeCodeBuilderUtils.ClearAndPrepareCacheDirectory(il2CppNativeCodeBuilder);

                var buildCacheDirectory = m_PlatformProvider.il2cppBuildCacheDirectory;
                Directory.CreateDirectory(buildCacheDirectory);

                var buildCacheNativeOutputFile = Path.Combine(GetNativeOutputRelativeDirectory(buildCacheDirectory), m_PlatformProvider.nativeLibraryFileName);
                var buildTargetGroup           = BuildPipeline.GetBuildTargetGroup(m_PlatformProvider.target);
                var compilerConfiguration      = PlayerSettings.GetIl2CppCompilerConfiguration(buildTargetGroup);
                var arguments = Il2CppNativeCodeBuilderUtils.AddBuilderArguments(il2CppNativeCodeBuilder, buildCacheNativeOutputFile, m_PlatformProvider.includePaths, m_PlatformProvider.libraryPaths, compilerConfiguration).ToList();

                var additionalArgs = IL2CPPUtils.GetAdditionalArguments();
                if (!string.IsNullOrEmpty(additionalArgs))
                {
                    arguments.Add(additionalArgs);
                }

                foreach (var buildingArgument in IL2CPPUtils.GetBuildingIL2CPPArguments(m_PlatformProvider, buildTargetGroup))
                {
                    if (!arguments.Contains(buildingArgument))
                    {
                        arguments.Add(buildingArgument);
                    }
                }

                arguments.Add($"--generatedcppdir={CommandLineFormatter.PrepareFileName(GetCppOutputDirectory(il2cppBuildCacheSource))}");
                arguments.Add($"--dotnetprofile=\"{IL2CPPUtils.ApiCompatibilityLevelToDotNetProfileArgument(PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup), m_PlatformProvider.target)}\"");
                arguments.AddRange(IL2CPPUtils.GetDebuggerIL2CPPArguments(m_PlatformProvider, buildTargetGroup));
                Action <ProcessStartInfo> setupStartInfo = il2CppNativeCodeBuilder.SetupStartInfo;

                RunIl2CppWithArguments(arguments, setupStartInfo);
            }
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
 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);
     }
 }
Пример #9
0
        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);
        }
Пример #10
0
        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);
        }
Пример #11
0
        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);
        }
Пример #12
0
 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);
     }
 }