Exemplo n.º 1
0
    public override void UpdateBootConfig(BuildTarget target, BootConfigData config, BuildOptions options)
    {
        base.UpdateBootConfig(target, config, options);

        if (PlayerSettings.forceSingleInstance)
        {
            config.AddKey("single-instance");
        }
        if (!PlayerSettings.useFlipModelSwapchain)
        {
            config.AddKey("force-d3d11-bltblt-mode");
        }
        if (IL2CPPUtils.UseIl2CppCodegenWithMonoBackend(BuildPipeline.GetBuildTargetGroup(target)))
        {
            config.Set("mono-codegen", "il2cpp");
        }
        if ((options & BuildOptions.EnableHeadlessMode) != 0)
        {
            config.AddKey("headless");
        }
        if ((options & BuildOptions.EnableCodeCoverage) != 0)
        {
            config.Set("enableCodeCoverage", "1");
        }
        if (!PlayerSettings.usePlayerLog)
        {
            config.AddKey("nolog");
        }
    }
Exemplo n.º 2
0
 protected virtual void SetupStagingArea()
 {
     Directory.CreateDirectory(this.DataFolder);
     this.CopyNativePlugins();
     this.CopyVirtualRealityDependencies();
     PostprocessBuildPlayer.InstallStreamingAssets(this.DataFolder);
     if (this.UseIl2Cpp)
     {
         this.CopyVariationFolderIntoStagingArea();
         string text  = this.StagingArea + "/Data";
         string text2 = this.DataFolder + "/Managed";
         string text3 = text2 + "/Resources";
         string text4 = text2 + "/Metadata";
         IL2CPPUtils.RunIl2Cpp(text, this.GetPlatformProvider(this.m_PostProcessArgs.target), delegate(string s)
         {
         }, this.m_PostProcessArgs.usedClassRegistry, this.Development);
         FileUtil.CreateOrCleanDirectory(text3);
         IL2CPPUtils.CopyEmbeddedResourceFiles(text, text3);
         FileUtil.CreateOrCleanDirectory(text4);
         IL2CPPUtils.CopyMetadataFiles(text, text4);
         IL2CPPUtils.CopySymmapFile(text + "/Native", text2);
     }
     if (this.InstallingIntoBuildsFolder)
     {
         this.CopyDataForBuildsFolder();
         return;
     }
     if (!this.UseIl2Cpp)
     {
         this.CopyVariationFolderIntoStagingArea();
     }
     this.RenameFilesInStagingArea();
 }
Exemplo n.º 3
0
        public static BeeDriver Make(RunnableProgram buildProgram, string dagName,
                                     string dagDirectory, bool useScriptUpdater, string projectDirectory, ProgressAPI progressAPI = null, RunnableProgram beeBackendProgram = null)
        {
            var sourceFileUpdaters = useScriptUpdater
                ? new[] { new UnityScriptUpdater(projectDirectory) }
            : Array.Empty <SourceFileUpdaterBase>();

            var processSourceFileUpdatersResult = new UnitySourceFileUpdatersResultHandler();

            NPath dagDir = dagDirectory ?? "Library/Bee";

            RecreateDagDirectoryIfNeeded(dagDir);
            NPath profilerOutputFile = UnityBeeDriverProfilerSession.GetTraceEventsOutputForNewBeeDriver() ?? $"{dagDir}/fullprofile.json";
            var   result             = new BeeDriver(buildProgram, beeBackendProgram ?? UnityBeeBackendProgram(), projectDirectory, dagName, dagDir.ToString(), sourceFileUpdaters, processSourceFileUpdatersResult, progressAPI ?? new UnityProgressAPI("Script Compilation"), profilerOutputFile: profilerOutputFile.ToString());

            result.DataForBuildProgram.Add(new ConfigurationData
            {
                Il2CppDir           = IL2CPPUtils.GetIl2CppFolder(),
                Il2CppPath          = IL2CPPUtils.GetExePath("il2cpp"),
                UnityLinkerPath     = IL2CPPUtils.GetExePath("UnityLinker"),
                NetCoreRunPath      = NetCoreRunProgram.NetCoreRunPath,
                EditorContentsPath  = EditorApplication.applicationContentsPath,
                Packages            = GetPackageInfos(NPath.CurrentDirectory.ToString()),
                UnityVersion        = Application.unityVersion,
                UnityVersionNumeric = new BeeBuildProgramCommon.Data.Version(Application.unityVersionVer, Application.unityVersionMaj, Application.unityVersionMin),
                UnitySourceCodePath = Unsupported.IsSourceBuild(false) ? Unsupported.GetBaseUnityDeveloperFolder() : null,
                AdvancedLicense     = PlayerSettings.advancedLicense,
                Batchmode           = InternalEditorUtility.inBatchMode,
                EmitDataForBeeWhy   = (Debug.GetDiagnosticSwitch("EmitDataForBeeWhy").value as bool?) ?? false,
            });
            return(result);
        }
        private static void WriteIl2CppOutputProjectFile(
            BuildTargetGroup buildTargetGroup,
            string projectTemplate,
            string projectItems,
            string filterItems,
            string targetPath,
            string additionalDefines,
            IIl2CppPlatformProvider il2cppPlatformProvider)
        {
            string[]             buildingIl2CppArguments = IL2CPPUtils.GetBuildingIL2CPPArguments(il2cppPlatformProvider, buildTargetGroup);
            string[]             debuggerIl2CppArguments = IL2CPPUtils.GetDebuggerIL2CPPArguments(il2cppPlatformProvider, buildTargetGroup);
            string               str1               = ((IEnumerable <string>)debuggerIl2CppArguments).Any <string>() ? ((IEnumerable <string>)debuggerIl2CppArguments).Aggregate <string>((Func <string, string, string>)((x, y) => x + " " + y)) : string.Empty;
            IEnumerable <string> second             = ((IEnumerable <string>)additionalDefines.Split(';')).Select <string, string>((Func <string, string>)(d => "--additional-defines=" + d));
            string               str2               = ((IEnumerable <string>)buildingIl2CppArguments).Concat <string>(second).Aggregate <string>((Func <string, string, string>)((x, y) => x + " " + y));
            string               netProfileArgument = IL2CPPUtils.ApiCompatibilityLevelToDotNetProfileArgument(PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup));
            string               str3               = ((IEnumerable <string>)IL2CPPUtils.GetBuilderDefinedDefines(il2cppPlatformProvider, buildTargetGroup)).Aggregate <string>((Func <string, string, string>)((x, y) => x + ";" + y)) + ";" + additionalDefines;
            string               contents1          = string.Format(projectTemplate, (object)projectItems, (object)str3, (object)str2, (object)netProfileArgument, (object)str1);

            FileUtil.DeleteFileOrDirectory(targetPath);
            File.WriteAllText(targetPath, contents1, Encoding.UTF8);
            string path      = targetPath + ".filters";
            string contents2 = string.Format(VisualStudioProjectHelpers.GetFiltersTemplate(), (object)filterItems);

            FileUtil.DeleteFileOrDirectory(path);
            File.WriteAllText(path, contents2, Encoding.UTF8);
        }
