Пример #1
0
        /// <summary>
        /// NOTE: This function must mirror the functionality of TargetPlatformBase::RequiresTempTarget
        /// </summary>
        private static bool RequiresTempTarget(FileReference RawProjectPath, bool bProjectHasCode, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, TargetType TargetType, bool bRequiresAssetNativization, bool bRequiresCookedData, out string OutReason)
        {
            // check to see if we already have a Target.cs file
            if (bProjectHasCode)
            {
                OutReason = null;
                return(false);
            }

            // check if asset nativization is enabled
            if (bRequiresAssetNativization)
            {
                OutReason = "asset nativization is enabled";
                return(true);
            }

            // Check if encryption or signing is enabled
            EncryptionAndSigning.CryptoSettings Settings = EncryptionAndSigning.ParseCryptoSettings(RawProjectPath.Directory, Platform);
            if (Settings.IsAnyEncryptionEnabled() || Settings.IsPakSigningEnabled())
            {
                OutReason = "encryption/signing is enabled";
                return(true);
            }

            // check the target platforms for any differences in build settings or additional plugins
            if (!CommandUtils.IsEngineInstalled() && !PlatformExports.HasDefaultBuildConfig(RawProjectPath, Platform))
            {
                OutReason = "project has non-default build configuration";
                return(true);
            }
            if (PlatformExports.RequiresBuild(RawProjectPath, Platform))
            {
                OutReason = "overriden by target platform";
                return(true);
            }

            // Read the project descriptor, and find all the plugins available to this project
            ProjectDescriptor Project = ProjectDescriptor.FromFile(RawProjectPath);

            // Enumerate all the available plugins
            Dictionary <string, PluginInfo> AllPlugins = Plugins.ReadAvailablePlugins(CommandUtils.EngineDirectory, DirectoryReference.FromFile(RawProjectPath), new List <DirectoryReference>()).ToDictionary(x => x.Name, x => x, StringComparer.OrdinalIgnoreCase);

            // find if there are any plugins enabled or disabled which differ from the default
            string Reason;

            if (RequiresTempTargetForCodePlugin(Project, Platform, Configuration, TargetType, AllPlugins, out Reason))
            {
                OutReason = Reason;
                return(true);
            }

            OutReason = null;
            return(false);
        }
