Ejemplo n.º 1
0
        public override void ExecuteBuild()
        {
            // Parse the target name
            string Target = ParseParamValue("Target");

            if (Target == null)
            {
                throw new AutomationException("Missing -Target=... argument");
            }

            // Parse the platform
            string PlatformParam = ParseParamValue("Platform");

            if (PlatformParam == null)
            {
                throw new AutomationException("Missing -Platform=... argument");
            }
            UnrealTargetPlatform Platform;

            if (!Enum.TryParse(PlatformParam, true, out Platform))
            {
                throw new AutomationException("Invalid platform '{0}'", PlatformParam);
            }

            // Parse the configuration
            string ConfigurationParam = ParseParamValue("Configuration");

            if (ConfigurationParam == null)
            {
                throw new AutomationException("Missing -Configuration=... argument");
            }
            UnrealTargetConfiguration Configuration;

            if (!Enum.TryParse(ConfigurationParam, true, out Configuration))
            {
                throw new AutomationException("Invalid configuration '{0}'", ConfigurationParam);
            }

            // Parse the project
            string Project = ParseParamValue("Project");

            if (Project != null && !File.Exists(Project))
            {
                throw new AutomationException("Specified project file '{0}' was not found", Project);
            }

            // Parse the architecture
            string Architecture = ParseParamValue("Architecture");

            // Check the receipt exists
            DirectoryReference ProjectDir = null;

            if (Project != null)
            {
                ProjectDir = new FileReference(Project).Directory;
            }
            FileReference ReceiptFile = TargetReceipt.GetDefaultPath(ProjectDir, Target, Platform, Configuration, Architecture);

            if (!FileReference.Exists(ReceiptFile))
            {
                throw new AutomationException("FortniteEditor receipt not found ({0})", ReceiptFile);
            }

            LogInformation("Found {0}", ReceiptFile);
        }