Exemplo n.º 5
0
 protected virtual void SetupStagingArea()
 {
     Directory.CreateDirectory(this.DataFolder);
     this.CopyNativePlugins();
     this.CopyVirtualRealityDependencies();
     PostprocessBuildPlayer.InstallStreamingAssets(this.DataFolder);
     if (this.UseIl2Cpp)
     {
         this.CopyVariationFolderIntoStagingArea();
         string str1 = this.StagingArea + "/Data";
         string destinationFolder = this.DataFolder + "/Managed";
         string str2 = destinationFolder + "/Resources";
         string str3 = destinationFolder + "/Metadata";
         IL2CPPUtils.RunIl2Cpp(str1, this.GetPlatformProvider(this.m_PostProcessArgs.target), (System.Action <string>)(s => {}), this.m_PostProcessArgs.usedClassRegistry, this.Development);
         FileUtil.CreateOrCleanDirectory(str2);
         IL2CPPUtils.CopyEmbeddedResourceFiles(str1, str2);
         FileUtil.CreateOrCleanDirectory(str3);
         IL2CPPUtils.CopyMetadataFiles(str1, str3);
         IL2CPPUtils.CopySymmapFile(str1 + "/Native", destinationFolder);
     }
     if (this.InstallingIntoBuildsFolder)
     {
         this.CopyDataForBuildsFolder();
     }
     else
     {
         if (!this.UseIl2Cpp)
         {
             this.CopyVariationFolderIntoStagingArea();
         }
         this.RenameFilesInStagingArea();
     }
 }
Exemplo n.º 6
0
        private void CopySymbolMap(string stagingArea, string assetsDataData, AndroidTargetDeviceType targetDeviceType)
        {
            string[] components        = new string[] { assetsDataData, "Managed" };
            string   destinationFolder = Paths.Combine(components);

            IL2CPPUtils.CopySymmapFile(Path.Combine(Path.Combine(Path.Combine(stagingArea, "libs"), targetDeviceType.ABI), "Data"), destinationFolder, "-" + targetDeviceType.Architecture);
        }
