Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/Scripts/Localisation.Automation.cs
Matt Kuhlenschmidt 47a097348a Copying //UE4/Dev-Editor to //UE4/Dev-Main (Source: //UE4/Dev-Editor @ 3167359)
#lockdown Nick.Penwarden
#rb none

==========================
MAJOR FEATURES + CHANGES
==========================

Change 3152124 on 2016/10/05 by Jamie.Dale

	Fixed SOutputLog filter not handling OnTextCommitted

Change 3152255 on 2016/10/05 by Michael.Dupuis

	#jira UE-28173 Support \" properly in FName

Change 3152273 on 2016/10/05 by Nick.Darnell

	Core - The module manager is now thread safer, we had a critical section around the internal module list - but we were incrementing/decrementing shared pointers to module data shared pointers that were not thread safe outside of the critical section.  Ran into a crash working on some heavily threaded code in automation.

Change 3152314 on 2016/10/05 by Nick.Darnell

	Automation - Continued work to rough out the automation workflow for screenshot.  Still lots of work remaining, but it appears the basic of approving images might be working as of this CL.

Change 3152316 on 2016/10/05 by Michael.Dupuis

	#jira UE-30346 Update selection when in tree view mode

Change 3152317 on 2016/10/05 by Nick.Darnell

	Automation - Adding some test shots to compare against to EngineTest for screenshot approval.

Change 3152319 on 2016/10/05 by Michael.Dupuis

	#jira UE-29817 StringAssetReference will now only open an Asset picker (not actor picker) as the goal is to reference an asset

Change 3152521 on 2016/10/05 by Nick.Darnell

	Automation - Fixing some issues with where it reads the screenshot compare rules.

Change 3152536 on 2016/10/05 by Alexis.Matte

	Fix FBX automation test.
	- Make sure the fbx test can avoid automatic detection of the mesh type
	- Avoid to log the warning when the importer set the material usage after creating a material for skeletalmesh.

Change 3152572 on 2016/10/05 by Nick.Darnell

	Automation - The GameProjectAutomationTests now do some pre-run house cleaning to make sure the project doesn't already exist, and tries to remove it if it was created previously but not deleted.

Change 3152591 on 2016/10/05 by Nick.Darnell

	Automation - Changing the game project errors to be errors.

Change 3153115 on 2016/10/06 by Jamie.Dale

	Removed superflous padding when SPropertyEditorAsset had no buttons

Change 3153215 on 2016/10/06 by Michael.Dupuis

	Fixed build warning

Change 3153248 on 2016/10/06 by Nick.Darnell

	Automation - Working on solving projects not being generated, suspect UBT isn't built or isn't available.

Change 3153255 on 2016/10/06 by Nick.Darnell

	PR #2835: Fix TestEqual AddError Message in FAutomationTestBase (Contributed by dorgonman)

	#jira UE-36922

Change 3153300 on 2016/10/06 by Nick.Darnell

	Automation - Enabled verbose logging to automation build farm.

Change 3153343 on 2016/10/06 by Matt.Kuhlenschmidt

	PR #2825: More project launcher progress improvements (Contributed by projectgheist)

Change 3153506 on 2016/10/06 by Gareth.Martin

	Fixed crash trying to edit landscape with r.LightPropagationVolume=1 enabled
	#jira UE-36933

Change 3153752 on 2016/10/06 by tim.gautier

	Add toggle button to UMG_Behavior. Set Level Blueprint for TM-UMG to AllWidget

Change 3153763 on 2016/10/06 by Nick.Darnell

	Automation - Disable verbose logging.

Change 3153778 on 2016/10/06 by Nick.Darnell

	PR #2837: Fixed engine compilation with defined LOG_SLATE_EVENTS (Contributed by Pierdek)

	#jira UE-36940

Change 3153943 on 2016/10/06 by Nick.Darnell

	Automation - Disabling some broken tests.

Change 3154035 on 2016/10/06 by Nick.Darnell

	Automation - Fixing re-runs for tests that want them.  Previously this wasn't working for any test that was run using the Reprostring method of being executed.

Change 3154039 on 2016/10/06 by Nick.Darnell

	Automation - Updating some test assets in the EngineTest project.

Change 3154476 on 2016/10/07 by Richard.TalbotWatkin

	Fix to regression where vertex color view in Mesh Paint Mode no longer worked correctly. We now allow selected static meshes to go down the dynamic path if VertexColors show mode is active.
	#jira UE-36772 - Selecting a channel in Vertex Paint mode does not show the channel color

Change 3154650 on 2016/10/07 by Alexis.Matte

	Add new front axis facing X option to fbx importer

