Example #1
0
 /// <summary>
 /// Builds BuildPatchTool for the specified platform.
 /// </summary>
 /// <param name="Command"></param>
 /// <param name="InPlatform"></param>
 public static void BuildBuildPatchTool(BuildCommand Command, UnrealBuildTool.UnrealTargetPlatform InPlatform)
 {
     BuildProduct(Command, new UE4Build.BuildTarget()
     {
         ProjectName = "",
         TargetName  = "BuildPatchTool",
         Platform    = InPlatform,
         Config      = UnrealBuildTool.UnrealTargetConfiguration.Development,
     });
 }
Example #2
0
 /// <summary>
 /// Builds BuildPatchTool for the specified platform.
 /// </summary>
 /// <param name="Command"></param>
 /// <param name="InPlatform"></param>
 public static void BuildBuildPatchTool(BuildCommand Command, UnrealBuildTool.UnrealTargetPlatform InPlatform)
 {
     BuildProduct(Command, new UE4Build.BuildTarget()
     {
         UprojectPath = null,
         TargetName   = "BuildPatchTool",
         Platform     = InPlatform,
         Config       = UnrealBuildTool.UnrealTargetConfiguration.Shipping,
     });
 }
Example #3
0
 /// <summary>
 /// Builds UnrealHeaderTool for the specified platform.
 /// </summary>
 /// <param name="Command"></param>
 /// <param name="InPlatform"></param>
 public static void BuildUnrealHeaderTool(BuildCommand Command, UnrealBuildTool.UnrealTargetPlatform InPlatform)
 {
     BuildProduct(Command, new UE4Build.BuildTarget()
     {
         UprojectPath = null,
         TargetName   = "UnrealHeaderTool",
         Platform     = InPlatform,
         Config       = UnrealBuildTool.UnrealTargetConfiguration.Development,
     });
 }
 /// <summary>
 /// Returns the default path of the editor executable to use for running commandlets.
 /// </summary>
 /// <param name="BuildRoot">Root directory for the build</param>
 /// <param name="HostPlatform">Platform to get the executable for</param>
 /// <returns>Path to the editor executable</returns>
 public static string GetEditorCommandletExe(string BuildRoot, UnrealBuildTool.UnrealTargetPlatform HostPlatform)
 {
     if (HostPlatform == UnrealBuildTool.UnrealTargetPlatform.Mac)
     {
         return(CommandUtils.CombinePaths(BuildRoot, "Engine/Binaries/Mac/UE4Editor.app/Contents/MacOS/UE4Editor"));
     }
     if (HostPlatform == UnrealBuildTool.UnrealTargetPlatform.Win64)
     {
         return(CommandUtils.CombinePaths(BuildRoot, "Engine/Binaries/Win64/UE4Editor-Cmd.exe"));
     }
     if (HostPlatform == UnrealBuildTool.UnrealTargetPlatform.Linux)
     {
         return(CommandUtils.CombinePaths(BuildRoot, "Engine/Binaries/Linux/UE4Editor"));
     }
     throw new AutomationException("EditorCommandlet is not supported for platform {0}", HostPlatform);
 }
Example #5
0
    /// <summary>
    /// Builds BuildPatchTool for the specified platform.
    /// </summary>
    /// <param name="Command"></param>
    /// <param name="InPlatform"></param>
    public static void BuildBuildPatchTool(BuildCommand Command, UnrealBuildTool.UnrealTargetPlatform InPlatform)
    {
        Log("Building BuildPatchTool");

        if (Command == null)
        {
            Command = new UE4BuildUtilDummyBuildCommand();
        }

        var UE4Build = new UE4Build(Command);

        var Agenda = new UE4Build.BuildAgenda();

        Agenda.Targets.Add(new UE4Build.BuildTarget()
        {
            ProjectName = "",
            TargetName  = "BuildPatchTool",
            Platform    = InPlatform,
            Config      = UnrealBuildTool.UnrealTargetConfiguration.Development,
        });

        UE4Build.Build(Agenda, InDeleteBuildProducts: true, InUpdateVersionFiles: true);
        UE4Build.CheckBuildProducts(UE4Build.BuildProductFiles);
    }
Example #6
0
 /// <summary>
 /// Determines if this reference is valid for the given target platform.
 /// </summary>
 /// <param name="Platform">The platform to check</param>
 /// <returns>True if the plugin for this target platform</returns>
 public bool IsSupportedTargetPlatform(UnrealTargetPlatform Platform)
 {
     return(SupportedTargetPlatforms == null || SupportedTargetPlatforms.Count == 0 || SupportedTargetPlatforms.Contains(Platform));
 }
Example #7
0
        /// <summary>
        /// Determine if a plugin is enabled for a given project
        /// </summary>
        /// <param name="Project">The project to check</param>
        /// <param name="Plugin">Information about the plugin</param>
        /// <param name="Platform">The target platform</param>
        /// <param name="Target"></param>
        /// <returns>True if the plugin should be enabled for this project</returns>
        public static bool IsPluginEnabledForProject(PluginInfo Plugin, ProjectDescriptor Project, UnrealTargetPlatform Platform, TargetType Target)
        {
            bool bEnabled = Plugin.EnabledByDefault;

            if (Project != null && Project.Plugins != null)
            {
                foreach (PluginReferenceDescriptor PluginReference in Project.Plugins)
                {
                    if (String.Compare(PluginReference.Name, Plugin.Name, true) == 0)
                    {
                        bEnabled = PluginReference.IsEnabledForPlatform(Platform) && PluginReference.IsEnabledForTarget(Target);
                    }
                }
            }
            return(bEnabled);
        }