Exemplo n.º 7
0
    private void ProcessIl2CppOutputForSolution(BuildPostProcessArgs args, IIl2CppPlatformProvider il2cppPlatformProvider, IEnumerable <string> cppPlugins)
    {
        if (EditorUtility.DisplayCancelableProgressBar("Building Player", "Copying IL2CPP related files", 0.1f))
        {
            throw new OperationCanceledException();
        }

        // Move managed assemblies
        var projectName = GetPathSafeProductName(args);

        FileUtil.MoveFileOrDirectory(args.stagingAreaDataManaged, Paths.Combine(args.stagingArea, projectName, "Managed"));

        // Move il2cpp data
        var il2cppOutputPath = IL2CPPBuilder.GetCppOutputPath(args.stagingAreaData);
        var il2cppDataSource = Path.Combine(il2cppOutputPath, "Data");
        var il2cppDataTarget = Path.Combine(args.stagingAreaData, "il2cpp_data");

        FileUtil.MoveFileOrDirectory(il2cppDataSource, il2cppDataTarget);

        // Move generated source code
        var il2cppOutputProjectDirectory = Path.Combine(args.stagingArea, "Il2CppOutputProject");
        var sourceFolder = Path.Combine(il2cppOutputProjectDirectory, "Source");

        Directory.CreateDirectory(sourceFolder);
        FileUtil.MoveFileOrDirectory(il2cppOutputPath, Path.Combine(sourceFolder, "il2cppOutput"));

        // Copy C++ plugins
        if (cppPlugins.Any())
        {
            var cppPluginsDirectory = Path.Combine(sourceFolder, "CppPlugins");
            Directory.CreateDirectory(cppPluginsDirectory);

            foreach (var cppPlugin in cppPlugins)
            {
                FileUtil.CopyFileOrDirectory(cppPlugin, Path.Combine(cppPluginsDirectory, Path.GetFileName(cppPlugin)));
            }
        }

        // Copy IL2CPP
        var il2cppSourceFolder = IL2CPPUtils.GetIl2CppFolder();
        var il2cppTargetFolder = Paths.Combine(il2cppOutputProjectDirectory, "IL2CPP");

        Directory.CreateDirectory(il2cppTargetFolder);

        FileUtil.CopyFileOrDirectory(Path.Combine(il2cppSourceFolder, "build"), Path.Combine(il2cppTargetFolder, "build"));
        FileUtil.CopyFileOrDirectory(Path.Combine(il2cppSourceFolder, "external"), Path.Combine(il2cppTargetFolder, "external"));
        FileUtil.CopyFileOrDirectory(Path.Combine(il2cppSourceFolder, "libil2cpp"), Path.Combine(il2cppTargetFolder, "libil2cpp"));

        if (IL2CPPUtils.EnableIL2CPPDebugger(il2cppPlatformProvider, BuildTargetGroup.Standalone))
        {
            FileUtil.CopyFileOrDirectory(Path.Combine(il2cppSourceFolder, "libmono"), Path.Combine(il2cppTargetFolder, "libmono"));
        }

        FileUtil.CopyFileOrDirectory(Path.GetDirectoryName(IL2CPPBuilder.GetMapFileParserPath()), Path.Combine(il2cppTargetFolder, "MapFileParser"));
        FileUtil.CopyFileOrDirectory(Path.Combine(il2cppSourceFolder, "il2cpp_root"), Path.Combine(il2cppTargetFolder, "il2cpp_root"));

        WriteIl2CppOutputProject(args, il2cppOutputProjectDirectory, il2cppPlatformProvider);
    }
Exemplo n.º 8
0
    private void SetupStagingArea(BuildPostProcessArgs args, HashSet <string> filesToNotOverwrite)
    {
        List <string> cppPlugins;

        if (GetCreateSolution(args) && (args.target == BuildTarget.StandaloneWindows || args.target == BuildTarget.StandaloneWindows64))
        {
            // For Windows Standalone player solution build, we want to copy plugins for all architectures as
            // the ultimate CPU architecture choice can be made from Visual Studio
            CopyNativePlugins(args, BuildTarget.StandaloneWindows, out cppPlugins);
            CopyNativePlugins(args, BuildTarget.StandaloneWindows64, out cppPlugins);
        }
        else
        {
            CopyNativePlugins(args, args.target, out cppPlugins);
        }

        CreateApplicationData(args);

        PostprocessBuildPlayer.InstallStreamingAssets(args.stagingAreaData, args.report);

        if (GetInstallingIntoBuildsFolder(args))
        {
            CopyDataForBuildsFolder(args);
        }
        else
        {
            CopyVariationFolderIntoStagingArea(args, filesToNotOverwrite);

            if (UseIl2Cpp)
            {
                var il2cppPlatformProvider = GetPlatformProvider(args);
                IL2CPPUtils.RunIl2Cpp(args.stagingAreaData, il2cppPlatformProvider, (cppOutputDir) => CopyCppPlugins(args, cppOutputDir, cppPlugins), args.usedClassRegistry);

                if (GetCreateSolution(args))
                {
                    ProcessIl2CppOutputForSolution(args, il2cppPlatformProvider, cppPlugins);
                }
                else
                {
                    ProcessIl2CppOutputForBinary(args);
                }
            }
            else
            {
                var buildTargetGroup      = BuildPipeline.GetBuildTargetGroup(args.target);
                var managedStrippingLevel = PlayerSettings.GetManagedStrippingLevel(buildTargetGroup);
                AssemblyStripper.StripForMonoBackend(args.target, args.usedClassRegistry, managedStrippingLevel, args.report);
            }

            RenameFilesInStagingArea(args);
        }
    }
Exemplo n.º 9
0
    public override void UpdateBootConfig(BuildTarget target, BootConfigData config, BuildOptions options)
    {
        base.UpdateBootConfig(target, config, options);

        if (PlayerSettings.forceSingleInstance)
        {
            config.AddKey("single-instance");
        }
        if (IL2CPPUtils.UseIl2CppCodegenWithMonoBackend(BuildPipeline.GetBuildTargetGroup(target)))
        {
            config.Set("mono-codegen", "il2cpp");
        }
    }
Exemplo n.º 10
0
    protected virtual string GetVariationName(BuildPostProcessArgs args)
    {
        var platformString      = PlatformStringFor(args.target);
        var configurationString = GetDevelopment(args) ? "development" : "nondevelopment";

        var scriptingBackend = "mono";

        if (UseIl2Cpp && !IL2CPPUtils.UseIl2CppCodegenWithMonoBackend(BuildTargetGroup.Standalone))
        {
            scriptingBackend = "il2cpp";
        }

        return($"{platformString}_{configurationString}_{scriptingBackend}");
    }
