Exemple #1
0
 public void PostProcessScriptsOnly(BuildPostProcessArgs args)
 {
     throw new NotImplementedException();
 }
 protected bool GetInstallingIntoBuildsFolder(BuildPostProcessArgs args)
 {
     return((args.options & BuildOptions.InstallInBuildFolder) != 0);
 }
 protected bool GetDevelopment(BuildPostProcessArgs args)
 {
     return((args.options & BuildOptions.Development) != 0);
 }
 protected abstract string GetStagingAreaPluginsFolder(BuildPostProcessArgs args);
 protected abstract string GetDestinationFolderForInstallingIntoBuildsFolder(BuildPostProcessArgs args);
    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);
        }
    }
 protected bool CopyPlayerFilter(string path, BuildPostProcessArgs args)
 {
     // Don't copy UnityEngine mdb files
     return(Path.GetExtension(path) != ".mdb" || !Path.GetFileName(path).StartsWith("UnityEngine."));
 }
Exemple #8
0
 protected virtual bool GetCreateSolution(BuildPostProcessArgs args)
 {
     return(false);
 }
Exemple #9
0
 protected static bool IsHeadlessMode(BuildPostProcessArgs args)
 {
     return((args.options & BuildOptions.EnableHeadlessMode) != 0);
 }
Exemple #10
0
 protected string GetVariationFolder(BuildPostProcessArgs args) =>
 Paths.Combine(args.playerPackage, "Variations", GetVariationName(args));
Exemple #11
0
 protected abstract void CopyVariationFolderIntoStagingArea(BuildPostProcessArgs args);
Exemple #12
0
 protected virtual void CopyPlayerSolutionIntoStagingArea(BuildPostProcessArgs args, HashSet <string> filesToNotOverwrite)
 {
     throw new NotSupportedException("CreateSolution is not supported on " + BuildPipeline.GetBuildTargetName(args.target));
 }
Exemple #13
0
 protected virtual void ProcessIl2CppOutputForSolution(BuildPostProcessArgs args, IIl2CppPlatformProvider il2cppPlatformProvider, IEnumerable <string> cppPlugins)
 {
     throw new NotSupportedException("CreateSolution is not supported on " + BuildPipeline.GetBuildTargetName(args.target));
 }
Exemple #14
0
    private void CopyNativePlugins(BuildPostProcessArgs args, out List <string> cppPlugins)
    {
        string buildTargetName = BuildPipeline.GetBuildTargetName(args.target);
        IPluginImporterExtension pluginImpExtension = new DesktopPluginImporterExtension();

        string pluginsFolder = GetStagingAreaPluginsFolder(args);
        string subDir32Bit   = Path.Combine(pluginsFolder, "x86");
        string subDir64Bit   = Path.Combine(pluginsFolder, "x86_64");

        bool haveCreatedPluginsFolder = false;
        bool haveCreatedSubDir32Bit   = false;
        bool haveCreatedSubDir64Bit   = false;

        cppPlugins = new List <string>();

        foreach (PluginImporter imp in PluginImporter.GetImporters(args.target))
        {
            BuildTarget t = args.target;

            // Skip .cpp files. They get copied to il2cpp output folder just before code compilation
            if (DesktopPluginImporterExtension.IsCppPluginFile(imp.assetPath))
            {
                cppPlugins.Add(imp.assetPath);
                continue;
            }

            // Skip managed DLLs.
            if (!imp.isNativePlugin)
            {
                continue;
            }

            // HACK: This should never happen.
            if (string.IsNullOrEmpty(imp.assetPath))
            {
                UnityEngine.Debug.LogWarning("Got empty plugin importer path for " + args.target.ToString());
                continue;
            }

            if (!haveCreatedPluginsFolder)
            {
                Directory.CreateDirectory(pluginsFolder);
                haveCreatedPluginsFolder = true;
            }

            bool   isDirectory = Directory.Exists(imp.assetPath);
            string cpu         = imp.GetPlatformData(t, "CPU");
            switch (cpu)
            {
            case "x86":
                if (t == BuildTarget.StandaloneWindows64 ||
                    t == BuildTarget.StandaloneLinux64)
                {
                    continue;
                }
                if (!haveCreatedSubDir32Bit)
                {
                    Directory.CreateDirectory(subDir32Bit);
                    haveCreatedSubDir32Bit = true;
                }
                break;

            case "x86_64":
                if (t != BuildTarget.StandaloneOSX &&
                    t != BuildTarget.StandaloneWindows64 &&
                    t != BuildTarget.StandaloneLinux64)
                {
                    continue;
                }
                if (!haveCreatedSubDir64Bit)
                {
                    Directory.CreateDirectory(subDir64Bit);
                    haveCreatedSubDir64Bit = true;
                }
                break;

            // This is a special case for CPU targets, means no valid CPU is selected
            case "None":
                continue;
            }

            string destinationPath = pluginImpExtension.CalculateFinalPluginPath(buildTargetName, imp);
            if (string.IsNullOrEmpty(destinationPath))
            {
                continue;
            }

            string finalDestinationPath = Path.Combine(pluginsFolder, destinationPath);

            if (isDirectory)
            {
                FileUtil.CopyDirectoryRecursive(imp.assetPath, finalDestinationPath);
            }
            else
            {
                FileUtil.UnityFileCopy(imp.assetPath, finalDestinationPath);
            }
        }

        // TODO: Move all plugins using GetExtensionPlugins to GetImporters and remove GetExtensionPlugins
        foreach (UnityEditorInternal.PluginDesc pluginDesc in PluginImporter.GetExtensionPlugins(args.target))
        {
            if (!haveCreatedPluginsFolder)
            {
                Directory.CreateDirectory(pluginsFolder);
                haveCreatedPluginsFolder = true;
            }

            string pluginCopyPath = Path.Combine(pluginsFolder, Path.GetFileName(pluginDesc.pluginPath));

            // Plugins copied through GetImporters take priority, don't overwrite
            if (Directory.Exists(pluginCopyPath) || File.Exists(pluginCopyPath))
            {
                continue;
            }

            if (Directory.Exists(pluginDesc.pluginPath))
            {
                FileUtil.CopyDirectoryRecursive(pluginDesc.pluginPath, pluginCopyPath);
            }
            else
            {
                FileUtil.CopyFileIfExists(pluginDesc.pluginPath, pluginCopyPath, false);
            }
        }
    }
