Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ internal record class BuildGraphPatchSet
[JsonPropertyName("File"), JsonRequired]
public string File { get; set; } = string.Empty;

[JsonPropertyName("Output4")]
public string? Output4 { get; set; } = null;

[JsonPropertyName("Output5"), JsonRequired]
public string Output { get; set; } = string.Empty;
public string Output5 { get; set; } = string.Empty;

[JsonPropertyName("Patches"), JsonRequired]
public BuildGraphPatchSetPatch[] Patches { get; set; } = Array.Empty<BuildGraphPatchSetPatch>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,24 @@ private async Task CopyMissingEngineBitsAsync(string enginePath)

public async Task PatchBuildGraphAsync(string enginePath, bool isEngineBuild)
{
var buildVersionFilePath = Path.Combine(enginePath, "Engine", "Build", "Build.version");
var isTargetingUnrealEngine4 = false;
if (File.Exists(buildVersionFilePath))
{
if (File.ReadAllText(buildVersionFilePath).Contains("UE4", StringComparison.Ordinal))
{
isTargetingUnrealEngine4 = true;
}
}
if (isTargetingUnrealEngine4)
{
_logger.LogTrace("Detected Unreal Engine 4.");
}
else
{
_logger.LogTrace("Detected Unreal Engine 5.");
}

var patchLevelFilePath = Path.Combine(enginePath, "Engine", "Source", "Programs", "UET.BuildGraphPatchLevel.json");
var buildGraphPatchStatus = new BuildGraphPatchStatus();
var applyPatches = false;
Expand Down Expand Up @@ -199,6 +217,15 @@ public async Task PatchBuildGraphAsync(string enginePath, bool isEngineBuild)

foreach (var patchDefinition in _patches)
{
if (string.IsNullOrWhiteSpace(patchDefinition.Output4) && isTargetingUnrealEngine4)
{
continue;
}
if (string.IsNullOrWhiteSpace(patchDefinition.Output5) && !isTargetingUnrealEngine4)
{
continue;
}

var filename = patchDefinition.File.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar);

var sourceFile = Path.Combine(enginePath, filename);
Expand Down Expand Up @@ -396,32 +423,35 @@ await _processExecutor.ExecuteAsync(
};
foreach (var project in projects)
{
_logger.LogInformation($"Restoring packages for: {project.name}");
var exitCode = await _processExecutor.ExecuteAsync(
new ProcessSpecification
{
FilePath = dotnetPath,
Arguments = [
"msbuild",
"/nologo",
"/verbosity:quiet",
project.path,
"/property:Configuration=Development",
"/property:Platform=AnyCPU",
"/p:WarningLevel=0",
"/target:Restore",
"/p:NuGetAudit=False",
],
EnvironmentVariables = new Dictionary<string, string>
{
{ "NUGET_PACKAGES", nugetStoragePath.Path }
}
},
CaptureSpecification.Passthrough,
CancellationToken.None).ConfigureAwait(false);
if (exitCode != 0)
if (Path.Exists(project.path))
{
throw new InvalidOperationException($"Failed to rebuild BuildGraph (msbuild restore exited with exit code {exitCode})");
_logger.LogInformation($"Restoring packages for: {project.name}");
var exitCode = await _processExecutor.ExecuteAsync(
new ProcessSpecification
{
FilePath = dotnetPath,
Arguments = [
"msbuild",
"/nologo",
"/verbosity:quiet",
project.path,
"/property:Configuration=Development",
"/property:Platform=AnyCPU",
"/p:WarningLevel=0",
"/target:Restore",
"/p:NuGetAudit=False",
],
EnvironmentVariables = new Dictionary<string, string>
{
{ "NUGET_PACKAGES", nugetStoragePath.Path }
}
},
CaptureSpecification.Passthrough,
CancellationToken.None).ConfigureAwait(false);
if (exitCode != 0)
{
throw new InvalidOperationException($"Failed to rebuild BuildGraph (msbuild restore exited with exit code {exitCode})");
}
}
}
foreach (var project in projects)
Expand All @@ -431,31 +461,34 @@ await _processExecutor.ExecuteAsync(
continue;
}

_logger.LogInformation($"Building: {project.name}");
var exitCode = await _processExecutor.ExecuteAsync(
new ProcessSpecification
{
FilePath = dotnetPath,
Arguments = [
"msbuild",
"/nologo",
"/verbosity:quiet",
project.path,
"/property:Configuration=Development",
"/property:Platform=AnyCPU",
"/p:WarningLevel=0",
"/p:NuGetAudit=False",
],
EnvironmentVariables = new Dictionary<string, string>
{
{ "NUGET_PACKAGES", nugetStoragePath.Path }
}
},
CaptureSpecification.Passthrough,
CancellationToken.None).ConfigureAwait(false);
if (exitCode != 0)
if (Path.Exists(project.path))
{
throw new InvalidOperationException($"Failed to rebuild BuildGraph (msbuild compile exited with exit code {exitCode})");
_logger.LogInformation($"Building: {project.name}");
var exitCode = await _processExecutor.ExecuteAsync(
new ProcessSpecification
{
FilePath = dotnetPath,
Arguments = [
"msbuild",
"/nologo",
"/verbosity:quiet",
project.path,
"/property:Configuration=Development",
"/property:Platform=AnyCPU",
"/p:WarningLevel=0",
"/p:NuGetAudit=False",
],
EnvironmentVariables = new Dictionary<string, string>
{
{ "NUGET_PACKAGES", nugetStoragePath.Path }
}
},
CaptureSpecification.Passthrough,
CancellationToken.None).ConfigureAwait(false);
if (exitCode != 0)
{
throw new InvalidOperationException($"Failed to rebuild BuildGraph (msbuild compile exited with exit code {exitCode})");
}
}
}

