/// <summary> /// Construct a custom build steps object from a Json object. /// </summary> public CustomBuildSteps(JsonObject RawObject) { foreach (string HostPlatformName in RawObject.KeyNames) { UnrealTargetPlatform Platform; if (UnrealTargetPlatform.TryParse(HostPlatformName, out Platform)) { HostPlatformToCommands.Add(Platform, RawObject.GetStringArrayField(HostPlatformName)); } } }
/// <summary> /// Read a receipt from disk. /// </summary> /// <param name="Location">Filename to read from</param> public static PrecompiledManifest Read(FileReference Location) { DirectoryReference BaseDir = Location.Directory; PrecompiledManifest Manifest = new PrecompiledManifest(); JsonObject RawObject = JsonObject.Read(Location); string[] OutputFiles = RawObject.GetStringArrayField("OutputFiles"); foreach (string OutputFile in OutputFiles) { Manifest.OutputFiles.Add(FileReference.Combine(BaseDir, OutputFile)); } return(Manifest); }
/// <summary> /// Checks to see if the assembly needs compilation /// </summary> /// <param name="SourceFiles">Set of source files</param> /// <param name="AssemblyManifestFilePath">File containing information about this assembly, like which source files it was built with and engine version</param> /// <param name="OutputAssemblyPath">Output path for the assembly</param> /// <returns>True if the assembly needs to be built</returns> private static bool RequiresCompilation(HashSet <FileReference> SourceFiles, FileReference AssemblyManifestFilePath, FileReference OutputAssemblyPath) { // Check to see if we already have a compiled assembly file on disk FileItem OutputAssemblyInfo = FileItem.GetItemByFileReference(OutputAssemblyPath); if (!OutputAssemblyInfo.Exists) { Log.TraceLog("Compiling {0}: Assembly does not exist", OutputAssemblyPath); return(true); } // Check the time stamp of the UnrealBuildTool.exe file. If Unreal Build Tool was compiled more // recently than the dynamically-compiled assembly, then we'll always recompile it. This is // because Unreal Build Tool's code may have changed in such a way that invalidate these // previously-compiled assembly files. FileItem ExecutableItem = FileItem.GetItemByFileReference(UnrealBuildTool.GetUBTPath()); if (ExecutableItem.LastWriteTimeUtc > OutputAssemblyInfo.LastWriteTimeUtc) { Log.TraceLog("Compiling {0}: {1} is newer", OutputAssemblyPath, ExecutableItem.Name); return(true); } // Make sure we have a manifest of source files used to compile the output assembly. If it doesn't exist // for some reason (not an expected case) then we'll need to recompile. FileItem AssemblySourceListFile = FileItem.GetItemByFileReference(AssemblyManifestFilePath); if (!AssemblySourceListFile.Exists) { Log.TraceLog("Compiling {0}: Missing source file list ({1})", OutputAssemblyPath, AssemblyManifestFilePath); return(true); } JsonObject Manifest = JsonObject.Read(AssemblyManifestFilePath); // check if the engine version is different string EngineVersionManifest = Manifest.GetStringField("EngineVersion"); string EngineVersionCurrent = FormatVersionNumber(ReadOnlyBuildVersion.Current); if (EngineVersionManifest != EngineVersionCurrent) { Log.TraceLog("Compiling {0}: Engine Version changed from {1} to {2}", OutputAssemblyPath, EngineVersionManifest, EngineVersionCurrent); return(true); } // Make sure the source files we're compiling are the same as the source files that were compiled // for the assembly that we want to load HashSet <FileItem> CurrentSourceFileItems = new HashSet <FileItem>(); foreach (string Line in Manifest.GetStringArrayField("SourceFiles")) { CurrentSourceFileItems.Add(FileItem.GetItemByPath(Line)); } // Get the new source files HashSet <FileItem> SourceFileItems = new HashSet <FileItem>(); foreach (FileReference SourceFile in SourceFiles) { SourceFileItems.Add(FileItem.GetItemByFileReference(SourceFile)); } // Check if there are any differences between the sets foreach (FileItem CurrentSourceFileItem in CurrentSourceFileItems) { if (!SourceFileItems.Contains(CurrentSourceFileItem)) { Log.TraceLog("Compiling {0}: Removed source file ({1})", OutputAssemblyPath, CurrentSourceFileItem); return(true); } } foreach (FileItem SourceFileItem in SourceFileItems) { if (!CurrentSourceFileItems.Contains(SourceFileItem)) { Log.TraceLog("Compiling {0}: Added source file ({1})", OutputAssemblyPath, SourceFileItem); return(true); } } // Check if any of the timestamps are newer foreach (FileItem SourceFileItem in SourceFileItems) { if (SourceFileItem.LastWriteTimeUtc > OutputAssemblyInfo.LastWriteTimeUtc) { Log.TraceLog("Compiling {0}: {1} is newer", OutputAssemblyPath, SourceFileItem); return(true); } } return(false); }