Change 3154785 on 2016/10/07 by Nick.Darnell

	Automation - Continued work on automation, ripping out the message bus from the screenshot manager, that's causing the screenshot manager to recieve shots from every machine ever running tests.  The Automation Controller is now in charge, and will tell the screenshot manager whatever it needs.

Change 3155131 on 2016/10/07 by Michael.Dupuis

	#jira UE-36509 Do not disabled inverse filter when doing a sync to asset

Change 3155141 on 2016/10/07 by Michael.Dupuis

	#jira UE-36056 Do not open the Actor Picker if we're working on an archetype object

Change 3155262 on 2016/10/07 by Michael.Dupuis

	#jira UE-19737 reset ctrl key when resetting state to None

Change 3156326 on 2016/10/09 by Matt.Kuhlenschmidt

	Fixed crash when asset picker is used without a property editor (usually a heavily customized property).

Change 3156473 on 2016/10/10 by Richard.TalbotWatkin

	Attempt to make geometry render / rebuild more robust in the hope of catching UE-36265.
	#jira UE-36265 - [CrashReport] UE4Editor_Engine!FModelSceneProxy::HasSelectedSurfaces() [modelrender.cpp:538]

Change 3156479 on 2016/10/10 by Richard.TalbotWatkin

	Fixed non-editor build.

Change 3156579 on 2016/10/10 by Alexis.Matte

	Add a check to make sure curve pointer is valid.
	#jira UE-36177

Change 3156585 on 2016/10/10 by Ben.Marsh

	Fix line endings for screenshot settings.

Change 3156617 on 2016/10/10 by Matt.Kuhlenschmidt

	Disable per-pixel blending of menus by default.  Causes artifacts on windows versions and we are not using it.

Change 3156674 on 2016/10/10 by Nick.Darnell

	Automation - Continued work on the automation workflow.  Now screenshot functional test actors actually have the screenshot processed for differences during the test back on the test controller machine, and then waits for the results of the comparison to be performed.

Change 3156709 on 2016/10/10 by Alexis.Matte

	#jira UE-16337
	Make sure the base mesh import data transform is used when we import a LOD.

Change 3156714 on 2016/10/10 by Nick.Darnell

	Automation - Fixing -game crash due to TestName being null in functional test.

Change 3156721 on 2016/10/10 by Nick.Darnell

	Automation - FunctionalAITest now implements IsReady to check if the navigation mesh has finished being built.

Change 3156748 on 2016/10/10 by Nick.Darnell

	Autopmation - Fixing a warning.

Change 3156943 on 2016/10/10 by Alex.Delesky

	Fixed an issue where closing out the "Add Code" window with an active toast stating that an IDE was downloading would prevent the toast from clearing correctly.

	#jira none

Change 3156946 on 2016/10/10 by Alex.Delesky

	#jira UE-36414 - Adding support for the P4Changelist command line argument to the P4 operations that were missing it.

Change 3158215 on 2016/10/11 by Nick.Darnell

	Automation - Continued work on the screenshot comparison, fixed a crash, the system now reports if the screenshot was new, as well as similar, so that the script can react and warn when new screenshots are produced.  Manually fired screenshots now properly wait until they've been compared before the test moves forward.

Change 3158322 on 2016/10/11 by Michael.Dupuis

	#jira UE-36063 If the collection is not shown when trying to save one, force show them so the user understand what is going on

Change 3158333 on 2016/10/11 by Alex.Delesky

	#jira UE-36829 - Rebuilt SVN 1.9.4 libs for Windows with CyrusSASL 2.1.26 and SWIG 3.0.10 support.

Change 3158399 on 2016/10/11 by Nick.Darnell

	Automation - TTF Font log statements that were not warnings are no longer warnings.

Change 3158406 on 2016/10/11 by Nick.Darnell

	Automation - Updating some automation scripts in the engnine that were using file paths to now use FStringAssetReferences, that cleaned up a lot of nasty convert filepath to asset reference code in the tests.  Also introducing some maps, and setting up the configs to use them to try and appease some of the existing tests that were expecting them.

Change 3158419 on 2016/10/11 by Alex.Delesky

	#jira UE-36829 - SVN 1.9.4 libraries, but also with Java 8u101 support.

Change 3158537 on 2016/10/11 by Nick.Darnell

	Automation - Updating some automation scripts in the engnine that were using file paths to now use FStringAssetReferences, that cleaned up a lot of nasty convert filepath to asset reference code in the tests.  Also introducing some maps, and setting up the configs to use them to try and appease some of the existing tests that were expecting them.

	Adding some missing files.