Expand Down
17 changes: 16 additions & 1 deletion UET/uet/Commands/Build/BuildCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ internal sealed class Options
public Option<bool> Deploy;
public Option<bool> StrictIncludes;
public Option<bool> StorageVirtualisation;
public Option<bool> Legacy;

public Option<DistributionSpec?> Distribution;

Expand Down Expand Up @@ -107,6 +108,11 @@ public Options(
description: "If set, enables storage virtualisation via UEFS.");
StorageVirtualisation.AddAlias("-u");

Legacy = new Option<bool>(
"--legacy",
description: "If set, indicates that the engine is Unreal Engine 4, not Unreal Engine 5. Do not report bugs when using this option - it is unsupported and 'best effort' only.");
Legacy.IsHidden = true;

// ==== .uproject / .uplugin options

Shipping = new Option<bool>(
Expand Down Expand Up @@ -288,6 +294,7 @@ public async Task<int> ExecuteAsync(InvocationContext context)
var pluginPackage = context.ParseResult.GetValueForOption(_options.PluginPackage);
var pluginVersionName = context.ParseResult.GetValueForOption(_options.PluginVersionName);
var pluginVersionNumber = context.ParseResult.GetValueForOption(_options.PluginVersionNumber);
var legacy = context.ParseResult.GetValueForOption(_options.Legacy);

// Configure the dynamic workspace provider to use workspace virtualisation
// if appropriate.
Expand Down Expand Up @@ -370,6 +377,13 @@ public async Task<int> ExecuteAsync(InvocationContext context)
_logger.LogInformation($"--plugin-package: {pluginPackage}");
_logger.LogInformation($"--plugin-version-name: {pluginVersionName}");
_logger.LogInformation($"--plugin-version-number: {pluginVersionNumber}");
if (legacy)
{
_logger.LogInformation($"--legacy: yes (unsupported)");
_logger.LogWarning("");
_logger.LogWarning("Use of the --legacy option is unsupported. Do not report bugs or issues when using this flag.");
_logger.LogWarning("");
}

BuildEngineSpecification engineSpec;
switch (engine.Type)
Expand Down Expand Up @@ -506,7 +520,8 @@ public async Task<int> ExecuteAsync(InvocationContext context)
localExecutor: executorName == "local",
isPluginRooted: false,
commandlinePluginVersionName: pluginVersionName,
commandlinePluginVersionNumber: pluginVersionNumber).ConfigureAwait(false);
commandlinePluginVersionNumber: pluginVersionNumber,
legacy).ConfigureAwait(false);
preparePlugin = pluginDistribution.Prepare;
break;
case BuildConfigEngineDistribution engineDistribution:
Expand Down
20 changes: 17 additions & 3 deletions UET/uet/Commands/Build/DefaultBuildSpecificationGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,19 @@ await _dynamicBuildGraphIncludeWriter.WriteBuildGraphMacroInclude(
return ($"__SHARED_STORAGE_PATH__/{nodeFilename}", $"__SHARED_STORAGE_PATH__/{macroFilename}");
}

