/// <summary> /// Gets the latest write time of any of the UnrealHeaderTool binaries (including DLLs and Plugins) or DateTime.MaxValue if UnrealHeaderTool does not exist /// </summary> /// <returns> /// Latest timestamp of UHT binaries or DateTime.MaxValue if UnrealHeaderTool is out of date and needs to be rebuilt. /// </returns> static bool GetHeaderToolTimestamp(out DateTime Timestamp) { using (var TimestampTimer = new ScopedTimer("GetHeaderToolTimestamp")) { // Try to read the receipt for UHT. string ReceiptPath = TargetReceipt.GetDefaultPath(BuildConfiguration.RelativeEnginePath, "UnrealHeaderTool", BuildHostPlatform.Current.Platform, UnrealTargetConfiguration.Development, null); if (!File.Exists(ReceiptPath)) { Timestamp = DateTime.MaxValue; return(false); } TargetReceipt Receipt; if (!TargetReceipt.TryRead(ReceiptPath, out Receipt)) { Timestamp = DateTime.MaxValue; return(false); } Receipt.ExpandPathVariables(UnrealBuildTool.EngineDirectory, UnrealBuildTool.EngineDirectory); // Check all the binaries exist, and that all the DLLs are built against the right version if (!CheckBinariesExist(Receipt) || !CheckDynamicLibaryVersionsMatch(Receipt)) { Timestamp = DateTime.MaxValue; return(false); } // Return the timestamp for all the binaries Timestamp = GetTimestampFromBinaries(Receipt); return(true); } }
/// <summary> /// Runs install/uninstall hooks for SDK /// </summary> /// <param name="PlatformSDKRoot">absolute path to platform SDK root</param> /// <param name="SDKVersionString">version string to run for (can be empty!)</param> /// <param name="Hook">which one of hooks to run</param> /// <param name="bHookCanBeNonExistent">whether a non-existing hook means failure</param> /// <returns>true if succeeded</returns> protected virtual bool RunAutoSDKHooks(string PlatformSDKRoot, string SDKVersionString, SDKHookType Hook, bool bHookCanBeNonExistent = true) { if (!IsAutoSDKSafe()) { Log.TraceLog(GetSDKTargetPlatformName() + " attempted to run SDK hook which could have damaged manual SDK install!"); return(false); } if (SDKVersionString != "") { string SDKDirectory = Path.Combine(PlatformSDKRoot, SDKVersionString); string HookExe = Path.Combine(SDKDirectory, GetHookExecutableName(Hook)); if (File.Exists(HookExe)) { Log.TraceLog("Running {0} hook {1}", Hook, HookExe); // run it Process HookProcess = new Process(); HookProcess.StartInfo.WorkingDirectory = SDKDirectory; HookProcess.StartInfo.FileName = HookExe; HookProcess.StartInfo.Arguments = ""; HookProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; // seems to break the build machines? //HookProcess.StartInfo.UseShellExecute = false; //HookProcess.StartInfo.RedirectStandardOutput = true; //HookProcess.StartInfo.RedirectStandardError = true; using (ScopedTimer HookTimer = new ScopedTimer("Time to run hook: ", LogEventType.Log)) { //installers may require administrator access to succeed. so run as an admmin. HookProcess.StartInfo.Verb = "runas"; HookProcess.Start(); HookProcess.WaitForExit(); } //LogAutoSDK(HookProcess.StandardOutput.ReadToEnd()); //LogAutoSDK(HookProcess.StandardError.ReadToEnd()); if (HookProcess.ExitCode != 0) { Log.TraceLog("Hook exited uncleanly (returned {0}), considering it failed.", HookProcess.ExitCode); return(false); } return(true); } else { Log.TraceLog("File {0} does not exist", HookExe); } } else { Log.TraceLog("Version string is blank for {0}. Can't determine {1} hook.", PlatformSDKRoot, Hook.ToString()); } return(bHookCanBeNonExistent); }
/// <summary> /// Gets the latest write time of any of the UnrealHeaderTool binaries (including DLLs and Plugins) or DateTime.MaxValue if UnrealHeaderTool does not exist /// </summary> /// <returns> /// Latest timestamp of UHT binaries or DateTime.MaxValue if UnrealHeaderTool is out of date and needs to be rebuilt. /// </returns> static DateTime CheckIfUnrealHeaderToolIsUpToDate() { var LatestWriteTime = DateTime.MinValue; int?MinVersion = null; using (var TimestampTimer = new ScopedTimer("GetHeaderToolTimestamp")) { var HeaderToolBinaries = GetHeaderToolBinaries(); // Find the latest write time for all UnrealHeaderTool binaries foreach (var Binary in HeaderToolBinaries) { var BinaryInfo = new FileInfo(Binary.Filename); if (BinaryInfo.Exists) { // Latest write time if (BinaryInfo.LastWriteTime > LatestWriteTime) { LatestWriteTime = BinaryInfo.LastWriteTime; } // Minimum version if (Binary.Version > -1) { MinVersion = MinVersion.HasValue ? Math.Min(MinVersion.Value, Binary.Version) : Binary.Version; } } } if (MinVersion.HasValue) { // If we were able to retrieve the minimal API version, go through all binaries one more time // and delete all binaries that do not match the minimum version (which for local builds would be 0, but it will // also detect bad or partial syncs) foreach (var Binary in HeaderToolBinaries) { if (Binary.Version > -1) { if (Binary.Version != MinVersion.Value) { // Bad sync File.Delete(Binary.Filename); LatestWriteTime = DateTime.MaxValue; Log.TraceWarning("Detected mismatched version in UHT binary {0} (API Version {1}, expected: {2})", Path.GetFileName(Binary.Filename), Binary.Version, MinVersion.Value); } } } } } // If UHT doesn't exist or is out of date/mismatched, force regenerate. return(LatestWriteTime > DateTime.MinValue ? LatestWriteTime : DateTime.MaxValue); }