Exemplo n.º 11
0
 public void Execute(PostProcessorContext context)
 {
     if (((ScriptingImplementation)context.Get <ScriptingImplementation>("ScriptingBackend")) == ScriptingImplementation.IL2CPP)
     {
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Generating native assemblies");
         }
         BuildTarget target          = context.Get <BuildTarget>("BuildTarget");
         string      str             = context.Get <string>("StagingArea");
         string[]    components      = new string[] { str, "assets", "bin", "Data" };
         string      stagingAreaData = Paths.Combine(components);
         string[]    textArray2      = new string[] { BuildPipeline.GetBuildToolsDirectory(target), "AndroidNativeLink.xml" };
         string[]    textArray3      = new string[] { stagingAreaData, "platform_native_link.xml" };
         FileUtil.CopyFileOrDirectory(Paths.Combine(textArray2), Paths.Combine(textArray3));
         AndroidTargetDevice     device     = context.Get <AndroidTargetDevice>("TargetDevice");
         AndroidTargetDeviceType deviceType = new AndroidTargetDeviceARMv7();
         if (device == AndroidTargetDevice.x86)
         {
             deviceType = new AndroidTargetDevicex86();
         }
         if (this.OnProgress != null)
         {
             this.OnProgress(this, "Compiling native assemblies for " + deviceType.Architecture);
         }
         string tempFolder         = Path.Combine(str, "Il2Cpp");
         bool   isDevelopmentBuild = context.Get <bool>("DevelopmentPlayer");
         RuntimeClassRegistry          runtimeClassRegistry = context.Get <RuntimeClassRegistry>("UsedClassRegistry");
         AndroidIl2CppPlatformProvider platformProvider     = new AndroidIl2CppPlatformProvider(target, deviceType, isDevelopmentBuild);
         IL2CPPUtils.RunIl2Cpp(tempFolder, stagingAreaData, platformProvider, null, runtimeClassRegistry, isDevelopmentBuild);
         AndroidTargetDeviceType type2 = null;
         if (device == AndroidTargetDevice.FAT)
         {
             type2 = new AndroidTargetDevicex86();
             if (this.OnProgress != null)
             {
                 this.OnProgress(this, "Compiling native assemblies for " + type2.Architecture);
             }
             platformProvider = new AndroidIl2CppPlatformProvider(target, type2, isDevelopmentBuild);
             IL2CPPUtils.RunCompileAndLink(tempFolder, stagingAreaData, platformProvider, null, runtimeClassRegistry, false);
         }
         this.FinalizeAndCleanup(str, stagingAreaData, tempFolder);
         this.CopySymbolMap(str, stagingAreaData, deviceType);
         if (type2 != null)
         {
             this.CopySymbolMap(str, stagingAreaData, type2);
         }
     }
 }
Exemplo n.º 12
0
    private void ProcessIl2CppOutputForBinary(BuildPostProcessArgs args)
    {
        // Move GameAssembly next to game executable
        var il2cppOutputNativeDirectory = Path.Combine(args.stagingAreaData, "Native");
        var gameAssemblyDirectory       = GetDirectoryForGameAssembly(args);

        foreach (var file in Directory.GetFiles(il2cppOutputNativeDirectory))
        {
            var fileName = Path.GetFileName(file);
            if (fileName.StartsWith("."))
            {
                continue; // Skip files starting with ., as they weren't output by our tools and potentially belong to the OS (like .DS_Store on macOS)
            }
            FileUtil.MoveFileOrDirectory(file, Path.Combine(gameAssemblyDirectory, fileName));
        }

        if (PlaceIL2CPPSymbolMapNextToExecutable())
        {
            // Move symbol map to be next to game executable
            FileUtil.MoveFileOrDirectory(Paths.Combine(il2cppOutputNativeDirectory, "Data", "SymbolMap"), Path.Combine(args.stagingArea, "SymbolMap"));
        }

        // Move il2cpp data directory one directory up
        FileUtil.MoveFileOrDirectory(Path.Combine(il2cppOutputNativeDirectory, "Data"), Path.Combine(args.stagingAreaData, "il2cpp_data"));

        // Native directory is supposed to be empty at this point
        FileUtil.DeleteFileOrDirectory(il2cppOutputNativeDirectory);

        var dataBackupFolder = Path.Combine(args.stagingArea, GetIl2CppDataBackupFolderName(args));

        FileUtil.CreateOrCleanDirectory(dataBackupFolder);

        // Move generated C++ code out of Data directory
        FileUtil.MoveFileOrDirectory(Path.Combine(args.stagingAreaData, "il2cppOutput"), Path.Combine(dataBackupFolder, "il2cppOutput"));

        if (IL2CPPUtils.UseIl2CppCodegenWithMonoBackend(BuildPipeline.GetBuildTargetGroup(args.target)))
        {
            // Are we using IL2CPP code generation with the Mono runtime? If so, strip the assemblies so we can use them for metadata.
            StripAssembliesToLeaveOnlyMetadata(args.target, args.stagingAreaDataManaged);
        }
        else
        {
            // Otherwise, move them to temp data directory as il2cpp does not need managed assemblies to run
            FileUtil.MoveFileOrDirectory(args.stagingAreaDataManaged, Path.Combine(dataBackupFolder, "Managed"));
        }

        ProcessPlatformSpecificIL2CPPOutput(args);
    }
