private static void CopyPlayerSolutionIntoStagingArea(
            BuildPostProcessArgs args,
            HashSet <string> filesToNotOverwrite,
            bool useIl2Cpp)
        {
            string pathSafeProductName = DesktopStandalonePostProcessor.GetPathSafeProductName(args);
            string str1 = Paths.Combine(new string[3]
            {
                (string)args.playerPackage,
                "Source",
                "WindowsPlayer"
            });
            string str2 = Path.Combine((string)args.stagingArea, "UnityPlayerStub");
            string str3 = Path.Combine((string)args.stagingArea, pathSafeProductName);

            FileUtil.DeleteFileOrDirectory(str2);
            FileUtil.DeleteFileOrDirectory(str3);
            FileUtil.CopyDirectory(Paths.Combine(new string[2]
            {
                str1,
                "UnityPlayerStub"
            }), str2, true);
            FileUtil.CopyDirectory(Paths.Combine(new string[2]
            {
                str1,
                "WindowsPlayer"
            }), str3, true);
            WindowsDesktopStandalonePostProcessor.RenameWindowsPlayerProject((string)args.stagingArea, pathSafeProductName, filesToNotOverwrite);
            WindowsDesktopStandalonePostProcessor.WriteProjectPropsFile((string)args.stagingArea, pathSafeProductName, useIl2Cpp);
            WindowsDesktopStandalonePostProcessor.WriteSolutionFile((string)args.stagingArea, pathSafeProductName, DesktopStandalonePostProcessor.IsHeadlessMode(args), filesToNotOverwrite, useIl2Cpp);
            WindowsDesktopStandalonePostProcessor.CopyPlayerIcon((string)args.stagingArea, pathSafeProductName);
        }
        private static void CopyVariationNativeBinaries(
            BuildPostProcessArgs args,
            string variation,
            string stagingDestination,
            bool copyPlayerExe,
            bool failIfNotBuilt,
            bool forSolutionBuild,
            bool useIl2Cpp)
        {
            string str1  = (string)args.playerPackage + "/Variations/" + variation;
            string path1 = (string)args.stagingArea + "/" + stagingDestination;

            if (!Directory.Exists(str1))
            {
                if (failIfNotBuilt)
                {
                    throw new DirectoryNotFoundException("Could not find " + str1 + " for building Windows Standalone player. Did you build this variation?");
                }
            }
            else
            {
                List <string> source = new List <string>();
                source.Add("(?:\\.lib$)");
                source.Add("(?:\\.exp$)");
                source.Add("(?:\\.ilk$)");
                if (!copyPlayerExe || DesktopStandalonePostProcessor.IsHeadlessMode(args))
                {
                    source.Add("(?:[/\\\\]WindowsPlayer.exe$)");
                    source.Add("(?:[/\\\\]WindowsPlayer_[^/\\\\]+$)");
                }
                if (!copyPlayerExe || !DesktopStandalonePostProcessor.IsHeadlessMode(args))
                {
                    source.Add("(?:[/\\\\]WindowsPlayerHeadless.exe$)");
                    source.Add("(?:[/\\\\]WindowsPlayerHeadless_[^/\\\\]+$)");
                }
                if (!UserBuildSettings.copyPDBFiles)
                {
                    source.Add("(?:\\.pdb$)");
                }
                string str2 = source.Any <string>() ? string.Join("|", source.ToArray()) : (string)null;
                FileUtil.CopyDirectoryFiltered(str1, path1, true, str2, false);
                if (useIl2Cpp & forSolutionBuild)
                {
                    FileUtil.CopyFileOrDirectory(Path.Combine(str1, "baselib.dll.lib"), Path.Combine(path1, "baselib.dll.lib"));
                }
                if (useIl2Cpp)
                {
                    return;
                }
                FileUtil.CopyDirectoryFiltered(str1 + "/MonoBleedingEdge", path1 + "/MonoBleedingEdge", true, (string)null, true);
            }
        }
 protected override void CopyVariationFolderIntoStagingArea(
     BuildPostProcessArgs args,
     HashSet <string> filesToNotOverwrite)
 {
     FileUtil.CopyDirectoryFiltered(this.GetVariationFolder(args) + "/Data", (string)args.stagingAreaData, true, (Func <string, bool>)(f => this.CopyPlayerFilter(f, args)), true);
     if (base.GetCreateSolution(args))
     {
         string str = this.UseIl2Cpp ? "il2cpp" : "mono";
         List <KeyValuePair <string, string> > keyValuePairList = new List <KeyValuePair <string, string> >(8);
         keyValuePairList.Add(new KeyValuePair <string, string>("win32_development_" + str, "x86/Debug"));
         keyValuePairList.Add(new KeyValuePair <string, string>("win32_development_" + str, "x86/Release"));
         keyValuePairList.Add(new KeyValuePair <string, string>("win32_nondevelopment_" + str, "x86/Master"));
         keyValuePairList.Add(new KeyValuePair <string, string>("win64_development_" + str, "x64/Debug"));
         keyValuePairList.Add(new KeyValuePair <string, string>("win64_development_" + str, "x64/Release"));
         keyValuePairList.Add(new KeyValuePair <string, string>("win64_nondevelopment_" + str, "x64/Master"));
         if (this.UseIl2Cpp)
         {
             keyValuePairList.Add(new KeyValuePair <string, string>("win32_nondevelopment_" + str, "x86/MasterWithLTCG"));
             keyValuePairList.Add(new KeyValuePair <string, string>("win64_nondevelopment_" + str, "x64/MasterWithLTCG"));
         }
         foreach (KeyValuePair <string, string> keyValuePair in keyValuePairList)
         {
             WindowsDesktopStandalonePostProcessor.CopyVariationNativeBinaries(args, keyValuePair.Key, WindowsDesktopStandalonePostProcessor.kSolutionOutputFolder + "/" + keyValuePair.Value, false, false, true, this.UseIl2Cpp);
         }
         WindowsDesktopStandalonePostProcessor.CopyPlayerSolutionIntoStagingArea(args, filesToNotOverwrite, this.UseIl2Cpp);
     }
     else
     {
         string variationName = this.GetVariationName(args);
         WindowsDesktopStandalonePostProcessor.CopyVariationNativeBinaries(args, variationName, string.Empty, true, true, false, this.UseIl2Cpp);
         string str1 = Path.Combine((string)args.stagingArea, DesktopStandalonePostProcessor.IsHeadlessMode(args) ? "WindowsPlayerHeadless.exe" : "WindowsPlayer.exe");
         if (!IconUtility.AddIconToWindowsExecutable(str1))
         {
             throw new BuildFailedException("Failed to add a custom icon to the executable.");
         }
         ((BuildReport)args.report).RecordFileAdded(str1, CommonRoles.executable);
         ((BuildReport)args.report).RecordFileAdded((string)args.stagingArea + "/UnityPlayer.dll", CommonRoles.engineLibrary);
         ((BuildReport)args.report).RecordFileAdded((string)args.stagingArea + "/UnityCrashHandler" + ((int)args.target == 19 ? "64" : "32") + ".exe", CommonRoles.crashHandler);
         foreach (string file in Directory.GetFiles((string)args.stagingArea, "*.pdb", SearchOption.TopDirectoryOnly))
         {
             ((BuildReport)args.report).RecordFileAdded((string)args.stagingArea + "/" + Path.GetFileName(file), CommonRoles.debugInfo);
         }
         string str2 = (string)args.stagingArea + "/" + this.GetDestinationExeName(args);
         FileUtil.MoveFileOrDirectory(str1, str2);
         ((BuildReport)args.report).RecordFilesMoved(str1, str2);
     }
     DesktopStandalonePostProcessor.RecordCommonFiles(args, this.GetVariationFolder(args), (string)args.stagingArea);
 }
 protected override void ProcessPlatformSpecificIL2CPPOutput(BuildPostProcessArgs args)
 {
     FileUtil.DeleteFileOrDirectory(Path.Combine((string)args.stagingArea, "GameAssembly.exp"));
     FileUtil.DeleteFileOrDirectory(Path.Combine((string)args.stagingArea, "GameAssembly.lib"));
     FileUtil.DeleteFileOrDirectory(Path.Combine((string)args.stagingArea, "GameAssembly.map"));
     if (UserBuildSettings.copyPDBFiles)
     {
         return;
     }
     FileUtil.MoveFileOrDirectory(Path.Combine((string)args.stagingArea, "GameAssembly.pdb"), Paths.Combine(new string[3]
     {
         (string)args.stagingArea,
         DesktopStandalonePostProcessor.GetIl2CppDataBackupFolderName(args),
         "GameAssembly.pdb"
     }));
 }