Exemple #15
0
 protected virtual void CheckSafeProjectOverwrite(BuildPostProcessArgs args)
 {
 }
Exemple #16
0
 protected static string GetPathSafeProductName(BuildPostProcessArgs args)
 {
     return(Paths.MakeValidFileName(args.productName));
 }
Exemple #17
0
 protected DesktopStandalonePostProcessor(BuildPostProcessArgs postProcessArgs)
 {
     this.m_PostProcessArgs = postProcessArgs;
 }
Exemple #18
0
 protected abstract void RenameFilesInStagingArea(BuildPostProcessArgs args);
 public override void PostProcess(BuildPostProcessArgs args)
 {
     SetupStagingArea(args);
     CopyStagingAreaIntoDestination(args);
 }
Exemple #20
0
 protected abstract IIl2CppPlatformProvider GetPlatformProvider(BuildPostProcessArgs args);
 protected virtual void CopyPlayerSolutionIntoStagingArea(BuildPostProcessArgs args)
 {
     throw new Exception("CreateSolution is not supported on " + BuildPipeline.GetBuildTargetName(args.target));
 }
Exemple #22
0
 protected virtual void ProcessPlatformSpecificIL2CPPOutput(BuildPostProcessArgs args)
 {
 }
 protected abstract void DeleteDestination(BuildPostProcessArgs args);
Exemple #24
0
 protected virtual void ProcessSymbolFiles(BuildPostProcessArgs args)
 {
 }
 protected abstract void CopyDataForBuildsFolder(BuildPostProcessArgs args);
Exemple #26
0
 protected static string GetIl2CppDataBackupFolderName(BuildPostProcessArgs args)
 {
     return(Path.GetFileNameWithoutExtension(args.installPath) + "_BackUpThisFolder_ButDontShipItWithYourGame");
 }
 protected virtual string GetDestinationFolder(BuildPostProcessArgs args)
 {
     return(FileUtil.UnityGetDirectoryName(args.installPath));
 }
Exemple #28
0
 protected virtual string GetDirectoryForGameAssembly(BuildPostProcessArgs args)
 {
     return(args.stagingArea);
 }
 protected virtual string GetVariationName(BuildPostProcessArgs args)
 {
     return(string.Format("{0}_{1}",
                          PlatformStringFor(args.target),
                          (GetDevelopment(args) ? "development" : "nondevelopment")));
 }
Exemple #30
0
 public void PostProcess(BuildPostProcessArgs args)
 {
     base.m_PostProcessArgs = args;
     base.PostProcess();
 }