2016-12-08 08:52:44 -05:00
|
|
|
|
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
// NOTE: This file is shared with AutomationToolLauncher. It can NOT have any references to non-system libraries
|
|
|
|
|
|
|
|
|
|
|
|
namespace AutomationTool
|
|
|
|
|
|
{
|
|
|
|
|
|
internal class SharedUtils
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Parses the command line string and returns an array of passed arguments.
|
2016-01-27 12:09:53 -05:00
|
|
|
|
/// Unlike the default parsing algorithm, this will treat \r\n characters
|
2014-03-14 14:13:41 -04:00
|
|
|
|
/// just like spaces.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>List of command line arguments.</returns>
|
|
|
|
|
|
public static string[] ParseCommandLine()
|
|
|
|
|
|
{
|
|
|
|
|
|
var CmdLine = Environment.CommandLine;
|
|
|
|
|
|
var Args = new List<string>();
|
|
|
|
|
|
StringBuilder Arg = new StringBuilder(CmdLine.Length);
|
|
|
|
|
|
bool bQuote = false;
|
2016-01-27 12:09:53 -05:00
|
|
|
|
int bEscape = 0;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
for (int Index = 0; Index < CmdLine.Length; ++Index)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool bCanAppend = true;
|
|
|
|
|
|
char C = CmdLine[Index];
|
|
|
|
|
|
if (!bQuote && Char.IsWhiteSpace(C))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Arg.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Args.Add(Arg.ToString());
|
|
|
|
|
|
Arg.Clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
bCanAppend = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (C == '\\' && Index < (CmdLine.Length - 1))
|
|
|
|
|
|
{
|
|
|
|
|
|
// Escape character
|
2016-01-27 12:09:53 -05:00
|
|
|
|
bEscape++;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
bCanAppend = false;
|
|
|
|
|
|
}
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3058348)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 2982033 on 2016/05/18 by Chad.Garyet
Checking in progress on the ue4 BuildGraph conversion.
Builds and Compiles editor and game on all platforms
Builds DDC on win64 and mac
Builds Tools on win64
Change 3047983 on 2016/07/13 by Ben.Marsh
PR #2597: Fix P4 environment used for running BuildUGS commandlet (Contributed by paulevans)
Change 3048267 on 2016/07/13 by Ben.Marsh
BuildGraph: Allow more permissive list of characters for node names; just restrict against characters which are illegal in filenames. Allows creating aggregate names which match job names (eg. "Editor, Tools & Monolithics").
Change 3048293 on 2016/07/13 by Ben.Marsh
BuildGraph: Allow passing -listonly without a specific -target=... parameter in BuildGraph, to see the contents of the entire script.
Change 3048454 on 2016/07/13 by Ben.Marsh
BuildGraph: Disable output of error messages when just printing the contents of the graph.
Change 3048507 on 2016/07/13 by Ben.Marsh
BuildGraph: Rename "Ticket" to "Token" for files used to ensure exclusive access to run part of a build.
Change 3049459 on 2016/07/14 by Matthew.Griffin
Updated location of HTML5 SDKs for Installed Builds
#jira UE-32171
Change 3049675 on 2016/07/14 by Matthew.Griffin
Ensured that all platforms are registered when running -validateplatform command
#jira UE-31082
Change 3049922 on 2016/07/14 by Ben.Marsh
UBT: Fix path to XML config file in boilerplate message.
Change 3051483 on 2016/07/15 by Ben.Marsh
EC: Remove code to prettify node names, now that we can have pretty node names explicitly.
Change 3051522 on 2016/07/15 by Ben.Marsh
BuildGraph: Change spawn task to fail if a non-zero exit code is returned by an external program. The minimum exit code to be treated as an error can be set using the "ErrorLevel" attribute, similar to ERRORLEVEL in DOS.
Change 3051770 on 2016/07/15 by Ben.Marsh
UGS: Add support for narrowing virtual streams; fetch event and precompiled binaries for parent stream instead.
Change 3052990 on 2016/07/17 by Ben.Marsh
Show the names of people with notifications disabled in the heading of failure emails, so it's clear that they're not on CC.
Change 3053556 on 2016/07/18 by Ben.Marsh
BuildGraph: Add a explicit <Option> tag instead of the <Property Default=""/> shenanigans, so that properties that are meant to be modified by the user are listed explicitly. Supported attributes are "DefaultValue" (which specifies a default if the user does not set it on the command line), "Description" (which explains the purpose of the option to users, which is displayed in a table when BuildGraph is invoked with the -listonly argument), and "Restrict" (which specifies a regex to validate an argument supplied by the user).
Also add an <EnvVar Name="Blah"/> tag which imports the given environment variable as a property (or sets it to "" if it doesn't exist), and rename the <Choose>/<Option>/<Otherwise> triple to <Switch>/<Case>/<Default> to avoid confusion with the new <Option> tag.
Change 3053688 on 2016/07/18 by Ben.Marsh
Update build scripts to link to p4-swarm rather than p4-web in dashboard pages and notification emails.
Change 3054039 on 2016/07/18 by Ben.Marsh
Fix confusing message when compiler isn't installed if the target forces VS2013
Change 3054360 on 2016/07/18 by Ben.Marsh
Remove GUBP support from EC scripts.
Change 3054399 on 2016/07/18 by Ben.Marsh
Remove circular include from Json.h -> JsonSerializerMacros.h -> Json.h
Change 3055671 on 2016/07/19 by Ben.Marsh
Remove incomplete UWP integration from UE4.
Change 3055943 on 2016/07/19 by Ben.Marsh
Remove the WinRT target platform.
Change 3056270 on 2016/07/19 by Ben.Marsh
Core: Move VectorRegister.h include to eliminate include dependency on UnrealMathUtility.h
Change 3056390 on 2016/07/19 by Ben.Marsh
Core: Directly include headers required by default JsonWriter template instantiation.
Change 3057444 on 2016/07/20 by Ben.Marsh
UBT: Fall back to checking for the VS140COMNTOOLS environment variable if we couldn't determine the Visual Studio installation directory from the registry. Allows using the standalone Visual Studio build tools to compile UE4.
Change 3058337 on 2016/07/20 by Ben.Marsh
Remove EnvVarsToXML. All target platforms now determine their compile environment directly from the registry.
Change 3058348 on 2016/07/20 by Ben.Marsh
Disable optimization for all automation projects. They don't generally do anything particularly CPU intensive, and VS2015 optimizations are inhibitive to debugging.
[CL 3058822 by Ben Marsh in Main branch]
2016-07-20 20:25:02 -04:00
|
|
|
|
else if(bEscape == 0 && C == '^' && Index + 1 < CmdLine.Length && CmdLine[Index + 1] == '&')
|
|
|
|
|
|
{
|
|
|
|
|
|
// Visual studio seems to escape ampersands as if for a batch file when running UAT *without* the debugger attached (ie. ctrl-f5)
|
|
|
|
|
|
Index++;
|
|
|
|
|
|
C = CmdLine[Index];
|
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
else if (C == '\"')
|
|
|
|
|
|
{
|
2016-01-27 12:09:53 -05:00
|
|
|
|
bCanAppend = bEscape > 0;
|
|
|
|
|
|
if (bEscape == 0)
|
2014-03-14 14:13:41 -04:00
|
|
|
|
{
|
|
|
|
|
|
bQuote = !bQuote;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
// Consume the scape character
|
2016-01-27 12:09:53 -05:00
|
|
|
|
bEscape--;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (bCanAppend)
|
|
|
|
|
|
{
|
2016-01-27 12:09:53 -05:00
|
|
|
|
if (bEscape > 0)
|
2014-03-14 14:13:41 -04:00
|
|
|
|
{
|
|
|
|
|
|
// Unused escape character.
|
2016-01-27 12:09:53 -05:00
|
|
|
|
Arg.Append('\\', bEscape);
|
|
|
|
|
|
bEscape = 0;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
}
|
|
|
|
|
|
Arg.Append(C);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (Arg.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Args.Add(Arg.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
// This code assumes that the first argument is the exe filename. Remove it.
|
|
|
|
|
|
Args.RemoveAt(0);
|
|
|
|
|
|
return Args.ToArray();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|