예제 #5
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 override bool GetCreateSolution(BuildPostProcessArgs args) => !DesktopStandalonePostProcessor.GetInstallingIntoBuildsFolder(args) && UserBuildSettings.createSolution;
        protected override void CheckSafeProjectOverwrite(BuildPostProcessArgs args)
        {
            if (DesktopStandalonePostProcessor.GetInstallingIntoBuildsFolder(args))
            {
                return;
            }
            string destinationFolder = base.GetDestinationFolder(args);

            if (base.GetCreateSolution(args))
            {
                if (File.Exists((string)args.installPath))
                {
                    throw new UnityException("Build path contains project built without \"Create Visual Studio Solution\" option, which is incompatible with current build settings. Consider building your project into an empty directory.");
                }
                if (this.UseIl2Cpp)
                {
                    string   path1    = Path.Combine(destinationFolder, WindowsDesktopStandalonePostProcessor.kSolutionOutputFolder);
                    string[] strArray = new string[6]
                    {
                        "x64/Debug",
                        "x64/Release",
                        "x64/Master",
                        "x86/Debug",
                        "x86/Release",
                        "x86/Master"
                    };
                    foreach (string path2 in strArray)
                    {
                        if (WindowsDesktopStandalonePostProcessor.IsMonoInFolder(Path.Combine(path1, path2)))
                        {
                            throw new UnityException("Build path contains project built with Mono scripting backend, while current project is using IL2CPP scripting backend. Consider building your project into an empty directory.");
                        }
                    }
                }
                else if (Directory.Exists(Path.Combine(destinationFolder, "Il2CppOutputProject")))
                {
                    throw new UnityException("Build path contains project built with IL2CPP scripting backend, while current project is using Mono scripting backend. Consider building your project into an empty directory.");
                }
            }
            else
            {
                string pathSafeProductName = DesktopStandalonePostProcessor.GetPathSafeProductName(args);
                string path1 = Path.Combine(destinationFolder, pathSafeProductName + ".sln");
                string path2 = Path.Combine(destinationFolder, "UnityCommon.props");
                if (File.Exists(path1) || File.Exists(path2))
                {
                    throw new UnityException("Build path contains project built with \"Create Visual Studio Solution\" option, which is incompatible with current build settings. Consider building your project into an empty directory.");
                }
                if (this.UseIl2Cpp)
                {
                    if (WindowsDesktopStandalonePostProcessor.IsMonoInFolder(destinationFolder))
                    {
                        throw new UnityException("Build path contains project built with Mono scripting backend, while current project is using IL2CPP scripting backend. Consider building your project into an empty directory.");
                    }
                }
                else if (File.Exists(Path.Combine(destinationFolder, "GameAssembly.dll")))
                {
                    throw new UnityException("Build path contains project built with IL2CPP scripting backend, while current project is using Mono scripting backend. Consider building your project into an empty directory.");
                }
            }
        }
 private string GetDestinationDataFolderRelativePath(BuildPostProcessArgs args) => base.GetCreateSolution(args) ? WindowsDesktopStandalonePostProcessor.kSolutionOutputFolder + "/" + DesktopStandalonePostProcessor.GetPathSafeProductName(args) + "_Data" : Path.GetFileNameWithoutExtension(this.GetDestinationExeName(args)) + "_Data";
예제 #9
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);
     }
 }