Change 3158726 on 2016/10/11 by Michael.Dupuis

	#jira UE-37001 Perform manual migration of UICurve to proper config category

Change 3158728 on 2016/10/11 by Nick.Darnell

	Automation - Fixing some warnings.  Adding more testing to the Domino map to serve as a better example.

Change 3158753 on 2016/10/11 by Michael.Dupuis

	#jira UE-26261 change it's by its

Change 3158984 on 2016/10/11 by Alexis.Matte

	Fix D&D folder import in content browser. We have to expand the root directory to have the correct path.
	#jira UE-32155

Change 3159640 on 2016/10/12 by Jamie.Dale

	Split localized package redirection out of FCoreDelegates::PackageNameResolvers

	They're different enough in behavior that the delegate resolution was breaking the localized package resolution by resolving in too many places and causing the localized package to be loaded with its real localized name as well as the fake non-localized name.

	#jira UE-37119

Change 3159741 on 2016/10/12 by Nick.Darnell

	Slate - Fixing the SGraphPanel's mouse offset calculations so that it works with HDPI mode.

Change 3159762 on 2016/10/12 by Nick.Darnell

	Automation - Adding a way to take a screenshot with the UI, not great yet - it doesn't really obey the rules of resolution, because of the method it uses.

Change 3160210 on 2016/10/12 by Gareth.Martin

	Fixed crash when changing Landscape LOD while using "Grass use Landscape Lightmap"

Change 3160216 on 2016/10/12 by Gareth.Martin

	Removed unused FLandscapeComponentSceneProxy::LayerNames and made LayerColors editor-only
	Fixed negative LODBias on landscape components to actually do anything

Change 3160239 on 2016/10/12 by Gareth.Martin

	Removed an unused variable

Change 3160455 on 2016/10/12 by Jamie.Dale

	Fixed FText properties exported to asset tags displaying in their NSLOCTEXT form in the asset tooltips

Change 3160457 on 2016/10/12 by Jamie.Dale

	Localization automation now groups everything into a single CL and reverts PO files without significant changes

Change 3160554 on 2016/10/12 by Nick.Darnell

	UMG - Fixing some panning logic to work with HDPI mode in the designer.

Change 3161712 on 2016/10/13 by Jamie.Dale

	Fixed TSharedMapView using hard-coded types

Change 3163044 on 2016/10/14 by Jamie.Dale

	Fixed line-break iterators incorrectly breaking words in CJK

Change 3163046 on 2016/10/14 by Jamie.Dale

	Text layout no longer creates break candidates when wrapping is disabled

Change 3163217 on 2016/10/14 by Jamie.Dale

	Fixed ensure caused by FMediaTextureResource::GetResourceSizeEx

Change 3163641 on 2016/10/14 by Alex.Delesky

	#jira UE-36829 - Updated Mac SVN libraries, along with a more accurate changelog for Windows SVN libs

Change 3164428 on 2016/10/17 by Nick.Darnell

	Slate - Making the FReply for SetMousePos easier to debug, since that option is potentially very frustrating to debug when someone is changing it.

Change 3164833 on 2016/10/17 by Jamie.Dale

	Fixed ParseNumber consuming strings with multiple sequential dots as valid numbers, eg) "10..."

Change 3164868 on 2016/10/17 by Alexis.Matte

	Remove re-import material and LOD import material
	#jira UE-36640

Change 3164874 on 2016/10/17 by Alexis.Matte

	Fix fbx scene re-import of staticmesh loosing there materials
	#jira UE-37032

Change 3165080 on 2016/10/17 by Alexis.Matte

	Remove skinxx workflow for static mesh
	#jira UE-37262

Change 3165232 on 2016/10/17 by Nick.Darnell

	Automation - Adding some sub-level testing.

Change 3165822 on 2016/10/18 by Nick.Darnell

	Slate - Add a counter to track how much time we spend drawing custom verts each frame.

Change 3165934 on 2016/10/18 by Nick.Darnell

	Slate - Addding cycle counters to SInvalidationPanel's Tick and Paint.

Change 3165947 on 2016/10/18 by Nick.Darnell

	Slate - Addding very verbose slate stats behind a compiler flag to avoid the large overhead of these stats.  To enable them you'll need to set WITH_VERY_VERBOSE_SLATE_STATS to 1, added a guide on debugging slate performance to the SlateGlobals.h

	// HOW TO GET AN IN-DEPTH PERFORMANCE ANALYSIS OF SLATE
	//
	// Step 1)
	//    Set WITH_VERY_VERBOSE_SLATE_STATS to 1.
	//
	// Step 2)
	//    When running the game (outside of the editor), run these commandline options
	//    in order and you'll get a large dump of where all the time is going in Slate.
	//
	//    stat group enable slateverbose
	//    stat group enable slateveryverbose
	//    stat dumpave -root=stat_slate -num=120 -ms=0