Exemplo n.º 13
0
    private void SetupStagingArea(BuildPostProcessArgs args, HashSet <string> filesToNotOverwrite)
    {
        Directory.CreateDirectory(args.stagingAreaData);

        List <string> cppPlugins;

        CopyNativePlugins(args, out cppPlugins);

        if (args.target == BuildTarget.StandaloneWindows ||
            args.target == BuildTarget.StandaloneWindows64)
        {
            CreateApplicationData(args);
        }

        PostprocessBuildPlayer.InstallStreamingAssets(args.stagingAreaData, args.report);

        if (GetInstallingIntoBuildsFolder(args))
        {
            CopyDataForBuildsFolder(args);
        }
        else
        {
            CopyVariationFolderIntoStagingArea(args);

            if (GetCreateSolution(args))
            {
                CopyPlayerSolutionIntoStagingArea(args, filesToNotOverwrite);
            }

            if (UseIl2Cpp)
            {
                var il2cppPlatformProvider = GetPlatformProvider(args);
                IL2CPPUtils.RunIl2Cpp(args.stagingAreaData, il2cppPlatformProvider, (cppOutputDir) => CopyCppPlugins(args, cppOutputDir, cppPlugins), args.usedClassRegistry);

                if (GetCreateSolution(args))
                {
                    ProcessIl2CppOutputForSolution(args, il2cppPlatformProvider, cppPlugins);
                }
                else
                {
                    ProcessIl2CppOutputForBinary(args);
                }
            }

            RenameFilesInStagingArea(args);
        }
    }
Exemplo n.º 14
0
    private void SetupStagingArea(BuildPostProcessArgs args, HashSet <string> filesToNotOverwrite)
    {
        List <string> cppPlugins;

        CopyNativePlugins(args, out cppPlugins);

        CreateApplicationData(args);

        PostprocessBuildPlayer.InstallStreamingAssets(args.stagingAreaData, args.report);

        if (GetInstallingIntoBuildsFolder(args))
        {
            CopyDataForBuildsFolder(args);
        }
        else
        {
            CopyVariationFolderIntoStagingArea(args);

            if (GetCreateSolution(args))
            {
                CopyPlayerSolutionIntoStagingArea(args, filesToNotOverwrite);
            }

            if (UseIl2Cpp)
            {
                var il2cppPlatformProvider = GetPlatformProvider(args);
                IL2CPPUtils.RunIl2Cpp(args.stagingAreaData, il2cppPlatformProvider, (cppOutputDir) => CopyCppPlugins(args, cppOutputDir, cppPlugins), args.usedClassRegistry);

                if (GetCreateSolution(args))
                {
                    ProcessIl2CppOutputForSolution(args, il2cppPlatformProvider, cppPlugins);
                }
                else
                {
                    ProcessIl2CppOutputForBinary(args);
                }
            }
            else
            {
                var buildTargetGroup      = BuildPipeline.GetBuildTargetGroup(args.target);
                var managedStrippingLevel = PlayerSettings.GetManagedStrippingLevel(buildTargetGroup);
                AssemblyStripper.StripForMonoBackend(args.target, args.usedClassRegistry, managedStrippingLevel, args.report);
            }

            RenameFilesInStagingArea(args);
        }
    }
Exemplo n.º 15
0
    protected void DeleteUnusedMono(string dataFolder, BuildReport report)
    {
        bool flag = IL2CPPUtils.UseIl2CppCodegenWithMonoBackend(BuildTargetGroup.Standalone);

        if (flag || EditorApplication.scriptingRuntimeVersion == ScriptingRuntimeVersion.Latest)
        {
            string text = Path.Combine(dataFolder, DesktopStandalonePostProcessor.GetMonoFolderName(ScriptingRuntimeVersion.Legacy));
            FileUtil.DeleteFileOrDirectory(text);
            report.RecordFilesDeletedRecursive(text);
        }
        if (flag || EditorApplication.scriptingRuntimeVersion == ScriptingRuntimeVersion.Legacy)
        {
            string text2 = Path.Combine(dataFolder, DesktopStandalonePostProcessor.GetMonoFolderName(ScriptingRuntimeVersion.Latest));
            FileUtil.DeleteFileOrDirectory(text2);
            report.RecordFilesDeletedRecursive(text2);
        }
    }
    protected void DeleteUnusedMono(string dataFolder, BuildReport report)
    {
        // Mono is built by the il2cpp builder, so we dont need the libs copied
        bool deleteBoth = IL2CPPUtils.UseIl2CppCodegenWithMonoBackend(BuildTargetGroup.Standalone);

        if (deleteBoth || EditorApplication.scriptingRuntimeVersion == ScriptingRuntimeVersion.Latest)
        {
            var monoPath = Path.Combine(dataFolder, GetMonoFolderName(ScriptingRuntimeVersion.Legacy));
            FileUtil.DeleteFileOrDirectory(monoPath);
            report.RecordFilesDeletedRecursive(monoPath);
        }
        if (deleteBoth || EditorApplication.scriptingRuntimeVersion == ScriptingRuntimeVersion.Legacy)
        {
            var monoPath = Path.Combine(dataFolder, GetMonoFolderName(ScriptingRuntimeVersion.Latest));
            FileUtil.DeleteFileOrDirectory(monoPath);
            report.RecordFilesDeletedRecursive(monoPath);
        }
    }