Example #8
0
        /// <summary>
        /// Creates a target rules object for the specified target name.
        /// </summary>
        /// <param name="TargetName">Name of the target</param>
        /// <param name="Platform">Platform being compiled</param>
        /// <param name="Configuration">Configuration being compiled</param>
        /// <param name="Architecture">Architecture being built</param>
        /// <param name="ProjectFile">Path to the project file for this target</param>
        /// <param name="bInEditorRecompile">Whether this is an editor recompile, where we need to guess the name of the editor target</param>
        /// <param name="TargetFileName">The original source file name of the Target.cs file for this target</param>
        /// <returns>The build target rules for the specified target</returns>
        public TargetRules CreateTargetRules(string TargetName, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, string Architecture, FileReference ProjectFile, bool bInEditorRecompile, out FileReference TargetFileName)
        {
            // Make sure the target file is known to us
            bool bFoundTargetName = TargetNameToTargetFile.ContainsKey(TargetName);

            if (bFoundTargetName == false)
            {
                if (Parent == null)
                {
                    //				throw new BuildException("Couldn't find target rules file for target '{0}' in rules assembly '{1}'.", TargetName, RulesAssembly.FullName);
                    string ExceptionMessage = "Couldn't find target rules file for target '";
                    ExceptionMessage += TargetName;
                    ExceptionMessage += "' in rules assembly '";
                    ExceptionMessage += CompiledAssembly.FullName;
                    ExceptionMessage += "'." + Environment.NewLine;

                    ExceptionMessage += "Location: " + CompiledAssembly.Location + Environment.NewLine;

                    ExceptionMessage += "Target rules found:" + Environment.NewLine;
                    foreach (KeyValuePair <string, FileReference> entry in TargetNameToTargetFile)
                    {
                        ExceptionMessage += "\t" + entry.Key + " - " + entry.Value + Environment.NewLine;
                    }

                    throw new BuildException(ExceptionMessage);
                }
                else
                {
                    return(Parent.CreateTargetRules(TargetName, Platform, Configuration, Architecture, ProjectFile, bInEditorRecompile, out TargetFileName));
                }
            }

            // Return the target file name to the caller
            TargetFileName = TargetNameToTargetFile[TargetName];

            // Currently, we expect the user's rules object type name to be the same as the module name + 'Target'
            string TargetTypeName = TargetName + "Target";

            // The build module must define a type named '<TargetName>Target' that derives from our 'TargetRules' type.
            TargetRules RulesObject = CreateTargetRulesInstance(TargetTypeName, new TargetInfo(TargetName, Platform, Configuration, Architecture, ProjectFile));

            if (bInEditorRecompile)
            {
                // Make sure this is an editor module.
                if (RulesObject != null)
                {
                    if (RulesObject.Type != TargetType.Editor)
                    {
                        // Not the editor... determine the editor project
                        string TargetSourceFolderString = TargetFileName.FullName;
                        Int32  SourceFolderIndex        = -1;
                        if (Utils.IsRunningOnMono)
                        {
                            TargetSourceFolderString = TargetSourceFolderString.Replace("\\", "/");
                            SourceFolderIndex        = TargetSourceFolderString.LastIndexOf("/Source/", StringComparison.InvariantCultureIgnoreCase);
                        }
                        else
                        {
                            TargetSourceFolderString = TargetSourceFolderString.Replace("/", "\\");
                            SourceFolderIndex        = TargetSourceFolderString.LastIndexOf("\\Source\\", StringComparison.InvariantCultureIgnoreCase);
                        }
                        if (SourceFolderIndex != -1)
                        {
                            DirectoryReference TargetSourceFolder = new DirectoryReference(TargetSourceFolderString.Substring(0, SourceFolderIndex + 7));
                            foreach (KeyValuePair <string, FileReference> CheckEntry in TargetNameToTargetFile)
                            {
                                if (CheckEntry.Value.IsUnderDirectory(TargetSourceFolder))
                                {
                                    if (CheckEntry.Key.Equals(TargetName, StringComparison.InvariantCultureIgnoreCase) == false)
                                    {
                                        // We have found a target in the same source folder that is not the original target found.
                                        // See if it is the editor project
                                        string      CheckTargetTypeName = CheckEntry.Key + "Target";
                                        TargetRules CheckRulesObject    = CreateTargetRulesInstance(CheckTargetTypeName, new TargetInfo(CheckEntry.Key, Platform, Configuration, Architecture, ProjectFile));
                                        if (CheckRulesObject != null)
                                        {
                                            if (CheckRulesObject.Type == TargetType.Editor)
                                            {
                                                // Found it
                                                // NOTE: This prevents multiple Editor targets from co-existing...
                                                RulesObject = CheckRulesObject;
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(RulesObject);
        }
Example #9
0
        /// <summary>
        /// Construct a PluginReferenceDescriptor from a Json object
        /// </summary>
        /// <param name="RawObject">The Json object containing a plugin reference descriptor</param>
        /// <returns>New PluginReferenceDescriptor object</returns>
        public static PluginReferenceDescriptor FromJsonObject(JsonObject RawObject)
        {
            string[] WhitelistPlatformNames;
            string[] BlacklistPlatformNames;
            string[] SupportedTargetPlatformNames;

            PluginReferenceDescriptor Descriptor = new PluginReferenceDescriptor(RawObject.GetStringField("Name"), null, RawObject.GetBoolField("Enabled"));

            RawObject.TryGetBoolField("Optional", out Descriptor.bOptional);
            RawObject.TryGetStringField("Description", out Descriptor.Description);
            RawObject.TryGetStringField("MarketplaceURL", out Descriptor.MarketplaceURL);
            RawObject.TryGetStringArrayField("WhitelistPlatforms", out WhitelistPlatformNames);
            RawObject.TryGetStringArrayField("BlacklistPlatforms", out BlacklistPlatformNames);
            RawObject.TryGetEnumArrayField <UnrealTargetConfiguration>("WhitelistTargetConfigurations", out Descriptor.WhitelistTargetConfigurations);
            RawObject.TryGetEnumArrayField <UnrealTargetConfiguration>("BlacklistTargetConfigurations", out Descriptor.BlacklistTargetConfigurations);
            RawObject.TryGetEnumArrayField <TargetType>("WhitelistTargets", out Descriptor.WhitelistTargets);
            RawObject.TryGetEnumArrayField <TargetType>("BlacklistTargets", out Descriptor.BlacklistTargets);
            RawObject.TryGetStringArrayField("SupportedTargetPlatforms", out SupportedTargetPlatformNames);

            try
            {
                // convert string array to UnrealTargetPlatform arrays
                if (WhitelistPlatformNames != null)
                {
                    Descriptor.WhitelistPlatforms = WhitelistPlatformNames.Select(x => UnrealTargetPlatform.Parse(x)).ToList();
                }
                if (BlacklistPlatformNames != null)
                {
                    Descriptor.BlacklistPlatforms = BlacklistPlatformNames.Select(x => UnrealTargetPlatform.Parse(x)).ToList();
                }
                if (SupportedTargetPlatformNames != null)
                {
                    Descriptor.SupportedTargetPlatforms = SupportedTargetPlatformNames.Select(x => UnrealTargetPlatform.Parse(x)).ToList();
                }
            }
            catch (BuildException Ex)
            {
                ExceptionUtils.AddContext(Ex, "while parsing PluginReferenceDescriptor {0}", Descriptor.Name);
                throw;
            }


            return(Descriptor);
        }
Example #10
0
 ///
 ///	VisualStudio project generation functions
 ///
 /// <summary>
 /// Whether this build platform has native support for VisualStudio
 /// </summary>
 /// <param name="InPlatform">  The UnrealTargetPlatform being built</param>
 /// <param name="InConfiguration"> The UnrealTargetConfiguration being built</param>
 /// <param name="ProjectFileFormat"></param>
 /// <returns>bool    true if native VisualStudio support (or custom VSI) is available</returns>
 public override bool HasVisualStudioSupport(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, VCProjectFileFormat ProjectFileFormat)
 {
     // iOS is not supported in VisualStudio
     return(false);
 }
 /// <summary>
 /// Gets the default architecture for a given platform
 /// </summary>
 /// <param name="Platform">The platform to get the default architecture for</param>
 /// <param name="ProjectFile">Project file to read settings from</param>
 /// <returns>The default architecture</returns>
 public static string GetDefaultArchitecture(UnrealTargetPlatform Platform, FileReference ProjectFile)
 {
     return(UEBuildPlatform.GetBuildPlatform(Platform).GetDefaultArchitecture(ProjectFile));
 }
Example #12
0
        /// <summary>
        /// Determines whether the given plugin module is part of the current build.
        /// </summary>
        /// <param name="Platform">The platform being compiled for</param>
        /// <param name="Configuration">The target configuration being compiled for</param>
        /// <param name="TargetName">Name of the target being built</param>
        /// <param name="TargetType">The type of the target being compiled</param>
        /// <param name="bBuildDeveloperTools">Whether the configuration includes developer tools (typically UEBuildConfiguration.bBuildDeveloperTools for UBT callers)</param>
        /// <param name="bBuildRequiresCookedData">Whether the configuration requires cooked content (typically UEBuildConfiguration.bBuildRequiresCookedData for UBT callers)</param>
        public bool IsCompiledInConfiguration(UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, string TargetName, TargetType TargetType, bool bBuildDeveloperTools, bool bBuildRequiresCookedData)
        {
            // Check the platform is whitelisted
            if (WhitelistPlatforms != null && WhitelistPlatforms.Length > 0 && !WhitelistPlatforms.Contains(Platform))
            {
                return(false);
            }

            // Check the platform is not blacklisted
            if (BlacklistPlatforms != null && BlacklistPlatforms.Contains(Platform))
            {
                return(false);
            }

            // Check the target is whitelisted
            if (WhitelistTargets != null && WhitelistTargets.Length > 0 && !WhitelistTargets.Contains(TargetType))
            {
                return(false);
            }

            // Check the target is not blacklisted
            if (BlacklistTargets != null && BlacklistTargets.Contains(TargetType))
            {
                return(false);
            }

            // Check the target configuration is whitelisted
            if (WhitelistTargetConfigurations != null && WhitelistTargetConfigurations.Length > 0 && !WhitelistTargetConfigurations.Contains(Configuration))
            {
                return(false);
            }

            // Check the target configuration is not blacklisted
            if (BlacklistTargetConfigurations != null && BlacklistTargetConfigurations.Contains(Configuration))
            {
                return(false);
            }

            // Special checks just for programs
            if (TargetType == TargetType.Program)
            {
                // Check the program name is whitelisted. Note that this behavior is slightly different to other whitelist/blacklist checks; we will whitelist a module of any type if it's explicitly allowed for this program.
                if (WhitelistPrograms != null && WhitelistPrograms.Length > 0)
                {
                    return(WhitelistPrograms.Contains(TargetName));
                }

                // Check the program name is not blacklisted
                if (BlacklistPrograms != null && BlacklistPrograms.Contains(TargetName))
                {
                    return(false);
                }
            }

            // Check the module is compatible with this target.
            switch (Type)
            {
            case ModuleHostType.Runtime:
            case ModuleHostType.RuntimeNoCommandlet:
                return(TargetType != TargetType.Program);

            case ModuleHostType.RuntimeAndProgram:
                return(true);

            case ModuleHostType.CookedOnly:
                return(bBuildRequiresCookedData);

            case ModuleHostType.UncookedOnly:
                return(!bBuildRequiresCookedData);

            case ModuleHostType.Developer:
                return(TargetType == TargetType.Editor || TargetType == TargetType.Program);

            case ModuleHostType.DeveloperTool:
                return(bBuildDeveloperTools);

            case ModuleHostType.Editor:
            case ModuleHostType.EditorNoCommandlet:
                return(TargetType == TargetType.Editor);

            case ModuleHostType.EditorAndProgram:
                return(TargetType == TargetType.Editor || TargetType == TargetType.Program);

            case ModuleHostType.Program:
                return(TargetType == TargetType.Program);

            case ModuleHostType.ServerOnly:
                return(TargetType != TargetType.Program && TargetType != TargetType.Client);

            case ModuleHostType.ClientOnly:
                return(TargetType != TargetType.Program && TargetType != TargetType.Server);
            }

            return(false);
        }
        /// <summary>
        /// Returns the standard path to the build receipt for a given target
        /// </summary>
        /// <param name="BaseDir">Base directory for the target being built; either the project directory or engine directory.</param>
        /// <param name="TargetName">The target being built</param>
        /// <param name="Platform">The target platform</param>
        /// <param name="Configuration">The target configuration</param>
        /// <param name="BuildArchitecture">The architecture being built</param>
        /// <returns>Path to the receipt for this target</returns>
        public static FileReference GetDefaultPath(DirectoryReference BaseDir, string TargetName, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, string BuildArchitecture)
        {
            // Get the architecture suffix. Platforms have the option of overriding whether to include this string in filenames.
            string ArchitectureSuffix = "";

            if (UEBuildPlatform.GetBuildPlatform(Platform).RequiresArchitectureSuffix())
            {
                ArchitectureSuffix = BuildArchitecture;
            }

            // Build the output filename
            if (String.IsNullOrEmpty(ArchitectureSuffix) && Configuration == UnrealTargetConfiguration.Development)
            {
                return(FileReference.Combine(BaseDir, "Binaries", Platform.ToString(), String.Format("{0}.target", TargetName)));
            }
            else
            {
                return(FileReference.Combine(BaseDir, "Binaries", Platform.ToString(), String.Format("{0}-{1}-{2}{3}.target", TargetName, Platform.ToString(), Configuration.ToString(), ArchitectureSuffix)));
            }
        }
        public override bool PrepTargetForDeployment(TargetReceipt Receipt)
        {
            // Use the project name if possible - InTarget.AppName changes for 'Client'/'Server' builds
            string ProjectName = Receipt.ProjectFile != null?Receipt.ProjectFile.GetFileNameWithoutAnyExtensions() : Receipt.Launch.GetFileNameWithoutExtension();

            Log.TraceInformation("Prepping {0} for deployment to {1}", ProjectName, Receipt.Platform.ToString());
            System.DateTime PrepDeployStartTime = DateTime.UtcNow;

            // Note: TargetReceipt.Read now expands path variables internally.
            TargetReceipt NewReceipt      = null;
            FileReference ReceiptFileName = TargetReceipt.GetDefaultPath(Receipt.ProjectDir != null ? Receipt.ProjectDir : UnrealBuildTool.EngineDirectory, Receipt.TargetName, Receipt.Platform, Receipt.Configuration, "Multi");

            if (!TargetReceipt.TryRead(ReceiptFileName, UnrealBuildTool.EngineDirectory, out NewReceipt))
            {
                NewReceipt = new TargetReceipt(Receipt.ProjectFile, Receipt.TargetName, Receipt.TargetType, Receipt.Platform, Receipt.Configuration, Receipt.Version, "Multi");
            }

            AddWinMDReferencesFromReceipt(Receipt, Receipt.ProjectDir != null ? Receipt.ProjectDir : UnrealBuildTool.EngineDirectory, UnrealBuildTool.EngineDirectory.ParentDirectory.FullName);

            //PrepForUATPackageOrDeploy(InTarget.ProjectFile, InAppName, InTarget.ProjectDirectory.FullName, InTarget.OutputPath.FullName, TargetBuildEnvironment.RelativeEnginePath, false, "", false);
            List <UnrealTargetConfiguration> TargetConfigs = new List <UnrealTargetConfiguration> {
                Receipt.Configuration
            };
            List <string> ExePaths = new List <string> {
                Receipt.Launch.FullName
            };
            string RelativeEnginePath = UnrealBuildTool.EngineDirectory.MakeRelativeTo(DirectoryReference.GetCurrentDirectory());

            WindowsArchitecture Arch = WindowsArchitecture.ARM64;

            if (Receipt.Architecture.ToLower() == "x64")
            {
                Arch = WindowsArchitecture.x64;
            }

            string SDK     = "";
            var    Results = Receipt.AdditionalProperties.Where(x => x.Name == "SDK");

            if (Results.Any())
            {
                SDK = Results.First().Value;
            }
            HoloLensExports.InitWindowsSdkToolPath(SDK);

            string AbsoluteExeDirectory         = Path.GetDirectoryName(ExePaths[0]);
            UnrealTargetPlatform Platform       = UnrealTargetPlatform.HoloLens;
            string        IntermediateDirectory = Path.Combine(Receipt.ProjectDir != null ? Receipt.ProjectDir.FullName : UnrealBuildTool.EngineDirectory.FullName, "Intermediate", "Deploy", WindowsExports.GetArchitectureSubpath(Arch));
            List <string> UpdatedFiles          = new HoloLensManifestGenerator().CreateManifest(Platform, Arch, AbsoluteExeDirectory, IntermediateDirectory, Receipt.ProjectFile, Receipt.ProjectDir != null ? Receipt.ProjectDir.FullName : UnrealBuildTool.EngineDirectory.FullName, TargetConfigs, ExePaths, WinMDReferences);

            PrepForUATPackageOrDeploy(Receipt.ProjectFile, ProjectName, Receipt.ProjectDir != null ? Receipt.ProjectDir.FullName : UnrealBuildTool.EngineDirectory.FullName, Arch, TargetConfigs, ExePaths, RelativeEnginePath, false, "", false);
            MakePackage(Receipt, NewReceipt, Arch, UpdatedFiles);
            CopyDataAndSymbolsBetweenReceipts(Receipt, NewReceipt, Arch);

            NewReceipt.Write(ReceiptFileName, UnrealBuildTool.EngineDirectory);

            // Log out the time taken to deploy...
            double PrepDeployDuration = (DateTime.UtcNow - PrepDeployStartTime).TotalSeconds;

            Log.TraceInformation("HoloLens deployment preparation took {0:0.00} seconds", PrepDeployDuration);

            return(true);
        }
Example #15
0
        /// <summary>
        /// Constructs a ModuleDescriptor from a Json object
        /// </summary>
        /// <param name="InObject"></param>
        /// <returns>The new module descriptor</returns>
        public static ModuleDescriptor FromJsonObject(JsonObject InObject)
        {
            ModuleDescriptor Module = new ModuleDescriptor(InObject.GetStringField("Name"), InObject.GetEnumField <ModuleHostType>("Type"));

            ModuleLoadingPhase LoadingPhase;

            if (InObject.TryGetEnumField <ModuleLoadingPhase>("LoadingPhase", out LoadingPhase))
            {
                Module.LoadingPhase = LoadingPhase;
            }

            try
            {
                string[] WhitelistPlatforms;
                if (InObject.TryGetStringArrayField("WhitelistPlatforms", out WhitelistPlatforms))
                {
                    Module.WhitelistPlatforms = Array.ConvertAll(WhitelistPlatforms, x => UnrealTargetPlatform.Parse(x));
                }

                string[] BlacklistPlatforms;
                if (InObject.TryGetStringArrayField("BlacklistPlatforms", out BlacklistPlatforms))
                {
                    Module.BlacklistPlatforms = Array.ConvertAll(BlacklistPlatforms, x => UnrealTargetPlatform.Parse(x));
                }
            }
            catch (BuildException Ex)
            {
                ExceptionUtils.AddContext(Ex, "while parsing module descriptor '{0}'", Module.Name);
                throw;
            }

            TargetType[] WhitelistTargets;
            if (InObject.TryGetEnumArrayField <TargetType>("WhitelistTargets", out WhitelistTargets))
            {
                Module.WhitelistTargets = WhitelistTargets;
            }

            TargetType[] BlacklistTargets;
            if (InObject.TryGetEnumArrayField <TargetType>("BlacklistTargets", out BlacklistTargets))
            {
                Module.BlacklistTargets = BlacklistTargets;
            }

            UnrealTargetConfiguration[] WhitelistTargetConfigurations;
            if (InObject.TryGetEnumArrayField <UnrealTargetConfiguration>("WhitelistTargetConfigurations", out WhitelistTargetConfigurations))
            {
                Module.WhitelistTargetConfigurations = WhitelistTargetConfigurations;
            }

            UnrealTargetConfiguration[] BlacklistTargetConfigurations;
            if (InObject.TryGetEnumArrayField <UnrealTargetConfiguration>("BlacklistTargetConfigurations", out BlacklistTargetConfigurations))
            {
                Module.BlacklistTargetConfigurations = BlacklistTargetConfigurations;
            }

            string[] WhitelistPrograms;
            if (InObject.TryGetStringArrayField("WhitelistPrograms", out WhitelistPrograms))
            {
                Module.WhitelistPrograms = WhitelistPrograms;
            }

            string[] BlacklistPrograms;
            if (InObject.TryGetStringArrayField("BlacklistPrograms", out BlacklistPrograms))
            {
                Module.BlacklistPrograms = BlacklistPrograms;
            }

            string[] AdditionalDependencies;
            if (InObject.TryGetStringArrayField("AdditionalDependencies", out AdditionalDependencies))
            {
                Module.AdditionalDependencies = AdditionalDependencies;
            }

            return(Module);
        }
Example #16
0
 public LinuxPlatform(UnrealTargetPlatform UnrealTarget, CppPlatform InCppPlatform, LinuxPlatformSDK InSDK)
     : base(UnrealTarget, InCppPlatform)
 {
     SDK = InSDK;
 }
        private static bool IsPathExcludedOnPlatform(string SourceFileRelativeToRoot, UnrealTargetPlatform targetPlatform)
        {
            switch (targetPlatform)
            {
            case UnrealTargetPlatform.Linux:
            {
                return(IsPathExcludedOnLinux(SourceFileRelativeToRoot));
            }

            case UnrealTargetPlatform.Mac:
            {
                return(IsPathExcludedOnMac(SourceFileRelativeToRoot));
            }

            case UnrealTargetPlatform.Win64:
            {
                return(IsPathExcludedOnWindows(SourceFileRelativeToRoot));
            }

            default:
            {
                return(false);
            }
            }
        }
Example #18
0
        /// <summary>
        /// Loads JunkManifest.txt file.
        /// </summary>
        /// <returns>Junk manifest file contents.</returns>
        static private List <string> LoadJunkManifest()
        {
            string        ManifestPath = ".." + Path.DirectorySeparatorChar + "Build" + Path.DirectorySeparatorChar + "JunkManifest.txt";
            List <string> JunkManifest = new List <string>();

            if (File.Exists(ManifestPath))
            {
                string MachineName = Environment.MachineName;
                using (StreamReader reader = new StreamReader(ManifestPath))
                {
                    string CurrentToRootDir = ".." + Path.DirectorySeparatorChar + "..";
                    string LineRead;
                    while ((LineRead = reader.ReadLine()) != null)
                    {
                        string JunkEntry = LineRead.Trim();
                        if (String.IsNullOrEmpty(JunkEntry) == false)
                        {
                            string[] Tokens           = JunkEntry.Split(":".ToCharArray());
                            bool     bIsValidJunkLine = true;
                            foreach (string Token in Tokens)
                            {
                                if (Token.StartsWith("Machine=", StringComparison.InvariantCultureIgnoreCase) == true)
                                {
                                    string[] InnerTokens = Token.Split("=".ToCharArray());
                                    // check if the machine name on the line matches the current machine name, if not, we don't apply this junk
                                    if (InnerTokens.Length == 2 && MachineName.StartsWith(InnerTokens[1]) == false)
                                    {
                                        // Not meant for this machine
                                        bIsValidJunkLine = false;
                                    }
                                }
                                else if (Token.StartsWith("Platform=", StringComparison.InvariantCultureIgnoreCase) == true)
                                {
                                    string[] InnerTokens = Token.Split("=".ToCharArray());
                                    // check if the machine name on the line matches the current machine name, if not, we don't apply this junk
                                    if (InnerTokens.Length == 2)
                                    {
                                        UnrealTargetPlatform ParsedPlatform = UEBuildPlatform.ConvertStringToPlatform(InnerTokens[1]);
                                        // if the platform is valid, then we want to keep the files, which means that we don't want to apply the junk line
                                        if (ParsedPlatform != UnrealTargetPlatform.Unknown)
                                        {
                                            if (UEBuildPlatform.GetBuildPlatform(ParsedPlatform, bInAllowFailure: true) != null)
                                            {
                                                // this is a good platform, so don't delete any files!
                                                bIsValidJunkLine = false;
                                            }
                                        }
                                    }
                                }
                            }

                            // All paths within the manifest are UE4 root directory relative.
                            // UBT's working directory is Engine\Source so add "..\..\" to each of the entires.
                            if (bIsValidJunkLine)
                            {
                                // the entry is always the last element in the token array (after the final :)
                                string FixedPath = Path.Combine(CurrentToRootDir, Tokens[Tokens.Length - 1]);
                                FixedPath = FixedPath.Replace('\\', Path.DirectorySeparatorChar);
                                JunkManifest.Add(FixedPath);
                            }
                        }
                    }
                }
            }
            return(JunkManifest);
        }
Example #19
0
        /// <summary>
        /// Determine if a plugin is enabled for a given project
        /// </summary>
        /// <param name="Project">The project to check</param>
        /// <param name="Plugin">Information about the plugin</param>
        /// <param name="Platform">The target platform</param>
        /// <param name="TargetType"></param>
        /// <param name="bBuildDeveloperTools"></param>
        /// <param name="bBuildEditor"></param>
        /// <param name="bBuildRequiresCookedData"></param>
        /// <returns>True if the plugin should be enabled for this project</returns>
        public static bool IsPluginDescriptorRequiredForProject(PluginInfo Plugin, ProjectDescriptor Project, UnrealTargetPlatform Platform, TargetType TargetType, bool bBuildDeveloperTools, bool bBuildEditor, bool bBuildRequiresCookedData)
        {
            // Check if it's referenced by name from the project descriptor. If it is, we'll need the plugin to be included with the project regardless of whether it has
            // any platform-specific modules or content, just so the runtime can make the call.
            if (Project != null && Project.Plugins != null)
            {
                foreach (PluginReferenceDescriptor PluginReference in Project.Plugins)
                {
                    if (String.Compare(PluginReference.Name, Plugin.Name, true) == 0)
                    {
                        return(PluginReference.IsEnabledForPlatform(Platform) && PluginReference.IsEnabledForTarget(TargetType));
                    }
                }
            }

            // If the plugin contains content, it should be included for all platforms
            if (Plugin.Descriptor.bCanContainContent)
            {
                return(true);
            }

            // Check if the plugin has any modules for the given target
            foreach (ModuleDescriptor Module in Plugin.Descriptor.Modules)
            {
                if (Module.IsCompiledInConfiguration(Platform, TargetType, bBuildDeveloperTools, bBuildEditor, bBuildRequiresCookedData))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #20
0
        /// <summary>
        /// Determine if a plugin is enabled for a given project
        /// </summary>
        /// <param name="Project">The project to check. May be null.</param>
        /// <param name="Plugin">Information about the plugin</param>
        /// <param name="Platform">The target platform</param>
        /// <param name="Configuration">The target configuration</param>
        /// <param name="TargetType">The type of target being built</param>
        /// <returns>True if the plugin should be enabled for this project</returns>
        public static bool IsPluginEnabledForTarget(PluginInfo Plugin, ProjectDescriptor Project, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, TargetType TargetType)
        {
            if (!Plugin.Descriptor.SupportsTargetPlatform(Platform))
            {
                return(false);
            }

            bool bAllowEnginePluginsEnabledByDefault = (Project == null ? true : !Project.DisableEnginePluginsByDefault);
            bool bEnabled = Plugin.IsEnabledByDefault(bAllowEnginePluginsEnabledByDefault);

            if (Project != null && Project.Plugins != null)
            {
                foreach (PluginReferenceDescriptor PluginReference in Project.Plugins)
                {
                    if (String.Compare(PluginReference.Name, Plugin.Name, true) == 0 && !PluginReference.bOptional)
                    {
                        bEnabled = PluginReference.IsEnabledForPlatform(Platform) && PluginReference.IsEnabledForTargetConfiguration(Configuration) && PluginReference.IsEnabledForTarget(TargetType);
                    }
                }
            }
            return(bEnabled);
        }
 public LinuxPlatform(UnrealTargetPlatform UnrealTarget, LinuxPlatformSDK InSDK)
     : base(UnrealTarget)
 {
     SDK = InSDK;
 }
 /// <summary>
 /// Check whether the given platform supports XGE
 /// </summary>
 /// <param name="Platform">Platform to check</param>
 /// <returns>True if the platform supports XGE</returns>
 public static bool CanUseXGE(UnrealTargetPlatform Platform)
 {
     return(UEBuildPlatform.IsPlatformAvailable(Platform) && UEBuildPlatform.GetBuildPlatform(Platform).CanUseXGE());
 }
        /// <summary>
        /// Read a receipt from disk.
        /// </summary>
        /// <param name="Location">Filename to read from</param>
        /// <param name="EngineDir">Engine directory for expanded variables</param>
        /// <param name="ProjectDir">Project directory for expanded variables</param>
        public static TargetReceipt Read(FileReference Location, DirectoryReference EngineDir, DirectoryReference ProjectDir)
        {
            JsonObject RawObject = JsonObject.Read(Location.FullName);

            // Read the initial fields
            string TargetName = RawObject.GetStringField("TargetName");
            UnrealTargetPlatform      Platform      = RawObject.GetEnumField <UnrealTargetPlatform>("Platform");
            UnrealTargetConfiguration Configuration = RawObject.GetEnumField <UnrealTargetConfiguration>("Configuration");
            string BuildId = RawObject.GetStringField("BuildId");

            // Try to read the build version
            BuildVersion Version;

            if (!BuildVersion.TryParse(RawObject.GetObjectField("Version"), out Version))
            {
                throw new JsonParseException("Invalid 'Version' field");
            }

            // Create the receipt
            TargetReceipt Receipt = new TargetReceipt(TargetName, Platform, Configuration, BuildId, Version);

            // Read the build products
            JsonObject[] BuildProductObjects;
            if (RawObject.TryGetObjectArrayField("BuildProducts", out BuildProductObjects))
            {
                foreach (JsonObject BuildProductObject in BuildProductObjects)
                {
                    string           Path;
                    BuildProductType Type;
                    if (BuildProductObject.TryGetStringField("Path", out Path) && BuildProductObject.TryGetEnumField("Type", out Type))
                    {
                        FileReference File = ExpandPathVariables(Path, EngineDir, ProjectDir);

                        string Module;
                        BuildProductObject.TryGetStringField("Module", out Module);

                        BuildProduct NewBuildProduct = Receipt.AddBuildProduct(File, Type);

                        bool IsPrecompiled;
                        if (BuildProductObject.TryGetBoolField("IsPrecompiled", out IsPrecompiled))
                        {
                            NewBuildProduct.IsPrecompiled = IsPrecompiled;
                        }
                    }
                }
            }

            // Read the runtime dependencies
            JsonObject[] RuntimeDependencyObjects;
            if (RawObject.TryGetObjectArrayField("RuntimeDependencies", out RuntimeDependencyObjects))
            {
                foreach (JsonObject RuntimeDependencyObject in RuntimeDependencyObjects)
                {
                    string Path;
                    if (RuntimeDependencyObject.TryGetStringField("Path", out Path))
                    {
                        FileReference File = ExpandPathVariables(Path, EngineDir, ProjectDir);

                        StagedFileType Type;
                        if (!RuntimeDependencyObject.TryGetEnumField("Type", out Type))
                        {
                            // Previous format included an optional IgnoreIfMissing flag, which was only used for debug files. We can explicitly reference them as DebugNonUFS files now.
                            bool bIgnoreIfMissing;
                            if (RuntimeDependencyObject.TryGetBoolField("IgnoreIfMissing", out bIgnoreIfMissing))
                            {
                                bIgnoreIfMissing = false;
                            }
                            Type = bIgnoreIfMissing? StagedFileType.DebugNonUFS : StagedFileType.NonUFS;
                        }

                        Receipt.RuntimeDependencies.Add(File, Type);
                    }
                }
            }

            // Read the additional properties
            JsonObject[] AdditionalPropertyObjects;
            if (RawObject.TryGetObjectArrayField("AdditionalProperties", out AdditionalPropertyObjects))
            {
                foreach (JsonObject AdditionalPropertyObject in AdditionalPropertyObjects)
                {
                    string Name;
                    if (AdditionalPropertyObject.TryGetStringField("Name", out Name))
                    {
                        string Value;
                        if (AdditionalPropertyObject.TryGetStringField("Value", out Value))
                        {
                            Receipt.AdditionalProperties.Add(new ReceiptProperty(Name, Value));
                        }
                    }
                }
            }

            // Read the precompiled dependencies
            string[] PrecompiledBuildDependencies;
            if (RawObject.TryGetStringArrayField("PrecompiledBuildDependencies", out PrecompiledBuildDependencies))
            {
                foreach (string PrecompiledBuildDependency in PrecompiledBuildDependencies)
                {
                    FileReference File = ExpandPathVariables(PrecompiledBuildDependency, EngineDir, ProjectDir);
                    Receipt.PrecompiledBuildDependencies.Add(File);
                }
            }

            // Read the precompiled dependencies
            string[] PrecompiledRuntimeDependencies;
            if (RawObject.TryGetStringArrayField("PrecompiledRuntimeDependencies", out PrecompiledRuntimeDependencies))
            {
                foreach (string PrecompiledRuntimeDependency in PrecompiledRuntimeDependencies)
                {
                    FileReference File = ExpandPathVariables(PrecompiledRuntimeDependency, EngineDir, ProjectDir);
                    Receipt.PrecompiledRuntimeDependencies.Add(File);
                }
            }

            return(Receipt);
        }
 /// <summary>
 /// Checks whether the given platform is available
 /// </summary>
 /// <param name="Platform">Platform to check</param>
 /// <returns>True if the platform is available, false otherwise</returns>
 public static bool IsPlatformAvailable(UnrealTargetPlatform Platform)
 {
     return(UEBuildPlatform.IsPlatformAvailable(Platform));
 }
        /// <summary>
        /// Checks whether the given project has a default build configuration
        /// </summary>
        /// <param name="ProjectFile">The project file</param>
        /// <param name="Platform">Platform to check settings for</param>
        /// <returns>True if the project uses the default build configuration</returns>
        public static bool HasDefaultBuildConfig(FileReference ProjectFile, UnrealTargetPlatform Platform)
        {
            UEBuildPlatform BuildPlat = UEBuildPlatform.GetBuildPlatform(Platform, true);

            return((BuildPlat == null)? true : BuildPlat.HasDefaultBuildConfig(Platform, ProjectFile.Directory));
        }
 /// <summary>
 /// Return the platform toolset string to write into the project configuration
 /// </summary>
 /// <param name="InPlatform">  The UnrealTargetPlatform being built</param>
 /// <param name="InConfiguration"> The UnrealTargetConfiguration being built</param>
 /// <param name="InProjectFileFormat"> The verison of VS</param>
 /// <param name="ProjectFileBuilder">String builder for the project file</param>
 /// <returns>string    The custom configuration section for the project file; Empty string if it doesn't require one</returns>
 public override void GetVisualStudioPlatformToolsetString(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, VCProjectFileFormat InProjectFileFormat, StringBuilder ProjectFileBuilder)
 {
     ProjectFileBuilder.AppendLine("    <PlatformToolset>" + VCProjectFileGenerator.GetProjectFilePlatformToolsetVersionString(InProjectFileFormat) + "</PlatformToolset>");
 }
Example #27
0
        /// <summary>
        /// Determine if a plugin is enabled for a given project
        /// </summary>
        /// <param name="Project">The project to check. May be null.</param>
        /// <param name="Plugin">Information about the plugin</param>
        /// <param name="Platform">The target platform</param>
        /// <param name="Configuration">The target configuration</param>
        /// <param name="TargetType">The type of target being built</param>
        /// <param name="bRequiresCookedData">Whether the target requires cooked data</param>
        /// <returns>True if the plugin should be enabled for this project</returns>
        public static bool IsPluginCompiledForTarget(PluginInfo Plugin, ProjectDescriptor Project, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, TargetType TargetType, bool bRequiresCookedData)
        {
            bool bCompiledForTarget = false;

            if (IsPluginEnabledForTarget(Plugin, Project, Platform, Configuration, TargetType) && Plugin.Descriptor.Modules != null)
            {
                bool bBuildDeveloperTools = (TargetType == TargetType.Editor || TargetType == TargetType.Program || (Configuration != UnrealTargetConfiguration.Test && Configuration != UnrealTargetConfiguration.Shipping));
                foreach (ModuleDescriptor Module in Plugin.Descriptor.Modules)
                {
                    if (Module.IsCompiledInConfiguration(Platform, Configuration, "", TargetType, bBuildDeveloperTools, bRequiresCookedData))
                    {
                        bCompiledForTarget = true;
                        break;
                    }
                }
            }
            return(bCompiledForTarget);
        }
Example #28
0
        /// <summary>
        /// Creates a target rules object for the specified target name.
        /// </summary>
        /// <param name="TargetName">Name of the target</param>
        /// <param name="Platform">The platform that the target is being built for</param>
        /// <param name="Configuration">The configuration the target is being built for</param>
        /// <param name="Architecture">The architecture the target is being built for</param>
        /// <param name="ProjectFile">The project containing the target being built</param>
        /// <param name="bInEditorRecompile">Whether this is an editor recompile, where we need to guess the name of the editor target</param>
        /// <returns>The build target rules for the specified target</returns>
        public TargetRules CreateTargetRules(string TargetName, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, string Architecture, FileReference ProjectFile, bool bInEditorRecompile)
        {
            FileReference TargetFileName;

            return(CreateTargetRules(TargetName, Platform, Configuration, Architecture, ProjectFile, bInEditorRecompile, out TargetFileName));
        }
 /// <summary>
 /// Whether this build platform has native support for VisualStudio
 /// </summary>
 /// <param name="InPlatform">  The UnrealTargetPlatform being built</param>
 /// <param name="InConfiguration"> The UnrealTargetConfiguration being built</param>
 /// <param name="ProjectFileFormat"> Which version of VS</param>
 /// <returns>bool    true if native VisualStudio support (or custom VSI) is available</returns>
 public override bool HasVisualStudioSupport(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, VCProjectFileFormat ProjectFileFormat)
 {
     // TODO: Returning true from here is resulting in VS erroring out when trying to build a game project for Lumin.
     return(false);            //IsVSLuminSupportInstalled(ProjectFileFormat);
 }
Example #30
0
 /// <summary>
 /// Whether this build platform has native support for VisualStudio
 /// </summary>
 /// <param name="InPlatform">  The UnrealTargetPlatform being built</param>
 /// <param name="InConfiguration"> The UnrealTargetConfiguration being built</param>
 /// <returns>bool    true if native VisualStudio support (or custom VSI) is available</returns>
 public override bool HasVisualStudioSupport(UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration)
 {
     // Debugging, etc. are dependent on the TADP being installed
     return(IsNsightInstalled());
 }