Ejemplo n.º 2
0
    public override void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC)
    {
        if (SC.bStageCrashReporter)
        {
            FileReference ReceiptFileName = TargetReceipt.GetDefaultPath(CommandUtils.EngineDirectory, "CrashReportClient", SC.StageTargetPlatform.PlatformType, UnrealTargetConfiguration.Shipping, null);
            if (FileReference.Exists(ReceiptFileName))
            {
                DirectoryReference EngineDir  = CommandUtils.EngineDirectory;
                DirectoryReference ProjectDir = DirectoryReference.FromFile(Params.RawProjectPath);
                TargetReceipt      Receipt    = TargetReceipt.Read(ReceiptFileName, EngineDir, ProjectDir);
                SC.StageBuildProductsFromReceipt(Receipt, true, false);
            }
        }

        // Stage all the build products
        Console.WriteLine("Staging all {0} build products", SC.StageTargets.Count);
        int BuildProductIdx = 0;

        foreach (StageTarget Target in SC.StageTargets)
        {
            Console.WriteLine(" Product {0}: {1}", BuildProductIdx, Target.Receipt.TargetName);
            SC.StageBuildProductsFromReceipt(Target.Receipt, Target.RequireFilesExist, Params.bTreatNonShippingBinariesAsDebugFiles);
            ++BuildProductIdx;
        }

        SC.StageFiles(StagedFileType.NonUFS, DirectoryReference.Combine(SC.ProjectRoot, "Content/Splash"), "Splash.bmp", false, null, null, true);

        // Stage the bootstrap executable
        if (!Params.NoBootstrapExe)
        {
            foreach (StageTarget Target in SC.StageTargets)
            {
                BuildProduct Executable = Target.Receipt.BuildProducts.FirstOrDefault(x => x.Type == BuildProductType.Executable);
                if (Executable != null)
                {
                    // only create bootstraps for executables
                    string FullExecutablePath = Path.GetFullPath(Executable.Path.FullName);
                    if (Executable.Path.FullName.Replace("\\", "/").Contains("/" + TargetPlatformType.ToString() + "/"))
                    {
                        string BootstrapArguments = "";
                        if (!ShouldStageCommandLine(Params, SC))
                        {
                            if (!SC.IsCodeBasedProject)
                            {
                                BootstrapArguments = String.Format("\\\"../../../{0}/{0}.uproject\\\"", SC.ShortProjectName);
                            }
                            else
                            {
                                BootstrapArguments = SC.ShortProjectName;
                            }
                        }

                        string BootstrapExeName;
                        if (SC.StageTargetConfigurations.Count > 1)
                        {
                            BootstrapExeName = Path.GetFileName(Executable.Path.FullName);
                        }
                        else if (Params.IsCodeBasedProject)
                        {
                            BootstrapExeName = Target.Receipt.TargetName;
                        }
                        else
                        {
                            BootstrapExeName = SC.ShortProjectName;
                        }

                        List <StagedFileReference> StagePaths = SC.FilesToStage.NonUFSStagingFiles.Where(x => x.Value == Executable.Path).Select(x => x.Key).ToList();
                        foreach (StagedFileReference StagePath in StagePaths)
                        {
                            StageBootstrapExecutable(SC, BootstrapExeName + ".sh", FullExecutablePath, StagePath.Name, BootstrapArguments);
                        }
                    }
                }
            }
        }
    }
    public override void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC)
    {
        // Engine non-ufs (binaries)

        if (SC.bStageCrashReporter)
        {
            FileReference ReceiptFileName = TargetReceipt.GetDefaultPath(CommandUtils.EngineDirectory, "CrashReportClient", SC.StageTargetPlatform.PlatformType, UnrealTargetConfiguration.Shipping, null);
            if (FileReference.Exists(ReceiptFileName))
            {
                DirectoryReference EngineDir  = CommandUtils.EngineDirectory;
                DirectoryReference ProjectDir = DirectoryReference.FromFile(Params.RawProjectPath);
                TargetReceipt      Receipt    = TargetReceipt.Read(ReceiptFileName, EngineDir, ProjectDir);
                SC.StageBuildProductsFromReceipt(Receipt, true, false);
            }
        }

        // Stage all the build products
        foreach (StageTarget Target in SC.StageTargets)
        {
            SC.StageBuildProductsFromReceipt(Target.Receipt, Target.RequireFilesExist, Params.bTreatNonShippingBinariesAsDebugFiles);
        }

        // Copy the splash screen, windows specific
        FileReference SplashImage = FileReference.Combine(SC.ProjectRoot, "Content", "Splash", "Splash.bmp");

        if (FileReference.Exists(SplashImage))
        {
            SC.StageFile(StagedFileType.NonUFS, SplashImage);
        }

        // Stage the bootstrap executable
        if (!Params.NoBootstrapExe)
        {
            foreach (StageTarget Target in SC.StageTargets)
            {
                BuildProduct Executable = Target.Receipt.BuildProducts.FirstOrDefault(x => x.Type == BuildProductType.Executable);
                if (Executable != null)
                {
                    // only create bootstraps for executables
                    List <StagedFileReference> StagedFiles = SC.FilesToStage.NonUFSFiles.Where(x => x.Value == Executable.Path).Select(x => x.Key).ToList();
                    if (StagedFiles.Count > 0 && Executable.Path.HasExtension(".exe"))
                    {
                        string BootstrapArguments = "";
                        if (!ShouldStageCommandLine(Params, SC))
                        {
                            if (!SC.IsCodeBasedProject)
                            {
                                BootstrapArguments = String.Format("..\\..\\..\\{0}\\{0}.uproject", SC.ShortProjectName);
                            }
                            else
                            {
                                BootstrapArguments = SC.ShortProjectName;
                            }
                        }

                        string BootstrapExeName;
                        if (SC.StageTargetConfigurations.Count > 1)
                        {
                            BootstrapExeName = Executable.Path.GetFileName();
                        }
                        else if (Params.IsCodeBasedProject)
                        {
                            BootstrapExeName = Target.Receipt.TargetName + ".exe";
                        }
                        else
                        {
                            BootstrapExeName = SC.ShortProjectName + ".exe";
                        }

                        foreach (StagedFileReference StagePath in StagedFiles)
                        {
                            StageBootstrapExecutable(SC, BootstrapExeName, Executable.Path, StagePath, BootstrapArguments);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 4
0
        /// <summary>
        /// Execute the task.
        /// </summary>
        /// <param name="Job">Information about the current job</param>
        /// <param name="BuildProducts">Set of build products produced by this node.</param>
        /// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param>
        public override void Execute(JobContext Job, HashSet <FileReference> BuildProducts, Dictionary <string, HashSet <FileReference> > TagNameToFileSet)
        {
            // Set the Engine directory
            DirectoryReference EngineDir = Parameters.EngineDir ?? CommandUtils.EngineDirectory;

            // Resolve the input list
            IEnumerable <FileReference> TargetFiles = ResolveFilespec(CommandUtils.RootDirectory, Parameters.Files, TagNameToFileSet);

            foreach (FileReference TargetFile in TargetFiles)
            {
                // check all files are .target files
                if (TargetFile.GetExtension() != ".target")
                {
                    throw new AutomationException("Invalid file passed to TagReceipt task ({0})", TargetFile.FullName);
                }

                // Print the name of the file being scanned
                Log.TraceInformation("Sanitizing {0}", TargetFile);
                using (new LogIndentScope("  "))
                {
                    // Read the receipt
                    TargetReceipt Receipt;
                    if (!TargetReceipt.TryRead(TargetFile, EngineDir, out Receipt))
                    {
                        CommandUtils.LogWarning("Unable to load file using TagReceipt task ({0})", TargetFile.FullName);
                        continue;
                    }

                    // Remove any build products that don't exist
                    List <BuildProduct> NewBuildProducts = new List <BuildProduct>(Receipt.BuildProducts.Count);
                    foreach (BuildProduct BuildProduct in Receipt.BuildProducts)
                    {
                        if (FileReference.Exists(BuildProduct.Path))
                        {
                            NewBuildProducts.Add(BuildProduct);
                        }
                        else
                        {
                            Log.TraceInformation("Removing build product: {0}", BuildProduct.Path);
                        }
                    }
                    Receipt.BuildProducts = NewBuildProducts;

                    // Remove any runtime dependencies that don't exist
                    RuntimeDependencyList NewRuntimeDependencies = new RuntimeDependencyList();
                    foreach (RuntimeDependency RuntimeDependency in Receipt.RuntimeDependencies)
                    {
                        if (FileReference.Exists(RuntimeDependency.Path))
                        {
                            NewRuntimeDependencies.Add(RuntimeDependency);
                        }
                        else
                        {
                            Log.TraceInformation("Removing runtime dependency: {0}", RuntimeDependency.Path);
                        }
                    }
                    Receipt.RuntimeDependencies = NewRuntimeDependencies;

                    // Save the new receipt
                    Receipt.Write(TargetFile, EngineDir);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Execute the task.
        /// </summary>
        /// <param name="Job">Information about the current job</param>
        /// <param name="BuildProducts">Set of build products produced by this node.</param>
        /// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param>
        public override void Execute(JobContext Job, HashSet <FileReference> BuildProducts, Dictionary <string, HashSet <FileReference> > TagNameToFileSet)
        {
            // Get the project path, and check it exists
            FileReference ProjectFile = null;

            if (Parameters.Project != null)
            {
                ProjectFile = ResolveFile(Parameters.Project);
                if (!FileReference.Exists(ProjectFile))
                {
                    throw new AutomationException("Couldn't find project '{0}'", ProjectFile.FullName);
                }
            }

            // Get the directories used for staging this project
            DirectoryReference SourceEngineDir  = CommandUtils.EngineDirectory;
            DirectoryReference SourceProjectDir = (ProjectFile == null)? SourceEngineDir : ProjectFile.Directory;

            // Get the output directories. We flatten the directory structure on output.
            DirectoryReference TargetDir        = ResolveDirectory(Parameters.ToDir);
            DirectoryReference TargetEngineDir  = DirectoryReference.Combine(TargetDir, "Engine");
            DirectoryReference TargetProjectDir = DirectoryReference.Combine(TargetDir, ProjectFile.GetFileNameWithoutExtension());

            // Get the path to the receipt
            FileReference ReceiptFileName = TargetReceipt.GetDefaultPath(SourceProjectDir, Parameters.Target, Parameters.Platform, Parameters.Configuration, Parameters.Architecture);

            // Try to load it
            TargetReceipt Receipt;

            if (!TargetReceipt.TryRead(ReceiptFileName, SourceEngineDir, SourceProjectDir, out Receipt))
            {
                throw new AutomationException("Couldn't read receipt '{0}'", ReceiptFileName);
            }

            // Stage all the build products needed at runtime
            HashSet <FileReference> SourceFiles = new HashSet <FileReference>();

            foreach (BuildProduct BuildProduct in Receipt.BuildProducts.Where(x => x.Type != BuildProductType.StaticLibrary && x.Type != BuildProductType.ImportLibrary))
            {
                SourceFiles.Add(BuildProduct.Path);
            }
            foreach (RuntimeDependency RuntimeDependency in Receipt.RuntimeDependencies.Where(x => x.Type != StagedFileType.UFS))
            {
                SourceFiles.Add(RuntimeDependency.Path);
            }

            // Get all the target files
            List <FileReference> TargetFiles = new List <FileReference>();

            foreach (FileReference SourceFile in SourceFiles)
            {
                // Get the destination file to copy to, mapping to the new engine and project directories as appropriate
                FileReference TargetFile;
                if (SourceFile.IsUnderDirectory(SourceEngineDir))
                {
                    TargetFile = FileReference.Combine(TargetEngineDir, SourceFile.MakeRelativeTo(SourceEngineDir));
                }
                else
                {
                    TargetFile = FileReference.Combine(TargetProjectDir, SourceFile.MakeRelativeTo(SourceProjectDir));
                }

                // Fixup the case of the output file. Would expect Platform.DeployLowerCaseFilenames() to return true here, but seems not to be the case.
                if (Parameters.Platform == UnrealTargetPlatform.PS4)
                {
                    TargetFile = FileReference.Combine(TargetDir, TargetFile.MakeRelativeTo(TargetDir).ToLowerInvariant());
                }

                // Only copy the output file if it doesn't already exist. We can stage multiple targets to the same output directory.
                if (Parameters.Overwrite || !FileReference.Exists(TargetFile))
                {
                    DirectoryReference.CreateDirectory(TargetFile.Directory);
                    CommandUtils.CopyFile(SourceFile.FullName, TargetFile.FullName);
                }

                // Add it to the list of target files
                TargetFiles.Add(TargetFile);
            }

            // Apply the optional tag to the build products
            foreach (string TagName in FindTagNamesFromList(Parameters.Tag))
            {
                FindOrAddTagSet(TagNameToFileSet, TagName).UnionWith(TargetFiles);
            }

            // Add the target file to the list of build products
            BuildProducts.UnionWith(TargetFiles);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Entry point for the commandlet
        /// </summary>
        public override void ExecuteBuild()
        {
            string OutputDir = ParseParamValue("OutputDir");
            string ContentOnlyPlatformsString = ParseParamValue("ContentOnlyPlatforms");
            IEnumerable <UnrealTargetPlatform> ContentOnlyPlatforms = Enumerable.Empty <UnrealTargetPlatform>();

            if (!String.IsNullOrWhiteSpace(ContentOnlyPlatformsString))
            {
                ContentOnlyPlatforms = ContentOnlyPlatformsString.Split(';').Where(x => !String.IsNullOrWhiteSpace(x)).Select(x => UnrealTargetPlatform.Parse(x));
            }
            string AnalyticsTypeOverride = ParseParamValue("AnalyticsTypeOverride");

            // Write InstalledBuild.txt to indicate Engine is installed
            string InstalledBuildFile = CommandUtils.CombinePaths(OutputDir, "Engine/Build/InstalledBuild.txt");

            CommandUtils.CreateDirectory(CommandUtils.GetDirectoryName(InstalledBuildFile));
            CommandUtils.WriteAllText(InstalledBuildFile, "");

            // Write InstalledBuild.txt to indicate Engine is installed
            string Project = ParseParamValue("Project");

            if (Project != null)
            {
                string InstalledProjectBuildFile = CommandUtils.CombinePaths(OutputDir, "Engine/Build/InstalledProjectBuild.txt");
                CommandUtils.CreateDirectory(CommandUtils.GetDirectoryName(InstalledProjectBuildFile));
                CommandUtils.WriteAllText(InstalledProjectBuildFile, new FileReference(Project).MakeRelativeTo(new DirectoryReference(OutputDir)));
            }

            string         OutputEnginePath     = Path.Combine(OutputDir, "Engine");
            string         OutputBaseEnginePath = Path.Combine(OutputEnginePath, "Config", "BaseEngine.ini");
            FileAttributes OutputAttributes     = FileAttributes.ReadOnly;
            List <String>  IniLines             = new List <String>();

            // Should always exist but if not, we don't need extra line
            if (File.Exists(OutputBaseEnginePath))
            {
                OutputAttributes = File.GetAttributes(OutputBaseEnginePath);
                IniLines.Add("");
            }
            else
            {
                CommandUtils.CreateDirectory(CommandUtils.GetDirectoryName(OutputBaseEnginePath));
                CommandUtils.WriteAllText(OutputBaseEnginePath, "");
                OutputAttributes = File.GetAttributes(OutputBaseEnginePath) | OutputAttributes;
            }

            // Create list of platform configurations installed in a Rocket build
            List <InstalledPlatformInfo.InstalledPlatformConfiguration> InstalledConfigs = new List <InstalledPlatformInfo.InstalledPlatformConfiguration>();

            // Add the editor platform, otherwise we'll never be able to run UAT
            string EditorArchitecture = PlatformExports.GetDefaultArchitecture(HostPlatform.Current.HostEditorPlatform, null);

            InstalledConfigs.Add(new InstalledPlatformInfo.InstalledPlatformConfiguration(UnrealTargetConfiguration.Development, HostPlatform.Current.HostEditorPlatform, TargetRules.TargetType.Editor, EditorArchitecture, "", EProjectType.Unknown, false));
            InstalledConfigs.Add(new InstalledPlatformInfo.InstalledPlatformConfiguration(UnrealTargetConfiguration.DebugGame, HostPlatform.Current.HostEditorPlatform, TargetRules.TargetType.Editor, EditorArchitecture, "", EProjectType.Unknown, false));

            foreach (UnrealTargetPlatform CodeTargetPlatform in UnrealTargetPlatform.GetValidPlatforms())
            {
                if (PlatformExports.IsPlatformAvailable(CodeTargetPlatform))
                {
                    string Architecture = PlatformExports.GetDefaultArchitecture(CodeTargetPlatform, null);

                    // Try to parse additional Architectures from the command line
                    string Architectures    = ParseParamValue(CodeTargetPlatform.ToString() + "Architectures");
                    string GPUArchitectures = ParseParamValue(CodeTargetPlatform.ToString() + "GPUArchitectures");

                    // Build a list of pre-compiled architecture combinations for this platform if any
                    List <string> AllArchNames;

                    if (!String.IsNullOrWhiteSpace(Architectures) && !String.IsNullOrWhiteSpace(GPUArchitectures))
                    {
                        AllArchNames = (from Arch in Architectures.Split('+')
                                        from GPUArch in GPUArchitectures.Split('+')
                                        select "-" + Arch + "-" + GPUArch).ToList();
                    }
                    else if (!String.IsNullOrWhiteSpace(Architectures))
                    {
                        AllArchNames = Architectures.Split('+').ToList();
                    }
                    // if there aren't any, use the default
                    else
                    {
                        AllArchNames = new List <string>()
                        {
                            Architecture
                        };
                    }

                    // Check whether this platform should only be used for content based projects
                    EProjectType ProjectType = ContentOnlyPlatforms.Contains(CodeTargetPlatform) ? EProjectType.Content : EProjectType.Any;

                    // Allow Content only platforms to be shown as options in all projects
                    bool bCanBeDisplayed = ProjectType == EProjectType.Content;
                    foreach (UnrealTargetConfiguration CodeTargetConfiguration in Enum.GetValues(typeof(UnrealTargetConfiguration)))
                    {
                        string[] TargetNames = new string[] { "UE4Game", "UE4Client", "UE4Server" };
                        foreach (string TargetName in TargetNames)
                        {
                            // Need to check for development receipt as we use that for the Engine code in DebugGame
                            UnrealTargetConfiguration EngineConfiguration = (CodeTargetConfiguration == UnrealTargetConfiguration.DebugGame) ? UnrealTargetConfiguration.Development : CodeTargetConfiguration;

                            // Android has multiple architecture flavors built without receipts, so use the default arch target instead
                            if (CodeTargetPlatform == UnrealTargetPlatform.Android)
                            {
                                FileReference ReceiptFileName = TargetReceipt.GetDefaultPath(new DirectoryReference(OutputEnginePath), TargetName, CodeTargetPlatform, EngineConfiguration, Architecture);
                                if (FileReference.Exists(ReceiptFileName))
                                {
                                    // Strip the output folder so that this can be used on any machine
                                    string RelativeReceiptFileName = ReceiptFileName.MakeRelativeTo(new DirectoryReference(OutputDir));

                                    // Blindly append all of the architecture names
                                    if (AllArchNames.Count > 0)
                                    {
                                        foreach (string Arch in AllArchNames)
                                        {
                                            InstalledConfigs.Add(new InstalledPlatformInfo.InstalledPlatformConfiguration(CodeTargetConfiguration, CodeTargetPlatform, TargetType.Game, Arch, RelativeReceiptFileName, ProjectType, bCanBeDisplayed));
                                        }
                                    }
                                    // if for some reason we didn't specify any flavors, just add the default one.
                                    else
                                    {
                                        InstalledConfigs.Add(new InstalledPlatformInfo.InstalledPlatformConfiguration(CodeTargetConfiguration, CodeTargetPlatform, TargetType.Game, Architecture, RelativeReceiptFileName, ProjectType, bCanBeDisplayed));
                                    }
                                }
                            }
                            // If we're not Android, check the existence of the target receipts for each architecture specified.
                            else
                            {
                                foreach (string Arch in AllArchNames)
                                {
                                    FileReference ReceiptFileName = TargetReceipt.GetDefaultPath(new DirectoryReference(OutputEnginePath), TargetName, CodeTargetPlatform, EngineConfiguration, Arch);
                                    if (FileReference.Exists(ReceiptFileName))
                                    {
                                        string RelativeReceiptFileName = ReceiptFileName.MakeRelativeTo(new DirectoryReference(OutputDir));
                                        InstalledConfigs.Add(new InstalledPlatformInfo.InstalledPlatformConfiguration(CodeTargetConfiguration, CodeTargetPlatform, TargetType.Game, Arch, RelativeReceiptFileName, ProjectType, bCanBeDisplayed));
                                    }
                                }
                            }
                        }
                    }
                }
            }

            UnrealBuildTool.InstalledPlatformInfo.WriteConfigFileEntries(InstalledConfigs, ref IniLines);

            if (!String.IsNullOrEmpty(AnalyticsTypeOverride))
            {
                // Write Custom Analytics type setting
                IniLines.Add("");
                IniLines.Add("[Analytics]");
                IniLines.Add(String.Format("UE4TypeOverride=\"{0}\"", AnalyticsTypeOverride));
            }

            // Make sure we can write to the the config file
            File.SetAttributes(OutputBaseEnginePath, OutputAttributes & ~FileAttributes.ReadOnly);
            File.AppendAllLines(OutputBaseEnginePath, IniLines);
            File.SetAttributes(OutputBaseEnginePath, OutputAttributes);
        }
        /// <summary>
        /// Execute the task.
        /// </summary>
        /// <param name="Job">Information about the current job</param>
        /// <param name="BuildProducts">Set of build products produced by this node.</param>
        /// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param>
        public override void Execute(JobContext Job, HashSet <FileReference> BuildProducts, Dictionary <string, HashSet <FileReference> > TagNameToFileSet)
        {
            // Output a warning if the project directory is specified
            if (Parameters.ProjectDir != null)
            {
                CommandUtils.LogWarning("The ProjectDir argument to the TagReceipt parameter is deprecated. This path is now determined automatically from the receipt.");
            }

            // Set the Engine directory
            DirectoryReference EngineDir = Parameters.EngineDir ?? CommandUtils.EngineDirectory;

            // Resolve the input list
            IEnumerable <FileReference> TargetFiles = ResolveFilespec(CommandUtils.RootDirectory, Parameters.Files, TagNameToFileSet);
            HashSet <FileReference>     Files       = new HashSet <FileReference>();

            foreach (FileReference TargetFile in TargetFiles)
            {
                // check all files are .target files
                if (TargetFile.GetExtension() != ".target")
                {
                    throw new AutomationException("Invalid file passed to TagReceipt task ({0})", TargetFile.FullName);
                }

                // Read the receipt
                TargetReceipt Receipt;
                if (!TargetReceipt.TryRead(TargetFile, EngineDir, out Receipt))
                {
                    CommandUtils.LogWarning("Unable to load file using TagReceipt task ({0})", TargetFile.FullName);
                    continue;
                }

                if (Parameters.BuildProducts)
                {
                    foreach (BuildProduct BuildProduct in Receipt.BuildProducts)
                    {
                        if (BuildProductType.HasValue && BuildProduct.Type != BuildProductType.Value)
                        {
                            continue;
                        }
                        if (StagedFileType.HasValue && TargetReceipt.GetStageTypeFromBuildProductType(BuildProduct) != StagedFileType.Value)
                        {
                            continue;
                        }
                        Files.Add(BuildProduct.Path);
                    }
                }

                if (Parameters.RuntimeDependencies)
                {
                    foreach (RuntimeDependency RuntimeDependency in Receipt.RuntimeDependencies)
                    {
                        // Skip anything that doesn't match the files we want
                        if (BuildProductType.HasValue)
                        {
                            continue;
                        }
                        if (StagedFileType.HasValue && RuntimeDependency.Type != StagedFileType.Value)
                        {
                            continue;
                        }

                        // Check which files exist, and warn about any that don't. Ignore debug files, as they are frequently excluded for size (eg. UE4 on GitHub). This matches logic during staging.
                        FileReference DependencyPath = RuntimeDependency.Path;
                        if (FileReference.Exists(DependencyPath))
                        {
                            Files.Add(DependencyPath);
                        }
                        else if (RuntimeDependency.Type != UnrealBuildTool.StagedFileType.DebugNonUFS)
                        {
                            CommandUtils.LogWarning("File listed as RuntimeDependency in {0} does not exist ({1})", TargetFile.FullName, DependencyPath.FullName);
                        }
                    }
                }
            }

            // Apply the tag to all the matching files
            FindOrAddTagSet(TagNameToFileSet, Parameters.With).UnionWith(Files);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Deploys the given target
 /// </summary>
 /// <param name="Receipt">Receipt for the target being deployed</param>
 public override void Deploy(TargetReceipt Receipt)
 {
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Entry point for the commandlet
        /// </summary>
        public override void ExecuteBuild()
        {
            string OutputDir = ParseParamValue("OutputDir");
            string ContentOnlyPlatformsString = ParseParamValue("ContentOnlyPlatforms");
            IEnumerable <UnrealTargetPlatform> ContentOnlyPlatforms = Enumerable.Empty <UnrealTargetPlatform>();

            if (!String.IsNullOrWhiteSpace(ContentOnlyPlatformsString))
            {
                ContentOnlyPlatforms = ContentOnlyPlatformsString.Split(';').Where(x => !String.IsNullOrWhiteSpace(x)).Select(x => (UnrealTargetPlatform)Enum.Parse(typeof(UnrealTargetPlatform), x));
            }
            string AnalyticsTypeOverride = ParseParamValue("AnalyticsTypeOverride");

            // Write InstalledBuild.txt to indicate Engine is installed
            string InstalledBuildFile = CommandUtils.CombinePaths(OutputDir, "Engine/Build/InstalledBuild.txt");

            CommandUtils.CreateDirectory(CommandUtils.GetDirectoryName(InstalledBuildFile));
            CommandUtils.WriteAllText(InstalledBuildFile, "");

            // Write InstalledBuild.txt to indicate Engine is installed
            string Project = ParseParamValue("Project");

            if (Project != null)
            {
                string InstalledProjectBuildFile = CommandUtils.CombinePaths(OutputDir, "Engine/Build/InstalledProjectBuild.txt");
                CommandUtils.CreateDirectory(CommandUtils.GetDirectoryName(InstalledProjectBuildFile));
                CommandUtils.WriteAllText(InstalledProjectBuildFile, new FileReference(Project).MakeRelativeTo(new DirectoryReference(OutputDir)));
            }

            string         OutputEnginePath     = Path.Combine(OutputDir, "Engine");
            string         OutputBaseEnginePath = Path.Combine(OutputEnginePath, "Config", "BaseEngine.ini");
            FileAttributes OutputAttributes     = FileAttributes.ReadOnly;
            List <String>  IniLines             = new List <String>();

            // Should always exist but if not, we don't need extra line
            if (File.Exists(OutputBaseEnginePath))
            {
                OutputAttributes = File.GetAttributes(OutputBaseEnginePath);
                IniLines.Add("");
            }
            else
            {
                CommandUtils.CreateDirectory(CommandUtils.GetDirectoryName(OutputBaseEnginePath));
                CommandUtils.WriteAllText(OutputBaseEnginePath, "");
                OutputAttributes = File.GetAttributes(OutputBaseEnginePath) | OutputAttributes;
            }

            // Create list of platform configurations installed in a Rocket build
            List <InstalledPlatformInfo.InstalledPlatformConfiguration> InstalledConfigs = new List <InstalledPlatformInfo.InstalledPlatformConfiguration>();

            foreach (UnrealTargetPlatform CodeTargetPlatform in Enum.GetValues(typeof(UnrealTargetPlatform)))
            {
                if (PlatformExports.IsPlatformAvailable(CodeTargetPlatform))
                {
                    string Architecture = PlatformExports.GetDefaultArchitecture(CodeTargetPlatform, null);

                    // Try to parse additional Architectures from the command line
                    string Architectures    = ParseParamValue(CodeTargetPlatform.ToString() + "Architectures");
                    string GPUArchitectures = ParseParamValue(CodeTargetPlatform.ToString() + "GPUArchitectures");

                    // Build a list of pre-compiled architecture combinations for this platform if any
                    List <string> AllArchNames;

                    if (!String.IsNullOrWhiteSpace(Architectures) && !String.IsNullOrWhiteSpace(GPUArchitectures))
                    {
                        AllArchNames = (from Arch in Architectures.Split('+')
                                        from GPUArch in GPUArchitectures.Split('+')
                                        select "-" + Arch + "-" + GPUArch).ToList();
                    }
                    else if (!String.IsNullOrWhiteSpace(Architectures))
                    {
                        AllArchNames = Architectures.Split('+').ToList();
                    }
                    else
                    {
                        AllArchNames = new List <string>();
                    }

                    // Check whether this platform should only be used for content based projects
                    EProjectType ProjectType = ContentOnlyPlatforms.Contains(CodeTargetPlatform) ? EProjectType.Content : EProjectType.Any;

                    // Allow Content only platforms to be shown as options in all projects
                    bool bCanBeDisplayed = ProjectType == EProjectType.Content;
                    foreach (UnrealTargetConfiguration CodeTargetConfiguration in Enum.GetValues(typeof(UnrealTargetConfiguration)))
                    {
                        // Need to check for development receipt as we use that for the Engine code in DebugGame
                        UnrealTargetConfiguration EngineConfiguration = (CodeTargetConfiguration == UnrealTargetConfiguration.DebugGame) ? UnrealTargetConfiguration.Development : CodeTargetConfiguration;
                        string ReceiptFileName = TargetReceipt.GetDefaultPath(OutputEnginePath, "UE4Game", CodeTargetPlatform, EngineConfiguration, Architecture);

                        if (File.Exists(ReceiptFileName))
                        {
                            // Strip the output folder so that this can be used on any machine
                            ReceiptFileName = new FileReference(ReceiptFileName).MakeRelativeTo(new DirectoryReference(OutputDir));

                            // If we have pre-compiled architectures for this platform then add an entry for each of these -
                            // there isn't a receipt for each architecture like some other platforms
                            if (AllArchNames.Count > 0)
                            {
                                foreach (string Arch in AllArchNames)
                                {
                                    InstalledConfigs.Add(new InstalledPlatformInfo.InstalledPlatformConfiguration(CodeTargetConfiguration, CodeTargetPlatform, TargetType.Game, Arch, ReceiptFileName, ProjectType, bCanBeDisplayed));
                                }
                            }
                            else
                            {
                                InstalledConfigs.Add(new InstalledPlatformInfo.InstalledPlatformConfiguration(CodeTargetConfiguration, CodeTargetPlatform, TargetType.Game, Architecture, ReceiptFileName, ProjectType, bCanBeDisplayed));
                            }
                        }
                    }
                }
            }

            UnrealBuildTool.InstalledPlatformInfo.WriteConfigFileEntries(InstalledConfigs, ref IniLines);

            if (!String.IsNullOrEmpty(AnalyticsTypeOverride))
            {
                // Write Custom Analytics type setting
                IniLines.Add("");
                IniLines.Add("[Analytics]");
                IniLines.Add(String.Format("UE4TypeOverride=\"{0}\"", AnalyticsTypeOverride));
            }

            // Make sure we can write to the the config file
            File.SetAttributes(OutputBaseEnginePath, OutputAttributes & ~FileAttributes.ReadOnly);
            File.AppendAllLines(OutputBaseEnginePath, IniLines);
            File.SetAttributes(OutputBaseEnginePath, OutputAttributes);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Execute the task.
        /// </summary>
        /// <param name="Job">Information about the current job</param>
        /// <param name="BuildProducts">Set of build products produced by this node.</param>
        /// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param>
        public override void Execute(JobContext Job, HashSet <FileReference
                                                              > BuildProducts, Dictionary <string, HashSet <FileReference> > TagNameToFileSet)
        {
            // Set the Engine directory
            DirectoryReference EngineDir = DirectoryReference.Combine(CommandUtils.RootDirectory, "Engine");

            if (!String.IsNullOrEmpty(Parameters.EngineDir))
            {
                EngineDir = DirectoryReference.Combine(CommandUtils.RootDirectory, Parameters.EngineDir);
            }

            // Set the Project directory
            DirectoryReference ProjectDir = DirectoryReference.Combine(CommandUtils.RootDirectory, "Engine");

            if (!String.IsNullOrEmpty(Parameters.ProjectDir))
            {
                ProjectDir = DirectoryReference.Combine(CommandUtils.RootDirectory, Parameters.ProjectDir);
            }

            // Resolve the input list
            IEnumerable <FileReference> TargetFiles = ResolveFilespec(CommandUtils.RootDirectory, Parameters.Files, TagNameToFileSet);
            HashSet <FileReference>     Files       = new HashSet <FileReference>();

            foreach (FileReference TargetFile in TargetFiles)
            {
                // check all files are .target files
                if (TargetFile.GetExtension() != ".target")
                {
                    throw new AutomationException("Invalid file passed to TagReceipt task ({0})", TargetFile.FullName);
                }

                // Read the receipt
                TargetReceipt Receipt;
                if (!TargetReceipt.TryRead(TargetFile, EngineDir, ProjectDir, out Receipt))
                {
                    CommandUtils.LogWarning("Unable to load file using TagReceipt task ({0})", TargetFile.FullName);
                    continue;
                }

                if (Parameters.BuildProducts)
                {
                    foreach (BuildProduct BuildProduct in Receipt.BuildProducts)
                    {
                        if (String.IsNullOrEmpty(Parameters.BuildProductType) || BuildProduct.Type == BuildProductType)
                        {
                            Files.Add(BuildProduct.Path);
                        }
                    }
                }

                if (Parameters.RuntimeDependencies)
                {
                    foreach (RuntimeDependency RuntimeDependency in Receipt.RuntimeDependencies)
                    {
                        if (String.IsNullOrEmpty(Parameters.StagedFileType) || RuntimeDependency.Type == StagedFileType)
                        {
                            // Only add files that exist as dependencies are assumed to always exist
                            FileReference DependencyPath = RuntimeDependency.Path;
                            if (FileReference.Exists(DependencyPath))
                            {
                                Files.Add(DependencyPath);
                            }
                            else
                            {
                                CommandUtils.LogWarning("File listed as RuntimeDependency in {0} does not exist ({1})", TargetFile.FullName, DependencyPath.FullName);
                            }
                        }
                    }
                }

                if (Parameters.PrecompiledBuildDependencies)
                {
                    foreach (FileReference PrecompiledBuildDependency in Receipt.PrecompiledBuildDependencies)
                    {
                        // Only add files that exist as dependencies are assumed to always exist
                        FileReference DependencyPath = PrecompiledBuildDependency;
                        if (FileReference.Exists(DependencyPath))
                        {
                            Files.Add(DependencyPath);
                        }
                        else
                        {
                            CommandUtils.LogWarning("File listed as PrecompiledBuildDependency in {0} does not exist ({1})", TargetFile.FullName, DependencyPath.FullName);
                        }
                    }
                }

                if (Parameters.PrecompiledRuntimeDependencies)
                {
                    foreach (FileReference PrecompiledRuntimeDependency in Receipt.PrecompiledRuntimeDependencies)
                    {
                        // Only add files that exist as dependencies are assumed to always exist
                        FileReference DependencyPath = PrecompiledRuntimeDependency;
                        if (FileReference.Exists(DependencyPath))
                        {
                            Files.Add(DependencyPath);
                        }
                        else
                        {
                            CommandUtils.LogWarning("File listed as PrecompiledRuntimeDependency in {0} does not exist ({1})", TargetFile.FullName, DependencyPath.FullName);
                        }
                    }
                }
            }

            // Apply the tag to all the matching files
            FindOrAddTagSet(TagNameToFileSet, Parameters.With).UnionWith(Files);
        }
Ejemplo n.º 11
0
    public override void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC)
    {
        // Engine non-ufs (binaries)

        if (SC.bStageCrashReporter)
        {
            string ReceiptFileName = TargetReceipt.GetDefaultPath(UnrealBuildTool.UnrealBuildTool.EngineDirectory.FullName, "CrashReportClient", SC.StageTargetPlatform.PlatformType, UnrealTargetConfiguration.Shipping, null);
            if (File.Exists(ReceiptFileName))
            {
                TargetReceipt Receipt = TargetReceipt.Read(ReceiptFileName);
                Receipt.ExpandPathVariables(UnrealBuildTool.UnrealBuildTool.EngineDirectory, (Params.RawProjectPath == null)? UnrealBuildTool.UnrealBuildTool.EngineDirectory : Params.RawProjectPath.Directory);
                SC.StageBuildProductsFromReceipt(Receipt, true, false);
            }
        }

        // Stage all the build products
        foreach (StageTarget Target in SC.StageTargets)
        {
            SC.StageBuildProductsFromReceipt(Target.Receipt, Target.RequireFilesExist, Params.bTreatNonShippingBinariesAsDebugFiles);
        }

        // Copy the splash screen, windows specific
        SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Content/Splash"), "Splash.bmp", false, null, null, true);

        // Stage the bootstrap executable
        if (!Params.NoBootstrapExe)
        {
            foreach (StageTarget Target in SC.StageTargets)
            {
                BuildProduct Executable = Target.Receipt.BuildProducts.FirstOrDefault(x => x.Type == BuildProductType.Executable);
                if (Executable != null)
                {
                    // only create bootstraps for executables
                    if (SC.NonUFSStagingFiles.ContainsKey(Executable.Path) && Path.GetExtension(Executable.Path) == ".exe")
                    {
                        string BootstrapArguments = "";
                        if (!SC.IsCodeBasedProject && !ShouldStageCommandLine(Params, SC))
                        {
                            BootstrapArguments = String.Format("..\\..\\..\\{0}\\{0}.uproject", SC.ShortProjectName);
                        }

                        string BootstrapExeName;
                        if (SC.StageTargetConfigurations.Count > 1)
                        {
                            BootstrapExeName = Path.GetFileName(Executable.Path);
                        }
                        else if (Params.IsCodeBasedProject)
                        {
                            BootstrapExeName = Target.Receipt.TargetName + ".exe";
                        }
                        else
                        {
                            BootstrapExeName = SC.ShortProjectName + ".exe";
                        }

                        foreach (string StagePath in SC.NonUFSStagingFiles[Executable.Path])
                        {
                            StageBootstrapExecutable(SC, BootstrapExeName, Executable.Path, StagePath, BootstrapArguments);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 12
0
        /// <summary>
        /// Execute the task.
        /// </summary>
        /// <param name="Job">Information about the current job</param>
        /// <param name="BuildProducts">Set of build products produced by this node.</param>
        /// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param>
        /// <returns>True if the task succeeded</returns>
        public override bool Execute(JobContext Job, HashSet <FileReference> BuildProducts, Dictionary <string, HashSet <FileReference> > TagNameToFileSet)
        {
            // Set the Engine directory
            DirectoryReference EngineDir = DirectoryReference.Combine(CommandUtils.RootDirectory, "Engine");

            if (!String.IsNullOrEmpty(Parameters.EngineDir))
            {
                EngineDir = DirectoryReference.Combine(CommandUtils.RootDirectory, Parameters.EngineDir);
            }

            // Set the Project directory
            DirectoryReference ProjectDir = DirectoryReference.Combine(CommandUtils.RootDirectory, "Engine");

            if (!String.IsNullOrEmpty(Parameters.ProjectDir))
            {
                ProjectDir = DirectoryReference.Combine(CommandUtils.RootDirectory, Parameters.ProjectDir);
            }

            // Resolve the input list
            IEnumerable <FileReference> TargetFiles          = ResolveFilespec(CommandUtils.RootDirectory, Parameters.Files, TagNameToFileSet);
            HashSet <FileReference>     Files                = new HashSet <FileReference>();
            HashSet <string>            WildcardDependencies = new HashSet <string>();

            foreach (FileReference TargetFile in TargetFiles)
            {
                // check all files are .target files
                if (TargetFile.GetExtension() != ".target")
                {
                    CommandUtils.LogError("Invalid file passed to TagReceipt task ({0})", TargetFile.FullName);
                    continue;
                }

                // Read the receipt
                TargetReceipt Receipt;
                if (!TargetReceipt.TryRead(TargetFile.FullName, out Receipt))
                {
                    CommandUtils.LogWarning("Unable to load file using TagReceipt task ({0})", TargetFile.FullName);
                    continue;
                }

                // Convert the paths to absolute
                Receipt.ExpandPathVariables(EngineDir, ProjectDir);

                if (Parameters.BuildProducts)
                {
                    foreach (BuildProduct BuildProduct in Receipt.BuildProducts)
                    {
                        if (String.IsNullOrEmpty(Parameters.BuildProductType) || BuildProduct.Type == BuildProductType)
                        {
                            Files.Add(new FileReference(BuildProduct.Path));
                        }
                    }
                }

                if (Parameters.RuntimeDependencies)
                {
                    foreach (RuntimeDependency RuntimeDependency in Receipt.RuntimeDependencies)
                    {
                        if (String.IsNullOrEmpty(Parameters.StagedFileType) || RuntimeDependency.Type == StagedFileType)
                        {
                            // If it doesn't contain any wildcards, just add the pattern directly
                            if (FileFilter.FindWildcardIndex(RuntimeDependency.Path) == -1)
                            {
                                // Only add files that exist as dependencies are assumed to always exist
                                FileReference DependencyPath = new FileReference(RuntimeDependency.Path);
                                if (DependencyPath.Exists())
                                {
                                    Files.Add(DependencyPath);
                                }
                                else
                                {
                                    // Give a warning about files that don't exist so that we can clean up build.cs files
                                    CommandUtils.LogWarning("File listed as RuntimeDependency in {0} does not exist ({1})", TargetFile.FullName, DependencyPath.FullName);
                                }
                            }
                            else
                            {
                                WildcardDependencies.Add(RuntimeDependency.Path);
                            }
                        }
                    }
                }

                if (Parameters.PrecompiledBuildDependencies)
                {
                    foreach (string PrecompiledBuildDependency in Receipt.PrecompiledBuildDependencies)
                    {
                        // If it doesn't contain any wildcards, just add the pattern directly
                        if (FileFilter.FindWildcardIndex(PrecompiledBuildDependency) == -1)
                        {
                            // Only add files that exist as dependencies are assumed to always exist
                            FileReference DependencyPath = new FileReference(PrecompiledBuildDependency);
                            if (DependencyPath.Exists())
                            {
                                Files.Add(DependencyPath);
                            }
                            else
                            {
                                // Give a warning about files that don't exist so that we can clean up build.cs files
                                CommandUtils.LogWarning("File listed as PrecompiledBuildDependency in {0} does not exist ({1})", TargetFile.FullName, DependencyPath.FullName);
                            }
                        }
                        else
                        {
                            WildcardDependencies.Add(PrecompiledBuildDependency);
                        }
                    }
                }

                if (Parameters.PrecompiledRuntimeDependencies)
                {
                    foreach (string PrecompiledRuntimeDependency in Receipt.PrecompiledRuntimeDependencies)
                    {
                        // If it doesn't contain any wildcards, just add the pattern directly
                        if (FileFilter.FindWildcardIndex(PrecompiledRuntimeDependency) == -1)
                        {
                            // Only add files that exist as dependencies are assumed to always exist
                            FileReference DependencyPath = new FileReference(PrecompiledRuntimeDependency);
                            if (DependencyPath.Exists())
                            {
                                Files.Add(DependencyPath);
                            }
                            else
                            {
                                // Give a warning about files that don't exist so that we can clean up build.cs files
                                CommandUtils.LogWarning("File listed as PrecompiledRuntimeDependency in {0} does not exist ({1})", TargetFile.FullName, DependencyPath.FullName);
                            }
                        }
                        else
                        {
                            WildcardDependencies.Add(PrecompiledRuntimeDependency);
                        }
                    }
                }
            }

            // Turn any wildcards into a file list
            Files.UnionWith(ResolveFilespecWithExcludePatterns(CommandUtils.RootDirectory, WildcardDependencies.ToList(), new List <string>(), TagNameToFileSet));

            // Apply the tag to all the matching files
            FindOrAddTagSet(TagNameToFileSet, Parameters.With).UnionWith(Files);

            return(true);
        }