/// <summary> /// Stage multiple files /// </summary> /// <param name="FileType">The type for the staged files</param> /// <param name="Files">The files to stage</param> public void StageFiles(StagedFileType FileType, IEnumerable <FileReference> Files) { foreach (FileReference File in Files) { StageFile(FileType, File); } }
/// <summary> /// Stage a single file to its default location /// </summary> /// <param name="FileType">The type of file being staged</param> /// <param name="InputFile">Path to the file</param> public void StageFile(StagedFileType FileType, FileReference InputFile) { StagedFileReference OutputFile; if (InputFile.IsUnderDirectory(ProjectRoot)) { OutputFile = StagedFileReference.Combine(RelativeProjectRootForStage, InputFile.MakeRelativeTo(ProjectRoot)); } else if (InputFile.HasExtension(".uplugin")) { if (InputFile.IsUnderDirectory(EngineRoot)) { OutputFile = new StagedFileReference(InputFile.MakeRelativeTo(LocalRoot)); } else { // This is a plugin that lives outside of the Engine/Plugins or Game/Plugins directory so needs to be remapped for staging/packaging // We need to remap C:\SomePath\PluginName\PluginName.uplugin to RemappedPlugins\PluginName\PluginName.uplugin OutputFile = new StagedFileReference(String.Format("RemappedPlugins/{0}/{1}", InputFile.GetFileNameWithoutExtension(), InputFile.GetFileName())); } } else if (InputFile.IsUnderDirectory(LocalRoot)) { OutputFile = new StagedFileReference(InputFile.MakeRelativeTo(LocalRoot)); } else { throw new AutomationException("Can't deploy {0} because it doesn't start with {1} or {2}", InputFile, ProjectRoot, LocalRoot); } StageFile(FileType, InputFile, OutputFile); }
public void StageBuildProductsFromReceipt(TargetReceipt Receipt, bool RequireDependenciesToExist, bool TreatNonShippingBinariesAsDebugFiles) { // Stage all the build products needed at runtime foreach (BuildProduct BuildProduct in Receipt.BuildProducts) { // allow missing files if needed if (RequireDependenciesToExist == false && FileReference.Exists(BuildProduct.Path) == false) { continue; } if (BuildProduct.Type == BuildProductType.Executable || BuildProduct.Type == BuildProductType.DynamicLibrary || BuildProduct.Type == BuildProductType.RequiredResource) { StagedFileType FileTypeToUse = StagedFileType.NonUFS; if (TreatNonShippingBinariesAsDebugFiles && Receipt.Configuration != UnrealTargetConfiguration.Shipping) { FileTypeToUse = StagedFileType.DebugNonUFS; } StageFile(FileTypeToUse, BuildProduct.Path); } else if (BuildProduct.Type == BuildProductType.SymbolFile || BuildProduct.Type == BuildProductType.MapFile) { // Symbol files aren't true dependencies so we can skip if they don't exist if (FileReference.Exists(BuildProduct.Path)) { StageFile(StagedFileType.DebugNonUFS, BuildProduct.Path); } } } }
/// <summary> /// Stage multiple files /// </summary> /// <param name="FileType">The type for the staged files</param> /// <param name="Files">The files to stage</param> public void StageFiles(StagedFileType FileType, DirectoryReference InputDir, IEnumerable <FileReference> Files, StagedDirectoryReference OutputDir) { foreach (FileReference File in Files) { StagedFileReference OutputFile = StagedFileReference.Combine(OutputDir, File.MakeRelativeTo(InputDir)); StageFile(FileType, File, OutputFile); } }
/// <summary> /// Stage multiple files /// </summary> /// <param name="FileType">The type for the staged files</param> /// <param name="InputDir">Input directory</param> /// <param name="InputFiles">List of input files</param> public void StageFiles(StagedFileType FileType, DirectoryReference InputDir, string Pattern, StageFilesSearch Option) { List <FileReference> InputFiles = FindFilesToStage(InputDir, Pattern, Option); foreach (FileReference InputFile in InputFiles) { StageFile(FileType, InputFile); } }
public void StageFile(StagedFileType FileType, string InputPath, string OutputPath = null, bool bRemap = true) { InputPath = InputPath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); if (OutputPath == null) { if (InputPath.StartsWith(ProjectRoot, StringComparison.InvariantCultureIgnoreCase)) { OutputPath = CommandUtils.CombinePaths(RelativeProjectRootForStage, InputPath.Substring(ProjectRoot.Length).TrimStart('/', '\\')); } else if (InputPath.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase)) { OutputPath = CommandUtils.CombinePaths(InputPath.Substring(LocalRoot.Length).TrimStart('/', '\\')); } else if (InputPath.EndsWith(".uplugin", StringComparison.InvariantCultureIgnoreCase)) { // This is a plugin that lives outside of the Engine/Plugins or Game/Plugins directory so needs to be remapped for staging/packaging // We need to remap C:\SomePath\PluginName\PluginName.uplugin to RemappedPlugins\PluginName\PluginName.uplugin int Index = InputPath.LastIndexOf(Path.DirectorySeparatorChar); if (Index != -1) { int PluginDirIndex = InputPath.LastIndexOf(Path.DirectorySeparatorChar, Index - 1); if (PluginDirIndex != -1) { OutputPath = CommandUtils.CombinePaths("RemappedPlugins", InputPath.Substring(PluginDirIndex)); } } if (OutputPath == null) { throw new AutomationException("Can't deploy {0} because the plugin path is non-standard, so could not be remapped", InputPath); } } else { throw new AutomationException("Can't deploy {0} because it doesn't start with {1} or {2}", InputPath, ProjectRoot, LocalRoot); } } if (bRemap) { OutputPath = StageTargetPlatform.Remap(OutputPath); } if (FileType == StagedFileType.UFS) { AddUniqueStagingFile(UFSStagingFiles, InputPath, OutputPath); } else if (FileType == StagedFileType.NonUFS) { AddStagingFile(NonUFSStagingFiles, InputPath, OutputPath); } else if (FileType == StagedFileType.DebugNonUFS) { AddStagingFile(NonUFSStagingFilesDebug, InputPath, OutputPath); } }
/// <summary> /// Stage multiple files for use by crash reporter /// </summary> /// <param name="FileType">The type of the staged file</param> /// <param name="InputDir">Location of the input directory</param> /// <param name="Option">Whether to stage all subdirectories or just the top-level directory</param> /// <param name="OutputDir">Location of the output directory within the staging folder</param> public void StageCrashReporterFiles(StagedFileType FileType, DirectoryReference InputDir, StageFilesSearch Option, StagedDirectoryReference OutputDir) { List <FileReference> InputFiles = FindFilesToStage(InputDir, Option); foreach (FileReference InputFile in InputFiles) { StagedFileReference StagedFile = StagedFileReference.Combine(OutputDir, InputFile.MakeRelativeTo(InputDir)); StageCrashReporterFile(FileType, InputFile, StagedFile); } }
private int StageExecutable(string Ext, DeploymentContext SC, string InPath, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcard = null, string NewPath = null, bool bAllowNone = false, StagedFileType InStageFileType = StagedFileType.NonUFS, string NewName = null) { int Result = SC.StageFiles(InStageFileType, InPath, Wildcard + Ext, bRecursive, ExcludeWildcard, NewPath, bAllowNone, true, (NewName == null) ? null : (NewName + Ext)); if (Result > 0) { SC.StageFiles(StagedFileType.DebugNonUFS, InPath, Wildcard + "pdb", bRecursive, ExcludeWildcard, NewPath, true, true, (NewName == null) ? null : (NewName + "pdb")); SC.StageFiles(StagedFileType.DebugNonUFS, InPath, Wildcard + "map", bRecursive, ExcludeWildcard, NewPath, true, true, (NewName == null) ? null : (NewName + "map")); } return Result; }
/// <summary> /// Stages a file for use by crash reporter. /// </summary> /// <param name="FileType">The type of the staged file</param> /// <param name="InputFile">Location of the input file</param> /// <param name="StagedFile">Location of the file in the staging directory</param> public void StageCrashReporterFile(StagedFileType FileType, FileReference InputFile, StagedFileReference StagedFile) { if (FileType == StagedFileType.UFS) { CrashReporterUFSFiles[StagedFile] = InputFile; } else { StageFile(FileType, InputFile, StagedFile); } }
private void StageAppBundle(DeploymentContext SC, DirectoryReference InPath, StagedDirectoryReference NewName) { // Files with DebugFileExtensions should always be DebugNonUFS List <string> DebugExtensions = GetDebugFileExtensions(); foreach (FileReference InputFile in DirectoryReference.EnumerateFiles(InPath, "*", SearchOption.AllDirectories)) { StagedFileReference OutputFile = StagedFileReference.Combine(NewName, InputFile.MakeRelativeTo(InPath)); StagedFileType FileType = DebugExtensions.Any(x => InputFile.HasExtension(x))? StagedFileType.DebugNonUFS : StagedFileType.NonUFS; SC.StageFile(FileType, InputFile, OutputFile); } }
/// <summary> /// Constructor /// </summary> /// <param name="InParameters">Parameters to select which files to search</param> public TagReceiptTask(TagReceiptTaskParameters InParameters) { Parameters = InParameters; if (!String.IsNullOrEmpty(Parameters.BuildProductType)) { BuildProductType = (BuildProductType)Enum.Parse(typeof(BuildProductType), Parameters.BuildProductType); } if (!String.IsNullOrEmpty(Parameters.StagedFileType)) { StagedFileType = (StagedFileType)Enum.Parse(typeof(StagedFileType), Parameters.StagedFileType); } }
/// <summary> /// Adds a file to be staged as the given type /// </summary> /// <param name="FileType">The type of file to be staged</param> /// <param name="StagedFile">The staged file location</param> /// <param name="InputFile">The input file</param> public void Add(StagedFileType FileType, StagedFileReference StagedFile, FileReference InputFile) { if (FileType == StagedFileType.UFS) { AddToDictionary(UFSStagingFiles, StagedFile, InputFile); } else if (FileType == StagedFileType.NonUFS) { AddToDictionary(NonUFSStagingFiles, StagedFile, InputFile); } else if (FileType == StagedFileType.DebugNonUFS) { AddToDictionary(NonUFSStagingFilesDebug, StagedFile, InputFile); } }
private void StageAppBundle(DeploymentContext SC, StagedFileType InStageFileType, string InPath, string NewName) { if (InStageFileType != StagedFileType.DebugNonUFS) { // Files with DebugFileExtensions should always be DebugNonUFS List<string> DebugExtentionWildCards = new List<string>(); foreach(string DebugExtention in GetDebugFileExtentions()) { string ExtensionWildcard = "*" + DebugExtention; DebugExtentionWildCards.Add(ExtensionWildcard); SC.StageFiles(StagedFileType.DebugNonUFS, InPath, ExtensionWildcard, true, null, NewName, true, true, null); } // Also stage the non-debug files, excluding the debug ones staged above SC.StageFiles(InStageFileType, InPath, "*", true, DebugExtentionWildCards.ToArray(), NewName, false, true, null); } else { // We are already DebugNonUFS, no need to do any special-casing SC.StageFiles(InStageFileType, InPath, "*", true, null, NewName, false, true, null); } }
private void StageAppBundle(DeploymentContext SC, StagedFileType InStageFileType, string InPath, string NewName) { if (InStageFileType != StagedFileType.DebugNonUFS) { // Files with DebugFileExtensions should always be DebugNonUFS List <string> DebugExtentionWildCards = new List <string>(); foreach (string DebugExtention in GetDebugFileExtentions()) { string ExtensionWildcard = "*" + DebugExtention; DebugExtentionWildCards.Add(ExtensionWildcard); SC.StageFiles(StagedFileType.DebugNonUFS, InPath, ExtensionWildcard, true, null, NewName, true, true, null); } // Also stage the non-debug files, excluding the debug ones staged above SC.StageFiles(InStageFileType, InPath, "*", true, DebugExtentionWildCards.ToArray(), NewName, false, true, null); } else { // We are already DebugNonUFS, no need to do any special-casing SC.StageFiles(InStageFileType, InPath, "*", true, null, NewName, false, true, null); } }
public void StageFile(StagedFileType FileType, string InputPath, string OutputPath = null, bool bRemap = true) { InputPath = InputPath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); if (OutputPath == null) { if (InputPath.StartsWith(ProjectRoot, StringComparison.InvariantCultureIgnoreCase)) { OutputPath = CommandUtils.CombinePaths(RelativeProjectRootForStage, InputPath.Substring(ProjectRoot.Length).TrimStart('/', '\\')); } else if (InputPath.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase)) { OutputPath = CommandUtils.CombinePaths(InputPath.Substring(LocalRoot.Length).TrimStart('/', '\\')); } else { throw new AutomationException("Can't deploy {0} because it doesn't start with {1} or {2}", InputPath, ProjectRoot, LocalRoot); } } if (bRemap) { OutputPath = StageTargetPlatform.Remap(OutputPath); } if (FileType == StagedFileType.UFS) { AddUniqueStagingFile(UFSStagingFiles, InputPath, OutputPath); } else if (FileType == StagedFileType.NonUFS) { AddStagingFile(NonUFSStagingFiles, InputPath, OutputPath); } else if (FileType == StagedFileType.DebugNonUFS) { AddStagingFile(NonUFSStagingFilesDebug, InputPath, OutputPath); } }
public void StageFiles(StagedFileType FileType, DirectoryReference InputDir, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcards = null, StagedDirectoryReference NewPath = null, bool bAllowNone = false, bool bRemap = true, string NewName = null, bool bAllowNotForLicenseesFiles = true, bool bStripFilesForOtherPlatforms = true, bool bConvertToLower = false) { int FilesAdded = 0; if (DirectoryReference.Exists(InputDir)) { FileReference[] InputFiles = CommandUtils.FindFiles(Wildcard, bRecursive, InputDir); HashSet <FileReference> ExcludeFiles = new HashSet <FileReference>(); if (ExcludeWildcards != null) { foreach (string ExcludeWildcard in ExcludeWildcards) { ExcludeFiles.UnionWith(CommandUtils.FindFiles(ExcludeWildcard, bRecursive, InputDir)); } } foreach (FileReference InputFile in InputFiles) { if (ExcludeFiles.Contains(InputFile)) { continue; } if (bStripFilesForOtherPlatforms && !bIsCombiningMultiplePlatforms && IsFileForOtherPlatform(InputFile)) { continue; } // Get the staged location for this file StagedFileReference Dest; if (NewPath != null) { // If the specified a new directory, first we deal with that, then apply the other things. This is used to collapse the sandbox, among other things. Dest = StagedFileReference.Combine(NewPath, InputFile.MakeRelativeTo(InputDir)); } else if (InputFile.IsUnderDirectory(ProjectRoot)) { // Project relative file Dest = StagedFileReference.Combine(RelativeProjectRootForStage, InputFile.MakeRelativeTo(ProjectRoot)); } else if (InputFile.IsUnderDirectory(LocalRoot)) { // Engine relative file Dest = new StagedFileReference(InputFile.MakeRelativeTo(LocalRoot)); } else { throw new AutomationException("Can't deploy {0} because it doesn't start with {1} or {2}", InputFile, ProjectRoot, LocalRoot); } if (!bAllowNotForLicenseesFiles && (Dest.ContainsName(new FileSystemName("NotForLicensees")) || Dest.ContainsName(new FileSystemName("NoRedist")))) { continue; } if (NewName != null) { Dest = StagedFileReference.Combine(Dest.Directory, NewName); } if (bRemap) { Dest = StageTargetPlatform.Remap(Dest); } if (bConvertToLower) { Dest = Dest.ToLowerInvariant(); } FilesToStage.Add(FileType, Dest, InputFile); FilesAdded++; } } if (FilesAdded == 0 && !bAllowNone && !bIsCombiningMultiplePlatforms) { throw new AutomationException(ExitCode.Error_StageMissingFile, "No files found to deploy for {0} with wildcard {1} and exclusions {2}", InputDir, Wildcard, String.Join(", ", ExcludeWildcards)); } }
/// <summary> /// Stage a single file /// </summary> /// <param name="FileType">The type for the staged file</param> /// <param name="InputFile">The source file</param> /// <param name="OutputFile">The staged file location</param> public void StageFile(StagedFileType FileType, FileReference InputFile, StagedFileReference OutputFile) { FilesToStage.Add(FileType, OutputFile, InputFile); }
/// <summary> /// Stage a single file to its default location /// </summary> /// <param name="FileType">The type of file being staged</param> /// <param name="InputFile">Path to the file</param> public void StageFile(StagedFileType FileType, FileReference InputFile) { StagedFileReference OutputFile = GetStagedFileLocation(InputFile); StageFile(FileType, InputFile, OutputFile); }
public void StageFile(StagedFileType FileType, string InputPath, string OutputPath = null, bool bRemap = true) { InputPath = InputPath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); if(OutputPath == null) { if(InputPath.StartsWith(ProjectRoot, StringComparison.InvariantCultureIgnoreCase)) { OutputPath = CommandUtils.CombinePaths(RelativeProjectRootForStage, InputPath.Substring(ProjectRoot.Length).TrimStart('/', '\\')); } else if (InputPath.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase)) { OutputPath = CommandUtils.CombinePaths(InputPath.Substring(LocalRoot.Length).TrimStart('/', '\\')); } else { throw new AutomationException("Can't deploy {0} because it doesn't start with {1} or {2}", InputPath, ProjectRoot, LocalRoot); } } if(bRemap) { OutputPath = StageTargetPlatform.Remap(OutputPath); } if (FileType == StagedFileType.UFS) { AddUniqueStagingFile(UFSStagingFiles, InputPath, OutputPath); } else if (FileType == StagedFileType.NonUFS) { AddUniqueStagingFile(NonUFSStagingFiles, InputPath, OutputPath); } else if (FileType == StagedFileType.DebugNonUFS) { AddUniqueStagingFile(NonUFSStagingFilesDebug, InputPath, OutputPath); } }
private void StageAppBundle(DeploymentContext SC, StagedFileType InStageFileType, string InPath, string NewName) { SC.StageFiles(InStageFileType, InPath, "*", true, null, NewName, false, true, null); }
/// <summary> /// Constructor /// </summary> /// <param name="InPath">Path to the runtime dependency</param> /// <param name="InType">How to stage the given path</param> public RuntimeDependency(string InPath, StagedFileType InType = StagedFileType.NonUFS) { Path = InPath; Type = InType; }
public override void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC) { // the first app is the "main" one, the rest are marked as debug files for exclusion from chunking/distribution StagedFileType WorkingFileType = StagedFileType.NonUFS; List <string> Exes = GetExecutableNames(SC); foreach (var Exe in Exes) { string AppBundlePath = ""; if (Exe.StartsWith(CombinePaths(SC.RuntimeProjectRootDir, "Binaries", SC.PlatformDir))) { AppBundlePath = CombinePaths(SC.ShortProjectName, "Binaries", SC.PlatformDir, Path.GetFileNameWithoutExtension(Exe) + ".app"); StageAppBundle(SC, WorkingFileType, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir, Path.GetFileNameWithoutExtension(Exe) + ".app"), AppBundlePath); } else if (Exe.StartsWith(CombinePaths(SC.RuntimeRootDir, "Engine/Binaries", SC.PlatformDir))) { AppBundlePath = CombinePaths("Engine/Binaries", SC.PlatformDir, Path.GetFileNameWithoutExtension(Exe) + ".app"); string AbsoluteBundlePath = CombinePaths(SC.LocalRoot, AppBundlePath); // ensure the ue4game binary exists, if applicable if (!SC.IsCodeBasedProject && !Directory.Exists(AbsoluteBundlePath) && !SC.bIsCombiningMultiplePlatforms) { LogError("Failed to find app bundle " + AbsoluteBundlePath); throw new AutomationException(ExitCode.Error_MissingExecutable, "Could not find app bundle {0}. You may need to build the UE4 project with your target configuration and platform.", AbsoluteBundlePath); } StageAppBundle(SC, WorkingFileType, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir, Path.GetFileNameWithoutExtension(Exe) + ".app"), AppBundlePath); } if (!string.IsNullOrEmpty(AppBundlePath)) { SC.StageFiles(WorkingFileType, CombinePaths(SC.ProjectRoot, "Build/Mac"), "Application.icns", false, null, CombinePaths(AppBundlePath, "Contents/Resources"), true); if (Params.bUsesSteam) { SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Source/ThirdParty/Steamworks/Steamv132/sdk/redistributable_bin/osx32"), "libsteam_api.dylib", false, null, CombinePaths(AppBundlePath, "Contents/MacOS"), true); } } // the first app is the "main" one, the rest are marked as debug files for exclusion from chunking/distribution WorkingFileType = StagedFileType.DebugNonUFS; } if (SC.bStageCrashReporter) { string CrashReportClientPath = CombinePaths("Engine/Binaries", SC.PlatformDir, "CrashReportClient.app"); StageAppBundle(SC, StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir, "CrashReportClient.app"), CrashReportClientPath); } // Copy the splash screen, Mac specific SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Content/Splash"), "Splash.bmp", false, null, null, true); // CEF3 files if (Params.bUsesCEF3) { SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/CEF3/Mac/"), "*", true, null, null, true); string UnrealCEFSubProcessPath = CombinePaths("Engine/Binaries", SC.PlatformDir, "UnrealCEFSubProcess.app"); StageAppBundle(SC, StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir, "UnrealCEFSubProcess.app"), UnrealCEFSubProcessPath); } // 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) && Executable.Path.Replace("\\", "/").Contains("/" + TargetPlatformType.ToString() + "/")) { 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) + ".app"; } else if (Params.IsCodeBasedProject) { BootstrapExeName = Target.Receipt.TargetName + ".app"; } else { BootstrapExeName = SC.ShortProjectName + ".app"; } string AppPath = Executable.Path.Substring(0, Executable.Path.LastIndexOf(".app/") + 4); object Dest = SC.NonUFSStagingFiles[Executable.Path]; foreach (var DestPath in SC.NonUFSStagingFiles[Executable.Path]) { string AppRelativePath = DestPath.Substring(0, DestPath.LastIndexOf(".app/") + 4); StageBootstrapExecutable(SC, BootstrapExeName, AppPath, AppRelativePath, BootstrapArguments); } } } } } // Copy the ShaderCache files, if they exist SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.ProjectRoot, "Content"), "ShaderCache.ushadercache", false, null, null, true); SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.ProjectRoot, "Content"), "ShaderCodeCache.ushadercode", false, null, null, true); }
public static void CreateStagingManifest(ProjectParams Params, DeploymentContext SC) { if (!Params.Stage) { return; } var ThisPlatform = SC.StageTargetPlatform; ThisPlatform.GetFilesToDeployOrStage(Params, SC); // Get the build.properties file // this file needs to be treated as a UFS file for casing, but NonUFS for being put into the .pak file // @todo: Maybe there should be a new category - UFSNotForPak string BuildPropertiesPath = CombinePaths(SC.LocalRoot, "Engine/Build"); if (SC.StageTargetPlatform.DeployLowerCaseFilenames(true)) { BuildPropertiesPath = BuildPropertiesPath.ToLower(); } SC.StageFiles(StagedFileType.NonUFS, BuildPropertiesPath, "build.properties", false, null, null, true); // move the UE4Commandline.txt file to the root of the stage // this file needs to be treated as a UFS file for casing, but NonUFS for being put into the .pak file // @todo: Maybe there should be a new category - UFSNotForPak string CommandLineFile = "UE4CommandLine.txt"; if (SC.StageTargetPlatform.DeployLowerCaseFilenames(true)) { CommandLineFile = CommandLineFile.ToLower(); } SC.StageFiles(StagedFileType.NonUFS, GetIntermediateCommandlineDir(SC), CommandLineFile, false, null, "", true, false); if (!Params.CookOnTheFly && !Params.SkipCookOnTheFly) // only stage the UFS files if we are not using cook on the fly { ConfigCacheIni PlatformGameConfig = new ConfigCacheIni(SC.StageTargetPlatform.PlatformType, "Game", CommandUtils.GetDirectoryName(Params.RawProjectPath)); // Initialize cultures to stage. List <string> CulturesToStage = null; // Use parameters if provided. if (Params.CulturesToCook != null && Params.CulturesToCook.Count > 0) { CulturesToStage = Params.CulturesToCook; } // Use configuration if otherwise lacking cultures to stage. if (CulturesToStage == null || CulturesToStage.Count == 0) { if (PlatformGameConfig != null) { PlatformGameConfig.GetArray("/Script/UnrealEd.ProjectPackagingSettings", "CulturesToStage", out CulturesToStage); } } // Error if no cultures have been provided. if (CulturesToStage == null || CulturesToStage.Count == 0) { throw new AutomationException("No cultures were specified for cooking and packaging. This will lead to fatal errors when launching. Specify culture codes via commandline (-CookCultures=) or using project packaging settings (+CulturesToStage)."); } // Engine ufs (content) SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.LocalRoot, "Engine/Config"), "*", true, null, null, false, !Params.UsePak(SC.StageTargetPlatform)); // TODO: Exclude localization data generation config files. if (Params.bUsesSlate) { if (Params.bUsesSlateEditorStyle) { SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.LocalRoot, "Engine/Content/Editor/Slate"), "*", true, null, null, false, !Params.UsePak(SC.StageTargetPlatform)); } SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.LocalRoot, "Engine/Content/Slate"), "*", true, null, null, false, !Params.UsePak(SC.StageTargetPlatform)); SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.ProjectRoot, "Content/Slate"), "*", true, null, CombinePaths(SC.RelativeProjectRootForStage, "Content/Slate"), true, !Params.UsePak(SC.StageTargetPlatform)); } foreach (string Culture in CulturesToStage) { StageLocalizationDataForCulture(SC, Culture, CombinePaths(SC.LocalRoot, "Engine/Content/Localization/Engine"), null, !Params.UsePak(SC.StageTargetPlatform)); } SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.LocalRoot, "Engine/Plugins"), "*.uplugin", true, null, null, true, !Params.UsePak(SC.StageTargetPlatform)); // Game ufs (content) SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.ProjectRoot), "*.uproject", false, null, CombinePaths(SC.RelativeProjectRootForStage), true, !Params.UsePak(SC.StageTargetPlatform)); SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.ProjectRoot, "Config"), "*", true, null, CombinePaths(SC.RelativeProjectRootForStage, "Config"), true, !Params.UsePak(SC.StageTargetPlatform)); // TODO: Exclude localization data generation config files. SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.ProjectRoot, "Plugins"), "*.uplugin", true, null, null, true, !Params.UsePak(SC.StageTargetPlatform)); foreach (string Culture in CulturesToStage) { StageLocalizationDataForCulture(SC, Culture, CombinePaths(SC.ProjectRoot, "Content/Localization/Game"), CombinePaths(SC.RelativeProjectRootForStage, "Content/Localization/Game"), !Params.UsePak(SC.StageTargetPlatform)); } // Stage any additional UFS and NonUFS paths specified in the project ini files; these dirs are relative to the game content directory if (PlatformGameConfig != null) { var ProjectContentRoot = CombinePaths(SC.ProjectRoot, "Content"); var StageContentRoot = CombinePaths(SC.RelativeProjectRootForStage, "Content"); List <string> ExtraUFSDirs; if (PlatformGameConfig.GetArray("/Script/UnrealEd.ProjectPackagingSettings", "DirectoriesToAlwaysStageAsUFS", out ExtraUFSDirs)) { // Each string has the format '(Path="TheDirToStage")' foreach (var PathStr in ExtraUFSDirs) { var PathParts = PathStr.Split('"'); if (PathParts.Length == 3) { var RelativePath = PathParts[1]; SC.StageFiles(StagedFileType.UFS, CombinePaths(ProjectContentRoot, RelativePath), "*", true, null, CombinePaths(StageContentRoot, RelativePath), true, !Params.UsePak(SC.StageTargetPlatform)); } } } List <string> ExtraNonUFSDirs; if (PlatformGameConfig.GetArray("/Script/UnrealEd.ProjectPackagingSettings", "DirectoriesToAlwaysStageAsNonUFS", out ExtraNonUFSDirs)) { // Each string has the format '(Path="TheDirToStage")' foreach (var PathStr in ExtraNonUFSDirs) { var PathParts = PathStr.Split('"'); if (PathParts.Length == 3) { var RelativePath = PathParts[1]; SC.StageFiles(StagedFileType.NonUFS, CombinePaths(ProjectContentRoot, RelativePath)); } } } } StagedFileType StagedFileTypeForMovies = StagedFileType.NonUFS; if (Params.FileServer) { // UFS is required when using a file server StagedFileTypeForMovies = StagedFileType.UFS; } if (SC.StageTargetPlatform.StageMovies) { SC.StageFiles(StagedFileTypeForMovies, CombinePaths(SC.LocalRoot, "Engine/Content/Movies"), "*", true, null, CombinePaths(SC.RelativeProjectRootForStage, "Engine/Content/Movies"), true, !Params.UsePak(SC.StageTargetPlatform)); SC.StageFiles(StagedFileTypeForMovies, CombinePaths(SC.ProjectRoot, "Content/Movies"), "*", true, null, CombinePaths(SC.RelativeProjectRootForStage, "Content/Movies"), true, !Params.UsePak(SC.StageTargetPlatform)); } // eliminate the sand box SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.ProjectRoot, "Saved", "Cooked", SC.CookPlatform), "*", true, null, "", true, !Params.UsePak(SC.StageTargetPlatform)); // CrashReportClient is a standalone slate app that does not look in the generated pak file, so it needs the Content/Slate and Shaders/StandaloneRenderer folders Non-UFS // @todo Make CrashReportClient more portable so we don't have to do this if (SC.bStageCrashReporter && UnrealBuildTool.UnrealBuildTool.PlatformSupportsCrashReporter(SC.StageTargetPlatform.PlatformType) && !SC.DedicatedServer) { //If the .dat file needs to be staged as NonUFS for non-Windows/Linux hosts we need to change the casing as we do with the build properties file above. SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Content/Slate")); SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Shaders/StandaloneRenderer")); SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Content/Localization/ICU")); // Linux platform stages ICU in GetFilesToDeployOrStage(), accounting for the actual architecture if (SC.StageTargetPlatform.PlatformType == UnrealTargetPlatform.Win64 || SC.StageTargetPlatform.PlatformType == UnrealTargetPlatform.Win32 || SC.StageTargetPlatform.PlatformType == UnrealTargetPlatform.Mac) { SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/ICU")); } // SSL libraries are only available for Win64 builds. // @see FPerforceSourceControlProvider::LoadSSLLibraries if (SC.StageTargetPlatform.PlatformType == UnrealTargetPlatform.Win64) { SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/OpenSSL")); } } } }
/// <summary> /// Stage multiple files /// </summary> /// <param name="FileType">The type for the staged files</param> /// <param name="InputDir">Input directory</param> /// <param name="Option">Whether to stage all subdirectories or just the top-level directory</param> /// <param name="OutputDir">Base directory for output files</param> public void StageFiles(StagedFileType FileType, DirectoryReference InputDir, StageFilesSearch Option, StagedDirectoryReference OutputDir) { StageFiles(FileType, InputDir, "*", Option, OutputDir); }
public override void GetFilesToDeployOrStage(ProjectParams Params, DeploymentContext SC) { if (Params.StageNonMonolithic) { if (SC.DedicatedServer) { if (SC.StageTargetConfigurations.Contains(UnrealTargetConfiguration.Development)) { SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir, "UE4Server.app")); SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir), "UE4Server-" + SC.ShortProjectName + ".dylib"); } if (SC.StageTargetConfigurations.Contains(UnrealTargetConfiguration.Test)) { SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir, "UE4Server-Mac-Test.app")); SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir), "UE4Server-" + SC.ShortProjectName + "-Mac-Test.dylib"); } if (SC.StageTargetConfigurations.Contains(UnrealTargetConfiguration.Shipping)) { SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir, "UE4Server-Mac-Shipping.app")); SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir), "UE4Server-" + SC.ShortProjectName + "-Mac-Shipping.dylib"); } SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Plugins"), "UE4Server-*.dylib", true); SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Plugins"), "UE4Server-*.dylib", true); } else { if (SC.StageTargetConfigurations.Contains(UnrealTargetConfiguration.Development)) { SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir, "UE4.app")); SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir), "UE4-" + SC.ShortProjectName + ".dylib"); } if (SC.StageTargetConfigurations.Contains(UnrealTargetConfiguration.Test)) { SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir, "UE4-Mac-Test.app")); SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir), "UE4-" + SC.ShortProjectName + "-Mac-Test.dylib"); } if (SC.StageTargetConfigurations.Contains(UnrealTargetConfiguration.Shipping)) { SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir, "UE4-Mac-Shipping.app")); SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir), "UE4-" + SC.ShortProjectName + "-Mac-Shipping.dylib"); } SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Plugins"), "UE4-*.dylib", true); SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Plugins"), "UE4-*.dylib", true, null, null, true); } } else { // the first app is the "main" one, the rest are marked as debug files for exclusion from chunking/distribution StagedFileType WorkingFileType = StagedFileType.NonUFS; List <string> Exes = GetExecutableNames(SC); foreach (var Exe in Exes) { string AppBundlePath = ""; if (Exe.StartsWith(CombinePaths(SC.RuntimeProjectRootDir, "Binaries", SC.PlatformDir))) { AppBundlePath = CombinePaths(SC.ShortProjectName, "Binaries", SC.PlatformDir, Path.GetFileNameWithoutExtension(Exe) + ".app"); StageAppBundle(SC, WorkingFileType, CombinePaths(SC.ProjectRoot, "Binaries", SC.PlatformDir, Path.GetFileNameWithoutExtension(Exe) + ".app"), AppBundlePath); } else if (Exe.StartsWith(CombinePaths(SC.RuntimeRootDir, "Engine/Binaries", SC.PlatformDir))) { AppBundlePath = CombinePaths("Engine/Binaries", SC.PlatformDir, Path.GetFileNameWithoutExtension(Exe) + ".app"); string AbsoluteBundlePath = CombinePaths(SC.LocalRoot, AppBundlePath); // ensure the ue4game binary exists, if applicable if (!SC.IsCodeBasedProject && !Directory.Exists(AbsoluteBundlePath) && !SC.bIsCombiningMultiplePlatforms) { Log("Failed to find app bundle " + AbsoluteBundlePath); AutomationTool.ErrorReporter.Error("Stage Failed.", (int)AutomationTool.ErrorCodes.Error_MissingExecutable); throw new AutomationException("Could not find app bundle {0}. You may need to build the UE4 project with your target configuration and platform.", AbsoluteBundlePath); } StageAppBundle(SC, WorkingFileType, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir, Path.GetFileNameWithoutExtension(Exe) + ".app"), AppBundlePath); } if (!string.IsNullOrEmpty(AppBundlePath)) { SC.StageFiles(WorkingFileType, CombinePaths(SC.ProjectRoot, "Build/Mac"), "Application.icns", false, null, CombinePaths(AppBundlePath, "Contents/Resources"), true); if (Params.bUsesSteam) { SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Source/ThirdParty/Steamworks/Steamv132/sdk/redistributable_bin/osx32"), "libsteam_api.dylib", false, null, CombinePaths(AppBundlePath, "Contents/MacOS"), true); } } // the first app is the "main" one, the rest are marked as debug files for exclusion from chunking/distribution WorkingFileType = StagedFileType.DebugNonUFS; } } // Copy the splash screen, Mac specific SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.ProjectRoot, "Content/Splash"), "Splash.bmp", false, null, null, true); // CEF3 files if (Params.bUsesCEF3) { SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/CEF3/Mac/"), "*", true, null, null, true); string UnrealCEFSubProcessPath = CombinePaths("Engine/Binaries", SC.PlatformDir, "UnrealCEFSubProcess.app"); StageAppBundle(SC, StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries", SC.PlatformDir, "UnrealCEFSubProcess.app"), UnrealCEFSubProcessPath); } }
/// <summary> /// Copy constructor /// </summary> /// <param name="InOther">Runtime dependency to copy settings from</param> public RuntimeDependency(RuntimeDependency InOther) { Path = InOther.Path; Type = InOther.Type; }
/// <summary> /// Stage multiple files for use by crash reporter /// </summary> /// <param name="FileType">The type of the staged file</param> /// <param name="InputDir">Location of the input directory</param> /// <param name="Option">Whether to stage all subdirectories or just the top-level directory</param> public void StageCrashReporterFiles(StagedFileType FileType, DirectoryReference InputDir, StageFilesSearch Option) { StageCrashReporterFiles(FileType, InputDir, Option, new StagedDirectoryReference(InputDir.MakeRelativeTo(LocalRoot))); }
/// <summary> /// Add a runtime dependency to the list /// </summary> /// <param name="InPath">Path to the runtime dependency. May include wildcards.</param> /// <param name="InType">How to stage this file</param> public void Add(FileReference InPath, StagedFileType InType) { Add(new RuntimeDependency(InPath, InType)); }
/// <summary> /// Add a runtime dependency to the list /// </summary> /// <param name="InPath">Path to the runtime dependency. May include wildcards.</param> /// <param name="InSourcePath">Source path for the file to be added as a dependency. May include wildcards.</param> /// <param name="InType">How to stage this file</param> public void Add(string InPath, string InSourcePath, StagedFileType InType = StagedFileType.NonUFS) { Inner.Add(new RuntimeDependency(InPath, InSourcePath, InType)); }
public int StageFiles(StagedFileType FileType, string InPath, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcard = null, string NewPath = null, bool bAllowNone = false, bool bRemap = true, string NewName = null, bool bAllowNotForLicenseesFiles = true, bool bStripFilesForOtherPlatforms = true) { int FilesAdded = 0; // make sure any ..'s are removed Utils.CollapseRelativeDirectories(ref InPath); if (CommandUtils.DirectoryExists(InPath)) { var All = CommandUtils.FindFiles(Wildcard, bRecursive, InPath); var Exclude = new HashSet<string>(); if (ExcludeWildcard != null) { foreach (var Excl in ExcludeWildcard) { var Remove = CommandUtils.FindFiles(Excl, bRecursive, InPath); foreach (var File in Remove) { Exclude.Add(CommandUtils.CombinePaths(File)); } } } foreach (var AllFile in All) { var FileToCopy = CommandUtils.CombinePaths(AllFile); if (Exclude.Contains(FileToCopy)) { continue; } if (!bAllowNotForLicenseesFiles && (FileToCopy.Contains("NotForLicensees") || FileToCopy.Contains("NoRedist"))) { continue; } if (bStripFilesForOtherPlatforms && !bIsCombiningMultiplePlatforms) { bool OtherPlatform = false; foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform))) { if (Plat != StageTargetPlatform.PlatformType && Plat != UnrealTargetPlatform.Unknown) { var Search = FileToCopy; if (Search.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase)) { if (LocalRoot.EndsWith("\\") || LocalRoot.EndsWith("/")) { Search = Search.Substring(LocalRoot.Length - 1); } else { Search = Search.Substring(LocalRoot.Length); } } if (Search.StartsWith(ProjectRoot, StringComparison.InvariantCultureIgnoreCase)) { if (ProjectRoot.EndsWith("\\") || ProjectRoot.EndsWith("/")) { Search = Search.Substring(ProjectRoot.Length - 1); } else { Search = Search.Substring(ProjectRoot.Length); } } if (Search.IndexOf(CommandUtils.CombinePaths("/" + Plat.ToString() + "/"), 0, StringComparison.InvariantCultureIgnoreCase) >= 0) { OtherPlatform = true; break; } } } if (OtherPlatform) { continue; } } string Dest; if (!FileToCopy.StartsWith(InPath)) { throw new AutomationException("Can't deploy {0}; it was supposed to start with {1}", FileToCopy, InPath); } string FileToRemap = FileToCopy; // If the specified a new directory, first we deal with that, then apply the other things // this is used to collapse the sandbox, among other things if (NewPath != null) { Dest = FileToRemap.Substring(InPath.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } Dest = CommandUtils.CombinePaths(NewPath, Dest); #if false // if the cooker rebases, I don't think we need to ever rebase while staging to a new path if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } // project relative stuff in a collapsed sandbox if (Dest.StartsWith(SourceRelativeProjectRoot, StringComparison.InvariantCultureIgnoreCase)) { Dest = Dest.Substring(SourceRelativeProjectRoot.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } Dest = CommandUtils.CombinePaths(RelativeProjectRootForStage, Dest); } #endif } // project relative file else if (FileToRemap.StartsWith(ProjectRoot, StringComparison.InvariantCultureIgnoreCase)) { Dest = FileToRemap.Substring(ProjectRoot.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } Dest = CommandUtils.CombinePaths(RelativeProjectRootForStage, Dest); } // engine relative file else if (FileToRemap.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase)) { Dest = CommandUtils.CombinePaths(FileToRemap.Substring(LocalRoot.Length)); } else { throw new AutomationException("Can't deploy {0} because it doesn't start with {1} or {2}", FileToRemap, ProjectRoot, LocalRoot); } if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } if (NewName != null) { Dest = CommandUtils.CombinePaths(Path.GetDirectoryName(Dest), NewName); } if (bRemap) { Dest = StageTargetPlatform.Remap(Dest); } if (FileType == StagedFileType.UFS) { AddUniqueStagingFile(UFSStagingFiles, FileToCopy, Dest); } else if (FileType == StagedFileType.NonUFS) { AddUniqueStagingFile(NonUFSStagingFiles, FileToCopy, Dest); } else if (FileType == StagedFileType.DebugNonUFS) { AddUniqueStagingFile(NonUFSStagingFilesDebug, FileToCopy, Dest); } FilesAdded++; } } if (FilesAdded == 0 && !bAllowNone && !bIsCombiningMultiplePlatforms) { AutomationTool.ErrorReporter.Error(String.Format("No files found to deploy for {0} with wildcard {1} and exclusions {2}", InPath, Wildcard, ExcludeWildcard), (int)AutomationTool.ErrorCodes.Error_StageMissingFile); throw new AutomationException("No files found to deploy for {0} with wildcard {1} and exclusions {2}", InPath, Wildcard, ExcludeWildcard); } return FilesAdded; }
private int StageExecutable(string Ext, DeploymentContext SC, string InPath, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcard = null, string NewPath = null, bool bAllowNone = false, StagedFileType InStageFileType = StagedFileType.NonUFS, string NewName = null) { int Result = SC.StageFiles(InStageFileType, InPath, Wildcard + Ext, bRecursive, ExcludeWildcard, NewPath, bAllowNone, true, (NewName == null) ? null : (NewName + Ext)); if (Result > 0) { SC.StageFiles(StagedFileType.DebugNonUFS, InPath, Wildcard + "pdb", bRecursive, ExcludeWildcard, NewPath, true, true, (NewName == null) ? null : (NewName + "pdb")); SC.StageFiles(StagedFileType.DebugNonUFS, InPath, Wildcard + "map", bRecursive, ExcludeWildcard, NewPath, true, true, (NewName == null) ? null : (NewName + "map")); } return(Result); }
public void StageFiles(StagedFileType FileType, string InPath, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcard = null, string NewPath = null, bool bAllowNone = false, bool bRemap = true, string NewName = null, bool bAllowNotForLicenseesFiles = true, bool bStripFilesForOtherPlatforms = true, bool bConvertToLower = false) { int FilesAdded = 0; // make sure any ..'s are removed Utils.CollapseRelativeDirectories(ref InPath); if (CommandUtils.DirectoryExists(InPath)) { var All = CommandUtils.FindFiles(Wildcard, bRecursive, InPath); var Exclude = new HashSet <string>(); if (ExcludeWildcard != null) { foreach (var Excl in ExcludeWildcard) { var Remove = CommandUtils.FindFiles(Excl, bRecursive, InPath); foreach (var File in Remove) { Exclude.Add(CommandUtils.CombinePaths(File)); } } } foreach (var AllFile in All) { var FileToCopy = CommandUtils.CombinePaths(AllFile); if (Exclude.Contains(FileToCopy)) { continue; } if (!bAllowNotForLicenseesFiles && (FileToCopy.Contains("NotForLicensees") || FileToCopy.Contains("NoRedist"))) { continue; } if (bStripFilesForOtherPlatforms && !bIsCombiningMultiplePlatforms) { bool OtherPlatform = false; foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform))) { bool bMatchesIniPlatform = (AllFile.EndsWith(".ini") && Plat == StageTargetPlatform.IniPlatformType); // filter ini files for the ini file platform bool bMatchesTargetPlatform = (Plat == StageTargetPlatform.PlatformType || Plat == UnrealTargetPlatform.Unknown); // filter platform files for the target platform if (!bMatchesIniPlatform && !bMatchesTargetPlatform) { var Search = FileToCopy; if (Search.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase)) { if (LocalRoot.EndsWith("\\") || LocalRoot.EndsWith("/")) { Search = Search.Substring(LocalRoot.Length - 1); } else { Search = Search.Substring(LocalRoot.Length); } } if (Search.StartsWith(ProjectRoot, StringComparison.InvariantCultureIgnoreCase)) { if (ProjectRoot.EndsWith("\\") || ProjectRoot.EndsWith("/")) { Search = Search.Substring(ProjectRoot.Length - 1); } else { Search = Search.Substring(ProjectRoot.Length); } } if (Search.IndexOf(CommandUtils.CombinePaths("/" + Plat.ToString() + "/"), 0, StringComparison.InvariantCultureIgnoreCase) >= 0) { OtherPlatform = true; break; } } } if (OtherPlatform) { continue; } } string Dest; if (!FileToCopy.StartsWith(InPath)) { throw new AutomationException("Can't deploy {0}; it was supposed to start with {1}", FileToCopy, InPath); } string FileToRemap = FileToCopy; // If the specified a new directory, first we deal with that, then apply the other things // this is used to collapse the sandbox, among other things if (NewPath != null) { Dest = FileToRemap.Substring(InPath.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } Dest = CommandUtils.CombinePaths(NewPath, Dest); #if false // if the cooker rebases, I don't think we need to ever rebase while staging to a new path if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } // project relative stuff in a collapsed sandbox if (Dest.StartsWith(SourceRelativeProjectRoot, StringComparison.InvariantCultureIgnoreCase)) { Dest = Dest.Substring(SourceRelativeProjectRoot.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } Dest = CommandUtils.CombinePaths(RelativeProjectRootForStage, Dest); } #endif } // project relative file else if (FileToRemap.StartsWith(ProjectRoot, StringComparison.InvariantCultureIgnoreCase)) { Dest = FileToRemap.Substring(ProjectRoot.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } Dest = CommandUtils.CombinePaths(RelativeProjectRootForStage, Dest); } // engine relative file else if (FileToRemap.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase)) { Dest = CommandUtils.CombinePaths(FileToRemap.Substring(LocalRoot.Length)); } else { throw new AutomationException("Can't deploy {0} because it doesn't start with {1} or {2}", FileToRemap, ProjectRoot, LocalRoot); } if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } if (NewName != null) { Dest = CommandUtils.CombinePaths(Path.GetDirectoryName(Dest), NewName); } if (bRemap) { Dest = StageTargetPlatform.Remap(Dest); } if (bConvertToLower) { Dest = Dest.ToLowerInvariant(); } if (FileType == StagedFileType.UFS) { AddUniqueStagingFile(UFSStagingFiles, FileToCopy, Dest); } else if (FileType == StagedFileType.NonUFS) { AddStagingFile(NonUFSStagingFiles, FileToCopy, Dest); } else if (FileType == StagedFileType.DebugNonUFS) { AddStagingFile(NonUFSStagingFilesDebug, FileToCopy, Dest); } FilesAdded++; } } if (FilesAdded == 0 && !bAllowNone && !bIsCombiningMultiplePlatforms) { throw new AutomationException(ExitCode.Error_StageMissingFile, "No files found to deploy for {0} with wildcard {1} and exclusions {2}", InPath, Wildcard, ExcludeWildcard); } }
/// <summary> /// Add a runtime dependency to the list /// </summary> /// <param name="InPath">Path to the runtime dependency. May include wildcards.</param> /// <param name="InType">How to stage this file</param> public void Add(string InPath, StagedFileType InType) { Inner.Add(new RuntimeDependency(InPath, InType)); }
/// <summary> /// Constructor /// </summary> /// <param name="InPath">Path to the runtime dependency</param> /// <param name="InType">How to stage the given path</param> public RuntimeDependency(FileReference InPath, StagedFileType InType = StagedFileType.NonUFS) { Path = InPath; Type = InType; }