2019-12-26 23:01:54 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2018-09-25 10:11:35 -04:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using AutomationTool;
|
|
|
|
|
using UnrealBuildTool;
|
2020-12-21 23:07:37 -04:00
|
|
|
using EpicGames.Core;
|
2018-09-25 10:11:35 -04:00
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
public class ExtractPaks : BuildCommand
|
|
|
|
|
{
|
|
|
|
|
public override void ExecuteBuild()
|
|
|
|
|
{
|
|
|
|
|
var bLayered = ParseParam("layered");
|
|
|
|
|
var SourceDirectory = ParseParamValue("sourcedirectory", null);
|
|
|
|
|
var TargetDirectory = ParseParamValue("targetdirectory", null);
|
|
|
|
|
var CryptoKeysFile = ParseParamValue("cryptokeysjson", null);
|
|
|
|
|
var Compressor = ParseParamValue("customcompressor", null);
|
2020-06-23 18:40:00 -04:00
|
|
|
var Project = ParseParamValue("project", null);
|
2018-09-25 10:11:35 -04:00
|
|
|
|
|
|
|
|
string ExtraArgs = "";
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(Compressor))
|
|
|
|
|
{
|
|
|
|
|
ExtraArgs += "-customcompressor=" + Compressor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Params.Contains("passargs"))
|
|
|
|
|
{
|
|
|
|
|
IEnumerable<string> ExtraArgArray = Params.Where((arg, index) => index > Array.IndexOf(Params, "passargs"));
|
|
|
|
|
|
|
|
|
|
if (ExtraArgArray.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
ExtraArgs += " -" + string.Join(" -", ExtraArgArray);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (String.IsNullOrEmpty(SourceDirectory))
|
|
|
|
|
{
|
|
|
|
|
throw new AutomationException("SourceDirectory is a required parameter");
|
|
|
|
|
}
|
|
|
|
|
if (String.IsNullOrEmpty(TargetDirectory))
|
|
|
|
|
{
|
|
|
|
|
throw new AutomationException("TargetDirectory is a required parameter");
|
|
|
|
|
}
|
|
|
|
|
if (String.IsNullOrEmpty(CryptoKeysFile))
|
|
|
|
|
{
|
|
|
|
|
throw new AutomationException("CryptoKeysJson is a required parameter");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DirectoryInfo SourceDirectoryInfo = new DirectoryInfo(SourceDirectory);
|
|
|
|
|
|
|
|
|
|
LogInformation("Extracting paks from {0} to {1}", SourceDirectory, TargetDirectory);
|
|
|
|
|
|
2020-06-23 18:40:00 -04:00
|
|
|
FileReference ProjectFile = null;
|
|
|
|
|
if (!string.IsNullOrEmpty(Project))
|
|
|
|
|
{
|
|
|
|
|
ProjectFile = ProjectUtils.FindProjectFileFromName(Project);
|
|
|
|
|
|
|
|
|
|
if (ProjectFile == null)
|
|
|
|
|
{
|
|
|
|
|
throw new AutomationException("Could not find project file based on {0}", Project);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PackageUtils.ExtractPakFiles(SourceDirectoryInfo, TargetDirectory, CryptoKeysFile, ExtraArgs, bLayered, ProjectFile);
|
2018-09-25 10:11:35 -04:00
|
|
|
}
|
|
|
|
|
}
|