Exemplo n.º 17
0
        public static BuildRequest BuildRequestFor(RunnableProgram buildProgram, string dagName, string dagDirectory, bool useScriptUpdater, string projectDirectory, ILPostProcessingProgram ilpp, StdOutMode stdoutMode, RunnableProgram beeBackendProgram = null)
        {
            NPath dagDir = dagDirectory ?? "Library/Bee";

            RecreateDagDirectoryIfNeeded(dagDir);
            var   performingPlayerBuild = UnityBeeDriverProfilerSession.PerformingPlayerBuild;
            NPath profilerOutputFile    = performingPlayerBuild ? UnityBeeDriverProfilerSession.GetTraceEventsOutputForPlayerBuild() : $"{dagDir}/fullprofile.json";

            return(new BuildRequest()
            {
                BuildProgram = buildProgram,
                BackendProgram = beeBackendProgram ?? UnityBeeBackendProgram(stdoutMode),
                ProjectRoot = projectDirectory,
                DagName = dagName,
                BuildStateDirectory = dagDir.EnsureDirectoryExists().ToString(),
                ProfilerOutputFile = profilerOutputFile.ToString(),
                // Use a null process name during a player build to avoid writing process metadata.  The player profiler will take care of writing the process metadata
                ProfilerProcessName = performingPlayerBuild ? null : "BeeDriver",
                SourceFileUpdaters = useScriptUpdater
                    ? new[] { new UnityScriptUpdater(projectDirectory) }
                    : Array.Empty <SourceFileUpdaterBase>(),
                ProcessSourceFileUpdatersResult = new UnitySourceFileUpdatersResultHandler(),

                DataForBuildProgram =
                {
                    () => new ConfigurationData
                    {
                        Il2CppDir = IL2CPPUtils.GetIl2CppFolder(),
                        Il2CppPath = IL2CPPUtils.GetExePath("il2cpp"),
                        UnityLinkerPath = IL2CPPUtils.GetExePath("UnityLinker"),
                        NetCoreRunPath = NetCoreRunProgram.NetCoreRunPath,
                        EditorContentsPath = EditorApplication.applicationContentsPath,
                        Packages = GetPackageInfos(NPath.CurrentDirectory.ToString()),
                        UnityVersion = Application.unityVersion,
                        UnityVersionNumeric = new BeeBuildProgramCommon.Data.Version(Application.unityVersionVer, Application.unityVersionMaj, Application.unityVersionMin),
                        UnitySourceCodePath = Unsupported.IsSourceBuild(false) ? Unsupported.GetBaseUnityDeveloperFolder() : null,
                        AdvancedLicense = PlayerSettings.advancedLicense,
                        Batchmode = InternalEditorUtility.inBatchMode,
                        EmitDataForBeeWhy = (Debug.GetDiagnosticSwitch("EmitDataForBeeWhy").value as bool?) ?? false,
                        NamedPipeOrUnixSocket = ilpp.NamedPipeOrUnixSocket,
                    }
                }
            });
        }
Exemplo n.º 18
0
 protected virtual void SetupStagingArea()
 {
     Directory.CreateDirectory(this.DataFolder);
     this.CopyNativePlugins();
     if (this.m_PostProcessArgs.target == BuildTarget.StandaloneWindows || this.m_PostProcessArgs.target == BuildTarget.StandaloneWindows64)
     {
         this.CreateApplicationData();
     }
     PostprocessBuildPlayer.InstallStreamingAssets(this.DataFolder);
     if (this.UseIl2Cpp)
     {
         this.CopyVariationFolderIntoStagingArea();
         string text  = this.StagingArea + "/Data";
         string text2 = this.DataFolder + "/Managed";
         string text3 = text2 + "/Resources";
         string text4 = text2 + "/Metadata";
         IL2CPPUtils.RunIl2Cpp(text, this.GetPlatformProvider(this.m_PostProcessArgs.target), delegate(string s)
         {
         }, this.m_PostProcessArgs.usedClassRegistry, this.Development);
         FileUtil.CreateOrCleanDirectory(text3);
         IL2CPPUtils.CopyEmbeddedResourceFiles(text, text3);
         FileUtil.CreateOrCleanDirectory(text4);
         IL2CPPUtils.CopyMetadataFiles(text, text4);
         IL2CPPUtils.CopySymmapFile(text + "/Native/Data", text2);
     }
     if (this.InstallingIntoBuildsFolder)
     {
         this.CopyDataForBuildsFolder();
     }
     else
     {
         if (!this.UseIl2Cpp)
         {
             this.CopyVariationFolderIntoStagingArea();
         }
         this.RenameFilesInStagingArea();
         this.m_PostProcessArgs.report.AddFilesRecursive(this.StagingArea, "");
         this.m_PostProcessArgs.report.RelocateFiles(this.StagingArea, "");
     }
 }
 protected virtual void SetupStagingArea()
 {
     Directory.CreateDirectory(this.DataFolder);
     this.CopyNativePlugins();
     PostprocessBuildPlayer.InstallStreamingAssets(this.DataFolder);
     if (this.UseIl2Cpp)
     {
         this.CopyVariationFolderIntoStagingArea();
         IL2CPPUtils.RunIl2Cpp(this.StagingArea + "/Data", this.GetPlatformProvider(this.m_PostProcessArgs.target), delegate(string s)
         {
         }, this.m_PostProcessArgs.usedClassRegistry);
     }
     if (this.InstallingIntoBuildsFolder)
     {
         return;
     }
     if (!this.UseIl2Cpp)
     {
         this.CopyVariationFolderIntoStagingArea();
     }
     this.RenameFilesInStagingArea();
 }
