Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/Scripts/AnalyzeThirdPartyLibs.Automation.cs

237 lines
6.5 KiB
C#
Raw Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using AutomationTool;
using UnrealBuildTool;
using System.Linq;
using Microsoft.Extensions.Logging;
using static AutomationTool.CommandUtils;
/*
- You can also use the full program to test compiling all or a subset of libs:
- From Engine/Build/BatchFiles, do:
- RunUAT AnalyzeThirdPartyLibs [-libs=lib1+lib2+lib3] [-changelist=NNNN]
*/
class PlatformLibraryInfo
{
public List<string> PathParticles = new List<string>();
public List<string> Manifest = new List<string>();
public long TotalSize = 0;
public string PlatformName;
public bool PartOfPlatform(string Filename)
{
foreach (string Particle in PathParticles)
{
if (Filename.IndexOf(Particle, StringComparison.InvariantCultureIgnoreCase) != -1)
{
return true;
}
}
return (PathParticles.Count == 0) ? true : false;
}
public PlatformLibraryInfo(string PlatformName, params string[] Values)
{
this.PlatformName = PlatformName;
PathParticles.AddRange(Values);
}
public void AddFile(string Filename, long Size)
{
Manifest.Add(Filename);
TotalSize += Size;
}
};
class ThirdPartyLibraryInfo
{
public List<string> Manifest = new List<string>();
public long GetSize(List<PlatformLibraryInfo> Platforms)
{
long TotalSize = 0;
foreach (string Filename in Manifest)
{
FileInfo FI = new FileInfo(Filename);
long Size = FI.Length;
foreach (PlatformLibraryInfo Platform in Platforms)
{
if (Platform.PartOfPlatform(Filename))
{
Platform.AddFile(Filename, Size);
}
}
TotalSize += Size;
}
return TotalSize;
}
public void FindLargeFiles(List<string> AllowedExtensions, long MinSize)
{
foreach (string Filename in Manifest)
{
FileInfo FI = new FileInfo(Filename);
long Size = FI.Length;
if (Size > MinSize)
{
bool bAllowed = false;
foreach (string Extension in AllowedExtensions)
{
if (Filename.EndsWith(Extension, StringComparison.InvariantCultureIgnoreCase))
{
bAllowed = true;
break;
}
}
if (!bAllowed)
{
Logger.LogWarning("{Filename} is {Arg1} with an unexpected extension", Filename, AnalyzeThirdPartyLibs.ToMegabytes(Size));
}
}
}
}
public ThirdPartyLibraryInfo(string Root)
{
string[] Files = Directory.GetFiles(Root, "*.*", SearchOption.AllDirectories);
Manifest.AddRange(Files);
}
}
[Help("Analyzes third party libraries")]
[Help("Libs", "[Optional] + separated list of libraries to compile; if not specified this job will build all libraries it can find builder scripts for")]
[Help("Changelist", "[Optional] a changelist to check out into; if not specified, a changelist will be created")]
class AnalyzeThirdPartyLibs : BuildCommand
{
// path to the third party directory
static private string LibDir = "Engine/Source/ThirdParty";
// batch/script file to look for when compiling
public static string ToMegabytes(long Size)
{
double SizeKB = Size / 1024.0;
double SizeMB = SizeKB / 1024.0;
return String.Format("{0:N2} MB", SizeMB);
}
public override void ExecuteBuild()
{
Logger.LogInformation("************************* Analyze Third Party Libs");
// figure out what batch/script to run
if (UnrealBuildTool.BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Win64 &&
UnrealBuildTool.BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac &&
UnrealBuildTool.BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Linux)
{
throw new AutomationException("Unknown runtime platform!");
}
// go to the third party lib dir
CommandUtils.PushDir(LibDir);
// figure out what libraries to evaluate
string LibsToEvaluateString = ParseParamValue("Libs");
// Determine which libraries to evaluate
List<string> LibsToEvaluate = new List<string>();
if (string.IsNullOrEmpty(LibsToEvaluateString))
{
// loop over third party directories looking for the right batch files
foreach (string Dir in Directory.EnumerateDirectories("."))
{
LibsToEvaluate.Add(Path.GetFileName(Dir));
}
}
else
{
// just split up the param and make sure the batch file exists
string[] Libs = LibsToEvaluateString.Split('+');
foreach (string Dir in Libs)
{
LibsToEvaluate.Add(Path.GetFileName(Dir));
}
}
// Make a list of platforms
List<PlatformLibraryInfo> Platforms = new List<PlatformLibraryInfo>();
Platforms.Add(new PlatformLibraryInfo("Windows", "Windows", "Win64", "VS20"));
Platforms.Add(new PlatformLibraryInfo("Mac", "Osx", "Mac"));
Platforms.Add(new PlatformLibraryInfo("iOS", "IOS"));
Platforms.Add(new PlatformLibraryInfo("Android", "Android"));
Platforms.Add(new PlatformLibraryInfo("Linux", "Linux"));
Platforms.Add(new PlatformLibraryInfo("VS2013", "VS2013", "vs12"));
Copying //UE4/Dev-Platform to //UE4/Main ========================== MAJOR FEATURES + CHANGES ========================== Change 2816560 on 2016/01/05 by Jeff.Campeau Remove duplicate CEF binaries Change 2835599 on 2016/01/20 by Lee.Clark PS4 - Added pragma optimization macros Change 2841103 on 2016/01/23 by Mark.Satterthwaite Integrate Git PR #1958: Fixed typo in EMetalFeatures enum #jira UE-25721 Change 2841369 on 2016/01/24 by Mark.Satterthwaite Fix for Metal crash due to attempt to set a null uniform & null SRV to a shader which requires both exist. #jira UE-25910 Change 2841795 on 2016/01/25 by Lee.Clark PS4 - MovieStreamer improvements * Use GPU for YUV conversion * Use new Software2 Decoder Change 2842261 on 2016/01/25 by Mark.Satterthwaite Fix some memory leaks. Change 2842831 on 2016/01/25 by Mark.Satterthwaite Metal implementation for RHIBlockUntilGPUIdle. Change 2842838 on 2016/01/25 by Mark.Satterthwaite When using parallel command contexts in Metal we must ensure that the FRingBuffer is still valid, which means some smart/weak pointers are in order. We should also ensure that functions that may return auto-released objects are appropriately wrapped with scoped autorelease pools. Texture creation failures should also be fatal as we never expect that to occur. Change 2842914 on 2016/01/25 by Mark.Satterthwaite Change assert in MetalTexture's format-shifting SRV constructor to enforce the Metal textureView limits: 1. No format shifting for MSAA color buffers. 2. No access to stencil in MSAA packed depth/stencil surface. This will allow Metal MSAA support to work on iOS when using separate depth & stencil textures since there's no format shifting involved there. #codereview peter.sauerbrei Change 2843028 on 2016/01/25 by Mark.Satterthwaite In Metal wwitch to blit on the correct context when copying out the stencil data into the stencil SRV copy. Change 2845531 on 2016/01/27 by Lee.Clark PS4 - Fix memory alignment for back buffers * Fix memory alignment for MapLargeBlock * Fix available direct memory tracking Change 2846491 on 2016/01/27 by Jeff.Campeau 2015 compile fixes for Orion Change 2847395 on 2016/01/28 by Mark.Satterthwaite Clear the stencil-SRV copy to 0 in Metal using a blit when created to avoid artefacts if used prior to the parent texture being rendered. #jira UE-25834 Change 2847419 on 2016/01/28 by Mark.Satterthwaite Apply the same fix to OpenGL's Stencil SRV logic as CL #2847395 applies to Metal. Change 2848093 on 2016/01/28 by Mark.Satterthwaite Cache parallel encoding Metal contexts & reuse them rather than creating a new one each time in order to massively improve parallel encoding performance. This required adding a reset function to Metal's internal state-cache which calls the CommandEncoder wrapper's reset so we don't accidently retain previous state. Change 2849469 on 2016/01/29 by Mark.Satterthwaite Defer render & compute command encoder construction to draw/dispatch etc to eliminate redundant encoders that then perform unnecessary driver & GPU synchronisation work. Currently Clear loadActions force an encoder even if it would then be empty as otherwise we see incorrect rendering. This needs to be tracked and optimised away too in order to achieve the same performance as D3D11. Change 2849820 on 2016/01/29 by Daniel.Lamb Fixed issue where a single DDC back end would not create a hierarchy. #codereview Peter.Sauerbrei Change 2850762 on 2016/02/01 by Jeff.Campeau System-wide critical section support for Xbox One Change 2850763 on 2016/02/01 by Jeff.Campeau Network and product config for Orion Change 2852459 on 2016/02/02 by Mark.Satterthwaite Temporarily disable the lazy render command-encoder construction while investigating why it turns some samples black in Metal SM5 mode. Change 2853947 on 2016/02/03 by Mark.Satterthwaite Fix some lazy encoder construction fallout which also means we don't need to recreate render encoder state when performing profiling - the next draw/clear will do that as required. Change 2854015 on 2016/02/03 by Mark.Satterthwaite Move Stencil SRV blitting into FMetalSurface::UpdateSRV called when binding the texture SRV instead of having it done immediately post-rendering. This should avoid paying for the blit when stencil SRV sampling is never used or multiple blits when render-encoders that write stencil are split up due to query buffer overflow or similar. The cost will be a blit per-bind instead which should be more predictable. Change 2854142 on 2016/02/03 by Mark.Satterthwaite Implemented GetTextureBaseRHI (brought over from Dev-Rendering CL #2853948) for Metal to avoid unnecessary virtual function call chain to resolve the FMetalSurface* from an RHI texture. Change 2854222 on 2016/02/03 by Mark.Satterthwaite Remove the uniform buffer resource caching from Metal to match Dev-Rendering CL #2853948. Change 2854246 on 2016/02/03 by Mark.Satterthwaite Removed the uniform buffer resource caching from OpenGLDrv & implemented GetTextureBaseRHI to avoid unnecessary virtual function calls to match Dev-Rendering CL #2853948. Change 2854279 on 2016/02/03 by Mark.Satterthwaite Remove direct access to the MTLCommandQueue, for parallel rendering to work we're going to need to do a bit of management that means its more sensible to keep it private. Change 2855524 on 2016/02/04 by Lee.Clark PS4 - Fix Grayscale SRGB support [CL 2898161 by Josh Adams in Main branch]
2016-03-07 20:55:29 -05:00
Platforms.Add(new PlatformLibraryInfo("VS2015", "VS2015", "vs14"));
List<long> LastSizes = new List<long>();
foreach (var Platform in Platforms)
{
LastSizes.Add(0);
}
// now go through and evaluate each package
long TotalSize = 0;
foreach (string Lib in LibsToEvaluate)
{
ThirdPartyLibraryInfo Info = new ThirdPartyLibraryInfo(Lib);
long Size = Info.GetSize(Platforms);
Logger.LogInformation("Library {Lib} is {Arg1}", Lib, ToMegabytes(Size));
long Total = 0;
for (int Index = 0; Index < Platforms.Count; ++Index)
{
PlatformLibraryInfo Platform = Platforms[Index];
long Growth = Platform.TotalSize - LastSizes[Index];
Logger.LogInformation(" {Arg0} is {Arg1}", Platform.PlatformName, ToMegabytes(Growth));
LastSizes[Index] = Platform.TotalSize;
Total += Growth;
}
Logger.LogInformation(" Platform neutral is probably {Arg0} (specific sum {Arg1})", ToMegabytes(Size - Total), ToMegabytes(Total));
TotalSize += Size;
}
// Make a list of known large file types
List<string> LargeFileExtensions = new List<string>();
LargeFileExtensions.AddRange(new string[] { ".pdb", ".a", ".lib", ".dll", ".dylib", ".bc", ".so" });
// Hackery, look for big files (re-traverses everything)
Logger.LogInformation("----");
foreach (string Lib in LibsToEvaluate)
{
ThirdPartyLibraryInfo Info = new ThirdPartyLibraryInfo(Lib);
Info.FindLargeFiles(LargeFileExtensions, 1024 * 1024);
}
Logger.LogInformation("----");
foreach (var Platform in Platforms)
{
Logger.LogInformation(" {Arg0} is {Arg1} (estimate)", Platform.PlatformName, ToMegabytes(Platform.TotalSize));
}
Logger.LogInformation(" OVERALL is {Arg0} (accurate)", ToMegabytes(TotalSize));
// undo the LibDir push
CommandUtils.PopDir();
PrintRunTime();
}
}