2019-12-26 23:01:54 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2018-12-14 11:21:22 -05:00
|
|
|
|
2018-08-31 11:49:06 -04:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2020-12-21 23:07:37 -04:00
|
|
|
using EpicGames.Core;
|
2021-06-11 18:20:44 -04:00
|
|
|
using UnrealBuildBase;
|
2018-08-31 11:49:06 -04:00
|
|
|
using UnrealBuildTool;
|
2023-03-08 12:43:35 -05:00
|
|
|
using Microsoft.Extensions.Logging;
|
2018-08-31 11:49:06 -04:00
|
|
|
|
|
|
|
|
namespace AutomationTool
|
|
|
|
|
{
|
|
|
|
|
[Help("Copy all the binaries for a target into a different folder. Can be restored using the UnstashTarget command. Useful for A/B testing.")]
|
|
|
|
|
[Help("-Name", "Name of the target")]
|
|
|
|
|
[Help("-Platform", "Platform that the target was built for")]
|
|
|
|
|
[Help("-Configuration", "Architecture that the target was built for")]
|
|
|
|
|
[Help("-Architecture", "Architecture that the target was built for")]
|
|
|
|
|
[Help("-Project", "Project file for the target")]
|
|
|
|
|
[Help("-To", "Output directory to store the stashed binaries")]
|
|
|
|
|
public class StashTarget : BuildCommand
|
|
|
|
|
{
|
|
|
|
|
public override void ExecuteBuild()
|
|
|
|
|
{
|
|
|
|
|
// Parse all the arguments
|
|
|
|
|
string TargetName = ParseRequiredStringParam("Name");
|
2019-05-24 11:51:54 -04:00
|
|
|
string PlatformName = ParseOptionalStringParam("Platform");
|
|
|
|
|
UnrealTargetPlatform Platform;
|
|
|
|
|
if (UnrealTargetPlatform.TryParse(PlatformName, out Platform))
|
|
|
|
|
{
|
|
|
|
|
Platform = HostPlatform.Current.HostEditorPlatform;
|
|
|
|
|
}
|
2018-08-31 11:49:06 -04:00
|
|
|
UnrealTargetConfiguration Configuration = ParseOptionalEnumParam<UnrealTargetConfiguration>("Configuration") ?? UnrealTargetConfiguration.Development;
|
UnrealArch/UnrealArchitectures changes
- Creates the UnrealArchitectures class, which wraps a list of UnrealArch objects
- UnrealArch is a single architecture, expandable enum-like struct
- There is no more concept of "no/default architecture", there is always a valid active architecture when building
- Most uses of "string Architecture" are replaced with one of the two above, depending if multiple architectures are supported or not
- UnrealArch has some platform-extensions for platform-specific naming (like Linux adds in LinuxName that turns, for instance, Arm64 -> aarch64-unknown-linux-gnueabi, which is used in folder names, etc)
- UnrealArch has bIsX64 which can be used determine intel instruction set (as opposed to arm)
- TargetRules class has an "Architecture" accessor that will return a single architecture if the active architectures is a single architecture, or throw an exception if multiple. This is useful in a majority of the cases where a paltform can only have a single architecture active in TargetRules (microsoft platforms, for instance, will create separate targets when compiling multiple architectures at once)
- Added UnrealArchitectureConfig class, which contains all the architecture information for a platform (what architectures are supported, what ones are currently active for given project, etc)
#preflight 63c81fb5b065224750a1759e
#rb mike.fricker,roman.dzieciol,joe.kirchoff,dmytro.vovk,brandon.schaefer [various parts]
#p4v-preflight-copy 23562471
[CL 23829977 by josh adams in ue5-main branch]
2023-01-24 09:30:28 -05:00
|
|
|
string ArchitectureString = ParseOptionalStringParam("Architecture");
|
|
|
|
|
UnrealArchitectures Architecture = UnrealArchitectures.FromString(ArchitectureString, Platform);
|
2018-08-31 11:49:06 -04:00
|
|
|
FileReference ProjectFile = ParseOptionalFileReferenceParam("Project");
|
|
|
|
|
DirectoryReference ToDir = ParseRequiredDirectoryReferenceParam("To");
|
|
|
|
|
|
|
|
|
|
// Read the receipt
|
2021-06-11 18:20:44 -04:00
|
|
|
FileReference ReceiptFile = TargetReceipt.GetDefaultPath(DirectoryReference.FromFile(ProjectFile) ?? Unreal.EngineDirectory, TargetName, Platform, Configuration, Architecture);
|
2018-08-31 11:49:06 -04:00
|
|
|
if(!FileReference.Exists(ReceiptFile))
|
|
|
|
|
{
|
|
|
|
|
throw new AutomationException("Unable to find '{0}'", ReceiptFile);
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-14 12:11:24 -05:00
|
|
|
TargetReceipt Receipt = TargetReceipt.Read(ReceiptFile);
|
2018-08-31 11:49:06 -04:00
|
|
|
|
|
|
|
|
// Enumerate all the files we want to move
|
|
|
|
|
List<FileReference> FilesToMove = new List<FileReference>();
|
|
|
|
|
FilesToMove.Add(ReceiptFile);
|
|
|
|
|
FilesToMove.AddRange(Receipt.BuildProducts.Select(x => x.Path));
|
|
|
|
|
|
|
|
|
|
// Move all the files to the output folder
|
|
|
|
|
DirectoryReference.CreateDirectory(ToDir);
|
|
|
|
|
CommandUtils.DeleteDirectoryContents(ToDir.FullName);
|
|
|
|
|
foreach(FileReference SourceFile in FilesToMove)
|
|
|
|
|
{
|
2021-06-11 18:20:44 -04:00
|
|
|
FileReference TargetFile = FileReference.Combine(ToDir, SourceFile.MakeRelativeTo(Unreal.RootDirectory));
|
2023-03-08 12:43:35 -05:00
|
|
|
Logger.LogInformation("Copying {SourceFile} to {TargetFile}", SourceFile, TargetFile);
|
2018-08-31 11:49:06 -04:00
|
|
|
CommandUtils.CopyFile(SourceFile.FullName, TargetFile.FullName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Help("Copy all the binaries from a target back into the root directory. Use in combination with the StashTarget command.")]
|
|
|
|
|
[Help("-From", "Directory to copy from")]
|
|
|
|
|
public class UnstashTarget : BuildCommand
|
|
|
|
|
{
|
|
|
|
|
public override void ExecuteBuild()
|
|
|
|
|
{
|
|
|
|
|
// Parse the arguments
|
|
|
|
|
DirectoryReference FromDir = ParseRequiredDirectoryReferenceParam("From");
|
|
|
|
|
if(!DirectoryReference.Exists(FromDir))
|
|
|
|
|
{
|
|
|
|
|
throw new AutomationException("Source directory '{0}' does not exist", FromDir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Just copy all the files into place
|
|
|
|
|
foreach(FileReference SourceFile in DirectoryReference.EnumerateFiles(FromDir, "*", SearchOption.AllDirectories))
|
|
|
|
|
{
|
2021-06-11 18:20:44 -04:00
|
|
|
FileReference TargetFile = FileReference.Combine(Unreal.RootDirectory, SourceFile.MakeRelativeTo(FromDir));
|
2023-03-08 12:43:35 -05:00
|
|
|
Logger.LogInformation("Copying {SourceFile} to {TargetFile}", SourceFile, TargetFile);
|
2018-08-31 11:49:06 -04:00
|
|
|
CopyFile(SourceFile.FullName, TargetFile.FullName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|