Exemplo n.º 20
0
        private void FinalizeAndCleanup(string stagingArea, string assetsDataData, string il2cppDir)
        {
            string[] components = new string[] { assetsDataData, "Managed" };
            string   from       = Paths.Combine(components);

            FileUtil.MoveFileOrDirectory(from, Path.Combine(il2cppDir, "Managed"));
            string[] textArray2 = new string[] { assetsDataData, "Native" };
            string[] textArray3 = new string[] { stagingArea, "libs" };
            FileUtil.CopyDirectoryRecursive(Paths.Combine(textArray2), Paths.Combine(textArray3));
            string[] textArray4 = new string[] { assetsDataData, "Native" };
            FileUtil.DeleteFileOrDirectory(Paths.Combine(textArray4));
            string dir  = Path.Combine(from, "Resources");
            string str3 = Path.Combine(from, "Metadata");
            string str4 = Path.Combine(from, "etc");

            FileUtil.CreateOrCleanDirectory(str3);
            FileUtil.CreateOrCleanDirectory(dir);
            FileUtil.CreateOrCleanDirectory(str4);
            IL2CPPUtils.CopyEmbeddedResourceFiles(il2cppDir, dir);
            IL2CPPUtils.CopyMetadataFiles(il2cppDir, str3);
            IL2CPPUtils.CopyConfigFiles(il2cppDir, str4);
        }
Exemplo n.º 21
0
 private void SetupStagingArea(BuildPostProcessArgs args)
 {
     if (this.UseIl2Cpp && this.GetCreateSolution())
     {
         throw new Exception("CreateSolution is not supported with IL2CPP build");
     }
     Directory.CreateDirectory(args.stagingAreaData);
     this.CopyNativePlugins(args);
     if (args.target == BuildTarget.StandaloneWindows || args.target == BuildTarget.StandaloneWindows64)
     {
         this.CreateApplicationData(args);
     }
     PostprocessBuildPlayer.InstallStreamingAssets(args.stagingAreaData, args.report);
     if (this.UseIl2Cpp)
     {
         this.CopyVariationFolderIntoStagingArea(args);
         IL2CPPUtils.RunIl2Cpp(args.stagingAreaData, this.GetPlatformProvider(args), null, args.usedClassRegistry);
         string   text = Path.Combine(args.stagingAreaData, "Native");
         string   directoryForGameAssembly = this.GetDirectoryForGameAssembly(args);
         string[] files = Directory.GetFiles(text);
         for (int i = 0; i < files.Length; i++)
         {
             string text2    = files[i];
             string fileName = Path.GetFileName(text2);
             if (!fileName.StartsWith("."))
             {
                 FileUtil.MoveFileOrDirectory(text2, Path.Combine(directoryForGameAssembly, fileName));
             }
         }
         if (this.PlaceIL2CPPSymbolMapNextToExecutable())
         {
             FileUtil.MoveFileOrDirectory(Paths.Combine(new string[]
             {
                 text,
                 "Data",
                 "SymbolMap"
             }), Path.Combine(args.stagingArea, "SymbolMap"));
         }
         FileUtil.MoveFileOrDirectory(Path.Combine(text, "Data"), Path.Combine(args.stagingAreaData, "il2cpp_data"));
         FileUtil.DeleteFileOrDirectory(text);
         string text3 = Path.Combine(args.stagingArea, this.GetIl2CppDataBackupFolderName(args));
         FileUtil.CreateOrCleanDirectory(text3);
         FileUtil.MoveFileOrDirectory(Path.Combine(args.stagingAreaData, "il2cppOutput"), Path.Combine(text3, "il2cppOutput"));
         if (IL2CPPUtils.UseIl2CppCodegenWithMonoBackend(BuildPipeline.GetBuildTargetGroup(args.target)))
         {
             DesktopStandalonePostProcessor.StripAssembliesToLeaveOnlyMetadata(args.target, args.stagingAreaDataManaged);
         }
         else
         {
             FileUtil.MoveFileOrDirectory(args.stagingAreaDataManaged, Path.Combine(text3, "Managed"));
         }
         this.ProcessPlatformSpecificIL2CPPOutput(args);
     }
     if (this.GetInstallingIntoBuildsFolder(args))
     {
         this.CopyDataForBuildsFolder(args);
     }
     else
     {
         if (!this.UseIl2Cpp)
         {
             this.CopyVariationFolderIntoStagingArea(args);
         }
         if (this.GetCreateSolution())
         {
             this.CopyPlayerSolutionIntoStagingArea(args);
         }
         this.RenameFilesInStagingArea(args);
     }
 }
