From f7238064c8680f6392793eb664ee2c773daff594 Mon Sep 17 00:00:00 2001
From: Oleksandr Kozlov <okozlov@microsoft.com>
Date: Tue, 1 Apr 2025 15:22:14 +0200
Subject: [PATCH] Support extra UBT args in UAT.BuildPlugin

Forwarding extra parameters to UBT to allow customizing the build of a plugin.
Example: runuat.bat buildpluing -plugin=... -ubtargs="-LinkerArguments=\"/profile\""

---
 .../Scripts/BuildPluginCommand.Automation.cs        | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/Engine/Source/Programs/AutomationTool/Scripts/BuildPluginCommand.Automation.cs b/Engine/Source/Programs/AutomationTool/Scripts/BuildPluginCommand.Automation.cs
index 5a43dc0c4..aaf3f192f 100644
--- a/Engine/Source/Programs/AutomationTool/Scripts/BuildPluginCommand.Automation.cs
+++ b/Engine/Source/Programs/AutomationTool/Scripts/BuildPluginCommand.Automation.cs
@@ -64,6 +64,9 @@ public sealed class BuildPlugin : BuildCommand
 		// Option for verifying that all include directive s
 		bool bStrictIncludes = ParseParam("StrictIncludes");
 
+		// Extra arguments forwarded to UBT
+		string UBTArgs = ParseParamValue("ubtargs");
+
 		// Make sure the packaging directory is valid
 		DirectoryReference PackageDir = new DirectoryReference(PackageParam);
 		
@@ -126,6 +129,16 @@ public sealed class BuildPlugin : BuildCommand
 			AdditionalArgs.Append(" -NoPCH -NoSharedPCH -DisableUnity");
 		}
 
+		// Pass extra parameters to UBT
+		if (string.IsNullOrEmpty(UBTArgs) == false)
+		{
+			Logger.LogInformation("Building with extra UBT parameters: {UBTArgs}", UBTArgs);
+			string Arg = UBTArgs;
+			Arg = Arg.TrimStart(new char[] { '\"' });
+			Arg = Arg.TrimEnd(new char[] { '\"' });
+			AdditionalArgs.Append(' ').Append(Arg);
+		}
+
 		// check if any architectures were specified
 		foreach (UnrealTargetPlatform Platform in UnrealTargetPlatform.GetValidPlatforms())
 		{
-- 
2.49.0.windows.1

