Пример #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, bool AssetNativizationRequested)
		{
			// 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")))
			{
				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)
				{
					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
                return true;
            }

			if (ClientTargetPlatforms != null)
			{
				foreach (UnrealTargetPlatform ClientPlatform in ClientTargetPlatforms)
				{
					EncryptionAndSigning.CryptoSettings Settings = EncryptionAndSigning.ParseCryptoSettings(RawProjectPath.Directory, ClientPlatform);
					if (Settings.IsAnyEncryptionEnabled() || Settings.bEnablePakSigning)
					{
						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);
					}
				}
			}

			// Change the working directory to be the Engine/Source folder. We are running from Engine/Binaries/DotNET
			DirectoryReference oldCWD = DirectoryReference.GetCurrentDirectory();
			try
			{
				DirectoryReference EngineSourceDirectory = DirectoryReference.Combine(CommandUtils.EngineDirectory, "Source");
				if (!DirectoryReference.Exists(EngineSourceDirectory)) // only set the directory if it exists, this should only happen if we are launching the editor from an artist sync
				{
					EngineSourceDirectory = DirectoryReference.Combine(CommandUtils.EngineDirectory, "Binaries");
				}
				Directory.SetCurrentDirectory(EngineSourceDirectory.FullName);

				// 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
				bool RetVal = false;
				foreach (UnrealTargetPlatform TargetPlatformType in TargetPlatforms)
				{
					if(!Automation.IsEngineInstalled() && !PlatformExports.HasDefaultBuildConfig(RawProjectPath, TargetPlatformType))
					{
						RetVal = true;
						break;
					}

					// find if there are any plugins enabled or disabled which differ from the default
					foreach(PluginInfo Plugin in AvailablePlugins)
					{
						bool bPluginEnabledForProject = Plugins.IsPluginEnabledForProject(Plugin, Project, TargetPlatformType, TargetType.Game);
						if ((bPluginEnabledForProject != Plugin.EnabledByDefault) || (bPluginEnabledForProject && Plugin.Descriptor.bInstalled))
						{
							// NOTE: this code was only marking plugins that compiled for the platform to upgrade to code project, however
							// this doesn't work in practice, because the runtime code will look for the plugin, without a .uplugin file,
							// and will fail. This is the safest way to make sure all platforms are acting the same. However, if you 
							// whitelist the plugin in the .uproject file, the above UProjectInfo.IsPluginEnabledForProject check won't pass
							// so you won't get in here. Leaving this commented out code in there, because someone is bound to come looking 
							// for why a non-whitelisted platform module is causing a project to convert to code-based. 
							// As an aside, if you run the project with UE4Game (not your Project's binary) from the debugger, it will work
							// _in this case_ because the .uplugin file will have been staged, and there is no needed library 
							// if(Plugin.Descriptor.Modules.Any(Module => Module.IsCompiledInConfiguration(TargetPlatformType, TargetType.Game, bBuildDeveloperTools: false, bBuildEditor: false)))
							{
								RetVal = true;
								break;
							}
						}
					}
				}
				return RetVal;
			}
			finally
			{
				// Change back to the original directory
				Directory.SetCurrentDirectory(oldCWD.FullName);
			}
		}
Пример #3
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);
        }