Exemplo n.º 22
0
        LinkerConfig LinkerConfigFor(BuildPostProcessArgs args)
        {
            var namedBuildTarget = GetNamedBuildTarget(args);
            var strippingLevel   = PlayerSettings.GetManagedStrippingLevel(namedBuildTarget);

            // IL2CPP does not support a managed stripping level of disabled. If the player settings
            // do try this (which should not be possible from the editor), use Low instead.
            if (GetUseIl2Cpp(args) && strippingLevel == ManagedStrippingLevel.Disabled)
            {
                strippingLevel = ManagedStrippingLevel.Minimal;
            }

            if (strippingLevel > ManagedStrippingLevel.Disabled)
            {
                var rcr = args.usedClassRegistry;

                var additionalArgs = new List <string>();

                var diagArgs = Debug.GetDiagnosticSwitch("VMUnityLinkerAdditionalArgs").value as string;
                if (!string.IsNullOrEmpty(diagArgs))
                {
                    additionalArgs.Add(diagArgs.Trim('\''));
                }

                var engineStrippingFlags = new List <string>();

                if (UnityEngine.Connect.UnityConnectSettings.enabled)
                {
                    engineStrippingFlags.Add("EnableUnityConnect");
                }
                if (UnityEngine.Analytics.PerformanceReporting.enabled)
                {
                    engineStrippingFlags.Add("EnablePerformanceReporting");
                }
                if (UnityEngine.Analytics.Analytics.enabled)
                {
                    engineStrippingFlags.Add("EnableAnalytics");
                }
                if (UnityEditor.CrashReporting.CrashReportingSettings.enabled)
                {
                    engineStrippingFlags.Add("EnableCrashReporting");
                }

                NPath managedAssemblyFolderPath = $"{args.stagingAreaData}/Managed";
                var   linkerRunInformation      = new UnityLinkerRunInformation(managedAssemblyFolderPath.MakeAbsolute().ToString(), null, args.target,
                                                                                rcr, strippingLevel, null, args.report);
                AssemblyStripper.WriteEditorData(linkerRunInformation);

                return(new LinkerConfig
                {
                    LinkXmlFiles = AssemblyStripper.GetLinkXmlFiles(linkerRunInformation).ToArray(),
                    EditorToLinkerData = linkerRunInformation.EditorToLinkerDataPath.ToNPath().MakeAbsolute().ToString(),
                    AssembliesToProcess = rcr.GetUserAssemblies()
                                          .Where(s => rcr.IsDLLUsed(s))
                                          .ToArray(),
                    Runtime = GetUseIl2Cpp(args) ? "il2cpp" : "mono",
                    Profile = IL2CPPUtils.ApiCompatibilityLevelToDotNetProfileArgument(
                        PlayerSettings.GetApiCompatibilityLevel(namedBuildTarget), args.target),
                    Ruleset = strippingLevel switch
                    {
                        ManagedStrippingLevel.Minimal => "Minimal",
                        ManagedStrippingLevel.Low => "Conservative",
                        ManagedStrippingLevel.Medium => "Aggressive",
                        ManagedStrippingLevel.High => "Experimental",
                        _ => throw new ArgumentException($"Unhandled {nameof(ManagedStrippingLevel)} value")
                    },
    private void SetupStagingArea(BuildPostProcessArgs args)
    {
        if (UseIl2Cpp && GetCreateSolution())
        {
            throw new Exception("CreateSolution is not supported with IL2CPP build");
        }

        Directory.CreateDirectory(args.stagingAreaData);

        List <string> cppPlugins;

        CopyNativePlugins(args, out cppPlugins);

        if (args.target == BuildTarget.StandaloneWindows ||
            args.target == BuildTarget.StandaloneWindows64)
        {
            CreateApplicationData(args);
        }

        PostprocessBuildPlayer.InstallStreamingAssets(args.stagingAreaData, args.report);

        if (UseIl2Cpp)
        {
            CopyVariationFolderIntoStagingArea(args);
            IL2CPPUtils.RunIl2Cpp(args.stagingAreaData, GetPlatformProvider(args), (cppOutputDir) => CopyCppPlugins(cppOutputDir, cppPlugins), args.usedClassRegistry);

            // Move GameAssembly next to game executable
            var il2cppOutputNativeDirectory = Path.Combine(args.stagingAreaData, "Native");
            var gameAssemblyDirectory       = GetDirectoryForGameAssembly(args);
            foreach (var file in Directory.GetFiles(il2cppOutputNativeDirectory))
            {
                var fileName = Path.GetFileName(file);
                if (fileName.StartsWith("."))
                {
                    continue; // Skip files starting with ., as they weren't output by our tools and potentially belong to the OS (like .DS_Store on macOS)
                }
                FileUtil.MoveFileOrDirectory(file, Path.Combine(gameAssemblyDirectory, fileName));
            }

            if (PlaceIL2CPPSymbolMapNextToExecutable())
            {
                // Move symbol map to be next to game executable
                FileUtil.MoveFileOrDirectory(Paths.Combine(il2cppOutputNativeDirectory, "Data", "SymbolMap"), Path.Combine(args.stagingArea, "SymbolMap"));
            }

            // Move il2cpp data directory one directory up
            FileUtil.MoveFileOrDirectory(Path.Combine(il2cppOutputNativeDirectory, "Data"), Path.Combine(args.stagingAreaData, "il2cpp_data"));

            // Native directory is supposed to be empty at this point
            FileUtil.DeleteFileOrDirectory(il2cppOutputNativeDirectory);

            var dataBackupFolder = Path.Combine(args.stagingArea, GetIl2CppDataBackupFolderName(args));
            FileUtil.CreateOrCleanDirectory(dataBackupFolder);

            // Move generated C++ code out of Data directory
            FileUtil.MoveFileOrDirectory(Path.Combine(args.stagingAreaData, "il2cppOutput"), Path.Combine(dataBackupFolder, "il2cppOutput"));

            if (IL2CPPUtils.UseIl2CppCodegenWithMonoBackend(BuildPipeline.GetBuildTargetGroup(args.target)))
            {
                // Are we using IL2CPP code generation with the Mono runtime? If so, strip the assemblies so we can use them for metadata.
                StripAssembliesToLeaveOnlyMetadata(args.target, args.stagingAreaDataManaged);
            }
            else
            {
                // Otherwise, move them to temp data directory as il2cpp does not need managed assemblies to run
                FileUtil.MoveFileOrDirectory(args.stagingAreaDataManaged, Path.Combine(dataBackupFolder, "Managed"));
            }

            ProcessPlatformSpecificIL2CPPOutput(args);
        }

        if (GetInstallingIntoBuildsFolder(args))
        {
            CopyDataForBuildsFolder(args);
        }
        else
        {
            if (!UseIl2Cpp)
            {
                CopyVariationFolderIntoStagingArea(args);
            }

            if (GetCreateSolution())
            {
                CopyPlayerSolutionIntoStagingArea(args);
            }
            RenameFilesInStagingArea(args);
        }
    }