Пример #2
0
        private static bool RequiresTempTarget(FileReference RawProjectPath, List <UnrealTargetPlatform> ClientTargetPlatforms, List <UnrealTargetConfiguration> ClientTargetConfigurations, bool AssetNativizationRequested, out string Reason)
        {
            // check to see if we already have a Target.cs file
            if (File.Exists(Path.Combine(Path.GetDirectoryName(RawProjectPath.FullName), "Source", RawProjectPath.GetFileNameWithoutExtension() + ".Target.cs")))
            {
                Reason = null;
                return(false);
            }
            else if (Directory.Exists(Path.Combine(Path.GetDirectoryName(RawProjectPath.FullName), "Source")))
            {
                // wasn't one in the main Source directory, let's check all sub-directories
                //@todo: may want to read each target.cs to see if it has a target corresponding to the project name as a final check
                FileInfo[] Files = (new DirectoryInfo(Path.Combine(Path.GetDirectoryName(RawProjectPath.FullName), "Source")).GetFiles("*.Target.cs", SearchOption.AllDirectories));
                if (Files.Length > 0)
                {
                    Reason = null;
                    return(false);
                }
            }

            //
            // once we reach this point, we can surmise that this is an asset-
            // only (code free) project

            if (AssetNativizationRequested)
            {
                // we're going to be converting some of the project's assets
                // into native code, so we require a distinct target (executable)
                // be generated for this project
                Reason = "asset nativization is enabled";
                return(true);
            }

            if (ClientTargetPlatforms != null)
            {
                foreach (UnrealTargetPlatform ClientPlatform in ClientTargetPlatforms)
                {
                    EncryptionAndSigning.CryptoSettings Settings = EncryptionAndSigning.ParseCryptoSettings(RawProjectPath.Directory, ClientPlatform);
                    if (Settings.IsAnyEncryptionEnabled() || Settings.IsPakSigningEnabled())
                    {
                        Reason = "encryption/signing is enabled";
                        return(true);
                    }
                }
            }

            // no Target file, now check to see if build settings have changed
            List <UnrealTargetPlatform> TargetPlatforms = ClientTargetPlatforms;

            if (ClientTargetPlatforms == null || ClientTargetPlatforms.Count < 1)
            {
                // No client target platforms, add all in
                TargetPlatforms = new List <UnrealTargetPlatform>();
                foreach (UnrealTargetPlatform TargetPlatformType in Enum.GetValues(typeof(UnrealTargetPlatform)))
                {
                    if (TargetPlatformType != UnrealTargetPlatform.Unknown)
                    {
                        TargetPlatforms.Add(TargetPlatformType);
                    }
                }
            }

            List <UnrealTargetConfiguration> TargetConfigurations = ClientTargetConfigurations;

            if (TargetConfigurations == null || TargetConfigurations.Count < 1)
            {
                // No client target configurations, add all in
                TargetConfigurations = new List <UnrealTargetConfiguration>();
                foreach (UnrealTargetConfiguration TargetConfigurationType in Enum.GetValues(typeof(UnrealTargetConfiguration)))
                {
                    if (TargetConfigurationType != UnrealTargetConfiguration.Unknown)
                    {
                        TargetConfigurations.Add(TargetConfigurationType);
                    }
                }
            }

            // Read the project descriptor, and find all the plugins available to this project
            ProjectDescriptor Project          = ProjectDescriptor.FromFile(RawProjectPath);
            List <PluginInfo> AvailablePlugins = Plugins.ReadAvailablePlugins(CommandUtils.EngineDirectory, RawProjectPath, Project.AdditionalPluginDirectories);

            // check the target platforms for any differences in build settings or additional plugins
            foreach (UnrealTargetPlatform TargetPlatformType in TargetPlatforms)
            {
                if (!CommandUtils.IsEngineInstalled() && !PlatformExports.HasDefaultBuildConfig(RawProjectPath, TargetPlatformType))
                {
                    Reason = "project has non-default build configuration";
                    return(true);
                }
                if (PlatformExports.RequiresBuild(RawProjectPath, TargetPlatformType))
                {
                    Reason = "overriden by target platform";
                    return(true);
                }

                // find if there are any plugins enabled or disabled which differ from the default
                foreach (PluginInfo Plugin in AvailablePlugins)
                {
                    bool bPluginEnabledForTarget = false;
                    foreach (UnrealTargetConfiguration TargetConfigType in TargetConfigurations)
                    {
                        bPluginEnabledForTarget |= Plugins.IsPluginEnabledForProject(Plugin, Project, TargetPlatformType, TargetConfigType, TargetRules.TargetType.Game);
                    }

                    bool bPluginEnabledForBaseTarget = false;
                    if (!Plugin.Descriptor.bInstalled)
                    {
                        foreach (UnrealTargetConfiguration TargetConfigType in TargetConfigurations)
                        {
                            bPluginEnabledForBaseTarget |= Plugins.IsPluginEnabledForProject(Plugin, null, TargetPlatformType, TargetConfigType, TargetRules.TargetType.Game);
                        }
                    }

                    if (bPluginEnabledForTarget != bPluginEnabledForBaseTarget)
                    {
                        if (bPluginEnabledForTarget)
                        {
                            Reason = String.Format("{0} plugin is enabled", Plugin.Name);
                            return(true);
                        }
                        else
                        {
                            Reason = String.Format("{0} plugin is disabled", Plugin.Name);
                            return(true);
                        }
                    }
                }
            }

            Reason = null;
            return(false);
        }