FileReference CreateHostProject(FileReference HostProjectFile, FileReference PluginFile) { DirectoryReference HostProjectDir = HostProjectFile.Directory; DirectoryReference.CreateDirectory(HostProjectDir); // Create the new project descriptor File.WriteAllText(HostProjectFile.FullName, "{ \"FileVersion\": 3, \"Plugins\": [ { \"Name\": \"" + PluginFile.GetFileNameWithoutExtension() + "\", \"Enabled\": true } ] }"); // Get the plugin directory in the host project, and copy all the files in DirectoryReference HostProjectPluginDir = DirectoryReference.Combine(HostProjectDir, "Plugins", PluginFile.GetFileNameWithoutExtension()); CommandUtils.ThreadedCopyFiles(PluginFile.Directory.FullName, HostProjectPluginDir.FullName); CommandUtils.DeleteDirectory(true, DirectoryReference.Combine(HostProjectPluginDir, "Intermediate").FullName); // Return the path to the plugin file in the host project return(FileReference.Combine(HostProjectPluginDir, PluginFile.GetFileName())); }
private static bool CopySharedCookedBuildForTargetInternal(string CookedBuildPath, string CookPlatform, string LocalPath, bool bOnlyCopyAssetRegistry) { string BuildRoot = CommandUtils.P4Enabled ? CommandUtils.P4Env.Branch.Replace("/", "+") : ""; string RecentCL = CommandUtils.P4Enabled ? CommandUtils.P4Env.Changelist.ToString() : ""; BuildVersion Version; if (BuildVersion.TryRead(BuildVersion.GetDefaultFileName(), out Version)) { RecentCL = Version.Changelist.ToString(); BuildRoot = Version.BranchName; } System.GC.Collect(); // check to see if we have already synced this build ;) var SyncedBuildFile = CommandUtils.CombinePaths(LocalPath, "SyncedBuild.txt"); string BuildCL = "Invalid"; if (File.Exists(SyncedBuildFile)) { BuildCL = File.ReadAllText(SyncedBuildFile); } if (RecentCL == "" && CookedBuildPath.Contains("[CL]")) { CommandUtils.Log("Unable to copy shared cooked build: Unable to determine CL number from P4 or UGS, and is required by SharedCookedBuildPath"); return(false); } if (RecentCL == "" && CookedBuildPath.Contains("[BRANCHNAME]")) { CommandUtils.Log("Unable to copy shared cooked build: Unable to determine BRANCHNAME number from P4 or UGS, and is required by SharedCookedBuildPath"); return(false); } CookedBuildPath = CookedBuildPath.Replace("[CL]", RecentCL.ToString()); CookedBuildPath = CookedBuildPath.Replace("[BRANCHNAME]", BuildRoot); CookedBuildPath = CookedBuildPath.Replace("[PLATFORM]", CookPlatform); if (Directory.Exists(CookedBuildPath) == false) { CommandUtils.Log("Unable to copy shared cooked build: Unable to find shared build at location {0} check SharedCookedBuildPath in Engine.ini SharedCookedBuildSettings is correct", CookedBuildPath); return(false); } CommandUtils.Log("Attempting download of latest shared build CL {0} from location {1}", RecentCL, CookedBuildPath); if (BuildCL == RecentCL.ToString()) { CommandUtils.Log("Already downloaded latest shared build at CL {0}", RecentCL); return(false); } if (bOnlyCopyAssetRegistry) { RecentCL += "RegistryOnly"; } if (BuildCL == RecentCL) { CommandUtils.Log("Already downloaded latest shared build at CL {0}", RecentCL); return(false); } // delete all the stuff CommandUtils.Log("Deleting previous shared build because it was out of date"); CommandUtils.DeleteDirectory(LocalPath); Directory.CreateDirectory(LocalPath); string CookedBuildMetadataDirectory = Path.Combine(CookedBuildPath, "Metadata"); CookedBuildMetadataDirectory = Path.GetFullPath(CookedBuildMetadataDirectory); string LocalBuildMetadataDirectory = Path.Combine(LocalPath, "Metadata"); LocalBuildMetadataDirectory = Path.GetFullPath(LocalBuildMetadataDirectory); if (Directory.Exists(CookedBuildMetadataDirectory)) { foreach (string FileName in Directory.EnumerateFiles(CookedBuildMetadataDirectory, "*.*", SearchOption.AllDirectories)) { string SourceFileName = Path.GetFullPath(FileName); string DestFileName = SourceFileName.Replace(CookedBuildMetadataDirectory, LocalBuildMetadataDirectory); Directory.CreateDirectory(Path.GetDirectoryName(DestFileName)); File.Copy(SourceFileName, DestFileName); } } if (CopySharedCookedBuildTask != null) { WaitForCopy(); } if (bOnlyCopyAssetRegistry == false) { CopySharedCookedBuildTask = Task.Run(() => { // find all the files in the staged directory string CookedBuildStagedDirectory = Path.GetFullPath(Path.Combine(CookedBuildPath, "Staged")); string LocalBuildStagedDirectory = Path.GetFullPath(Path.Combine(LocalPath, "Staged")); if (Directory.Exists(CookedBuildStagedDirectory)) { foreach (string FileName in Directory.EnumerateFiles(CookedBuildStagedDirectory, "*.*", SearchOption.AllDirectories)) { string SourceFileName = Path.GetFullPath(FileName); string DestFileName = SourceFileName.Replace(CookedBuildStagedDirectory, LocalBuildStagedDirectory); Directory.CreateDirectory(Path.GetDirectoryName(DestFileName)); File.Copy(SourceFileName, DestFileName); } } File.WriteAllText(SyncedBuildFile, RecentCL.ToString()); } ); } else { File.WriteAllText(SyncedBuildFile, RecentCL.ToString()); } return(true); }
public override void ExecuteBuild() { // Get the plugin filename string PluginParam = ParseParamValue("Plugin"); if (PluginParam == null) { throw new AutomationException("Missing -Plugin=... argument"); } // Check it exists FileReference PluginFile = new FileReference(PluginParam); if (!FileReference.Exists(PluginFile)) { throw new AutomationException("Plugin '{0}' not found", PluginFile.FullName); } // Get the output directory string PackageParam = ParseParamValue("Package"); if (PackageParam == null) { throw new AutomationException("Missing -Package=... argument"); } // Option for verifying that all include directive s bool bStrictIncludes = ParseParam("StrictIncludes"); // Whether to use VS2019 for compiling all targets. By default, we currently use 2017 for compiling static libraries for maximum compatibility. bool bVS2019 = ParseParam("VS2019"); // Make sure the packaging directory is valid DirectoryReference PackageDir = new DirectoryReference(PackageParam); if (PluginFile.IsUnderDirectory(PackageDir)) { throw new AutomationException("Packaged plugin output directory must be different to source"); } if (PackageDir.IsUnderDirectory(DirectoryReference.Combine(CommandUtils.RootDirectory, "Engine"))) { throw new AutomationException("Output directory for packaged plugin must be outside engine directory"); } // Clear the output directory of existing stuff if (DirectoryReference.Exists(PackageDir)) { CommandUtils.DeleteDirectoryContents(PackageDir.FullName); } else { DirectoryReference.CreateDirectory(PackageDir); } // Create a placeholder FilterPlugin.ini with instructions on how to use it FileReference SourceFilterFile = FileReference.Combine(PluginFile.Directory, "Config", "FilterPlugin.ini"); if (!FileReference.Exists(SourceFilterFile)) { List <string> Lines = new List <string>(); Lines.Add("[FilterPlugin]"); Lines.Add("; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and"); Lines.Add("; may include \"...\", \"*\", and \"?\" wildcards to match directories, files, and individual characters respectively."); Lines.Add(";"); Lines.Add("; Examples:"); Lines.Add("; /README.txt"); Lines.Add("; /Extras/..."); Lines.Add("; /Binaries/ThirdParty/*.dll"); DirectoryReference.CreateDirectory(SourceFilterFile.Directory); CommandUtils.WriteAllLines_NoExceptions(SourceFilterFile.FullName, Lines.ToArray()); } // Create a host project for the plugin. For script generator plugins, we need to have UHT be able to load it, which can only happen if it's enabled in a project. FileReference HostProjectFile = FileReference.Combine(PackageDir, "HostProject", "HostProject.uproject"); FileReference HostProjectPluginFile = CreateHostProject(HostProjectFile, PluginFile); // Read the plugin CommandUtils.LogInformation("Reading plugin from {0}...", HostProjectPluginFile); PluginDescriptor Plugin = PluginDescriptor.FromFile(HostProjectPluginFile); // Get the arguments for the compile StringBuilder AdditionalArgs = new StringBuilder(); if (bStrictIncludes) { CommandUtils.LogInformation("Building with precompiled headers and unity disabled"); AdditionalArgs.Append(" -NoPCH -NoSharedPCH -DisableUnity"); } // Compile the plugin for all the target platforms List <UnrealTargetPlatform> HostPlatforms = ParseParam("NoHostPlatform")? new List <UnrealTargetPlatform>() : new List <UnrealTargetPlatform> { BuildHostPlatform.Current.Platform }; List <UnrealTargetPlatform> TargetPlatforms = GetTargetPlatforms(this, BuildHostPlatform.Current.Platform); FileReference[] BuildProducts = CompilePlugin(HostProjectFile, HostProjectPluginFile, Plugin, HostPlatforms, TargetPlatforms, AdditionalArgs.ToString(), bVS2019); // Package up the final plugin data PackagePlugin(HostProjectPluginFile, BuildProducts, PackageDir, ParseParam("unversioned")); // Remove the host project if (!ParseParam("NoDeleteHostProject")) { CommandUtils.DeleteDirectory(HostProjectFile.Directory.FullName); } }
private static bool CopySharedCookedBuildForTargetInternal(string CookedBuildPath, string CookPlatform, string LocalPath, bool bOnlyCopyAssetRegistry) { // check to see if we have already synced this build ;) var SyncedBuildFile = CommandUtils.CombinePaths(LocalPath, "SyncedBuild.txt"); string BuildCL = "Invalid"; if (File.Exists(SyncedBuildFile)) { BuildCL = File.ReadAllText(SyncedBuildFile); } CommandUtils.LogInformation("Attempting download of latest shared build from {0}", CookedBuildPath); string SavedBuildCL = string.Format("{0} {1}", CookedBuildPath, bOnlyCopyAssetRegistry ? "RegistryOnly" : ""); if (BuildCL == SavedBuildCL) { CommandUtils.LogInformation("Already downloaded latest shared build at CL {0}", SavedBuildCL); return(false); } if (Directory.Exists(CookedBuildPath) == false) { CommandUtils.LogInformation("Unable to copy shared cooked build: Unable to find shared build at location {0} check SharedCookedBuildPath in Engine.ini SharedCookedBuildSettings is correct", CookedBuildPath); return(false); } // delete all the stuff CommandUtils.LogInformation("Deleting previous shared build because it was out of date"); CommandUtils.DeleteDirectory(LocalPath); Directory.CreateDirectory(LocalPath); string CookedBuildMetadataDirectory = Path.Combine(CookedBuildPath, "Metadata"); CookedBuildMetadataDirectory = Path.GetFullPath(CookedBuildMetadataDirectory); string LocalBuildMetadataDirectory = Path.Combine(LocalPath, "Metadata"); LocalBuildMetadataDirectory = Path.GetFullPath(LocalBuildMetadataDirectory); if (Directory.Exists(CookedBuildMetadataDirectory)) { foreach (string FileName in Directory.EnumerateFiles(CookedBuildMetadataDirectory, "*.*", SearchOption.AllDirectories)) { string SourceFileName = Path.GetFullPath(FileName); string DestFileName = SourceFileName.Replace(CookedBuildMetadataDirectory, LocalBuildMetadataDirectory); Directory.CreateDirectory(Path.GetDirectoryName(DestFileName)); File.Copy(SourceFileName, DestFileName); } } if (CopySharedCookedBuildTask != null) { WaitForCopy(); } if (bOnlyCopyAssetRegistry == false) { CopySharedCookedBuildTask = Task.Run(() => { // find all the files in the staged directory string CookedBuildStagedDirectory = Path.GetFullPath(Path.Combine(CookedBuildPath, "Staged")); string LocalBuildStagedDirectory = Path.GetFullPath(Path.Combine(LocalPath, "Staged")); if (Directory.Exists(CookedBuildStagedDirectory)) { foreach (string FileName in Directory.EnumerateFiles(CookedBuildStagedDirectory, "*.*", SearchOption.AllDirectories)) { string SourceFileName = Path.GetFullPath(FileName); string DestFileName = SourceFileName.Replace(CookedBuildStagedDirectory, LocalBuildStagedDirectory); Directory.CreateDirectory(Path.GetDirectoryName(DestFileName)); File.Copy(SourceFileName, DestFileName); } } File.WriteAllText(SyncedBuildFile, SavedBuildCL); } ); } else { File.WriteAllText(SyncedBuildFile, SavedBuildCL); } return(true); }
public override void ExecuteBuild() { // Get the plugin filename string PluginFileName = ParseParamValue("Plugin"); if (PluginFileName == null) { throw new AutomationException("Plugin file name was not specified via the -plugin argument"); } // Read the plugin PluginDescriptor Plugin = PluginDescriptor.FromFile(PluginFileName); // Clean the intermediate build directory string IntermediateBuildDirectory = Path.Combine(Path.GetDirectoryName(PluginFileName), "Intermediate", "Build"); if (CommandUtils.DirectoryExists(IntermediateBuildDirectory)) { CommandUtils.DeleteDirectory(IntermediateBuildDirectory); } // Get any additional arguments from the commandline string AdditionalArgs = ""; if (ParseParam("Rocket")) { AdditionalArgs += " -Rocket"; } // Build the host platforms List <string> ReceiptFileNames = new List <string>(); UE4Build.BuildAgenda Agenda = new UE4Build.BuildAgenda(); UnrealTargetPlatform HostPlatform = BuildHostPlatform.Current.Platform; if (!ParseParam("NoHostPlatform")) { AddPluginToAgenda(Agenda, PluginFileName, Plugin, "UE4Editor", TargetRules.TargetType.Editor, HostPlatform, UnrealTargetConfiguration.Development, ReceiptFileNames, AdditionalArgs); } // Add the game targets List <UnrealTargetPlatform> TargetPlatforms = Rocket.RocketBuild.GetTargetPlatforms(this, HostPlatform); foreach (UnrealTargetPlatform TargetPlatform in TargetPlatforms) { if (Rocket.RocketBuild.IsCodeTargetPlatform(HostPlatform, TargetPlatform)) { AddPluginToAgenda(Agenda, PluginFileName, Plugin, "UE4Game", TargetRules.TargetType.Game, TargetPlatform, UnrealTargetConfiguration.Development, ReceiptFileNames, AdditionalArgs); AddPluginToAgenda(Agenda, PluginFileName, Plugin, "UE4Game", TargetRules.TargetType.Game, TargetPlatform, UnrealTargetConfiguration.Shipping, ReceiptFileNames, AdditionalArgs); } } // Build it UE4Build Build = new UE4Build(this); Build.Build(Agenda, InDeleteBuildProducts: true, InUpdateVersionFiles: false); // Package the plugin to the output folder string PackageDirectory = ParseParamValue("Package"); if (PackageDirectory != null) { List <BuildProduct> BuildProducts = GetBuildProductsFromReceipts(ReceiptFileNames); PackagePlugin(PluginFileName, BuildProducts, PackageDirectory); } }
public override void ExecuteBuild() { int WorkingCL = -1; FileReference PluginFile = null; string ProjectFileName = ParseParamValue("Project"); if (ProjectFileName == null) { ProjectFileName = CombinePaths(CmdEnv.LocalRoot, "SimpleGame", "SimpleGame.uproject"); } LogInformation(ProjectFileName); ProjectParams Params = GetParams(this, ProjectFileName, out PluginFile); // Check whether folder already exists so we know if we can delete it later string PlatformStageDir = Path.Combine(Params.StageDirectoryParam, "WindowsNoEditor"); bool bPreExistingStageDir = Directory.Exists(PlatformStageDir); PluginDescriptor Plugin = PluginDescriptor.FromFile(PluginFile); FileReference ProjectFile = new FileReference(ProjectFileName); // Add Plugin to folders excluded for nativization in config file FileReference UserEditorIni = new FileReference(Path.Combine(Path.GetDirectoryName(ProjectFileName), "Config", "UserEditor.ini")); bool bPreExistingUserEditorIni = FileReference.Exists(UserEditorIni); if (!bPreExistingUserEditorIni) { // Expect this most of the time so we will create and clean up afterwards DirectoryReference.CreateDirectory(UserEditorIni.Directory); CommandUtils.WriteAllText(UserEditorIni.FullName, ""); } const string ConfigSection = "BlueprintNativizationSettings"; const string ConfigKey = "ExcludedFolderPaths"; string ConfigValue = "/" + PluginFile.GetFileNameWithoutAnyExtensions() + "/"; ConfigFile UserEditorConfig = new ConfigFile(UserEditorIni); ConfigFileSection BPNSection = UserEditorConfig.FindOrAddSection(ConfigSection); bool bUpdateConfigFile = !BPNSection.Lines.Exists(x => String.Equals(x.Key, ConfigKey, StringComparison.OrdinalIgnoreCase) && String.Equals(x.Value, ConfigValue, StringComparison.OrdinalIgnoreCase)); if (bUpdateConfigFile) { BPNSection.Lines.Add(new ConfigLine(ConfigLineAction.Add, ConfigKey, ConfigValue)); UserEditorConfig.Write(UserEditorIni); } Project.Cook(Params); if (!bPreExistingUserEditorIni) { FileReference.Delete(UserEditorIni); } Project.CopyBuildToStagingDirectory(Params); Project.Package(Params, WorkingCL); Project.Archive(Params); Project.Deploy(Params); // Get path to where the plugin was staged string StagedPluginDir = Path.Combine(PlatformStageDir, Path.GetFileNameWithoutExtension(ProjectFileName), PluginFile.Directory.MakeRelativeTo(ProjectFile.Directory)); string ZipFile = Path.Combine(Params.StageDirectoryParam, PluginFile.GetFileNameWithoutAnyExtensions()); CommandUtils.DeleteFile(ZipFile); System.IO.Compression.ZipFile.CreateFromDirectory(StagedPluginDir, ZipFile + ".zip"); if (!bPreExistingStageDir) { CommandUtils.DeleteDirectory(PlatformStageDir); } }
static void CopySharedCookedBuildForTarget(ProjectParams Params, TargetPlatformDescriptor TargetPlatform, string CookPlatform) { string ProjectPath = Params.RawProjectPath.FullName; var LocalPath = CombinePaths(GetDirectoryName(ProjectPath), "Saved", "SharedIterativeBuild", CookPlatform); // get network location ConfigHierarchy Hierarchy = ConfigCache.ReadHierarchy(ConfigHierarchyType.Engine, DirectoryReference.FromFile(Params.RawProjectPath), TargetPlatform.Type); string CookedBuildPath; if (Hierarchy.GetString("SharedCookedBuildSettings", "SharedCookedBuildPath", out CookedBuildPath) == false) { Log("Unable to copy shared cooked build: SharedCookedBuildPath not set in Engine.ini SharedCookedBuildSettings"); return; } string BuildRoot = P4Enabled ? P4Env.BuildRootP4.Replace("/", "+") : ""; int RecentCL = P4Enabled ? P4Env.Changelist : 0; BuildVersion Version; if (BuildVersion.TryRead(out Version)) { RecentCL = Version.Changelist; BuildRoot = Version.BranchName; } // check to see if we have already synced this build ;) var SyncedBuildFile = CombinePaths(LocalPath, "SyncedBuild.txt"); string BuildCL = "Invalid"; if (File.Exists(SyncedBuildFile)) { BuildCL = File.ReadAllText(SyncedBuildFile); } if (RecentCL == 0 && CookedBuildPath.Contains("[CL]")) { Log("Unable to copy shared cooked build: Unable to determine CL number from P4 or UGS, and is required by SharedCookedBuildPath"); return; } if (RecentCL == 0 && CookedBuildPath.Contains("[BRANCHNAME]")) { Log("Unable to copy shared cooked build: Unable to determine BRANCHNAME number from P4 or UGS, and is required by SharedCookedBuildPath"); return; } CookedBuildPath = CookedBuildPath.Replace("[CL]", RecentCL.ToString()); CookedBuildPath = CookedBuildPath.Replace("[BRANCHNAME]", BuildRoot); CookedBuildPath = CookedBuildPath.Replace("[PLATFORM]", CookPlatform); if (Directory.Exists(CookedBuildPath) == false) { Log("Unable to copy shared cooked build: Unable to find shared build at location {0} check SharedCookedBuildPath in Engine.ini SharedCookedBuildSettings is correct", CookedBuildPath); return; } Log("Attempting download of latest shared build CL {0} from location {1}", RecentCL, CookedBuildPath); if (BuildCL == RecentCL.ToString()) { Log("Already downloaded latest shared build at CL {0}", RecentCL); return; } // delete all the stuff Log("Deleting previous shared build because it was out of date"); CommandUtils.DeleteDirectory(LocalPath); Directory.CreateDirectory(LocalPath); // find all the files in the staged directory string CookedBuildStagedDirectory = Path.GetFullPath(Path.Combine(CookedBuildPath, "Staged")); string LocalBuildStagedDirectory = Path.GetFullPath(Path.Combine(LocalPath, "Staged")); if (Directory.Exists(CookedBuildStagedDirectory)) { foreach (string FileName in Directory.EnumerateFiles(CookedBuildStagedDirectory, "*.*", SearchOption.AllDirectories)) { string SourceFileName = Path.GetFullPath(FileName); string DestFileName = SourceFileName.Replace(CookedBuildStagedDirectory, LocalBuildStagedDirectory); Directory.CreateDirectory(Path.GetDirectoryName(DestFileName)); File.Copy(SourceFileName, DestFileName); } } string CookedBuildCookedDirectory = Path.Combine(CookedBuildPath, "Cooked"); CookedBuildCookedDirectory = Path.GetFullPath(CookedBuildCookedDirectory); string LocalBuildCookedDirectory = Path.Combine(LocalPath, "Cooked"); LocalBuildCookedDirectory = Path.GetFullPath(LocalBuildCookedDirectory); if (Directory.Exists(CookedBuildCookedDirectory)) { foreach (string FileName in Directory.EnumerateFiles(CookedBuildCookedDirectory, "*.*", SearchOption.AllDirectories)) { string SourceFileName = Path.GetFullPath(FileName); string DestFileName = SourceFileName.Replace(CookedBuildCookedDirectory, LocalBuildCookedDirectory); Directory.CreateDirectory(Path.GetDirectoryName(DestFileName)); File.Copy(SourceFileName, DestFileName); } } File.WriteAllText(SyncedBuildFile, RecentCL.ToString()); return; }
public override void ExecuteBuild() { // Get the plugin filename string PluginParam = ParseParamValue("Plugin"); if (PluginParam == null) { throw new AutomationException("Plugin file name was not specified via the -plugin argument"); } // Read the plugin FileReference PluginFile = new FileReference(PluginParam); DirectoryReference PluginDirectory = PluginFile.Directory; PluginDescriptor Plugin = PluginDescriptor.FromFile(PluginFile); // Clean the intermediate build directory DirectoryReference IntermediateBuildDirectory = DirectoryReference.Combine(PluginDirectory, "Intermediate", "Build"); if (CommandUtils.DirectoryExists(IntermediateBuildDirectory.FullName)) { CommandUtils.DeleteDirectory(IntermediateBuildDirectory.FullName); } // Create a host project for the plugin. For script generator plugins, we need to have UHT be able to load it - and that can only happen if it's enabled in a project. DirectoryReference HostProjectDirectory = DirectoryReference.Combine(new DirectoryReference(CommandUtils.CmdEnv.LocalRoot), "HostProject"); if (CommandUtils.DirectoryExists(HostProjectDirectory.FullName)) { CommandUtils.DeleteDirectory(HostProjectDirectory.FullName); } DirectoryReference HostProjectPluginDirectory = DirectoryReference.Combine(HostProjectDirectory, "Plugins", PluginFile.GetFileNameWithoutExtension()); string[] CopyPluginFiles = Directory.EnumerateFiles(PluginDirectory.FullName, "*", SearchOption.AllDirectories).ToArray(); foreach (string CopyPluginFile in CopyPluginFiles) { CommandUtils.CopyFile(CopyPluginFile, CommandUtils.MakeRerootedFilePath(CopyPluginFile, PluginDirectory.FullName, HostProjectPluginDirectory.FullName)); } FileReference HostProjectPluginFile = FileReference.Combine(HostProjectPluginDirectory, PluginFile.GetFileName()); FileReference HostProjectFile = FileReference.Combine(HostProjectDirectory, "HostProject.uproject"); File.WriteAllText(HostProjectFile.FullName, "{ \"FileVersion\": 3, \"Plugins\": [ { \"Name\": \"" + PluginFile.GetFileNameWithoutExtension() + "\", \"Enabled\": true } ] }"); // Get any additional arguments from the commandline string AdditionalArgs = ""; // Build the host platforms List <string> ReceiptFileNames = new List <string>(); UnrealTargetPlatform HostPlatform = BuildHostPlatform.Current.Platform; if (!ParseParam("NoHostPlatform")) { if (Plugin.bCanBeUsedWithUnrealHeaderTool) { BuildPluginWithUBT(PluginFile, Plugin, null, "UnrealHeaderTool", TargetRules.TargetType.Program, HostPlatform, UnrealTargetConfiguration.Development, ReceiptFileNames, String.Format("{0} -plugin {1}", AdditionalArgs, CommandUtils.MakePathSafeToUseWithCommandLine(HostProjectPluginFile.FullName))); } BuildPluginWithUBT(PluginFile, Plugin, HostProjectFile, "UE4Editor", TargetRules.TargetType.Editor, HostPlatform, UnrealTargetConfiguration.Development, ReceiptFileNames, AdditionalArgs); } // Add the game targets List <UnrealTargetPlatform> TargetPlatforms = Rocket.RocketBuild.GetTargetPlatforms(this, HostPlatform); foreach (UnrealTargetPlatform TargetPlatform in TargetPlatforms) { if (Rocket.RocketBuild.IsCodeTargetPlatform(HostPlatform, TargetPlatform)) { BuildPluginWithUBT(PluginFile, Plugin, HostProjectFile, "UE4Game", TargetRules.TargetType.Game, TargetPlatform, UnrealTargetConfiguration.Development, ReceiptFileNames, AdditionalArgs); BuildPluginWithUBT(PluginFile, Plugin, HostProjectFile, "UE4Game", TargetRules.TargetType.Game, TargetPlatform, UnrealTargetConfiguration.Shipping, ReceiptFileNames, AdditionalArgs); } } // Package the plugin to the output folder string PackageDirectory = ParseParamValue("Package"); if (PackageDirectory != null) { List <BuildProduct> BuildProducts = GetBuildProductsFromReceipts(UnrealBuildTool.UnrealBuildTool.EngineDirectory, HostProjectDirectory, ReceiptFileNames); PackagePlugin(HostProjectPluginFile, BuildProducts, PackageDirectory); } }
public override bool PublishSymbols(DirectoryReference SymbolStoreDirectory, List <FileReference> Files, string Product, string BuildVersion = null) { // Get the SYMSTORE.EXE path, using the latest SDK version we can find. FileReference SymStoreExe = GetSymStoreExe(); List <FileReference> FilesToAdd = Files.Where(x => x.HasExtension(".pdb") || x.HasExtension(".exe") || x.HasExtension(".dll")).ToList(); if (FilesToAdd.Count > 0) { DateTime Start = DateTime.Now; DirectoryReference TempSymStoreDir = DirectoryReference.Combine(RootDirectory, "Saved", "SymStore"); if (DirectoryReference.Exists(TempSymStoreDir)) { CommandUtils.DeleteDirectory(TempSymStoreDir); DirectoryReference.CreateDirectory(TempSymStoreDir); } string TempFileName = Path.GetTempFileName(); try { File.WriteAllLines(TempFileName, FilesToAdd.Select(x => x.FullName), Encoding.ASCII); // Copy everything to the temp symstore ProcessStartInfo StartInfo = new ProcessStartInfo(); StartInfo.FileName = SymStoreExe.FullName; StartInfo.Arguments = string.Format("add /f \"@{0}\" /s \"{1}\" /t \"{2}\"", TempFileName, TempSymStoreDir, Product); StartInfo.UseShellExecute = false; StartInfo.CreateNoWindow = true; if (Utils.RunLocalProcessAndLogOutput(StartInfo) != 0) { return(false); } } finally { File.Delete(TempFileName); } DateTime CompressDone = DateTime.Now; LogInformation("Took {0}s to compress the symbol files to temp path {1}", (CompressDone - Start).TotalSeconds, TempSymStoreDir); int CopiedCount = 0; // Take each new compressed file made and try and copy it to the real symstore. Exclude any symstore admin files foreach (FileReference File in DirectoryReference.EnumerateFiles(TempSymStoreDir, "*.*", SearchOption.AllDirectories).Where(File => IsSymbolFile(File))) { string RelativePath = File.MakeRelativeTo(DirectoryReference.Combine(TempSymStoreDir)); FileReference ActualDestinationFile = FileReference.Combine(SymbolStoreDirectory, RelativePath); // Try and add a version file. Do this before checking to see if the symbol is there already in the case of exact matches (multiple builds could use the same pdb, for example) if (!string.IsNullOrWhiteSpace(BuildVersion)) { FileReference BuildVersionFile = FileReference.Combine(ActualDestinationFile.Directory, string.Format("{0}.version", BuildVersion)); // Attempt to create the file. Just continue if it fails. try { DirectoryReference.CreateDirectory(BuildVersionFile.Directory); FileReference.WriteAllText(BuildVersionFile, string.Empty); } catch (Exception Ex) { LogWarning("Failed to write the version file, reason {0}", Ex.ToString()); } } // Don't bother copying the temp file if the destination file is there already. if (FileReference.Exists(ActualDestinationFile)) { LogInformation("Destination file {0} already exists, skipping", ActualDestinationFile.FullName); continue; } FileReference TempDestinationFile = new FileReference(ActualDestinationFile.FullName + Guid.NewGuid().ToString()); try { CommandUtils.CopyFile(File.FullName, TempDestinationFile.FullName); } catch (Exception Ex) { throw new AutomationException("Couldn't copy the symbol file to the temp store! Reason: {0}", Ex.ToString()); } // Move the file in the temp store over. try { FileReference.Move(TempDestinationFile, ActualDestinationFile); //LogVerbose("Moved {0} to {1}", TempDestinationFile, ActualDestinationFile); CopiedCount++; } catch (Exception Ex) { // If the file is there already, it was likely either copied elsewhere (and this is an ioexception) or it had a file handle open already. // Either way, it's fine to just continue on. if (FileReference.Exists(ActualDestinationFile)) { LogInformation("Destination file {0} already exists or was in use, skipping.", ActualDestinationFile.FullName); continue; } // If it doesn't exist, we actually failed to copy it entirely. else { LogWarning("Couldn't move temp file {0} to the symbol store at location {1}! Reason: {2}", TempDestinationFile.FullName, ActualDestinationFile.FullName, Ex.ToString()); } } // Delete the temp one no matter what, don't want them hanging around in the symstore finally { FileReference.Delete(TempDestinationFile); } } LogInformation("Took {0}s to copy {1} symbol files to the store at {2}", (DateTime.Now - CompressDone).TotalSeconds, CopiedCount, SymbolStoreDirectory); FileReference PingmeFile = FileReference.Combine(SymbolStoreDirectory, "pingme.txt"); if (!FileReference.Exists(PingmeFile)) { LogInformation("Creating {0} to mark path as three-tiered symbol location", PingmeFile); File.WriteAllText(PingmeFile.FullName, "Exists to mark this as a three-tiered symbol location"); } } return(true); }