Change 3165962 on 2016/10/18 by Nick.Darnell

	UMG - Play first frame of sequence in UMG immediately when told to play an animation.

Change 3165981 on 2016/10/18 by Nick.Darnell

	Core - GetDisplayNameText now stores the FName for DisplayName in a static instead of using TEXT("DisplayName").

Change 3166000 on 2016/10/18 by Jamie.Dale

	Removed bulk-data from fonts

	The main complaints about composite fonts have always been:
	 1) They use too much memory at runtime.
	 2) They bloat if you use the same font face twice.
	 3) They often break when used outside the game thread.

	This change aims to address all of these issues by removing bulk-data from fonts (which was the cause of the memory bloat and threading issues), and introduces UFontFace assets (which allow you to re-use the same font face in different entries within a composite font).

	No existing font data is lost during this transition, however you must manually update your UFont assets to reference external UFontFace assets before you're able to edit the existing data (which is automatically upgraded to UFontFace assets *within* the UFont package). This upgrade can be done via the composite font editor.

	During cook these UFontFace assets write out the actual TTF/OTF font data as a .ufont file, which is what FreeType actually loads at runtime (the internals of the Slate font cache are now completely independent of UObjects and their lifetimes and loading concerns).

	Since we're now always loading files from disk, we can also give the user an option of whether to "pre-load" (which will load the entire font into memory, like bulk-data always used to), or "stream" the font from disk (which has minimal memory overhead, but needs decent I/O performance).

Change 3166001 on 2016/10/18 by Jamie.Dale

	Updated the Launcher to no longer use bulk-data for fonts

Change 3166003 on 2016/10/18 by Jamie.Dale

	Updated the Engine fonts to use UFontFace assets

Change 3166028 on 2016/10/18 by Alex.Delesky

	#jira UE-37021 - The scrollbar will now remain at the bottom of the output log after specifying a filter.

Change 3166071 on 2016/10/18 by Nick.Darnell

	Slate - Fixing a warning about hiding an inherited member.

Change 3166213 on 2016/10/18 by Jamie.Dale

	Fixing crash caused by accessing a zeroed FText

Change 3166222 on 2016/10/18 by Nick.Darnell

	Automation - Adding some code to end the sub level test when it starts.

Change 3166231 on 2016/10/18 by Nick.Darnell

	Editor - Fixing the build warning, SOutputLog.cpp:748:4: warning: field 'TextLayout' will be initialized after field 'CachedNumMessages'

Change 3166717 on 2016/10/18 by Nick.Darnell

	Automation - Removing references to old options that are no longer file paths, and are now StringAssetReferences these options were not being used by anyone as far as I can tell.

	#jira UE-37482

Change 3167279 on 2016/10/19 by Jamie.Dale

	Fixed text render component regression with custom MIDs

	#jira UE-37305

Change 3167356 on 2016/10/19 by Alexis.Matte

	Make sure the old asset are build correctly
	#jira UE-37461

Change 3167359 on 2016/10/19 by Alexis.Matte

	Fix re-import of mesh material assignment regression
	#jira UE-37479

[CL 3168049 by Matt Kuhlenschmidt in Main branch]
2016-10-19 15:01:48 -04:00

