You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden ========================== MAJOR FEATURES + CHANGES ========================== Change 3315219 on 2017/02/21 by Steve.Robb Fix for FObjectAndNameAsStringProxyArchive when serializing a TWeakObjectPtr. Change 3315285 on 2017/02/21 by Steve.Robb Explicitly pass string builder into code generation functions. Change 3315341 on 2017/02/21 by Ben.Marsh UAT: Clean up some formatting in StreamCopyDescription output - remove #fyi lines, exclude merge commits, and remove some blank lines. Change 3315350 on 2017/02/21 by Ben.Marsh Fix shared resource files not being rebuilt if the version header changes. Change 3315823 on 2017/02/21 by Ben.Marsh UAT: Use a class derived from AutomationException to return information specific to commandlets failing, rather than putting it in the base class. Change 3315826 on 2017/02/21 by Ben.Marsh UAT: Move Distiller class from general use in UAT; FileFilter provides a much safer and fully featured implementation of the same concepts. Change 3315857 on 2017/02/21 by Ben.Marsh UBT: Remove the StripBaseDirectory() and MakeRerootedFilePath() utility functions from UBT. These operations can now be done more safely with FileReference objects. Change 3315942 on 2017/02/21 by Ben.Marsh UBT: Convert FileFilter to use FileReference and DirectoryReference arguments everywhere. Change3316236on 2017/02/22 by Maciej.Mroz #jira UE-42045 Nativization Fixed Warning: TEnumAsByte is not intended for use with enum Change 3316253 on 2017/02/22 by Robert.Manuszewski Fixes for the async log file writer hangs and crashes. - potential fix for the logging system hang when running out of disk space while flushing log - fix for unexpected concurrency assert when flushing the log buffer to disk Change3316293on 2017/02/22 by Steve.Robb GetTypeHash and lexicographical comparison operators (operator<() etc.) for TTuple. Change 3316342 on 2017/02/22 by Maciej.Mroz Nativization: Wrappers (stubs) required only by other wrappers are properly generated. #codereview: Mike.Beach Change 3316344 on 2017/02/22 by Maciej.Mroz Fixed crash in nativized Odin Async loading properly handles nativized structs. Change 3316359 on 2017/02/22 by Steve.Robb GitHub #3287 : Ignore #pragma in USTRUCTs #jira UE-42248 Change 3316389 on 2017/02/22 by Matthew.Griffin Switched Installed Engine Filters to multiline properties to make them more readable Added Oodle to list of excluded plugins #jira UE-42030 Change 3316392 on 2017/02/22 by Ben.Marsh UBT: Split out FileReference/DirectoryReference classes into their own file. Change 3316394 on 2017/02/22 by Ben.Marsh UBT: Move FileReference/DirectoryReference extension methods into the appropriate file. Change 3316411 on 2017/02/22 by Ben.Marsh UAT: Remove file functions that take multiple arguments. There's not really a compelling use case for these to exist over looping from the calling code. Change 3316446 on 2017/02/22 by Ben.Marsh UAT: Try disabling function name prefix to log output from UAT, to see if it improves readability. Function names are still included in the log file for debugging. Change 3316575 on 2017/02/22 by Ben.Marsh UAT: Remove unused functionality for dealing with labels, and output a more human readable list of P4 settings at startup. Change 3318481 on 2017/02/22 by Steve.Robb Use of FMath::IsPowerOfTwo in check. Static assert to ensure that an inline set allocator will have a hash size of a power of two. Change 3318496 on 2017/02/22 by Steve.Robb Fix for TSet visualizers. Change 3318919 on 2017/02/23 by Steve.Robb Fix for hot reloading UScriptStruct-derived objects in a module, where the CDOs of these objects haven't had PrepareCppStructOps() called on them. #jira UE-42178 Change 3318942 on 2017/02/23 by Steve.Robb Removal of a redundant insertion which can cause problems on reallocation of the map. Change 3319010 on 2017/02/23 by Ben.Marsh UBT: Fix exception when a file that was previously part of the working set is deleted. Change 3319134 on 2017/02/23 by Robert.Manuszewski Better fix for a deadlock when flushing log while it's already being flushed due to flush timer on the async log writer thread. Change 3319249 on 2017/02/23 by Matthew.Griffin Added a function to check if running with debug game libs instead of checking command line in multiple places Added -RunConfig parameter, which has equivalent result to -debug if value of parameter starts with 'debug' Added -RunConfig=$(Configuration) as a default commandline argument for Mac so that editor can use debug game libs Removed -Shipping argument from VCProject generation as it's not used anymore Change 3319253 on 2017/02/23 by Maciej.Mroz #jira UE-41846 New mechanism to gather modules necessary for Nativized Assets. The modules are listed based on included headers. Previously the dependencies was gathered only in FBlueprintNativeCodeGenManifest::GatherModuleDependencies. Change3319591on 2017/02/23 by Ben.Marsh Don't strip prefixes beginning with WARNING: or ERROR: using the Postp filter. Change 3320357 on 2017/02/23 by Steven.Hutton Slight changes to Add Crash method - Returning select fields instead of entity objects in queries for perf reasons. Change 3320361 on 2017/02/23 by Steven.Hutton Performance improvements subsequent to the recent database changes. Change 3320446 on 2017/02/23 by Steven.Hutton adding my temporary performance tracker class - reports to a private slack channel with add crash performance data. Change 3320479 on 2017/02/23 by Ben.Marsh Fix CIS errors. Change 3320576 on 2017/02/23 by Jin.Zhang Update CrashReporter to use AWS Change 3320742 on 2017/02/23 by Jin.Zhang Merging crash caching Change 3321119 on 2017/02/24 by Robert.Manuszewski DLL injection protection support for non-monolithic builds Change 3323308 on 2017/02/27 by Matthew.Griffin Moved compilation of SwarmInterface after its dependencies so that we will see a build failure immediately if they change version in future Change 3323423 on 2017/02/27 by Chad.Garyet Adding a script to check and warn about csproj targeted .net versions being mismatched #JIRA UE-39624 Change 3323442 on 2017/02/27 by Ben.Marsh UBT: Output an error if an engine module references a game module. Change 3323743 on 2017/02/27 by Ben.Marsh PR #3303: Resolved PVS scan issues (Contributed by projectgheist) Change 3323748 on 2017/02/27 by Ben.Marsh Convert whitespace to tabs. Change 3324851 on 2017/02/28 by Chris.Wood Add Odin symbol locations to engine config for MDD on CR server. NotForLicensees Change 3324979 on 2017/02/28 by Gil.Gribb Fixed bad merge of priority change in the EDL. Change 3326889 on 2017/03/01 by Steven.Hutton Update to buggs controller to generate faster queries. Change 3326910 on 2017/03/01 by Robert.Manuszewski Removing legacy #if from PackageFileSummary. Change 3327118 on 2017/03/01 by Gil.Gribb UE4 - Fixed race that resulted in a memory leak when reading compressed paks. Change 3327633 on 2017/03/01 by Gil.Gribb UE4 - Added a cvar to control the pak precacher thottle. Change 3327674 on 2017/03/01 by Steve.Robb Unified boilerplate between all generated code files. Change 3328544 on 2017/03/01 by Chris.Wood CrashReportProcess.config update (CRP v1.2.17) Tweaks to a few values. Update website URL to explicitly point to old, non-cloud site on devweb-02. Change 3328714 on 2017/03/01 by Chris.Wood Correct CRP config regression. Point website at new cloud site. Still v1.2.17 Change3329192on 2017/03/02 by Matthew.Griffin Added Shared Build Id file to the list of Precompiled Build Dependencies in a target receipt so that it's brought into an installed build Change 3329285 on 2017/03/02 by Ben.Marsh UGS: Allow a project to specify a filters for the streams that should be displayed for fast-switching to. The QuickSelectStreamList seting in the [Options] section of the project settings references a depot path containing a list of strings used to filter the stream list. An option is shown to switch back to showing all available streams, if desired. Change 3330636 on 2017/03/02 by Ben.Marsh UBT: Bump version number of C++ include cache to force it to be rebuilt with additional include information for the default RC files. Change 3331262 on 2017/03/03 by Robert.Manuszewski Merging Dev-LoadTimes to Dev-Core (Garbage Collection performance improvements) - Improved GC multithreading - Improved BeginDestroy performance - Introduced ULevelActorCluster for StaticMeshActor and ReflectionCapture actor clustering (can be toggled through project settings or console command gc.ActorClusterEnabled) - A few improvements to AddReferencedObjects functions - Misc improvements to GC code - Garbage Collector now properly handles clusters which had their objects marked as pending kill - Blueprints can now create clusters too (can be toggled through project settings or console command gc.BlueprintClusteringEnabled, defaults to disabled) Change 3331285 on 2017/03/03 by Robert.Manuszewski A few fixes for the previous check-in. Change 3332001 on 2017/03/03 by Ben.Marsh UBT: Add support for generating a UDN file containing the valid settings for BuildConfiguration.xml. Pass -configdoc=<filename> on the command line to generate such a file. Change 3332022 on 2017/03/03 by Ben.Marsh Update documentation for where to find the BuildConfiguration settings. Change 3332031 on 2017/03/03 by Ben.Marsh Remove documentation for Windows XP support; it has been removed in the 4.16 release. Change 3332256 on 2017/03/03 by Ben.Marsh UBT: Add support for generating a UDN page containing module and target settings. Change 3332458 on 2017/03/03 by Ben.Marsh UBT: Improvements to generated documentation. Change 3332459 on 2017/03/03 by Ben.Marsh Add generated documentation for .target.cs files, .build.cs files, and BuildConfiguration.xml files. Change 3332460 on 2017/03/03 by Ben.Marsh UBT: Make LinkTypePrivate actually private, so it doesn't show up in the docs. Change 3332899 on 2017/03/06 by Robert.Manuszewski Making sure actor clustering is not used in the editor (fix for actors being deleted when GC runs in the editor) #jira UE-42548 Change 3332955 on 2017/03/06 by Maciej.Mroz Nativization distinguishes client and server platform: - Separated lists on additional assets, additional modules, excluded assets, excluded modules, excluded paths (in config) - Context (compilation options, nativization options and platform) is deliveren to BPCOmpilerCppBackend in FCompilerNativizationOptions struct. - Wrappers (for unconverted BPs) are created only when they are directly called. - Fortnite dedicated server can be nativized Change 3332990 on 2017/03/06 by Ben.Marsh UBT: Add more comprehensive wrapper methods for System.IO.File and System.IO.Directory to FileReference and DirectoryReference. Change 3333032 on 2017/03/06 by Ben.Marsh Documentation for build tools Change 3333037 on 2017/03/06 by Ben.Marsh Add a build step to extract UAT and UBT documentation from XML comments. Change 3333089 on 2017/03/06 by Ben.Marsh UAT: Re-enable logging the calling function to the console in UAT. Needs a pass for readability first. Change 3333651 on 2017/03/06 by Gil.Gribb UE4 - Fix a werid recursive situation where StaticLoadObject could return an object that has not finished loading. Also produces a fatal error if this sometimes happens. EDL only. Change 3335236 on 2017/03/07 by Ben.Marsh UGS: Set the sync changelist separately to the compatibility changelist. Change 3335261 on 2017/03/07 by Gil.Gribb UE4 - Fixed batched render fences when BeginDestroy calls FlushRenderingCommands. Change 3335740 on 2017/03/07 by Gil.Gribb maybe fix static analysis warning Change 3335945 on 2017/03/07 by Steve.Robb Move FFindInstancedReferenceSubobjectHelper code out of header. Add map/set property support to allow instanced members of these container types to be handled during CPFUO. https://udn.unrealengine.com/questions/349232/tmap-with-instanced-object-as-value-gets-cleared-o.html Change 3336693 on 2017/03/07 by Ben.Marsh UBT: Use shared PCHs for game plugins by default, to reduce time spent generating individual PCHs. Change3336694on 2017/03/07 by Steve.Robb Static assert added to TMap to prevent the use of keys which don't implement a GetTypeHash. Fixes to types which relied on implicit conversions when calling GetTypeHash. Workaround in SAssetView.h and PropertyEditorModule.h for an apparent VC bug where the compiler wrongly instantiates TPointerIsConvertibleFromTo for certain forward-declared types, causing future TSharedPtr conversions to fail. #jira UE-42441 Change 3336698 on 2017/03/07 by Steve.Robb Hardcoded endpoint handling replaced with a generic string. Obsolete .proto and .java code generation removed. Change 3336811 on 2017/03/07 by Wes.Hunt Add a game blacklist to the crash report processor. Fixed a syntax error in Config.cs, added a XML comment to shut up a warning. Change 3336973 on 2017/03/08 by Steve.Robb Fix for missing GetTypeHash in a plugin. Change 3336996 on 2017/03/08 by Steve.Robb Significant refactor of code generation, to try and make data flow more apparent. Change 3337571 on 2017/03/08 by Steve.Robb CIS fixes for missing GetTypeHash functions. Non-unity fix. Change 3337588 on 2017/03/08 by Gil.Gribb UE4 - Fixed obscure check with flushing rhi resources. Change 3337620 on 2017/03/08 by Steve.Robb WITH_HOT_RELOAD_CTORS macros removed. UseVTableConstructors config option removed. Change 3339369 on 2017/03/09 by Steve.Robb GetTypeHash overload for nn::account::Uid. Change 3339464 on 2017/03/09 by Daniel.Lamb Fixed assert in 4.15 to do with trying to gather dependency info from invalid packages. #jira UE-42583 #test Editor + Cook + Run shootergame Change 3339465 on 2017/03/09 by Maciej.Mroz Fixed serialization issue, after UserDefinedEnum was used in EnumProperty. Change 3339469 on 2017/03/09 by Maciej.Mroz Fixed Nativization problem, when default value is passed as non-const reference. Change 3340178 on 2017/03/09 by Daniel.Lamb Added support for in memory only packages. The Cooker ignores these and added core functions to recognize these packages. Other systems will need to add support where nessisary. Change 3341002 on 2017/03/10 by Maciej.Mroz Nativization: Fixed FFindHeadersToInclude. Headers necessary for owners of subobjects are properly included. Change 3341076 on 2017/03/10 by Steve.Robb Fix for FBakedTextureSourceInfo move semantics. #jira UE-42658 Change 3341160 on 2017/03/10 by Gil.Gribb UE4 - Fix hazard with SetMaterialUsage from a thread. Change 3341409 on 2017/03/10 by Steve.Robb Reduction of the generated code size for StaticRegisterNatives functions. Change 3341523 on 2017/03/10 by Steve.Robb Code generation simplified. Change 3341800 on 2017/03/10 by Ben.Marsh UnrealVS: Fix UnrealVS compatibility with RTM version of Visual Studio 2017. 2017 toolchain for extensions is no longer able to build <= 2015 extensions due to validation of the VSIX manifest, so create a separate solution for it. Change 3342034 on 2017/03/10 by Ben.Marsh Fix compiler setting not being loaded correctly into the Windows target settings dialog. #jira UE-42746 Change 3342041 on 2017/03/10 by Ben.Marsh Fix -ErrorOnEngineContentUse not being set in the cooker options correctly. Change 3342094 on 2017/03/10 by Steve.Robb Fix to deteministic name order during code generation. Change 3342251 on 2017/03/10 by Daniel.Lamb Integrate fix for resave lightmaps commandlet when upgrading from no mapbuilddatapackages to mapbuilddatapackages. #thanks Tim.Hagberg #test None Change 3342961 on 2017/03/13 by Robert.Manuszewski Fixing memory leak when playing while running -nullrhi on the commandline in cooked games caused by shader resources not being destroyed. #jira FORT-38977 Change 3343022 on 2017/03/13 by Steve.Robb GetTypeHash fixes for FUniqueNetIdLive. #jira UE-42788 Change 3343448 on 2017/03/13 by Steve.Robb Compiled-in defer object order fixed. Debuggability of the deferred registration map improved. #jira UE-42828 [CL 3345747 by Ben Marsh in Main branch]
376 lines
14 KiB
C#
376 lines
14 KiB
C#
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using UnrealBuildTool;
|
|
|
|
namespace AutomationTool
|
|
{
|
|
/// <summary>
|
|
/// Local P4 environment settings
|
|
/// </summary>
|
|
class LocalP4Environment : P4Environment
|
|
{
|
|
internal LocalP4Environment(P4Connection Connection, CommandEnvironment CmdEnv)
|
|
: base(Connection, CmdEnv)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes the environment. Tries to autodetect all source control settings.
|
|
/// </summary>
|
|
/// <param name="CompilationEnv">Compilation environment</param>
|
|
protected override void InitEnvironment(P4Connection Connection, CommandEnvironment CmdEnv)
|
|
{
|
|
var HostName = Environment.MachineName.ToLower();
|
|
var P4PortEnv = DetectP4Port();
|
|
|
|
var UserName = CommandUtils.GetEnvVar(EnvVarNames.User);
|
|
if (String.IsNullOrEmpty(UserName))
|
|
{
|
|
UserName = DetectUserName(Connection);
|
|
}
|
|
|
|
var CommandLineClient = CommandUtils.GetEnvVar(EnvVarNames.Client);
|
|
P4ClientInfo ThisClient = null;
|
|
if (String.IsNullOrEmpty(CommandLineClient) == false)
|
|
{
|
|
ThisClient = Connection.GetClientInfo(CommandLineClient);
|
|
if (ThisClient == null)
|
|
{
|
|
throw new AutomationException("Unable to find client {0}", CommandLineClient);
|
|
}
|
|
if (String.Compare(ThisClient.Owner, UserName, true) != 0)
|
|
{
|
|
throw new AutomationException("Client specified with {0}={1} has a different owner then the detected user name (has: {2}, expected: {3})",
|
|
EnvVarNames.Client, CommandLineClient, ThisClient.Owner, UserName);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ThisClient = DetectClient(Connection, UserName, HostName, CmdEnv.UATExe);
|
|
}
|
|
|
|
Log.TraceInformation("Using user {0} clientspec {1} {2}", UserName, ThisClient.Name, ThisClient.RootPath);
|
|
Environment.SetEnvironmentVariable("P4CLIENT", ThisClient.Name);
|
|
|
|
string BuildRootPath;
|
|
string ClientRootPath;
|
|
DetectRootPaths(Connection, CmdEnv.LocalRoot, ThisClient, out BuildRootPath, out ClientRootPath);
|
|
|
|
CommandUtils.ConditionallySetEnvVar(EnvVarNames.P4Port, P4PortEnv);
|
|
CommandUtils.ConditionallySetEnvVar(EnvVarNames.User, UserName);
|
|
CommandUtils.ConditionallySetEnvVar(EnvVarNames.Client, ThisClient.Name);
|
|
CommandUtils.ConditionallySetEnvVar(EnvVarNames.BuildRootP4, BuildRootPath);
|
|
CommandUtils.ConditionallySetEnvVar(EnvVarNames.ClientRoot, ClientRootPath);
|
|
|
|
var CLString = CommandUtils.GetEnvVar(EnvVarNames.Changelist, null);
|
|
if (String.IsNullOrEmpty(CLString) && CommandUtils.P4CLRequired)
|
|
{
|
|
CLString = DetectCurrentCL(Connection, ClientRootPath);
|
|
}
|
|
if (!String.IsNullOrEmpty(CLString))
|
|
{
|
|
CommandUtils.ConditionallySetEnvVar(EnvVarNames.Changelist, CLString);
|
|
}
|
|
|
|
var CodeCLString = CommandUtils.GetEnvVar(EnvVarNames.CodeChangelist, null);
|
|
if (String.IsNullOrEmpty(CodeCLString) && CommandUtils.P4CLRequired)
|
|
{
|
|
CodeCLString = DetectCurrentCodeCL(Connection, ClientRootPath);
|
|
}
|
|
if (!String.IsNullOrEmpty(CodeCLString))
|
|
{
|
|
CommandUtils.ConditionallySetEnvVar(EnvVarNames.CodeChangelist, CodeCLString);
|
|
}
|
|
|
|
CommandUtils.ConditionallySetEnvVar("P4USER", UserName);
|
|
CommandUtils.ConditionallySetEnvVar("P4CLIENT", ThisClient.Name);
|
|
|
|
var P4Password = Environment.GetEnvironmentVariable(EnvVarNames.P4Password);
|
|
if (!String.IsNullOrEmpty(P4Password))
|
|
{
|
|
CommandUtils.ConditionallySetEnvVar("P4PASSWD", P4Password);
|
|
}
|
|
|
|
SetBuildRootEscaped();
|
|
|
|
base.InitEnvironment(Connection, CmdEnv);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets the escaped build root environment variable. If the build root is not set, UAT's location UE4 root will be used.
|
|
/// </summary>
|
|
private void SetBuildRootEscaped()
|
|
{
|
|
var BuildRoot = CommandUtils.GetEnvVar(EnvVarNames.BuildRootP4);
|
|
if (String.IsNullOrEmpty(BuildRoot))
|
|
{
|
|
throw new AutomationException("Build root is empty");
|
|
}
|
|
BuildRoot = CommandUtils.EscapePath(BuildRoot);
|
|
CommandUtils.ConditionallySetEnvVar(EnvVarNames.BuildRootEscaped, BuildRoot);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Detects the current changelist the workspace is synced to.
|
|
/// </summary>
|
|
/// <param name="ClientRootPath">Workspace path.</param>
|
|
/// <returns>Changelist number as a string.</returns>
|
|
private static string DetectCurrentCL(P4Connection Connection, string ClientRootPath)
|
|
{
|
|
CommandUtils.LogVerbose("uebp_CL not set, detecting 'have' CL...");
|
|
|
|
// Retrieve the current changelist
|
|
var P4Result = Connection.P4("changes -m 1 " + CommandUtils.CombinePaths(PathSeparator.Depot, ClientRootPath, "/...#have"), AllowSpew: false);
|
|
var CLTokens = P4Result.Output.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
|
var CLString = CLTokens[1];
|
|
var CL = Int32.Parse(CLString);
|
|
if (CLString != CL.ToString())
|
|
{
|
|
throw new AutomationException("Failed to retrieve current changelist.");
|
|
}
|
|
return CLString;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Detects the current code changelist the workspace is synced to.
|
|
/// </summary>
|
|
/// <param name="ClientRootPath">Workspace path.</param>
|
|
/// <returns>Changelist number as a string.</returns>
|
|
private static string DetectCurrentCodeCL(P4Connection Connection, string ClientRootPath)
|
|
{
|
|
CommandUtils.LogVerbose("uebp_CodeCL not set, detecting last code CL...");
|
|
|
|
// Retrieve the current changelist
|
|
string P4Cmd = String.Format("changes -m 1 \"{0}/....cpp#have\" \"{0}/....h#have\" \"{0}/....inl#have\" \"{0}/....cs#have\" \"{0}/....usf#have\"", CommandUtils.CombinePaths(PathSeparator.Depot, ClientRootPath));
|
|
IProcessResult P4Result = Connection.P4(P4Cmd, AllowSpew: false);
|
|
|
|
// Loop through all the lines of the output. Even though we requested one result, we'll get one for each search pattern.
|
|
int CL = 0;
|
|
foreach(string Line in P4Result.Output.Split('\n'))
|
|
{
|
|
string[] Tokens = Line.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
|
if(Tokens.Length >= 2)
|
|
{
|
|
int LineCL = Int32.Parse(Tokens[1]);
|
|
CL = Math.Max(CL, LineCL);
|
|
}
|
|
}
|
|
return CL.ToString();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Detects root paths for the specified client.
|
|
/// </summary>
|
|
/// <param name="UATLocation">AutomationTool.exe location</param>
|
|
/// <param name="ThisClient">Client to detect the root paths for</param>
|
|
/// <param name="BuildRootPath">Build root</param>
|
|
/// <param name="LocalRootPath">Local root</param>
|
|
/// <param name="ClientRootPath">Client root</param>
|
|
private static void DetectRootPaths(P4Connection Connection, string LocalRootPath, P4ClientInfo ThisClient, out string BuildRootPath, out string ClientRootPath)
|
|
{
|
|
if(!String.IsNullOrEmpty(ThisClient.Stream))
|
|
{
|
|
BuildRootPath = ThisClient.Stream;
|
|
ClientRootPath = String.Format("//{0}", ThisClient.Name);
|
|
}
|
|
else
|
|
{
|
|
// Figure out the build root
|
|
string KnownFilePathFromRoot = CommandEnvironment.KnownFileRelativeToRoot;
|
|
string KnownLocalPath = CommandUtils.MakePathSafeToUseWithCommandLine(CommandUtils.CombinePaths(PathSeparator.Slash, LocalRootPath, KnownFilePathFromRoot));
|
|
IProcessResult P4Result = Connection.P4(String.Format("files -m 1 {0}", KnownLocalPath), AllowSpew: false);
|
|
|
|
string KnownFileDepotMapping = P4Result.Output;
|
|
|
|
// Get the build root
|
|
Log.TraceVerbose("Looking for {0} in {1}", KnownFilePathFromRoot, KnownFileDepotMapping);
|
|
int EndIdx = KnownFileDepotMapping.IndexOf(KnownFilePathFromRoot, StringComparison.CurrentCultureIgnoreCase);
|
|
if (EndIdx < 0)
|
|
{
|
|
EndIdx = KnownFileDepotMapping.IndexOf(CommandUtils.ConvertSeparators(PathSeparator.Slash, KnownFilePathFromRoot), StringComparison.CurrentCultureIgnoreCase);
|
|
}
|
|
// Get the root path without the trailing path separator
|
|
BuildRootPath = KnownFileDepotMapping.Substring(0, EndIdx - 1);
|
|
|
|
// Get the client root
|
|
if (LocalRootPath.StartsWith(CommandUtils.CombinePaths(PathSeparator.Slash, ThisClient.RootPath, "/"), StringComparison.InvariantCultureIgnoreCase) || LocalRootPath == CommandUtils.CombinePaths(PathSeparator.Slash, ThisClient.RootPath))
|
|
{
|
|
ClientRootPath = CommandUtils.CombinePaths(PathSeparator.Depot, String.Format("//{0}/", ThisClient.Name), LocalRootPath.Substring(ThisClient.RootPath.Length));
|
|
}
|
|
else
|
|
{
|
|
throw new AutomationException("LocalRootPath ({0}) does not start with the client root path ({1})", LocalRootPath, ThisClient.RootPath);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Detects a workspace given the current user name, host name and depot path.
|
|
/// </summary>
|
|
/// <param name="UserName">User name</param>
|
|
/// <param name="HostName">Host</param>
|
|
/// <param name="UATLocation">Path to UAT exe, this will be checked agains the root path.</param>
|
|
/// <returns>Client to use.</returns>
|
|
private static P4ClientInfo DetectClient(P4Connection Connection, string UserName, string HostName, string UATLocation)
|
|
{
|
|
CommandUtils.LogVerbose("uebp_CLIENT not set, detecting current client...");
|
|
|
|
var MatchingClients = new List<P4ClientInfo>();
|
|
P4ClientInfo[] P4Clients = Connection.GetClientsForUser(UserName, UATLocation);
|
|
foreach (var Client in P4Clients)
|
|
{
|
|
if (!String.IsNullOrEmpty(Client.Host) && String.Compare(Client.Host, HostName, true) != 0)
|
|
{
|
|
Log.TraceInformation("Rejecting client because of different Host {0} \"{1}\" != \"{2}\"", Client.Name, Client.Host, HostName);
|
|
continue;
|
|
}
|
|
|
|
MatchingClients.Add(Client);
|
|
}
|
|
|
|
P4ClientInfo ClientToUse = null;
|
|
if (MatchingClients.Count == 0)
|
|
{
|
|
throw new AutomationException("No matching clientspecs found!");
|
|
}
|
|
else if (MatchingClients.Count == 1)
|
|
{
|
|
ClientToUse = MatchingClients[0];
|
|
}
|
|
else
|
|
{
|
|
// We may have empty host clients here, so pick the first non-empty one if possible
|
|
foreach (var Client in MatchingClients)
|
|
{
|
|
if (!String.IsNullOrEmpty(Client.Host) && String.Compare(Client.Host, HostName, true) == 0)
|
|
{
|
|
ClientToUse = Client;
|
|
break;
|
|
}
|
|
}
|
|
if (ClientToUse == null)
|
|
{
|
|
Log.TraceWarning("{0} clients found that match the current host and root path. The most recently accessed client will be used.", MatchingClients.Count);
|
|
ClientToUse = GetMostRecentClient(MatchingClients);
|
|
}
|
|
}
|
|
|
|
return ClientToUse;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Given a list of clients with the same owner and root path, tries to find the most recently accessed one.
|
|
/// </summary>
|
|
/// <param name="Clients">List of clients with the same owner and path.</param>
|
|
/// <returns>The most recent client from the list.</returns>
|
|
private static P4ClientInfo GetMostRecentClient(List<P4ClientInfo> Clients)
|
|
{
|
|
Log.TraceVerbose("Detecting the most recent client.");
|
|
P4ClientInfo MostRecentClient = null;
|
|
var MostRecentAccessTime = DateTime.MinValue;
|
|
foreach (var ClientInfo in Clients)
|
|
{
|
|
if (ClientInfo.Access.Ticks > MostRecentAccessTime.Ticks)
|
|
{
|
|
MostRecentAccessTime = ClientInfo.Access;
|
|
MostRecentClient = ClientInfo;
|
|
}
|
|
}
|
|
if (MostRecentClient == null)
|
|
{
|
|
throw new AutomationException("Failed to determine the most recent client in {0}", Clients[0].RootPath);
|
|
}
|
|
return MostRecentClient;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Detects current user name.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private static string DetectUserName(P4Connection Connection)
|
|
{
|
|
var UserName = String.Empty;
|
|
var P4Result = Connection.P4("info", AllowSpew: false);
|
|
if (P4Result.ExitCode != 0)
|
|
{
|
|
throw new AutomationException("Perforce command failed: {0}. Please make sure your P4PORT or {1} is set properly.", P4Result.Output, EnvVarNames.P4Port);
|
|
}
|
|
|
|
// Retrieve the P4 user name
|
|
var Tags = Connection.ParseTaggedP4Output(P4Result.Output);
|
|
Tags.TryGetValue("User name", out UserName);
|
|
|
|
if (String.IsNullOrEmpty(UserName))
|
|
{
|
|
UserName = Environment.GetEnvironmentVariable(EnvVarNames.User);
|
|
|
|
if (!String.IsNullOrEmpty(UserName))
|
|
{
|
|
Log.TraceWarning("Unable to retrieve perforce user name. Trying to fall back to {0} which is set to {1}.", EnvVarNames.User, UserName);
|
|
}
|
|
else
|
|
{
|
|
throw new AutomationException("Failed to retrieve user name.");
|
|
}
|
|
}
|
|
|
|
Environment.SetEnvironmentVariable("P4USER", UserName);
|
|
|
|
return UserName;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Attempts to detect source control server address from environment variables.
|
|
/// </summary>
|
|
/// <returns>Source control server address.</returns>
|
|
private static string DetectP4Port()
|
|
{
|
|
string P4PortEnv = Environment.GetEnvironmentVariable("P4PORT");
|
|
if(String.IsNullOrEmpty(P4PortEnv))
|
|
{
|
|
// If it's not set, spawn Perforce to get the current server port setting
|
|
IProcessResult Result = CommandUtils.Run(HostPlatform.Current.P4Exe, "set P4PORT", null, CommandUtils.ERunOptions.NoLoggingOfRunCommand);
|
|
if (Result.ExitCode == 0)
|
|
{
|
|
const string KeyName = "P4PORT=";
|
|
if (Result.Output.StartsWith(KeyName))
|
|
{
|
|
int LastIdx = Result.Output.IndexOfAny(new char[] { ' ', '\n' });
|
|
if (LastIdx == -1)
|
|
{
|
|
LastIdx = Result.Output.Length;
|
|
}
|
|
P4PortEnv = Result.Output.Substring(KeyName.Length, LastIdx - KeyName.Length);
|
|
}
|
|
}
|
|
|
|
// Otherwise fallback to the uebp variables, or the default
|
|
if(String.IsNullOrEmpty(P4PortEnv))
|
|
{
|
|
// Try to read the P4PORT environment and check if it is set correctly
|
|
P4PortEnv = Environment.GetEnvironmentVariable(EnvVarNames.P4Port);
|
|
|
|
// If not, try to fallback to Mapping.P4Port and set this as P4PORT before continueing
|
|
if (!String.IsNullOrEmpty(P4PortEnv))
|
|
{
|
|
Log.TraceWarning("P4PORT is not set. Falling back to {0} which is set to {1}.", EnvVarNames.P4Port, P4PortEnv);
|
|
}
|
|
else
|
|
{
|
|
// If that fails as well, we just give it a shot with perforce:1666 and hope that this works
|
|
Log.TraceWarning("P4PORT is not set. Trying to fallback to perforce:1666");
|
|
P4PortEnv = "perforce:1666";
|
|
}
|
|
}
|
|
|
|
Environment.SetEnvironmentVariable("P4PORT", P4PortEnv);
|
|
}
|
|
return P4PortEnv;
|
|
}
|
|
}
|
|
}
|