private static bool IsUnrealEngine4(string enginePath)
{
var buildVersionFilePath = Path.Combine(enginePath, "Engine", "Build", "Build.version");
if (File.Exists(buildVersionFilePath))
{
if (File.ReadAllText(buildVersionFilePath).Contains("UE4", StringComparison.Ordinal))
{
return true;
}
}
return false;
}

public async Task<BuildSpecification> BuildConfigPluginToBuildSpecAsync(
BuildEngineSpecification engineSpec,
BuildGraphEnvironment buildGraphEnvironment,
Expand All @@ -353,7 +366,8 @@ public async Task<BuildSpecification> BuildConfigPluginToBuildSpecAsync(
bool localExecutor,
bool isPluginRooted,
string? commandlinePluginVersionName,
long? commandlinePluginVersionNumber)
long? commandlinePluginVersionNumber,
bool legacy)
{
// Determine build matrix.
var editorTargetPlatforms = FilterIncompatiblePlatforms((distribution.Build.Editor?.Platforms ?? new[] { BuildConfigPluginBuildEditorPlatform.Win64 }).Select(x =>
Expand Down Expand Up @@ -520,7 +534,7 @@ public async Task<BuildSpecification> BuildConfigPluginToBuildSpecAsync(
{ "ScriptMacroIncludes", scriptMacroIncludes },

// General options
{ "IsUnrealEngine5", "true" },
{ "IsUnrealEngine5", legacy ? "false" : "true" },

// Clean options
{ $"CleanDirectories", string.Join(";", cleanDirectories) },
Expand All @@ -537,7 +551,7 @@ public async Task<BuildSpecification> BuildConfigPluginToBuildSpecAsync(
{ $"MacPlatforms", $"IOS;Mac" },
{ $"StrictIncludes", strictIncludes || strictIncludesAtPluginLevel ? "true" : "false" },
{ $"Allow2019", "false" },
{ $"EnginePrefix", "Unreal" },
{ $"EnginePrefix", legacy ? "UE4" : "Unreal" },

// Package options
{ $"ExecutePackage", executePackage ? "true" : "false" },
Expand Down
3 changes: 2 additions & 1 deletion UET/uet/Commands/Build/IBuildSpecificationGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ Task<BuildSpecification> BuildConfigPluginToBuildSpecAsync(
bool localExecutor,
bool isPluginRooted,
string? commandlinePluginVersionName,
long? commandlinePluginVersionNumber);
long? commandlinePluginVersionNumber,
bool legacy);

Task<BuildSpecification> BuildConfigEngineToBuildSpecAsync(
BuildEngineSpecification engineSpec,
Expand Down
3 changes: 2 additions & 1 deletion UET/uet/Commands/Test/TestCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ public async Task<int> ExecuteAsync(InvocationContext context)
localExecutor: true,
isPluginRooted: true,
commandlinePluginVersionName: null,
commandlinePluginVersionNumber: null).ConfigureAwait(false);
commandlinePluginVersionNumber: null,
false).ConfigureAwait(false);
break;
default:
throw new NotSupportedException();
Expand Down