454 lines
18 KiB
C#

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.IO;
using System.Security.Cryptography;
using AutomationTool;
using UnrealBuildTool;
using EpicGames.Localization;
[Help("Updates the external localization data using the arguments provided.")]
[Help("UEProjectRoot", "Optional root-path to the project we're gathering for (defaults to CmdEnv.LocalRoot if unset).")]
[Help("UEProjectDirectory", "Sub-path to the project we're gathering for (relative to UEProjectRoot).")]
[Help("UEProjectName", "Optional name of the project we're gathering for (should match its .uproject file, eg QAGame).")]
[Help("LocalizationProjectNames", "Comma separated list of the projects to gather text from.")]
[Help("LocalizationBranch", "Optional suffix to use when uploading the new data to the localization provider.")]
[Help("LocalizationProvider", "Optional localization provide override (default is OneSky).")]
[Help("LocalizationSteps", "Optional comma separated list of localization steps to perform [Download, Gather, Import, Export, Compile, GenerateReports, Upload] (default is all). Only valid for projects using a modular config.")]
[Help("IncludePlugins", "Optional flag to include plugins from within the given UEProjectDirectory as part of the gather. This may optionally specify a comma separated list of the specific plugins to gather (otherwise all plugins will be gathered).")]
[Help("ExcludePlugins", "Optional comma separated list of plugins to exclude from the gather.")]
[Help("AdditionalCommandletArguments", "Optional arguments to pass to the gather process.")]
class Localise : BuildCommand
{
private struct LocalizationBatch
{
public LocalizationBatch(string InUEProjectDirectory, string InRemoteFilenamePrefix, List<string> InLocalizationProjectNames)
{
UEProjectDirectory = InUEProjectDirectory;
RemoteFilenamePrefix = InRemoteFilenamePrefix;
LocalizationProjectNames = InLocalizationProjectNames;
}
public string UEProjectDirectory;
public string RemoteFilenamePrefix;
public List<string> LocalizationProjectNames;
};
public override void ExecuteBuild()
{
var UEProjectRoot = ParseParamValue("UEProjectRoot");
if (UEProjectRoot == null)
{
UEProjectRoot = CmdEnv.LocalRoot;
}
var UEProjectDirectory = ParseParamValue("UEProjectDirectory");
if (UEProjectDirectory == null)
{
throw new AutomationException("Missing required command line argument: 'UEProjectDirectory'");
}
var UEProjectName = ParseParamValue("UEProjectName");
if (UEProjectName == null)
{
UEProjectName = "";
}
var LocalizationProjectNames = new List<string>();
{
var LocalizationProjectNamesStr = ParseParamValue("LocalizationProjectNames");
if (LocalizationProjectNamesStr != null)
{
foreach (var ProjectName in LocalizationProjectNamesStr.Split(','))
{
LocalizationProjectNames.Add(ProjectName.Trim());
}
}
}
var LocalizationProviderName = ParseParamValue("LocalizationProvider");
if (LocalizationProviderName == null)
{
LocalizationProviderName = "OneSky";
}
var LocalizationSteps = new List<string>();
{
var LocalizationStepsStr = ParseParamValue("LocalizationSteps");
if (LocalizationStepsStr == null)
{
LocalizationSteps.AddRange(new string[] { "Download", "Gather", "Import", "Export", "Compile", "GenerateReports", "Upload" });
}
else
{
foreach (var StepName in LocalizationStepsStr.Split(','))
{
LocalizationSteps.Add(StepName.Trim());
}
}
LocalizationSteps.Add("Monolithic"); // Always allow the monolithic scripts to run as we don't know which steps they do
}
var ShouldGatherPlugins = ParseParam("IncludePlugins");
var IncludePlugins = new List<string>();
var ExcludePlugins = new List<string>();
if (ShouldGatherPlugins)
{
var IncludePluginsStr = ParseParamValue("IncludePlugins");
if (IncludePluginsStr != null)
{
foreach (var PluginName in IncludePluginsStr.Split(','))
{
IncludePlugins.Add(PluginName.Trim());
}
}
var ExcludePluginsStr = ParseParamValue("ExcludePlugins");
if (ExcludePluginsStr != null)
{
foreach (var PluginName in ExcludePluginsStr.Split(','))
{
ExcludePlugins.Add(PluginName.Trim());
}
}
}
var AdditionalCommandletArguments = ParseParamValue("AdditionalCommandletArguments");
if (AdditionalCommandletArguments == null)
{
AdditionalCommandletArguments = "";
}
var LocalizationBatches = new List<LocalizationBatch>();
// Add the static set of localization projects as a batch
if (LocalizationProjectNames.Count > 0)
{
LocalizationBatches.Add(new LocalizationBatch(UEProjectDirectory, "", LocalizationProjectNames));
}
// Build up any additional batches needed for plugins
if (ShouldGatherPlugins)
{
var PluginsRootDirectory = CombinePaths(UEProjectRoot, UEProjectDirectory, "Plugins");
IReadOnlyList<PluginInfo> AllPlugins = Plugins.ReadPluginsFromDirectory(new DirectoryReference(PluginsRootDirectory), UEProjectName.Length == 0 ? PluginLoadedFrom.Engine : PluginLoadedFrom.GameProject);
// Add a batch for each plugin that meets our criteria
foreach (var PluginInfo in AllPlugins)
{
bool ShouldIncludePlugin = (IncludePlugins.Count == 0 || IncludePlugins.Contains(PluginInfo.Name)) && !ExcludePlugins.Contains(PluginInfo.Name);
if (ShouldIncludePlugin && PluginInfo.Descriptor.LocalizationTargets != null && PluginInfo.Descriptor.LocalizationTargets.Length > 0)
{
var RootRelativePluginPath = PluginInfo.Directory.MakeRelativeTo(new DirectoryReference(UEProjectRoot));
RootRelativePluginPath = RootRelativePluginPath.Replace('\\', '/'); // Make sure we use / as these paths are used with P4
var PluginTargetNames = new List<string>();
foreach (var LocalizationTarget in PluginInfo.Descriptor.LocalizationTargets)
{
PluginTargetNames.Add(LocalizationTarget.Name);
}
LocalizationBatches.Add(new LocalizationBatch(RootRelativePluginPath, PluginInfo.Name, PluginTargetNames));
}
}
}
// Create a single changelist to use for all changes, and hash the current PO files on disk so we can work out whether they actually change
int PendingChangeList = 0;
Dictionary<string, byte[]> InitalPOFileHashes = null;
if (P4Enabled)
{
PendingChangeList = P4.CreateChange(P4Env.Client, "Localization Automation");
InitalPOFileHashes = GetPOFileHashes(LocalizationBatches, UEProjectRoot);
}
// Process each localization batch
foreach (var LocalizationBatch in LocalizationBatches)
{
ProcessLocalizationProjects(LocalizationBatch, PendingChangeList, UEProjectRoot, UEProjectName, LocalizationProviderName, LocalizationSteps, AdditionalCommandletArguments);
}
// Submit that single changelist now
if (P4Enabled && AllowSubmit)
{
// Revert any PO files that haven't changed aside from their header
{
var POFilesToRevert = new List<string>();
var CurrentPOFileHashes = GetPOFileHashes(LocalizationBatches, UEProjectRoot);
foreach (var CurrentPOFileHashPair in CurrentPOFileHashes)
{
byte[] InitialPOFileHash;
if (InitalPOFileHashes.TryGetValue(CurrentPOFileHashPair.Key, out InitialPOFileHash) && InitialPOFileHash.SequenceEqual(CurrentPOFileHashPair.Value))
{
POFilesToRevert.Add(CurrentPOFileHashPair.Key);
}
}
if (POFilesToRevert.Count > 0)
{
var P4RevertCommandline = new StringBuilder();
foreach (var POFileToRevert in POFilesToRevert)
{
P4RevertCommandline.Append('"');
P4RevertCommandline.Append(POFileToRevert);
P4RevertCommandline.Append('"');
P4RevertCommandline.Append(' ');
}
P4.Revert(P4RevertCommandline.ToString());
}
}
int SubmittedChangeList;
P4.Submit(PendingChangeList, out SubmittedChangeList);
}
}
private void ProcessLocalizationProjects(LocalizationBatch LocalizationBatch, int PendingChangeList, string UEProjectRoot, string UEProjectName, string LocalizationProviderName, List<string> LocalizationSteps, string AdditionalCommandletArguments)
{
var EditorExe = CombinePaths(CmdEnv.LocalRoot, @"Engine/Binaries/Win64/UE4Editor-Cmd.exe");
var RootWorkingDirectory = CombinePaths(UEProjectRoot, LocalizationBatch.UEProjectDirectory);
// Try and find our localization provider
LocalizationProvider LocProvider = null;
{
LocalizationProvider.LocalizationProviderArgs LocProviderArgs;
LocProviderArgs.RootWorkingDirectory = RootWorkingDirectory;
LocProviderArgs.RemoteFilenamePrefix = LocalizationBatch.RemoteFilenamePrefix;
LocProviderArgs.CommandUtils = this;
LocProviderArgs.PendingChangeList = PendingChangeList;
LocProvider = LocalizationProvider.GetLocalizationProvider(LocalizationProviderName, LocProviderArgs);
}
// Make sure the Localization configs and content is up-to-date to ensure we don't get errors later on
if (P4Enabled)
{
Log("Sync necessary content to head revision");
P4.Sync(P4Env.BuildRootP4 + "/" + LocalizationBatch.UEProjectDirectory + "/Config/Localization/...");
P4.Sync(P4Env.BuildRootP4 + "/" + LocalizationBatch.UEProjectDirectory + "/Content/Localization/...");
}
// Generate the info we need to gather for each project
var ProjectInfos = new List<ProjectInfo>();
foreach (var ProjectName in LocalizationBatch.LocalizationProjectNames)
{
ProjectInfos.Add(GenerateProjectInfo(RootWorkingDirectory, ProjectName, LocalizationSteps));
}
if (LocalizationSteps.Contains("Download") && LocProvider != null)
{
// Export all text from our localization provider
foreach (var ProjectInfo in ProjectInfos)
{
LocProvider.DownloadProjectFromLocalizationProvider(ProjectInfo.ProjectName, ProjectInfo.ImportInfo);
}
}
// Setup editor arguments for SCC.
string EditorArguments = String.Empty;
if (P4Enabled)
{
EditorArguments = String.Format("-SCCProvider={0} -P4Port={1} -P4User={2} -P4Client={3} -P4Passwd={4} -P4Changelist={5} -EnableSCC -DisableSCCSubmit", "Perforce", P4Env.P4Port, P4Env.User, P4Env.Client, P4.GetAuthenticationToken(), PendingChangeList);
}
else
{
EditorArguments = String.Format("-SCCProvider={0}", "None");
}
EditorArguments += " -Unattended";
// Execute commandlet for each config in each project.
bool bLocCommandletFailed = false;
foreach (var ProjectInfo in ProjectInfos)
{
foreach (var LocalizationStep in ProjectInfo.LocalizationSteps)
{
if (!LocalizationSteps.Contains(LocalizationStep.Name))
{
continue;
}
var CommandletArguments = String.Format("-config=\"{0}\"", LocalizationStep.LocalizationConfigFile);
if (!String.IsNullOrEmpty(AdditionalCommandletArguments))
{
CommandletArguments += " " + AdditionalCommandletArguments;
}
string Arguments = String.Format("{0} -run=GatherText {1} {2}", UEProjectName, EditorArguments, CommandletArguments);
Log("Running localization commandlet: {0}", Arguments);
var StartTime = DateTime.UtcNow;
var RunResult = Run(EditorExe, Arguments, null, ERunOptions.Default | ERunOptions.NoLoggingOfRunCommand); // Disable logging of the run command as it will print the exit code which GUBP can pick up as an error (we do that ourselves below)
var RunDuration = (DateTime.UtcNow - StartTime).TotalMilliseconds;
Log("Localization commandlet finished in {0}s", RunDuration / 1000);
if (RunResult.ExitCode != 0)
{
LogWarning("The localization commandlet exited with code {0} which likely indicates a crash. It ran with the following arguments: '{1}'", RunResult.ExitCode, Arguments);
bLocCommandletFailed = true;
break; // We failed a step, so don't process any other steps in this config chain
}
}
}
if (LocalizationSteps.Contains("Upload") && LocProvider != null)
{
if (bLocCommandletFailed)
{
LogWarning("Skipping upload to the localization provider due to an earlier commandlet failure.");
}
else
{
// Upload all text to our localization provider
foreach (var ProjectInfo in ProjectInfos)
{
LocProvider.UploadProjectToLocalizationProvider(ProjectInfo.ProjectName, ProjectInfo.ExportInfo);
}
}
}
}
private ProjectInfo GenerateProjectInfo(string RootWorkingDirectory, string ProjectName, List<string> LocalizationSteps)
{
var ProjectInfo = new ProjectInfo();
ProjectInfo.ProjectName = ProjectName;
ProjectInfo.LocalizationSteps = new List<ProjectStepInfo>();
// Projects generated by the localization dashboard will use multiple config files that must be run in a specific order
// Older projects (such as the Engine) would use a single config file containing all the steps
// Work out which kind of project we're dealing with...
var MonolithicConfigFile = CombinePaths(RootWorkingDirectory, String.Format(@"Config/Localization/{0}.ini", ProjectName));
if (File.Exists(MonolithicConfigFile))
{
ProjectInfo.LocalizationSteps.Add(new ProjectStepInfo("Monolithic", MonolithicConfigFile));
ProjectInfo.ImportInfo = GenerateProjectImportExportInfo(MonolithicConfigFile);
ProjectInfo.ExportInfo = ProjectInfo.ImportInfo;
}
else
{
var FileSuffixes = new[] {
new { Suffix = "Gather", Required = LocalizationSteps.Contains("Gather") },
new { Suffix = "Import", Required = LocalizationSteps.Contains("Import") || LocalizationSteps.Contains("Download") }, // Downloading needs the parsed ImportInfo
new { Suffix = "Export", Required = LocalizationSteps.Contains("Gather") || LocalizationSteps.Contains("Upload")}, // Uploading needs the parsed ExportInfo
new { Suffix = "Compile", Required = LocalizationSteps.Contains("Compile") },
new { Suffix = "GenerateReports", Required = false }
};
foreach (var FileSuffix in FileSuffixes)
{
var ModularConfigFile = CombinePaths(RootWorkingDirectory, String.Format(@"Config/Localization/{0}_{1}.ini", ProjectName, FileSuffix.Suffix));
if (File.Exists(ModularConfigFile))
{
ProjectInfo.LocalizationSteps.Add(new ProjectStepInfo(FileSuffix.Suffix, ModularConfigFile));
if (FileSuffix.Suffix == "Import")
{
ProjectInfo.ImportInfo = GenerateProjectImportExportInfo(ModularConfigFile);
}
else if (FileSuffix.Suffix == "Export")
{
ProjectInfo.ExportInfo = GenerateProjectImportExportInfo(ModularConfigFile);
}
}
else if (FileSuffix.Required)
{
throw new AutomationException("Failed to find a required config file! '{0}'", ModularConfigFile);
}
}
}
return ProjectInfo;
}
private ProjectImportExportInfo GenerateProjectImportExportInfo(string LocalizationConfigFile)
{
var ProjectImportExportInfo = new ProjectImportExportInfo();
var LocalizationConfig = new ConfigCacheIni(new FileReference(LocalizationConfigFile));
if (!LocalizationConfig.GetString("CommonSettings", "DestinationPath", out ProjectImportExportInfo.DestinationPath))
{
throw new AutomationException("Failed to find a required config key! Section: 'CommonSettings', Key: 'DestinationPath', File: '{0}'", LocalizationConfigFile);
}
if (!LocalizationConfig.GetString("CommonSettings", "ManifestName", out ProjectImportExportInfo.ManifestName))
{
throw new AutomationException("Failed to find a required config key! Section: 'CommonSettings', Key: 'ManifestName', File: '{0}'", LocalizationConfigFile);
}
if (!LocalizationConfig.GetString("CommonSettings", "ArchiveName", out ProjectImportExportInfo.ArchiveName))
{
throw new AutomationException("Failed to find a required config key! Section: 'CommonSettings', Key: 'ArchiveName', File: '{0}'", LocalizationConfigFile);
}
if (!LocalizationConfig.GetString("CommonSettings", "PortableObjectName", out ProjectImportExportInfo.PortableObjectName))
{
throw new AutomationException("Failed to find a required config key! Section: 'CommonSettings', Key: 'PortableObjectName', File: '{0}'", LocalizationConfigFile);
}
if (!LocalizationConfig.GetString("CommonSettings", "NativeCulture", out ProjectImportExportInfo.NativeCulture))
{
throw new AutomationException("Failed to find a required config key! Section: 'CommonSettings', Key: 'NativeCulture', File: '{0}'", LocalizationConfigFile);
}
if (!LocalizationConfig.GetArray("CommonSettings", "CulturesToGenerate", out ProjectImportExportInfo.CulturesToGenerate))
{
throw new AutomationException("Failed to find a required config key! Section: 'CommonSettings', Key: 'CulturesToGenerate', File: '{0}'", LocalizationConfigFile);
}
if (!LocalizationConfig.GetBool("CommonSettings", "bUseCultureDirectory", out ProjectImportExportInfo.bUseCultureDirectory))
{
// bUseCultureDirectory is optional, default is true
ProjectImportExportInfo.bUseCultureDirectory = true;
}
return ProjectImportExportInfo;
}
private Dictionary<string, byte[]> GetPOFileHashes(List<LocalizationBatch> LocalizationBatches, string UEProjectRoot)
{
var AllFiles = new Dictionary<string, byte[]>();
foreach (var LocalizationBatch in LocalizationBatches)
{
var LocalizationPath = CombinePaths(UEProjectRoot, LocalizationBatch.UEProjectDirectory, "Content", "Localization");
string[] POFileNames = Directory.GetFiles(LocalizationPath, "*.po", SearchOption.AllDirectories);
foreach (var POFileName in POFileNames)
{
using (StreamReader POFileReader = File.OpenText(POFileName))
{
// Don't include the PO header (everything up to the first empty line) in the hash as it contains transient information (like timestamps) that we don't care about
bool bHasParsedHeader = false;
var POFileHash = MD5.Create();
string POFileLine;
while ((POFileLine = POFileReader.ReadLine()) != null)
{
if (!bHasParsedHeader)
{
bHasParsedHeader = POFileLine.Length == 0;
continue;
}
var POFileLineBytes = Encoding.UTF8.GetBytes(POFileLine);
POFileHash.TransformBlock(POFileLineBytes, 0, POFileLineBytes.Length, null, 0);
}
POFileHash.TransformFinalBlock(new byte[0], 0, 0);
AllFiles.Add(POFileName, POFileHash.Hash);
}
}
}
return AllFiles;
}
}