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);
    }
Exemple #2
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,
                    }
                }
            });
        }
        public static BeeDriver Make(
            RunnableProgram buildProgram,
            string dagName,
            string dagDirectory,
            bool useScriptUpdater,
            string projectDirectory,
            ILPostProcessingProgram ilpp,
            StdOutMode stdoutMode,
            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(stdoutMode), 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,
                NamedPipeOrUnixSocket = ilpp.NamedPipeOrUnixSocket,
            });
            return(result);
        }