Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/AutomationUtils/BuildUtils.cs
Ben Marsh 5e75112469 Copying //UE4/Dev-Build to //UE4/Main
==========================
MAJOR FEATURES + CHANGES
==========================

Change 2828332 on 2016/01/14 by Matthew.Griffin

	Ensure that warnings from Dynamic Compilation of build.cs files are propagated up to user when compiling in Visual Studio etc.

Change 2828335 on 2016/01/14 by Matthew.Griffin

	Renaming AddThirdParty... functions to AddEngineThirdParty... so it's clear we're talking about third party libraries within the engine directory. This removes another couple of RunningRocket checks and uses the IsMonolithic property now.

Change 2831365 on 2016/01/16 by Ben.Marsh

	Add a UAT command to remove any temp storage directories older than a specified length of time, and disable the GUBP node to do so when running with -NewEC. Better to set this up as a separate scheduled task for each temp storage folder we have, rather than run it as part of GUBP builds above a certain size.

Change 2832166 on 2016/01/18 by Ben.Marsh

	Make INI file parsing much more tolerant to errors, because it prevents the build system from starting up. Now outputs warnings rather than throwing exceptions.

Change 2835725 on 2016/01/20 by Matthew.Griffin

	Removed more uses of RunningRocket functions

	Switch Linux staging check to see if required files exist until switched to using receipts
	Always stage CrashReporter for Linux
	Mac and Linux will not use Compile Lean And Mean when generating project files
	Allow normal DynamicCompilation check to occur in binary builds
	Allow XMPP dependency on WebRTC now that it's publically distributed

Change 2835864 on 2016/01/20 by Matthew.Griffin

	Made sure -rocket is passed when generating project files as this has to work from UnrealVersionSelector with every version of the Engine we've released.
	Also tidied up some arguments that are set in UVS and never used.

Change 2839932 on 2016/01/22 by Matthew.Griffin

	Removed last uses of RunningRocket from UnrealBuildTool

	Changed Mac Build.sh so that it doesn't try to build UBT so that it can be used in installed builds the same way as windows.
	Combined code doing very similar things for single games and rocket projects.
	Removed check on whether to add client and server targets in Rocket as we don't distribute the .target.cs files.
	Removed RunningRocket function and the code checking for -rocket on the command line

Change 2846971 on 2016/01/28 by Matthew.Griffin

	Replaced RunningRocket with IsEngineInstalled for all Engine programs that won't need to be built.

Change 2853879 on 2016/02/03 by Matthew.Griffin

	Added UnrealLightmass to list of programs to build when Build Solution is used and Editor configuration is selected

	#jira UE-25666

#lockdown Nick.Penwarden

[CL 2854567 by Ben Marsh in Main branch]
2016-02-03 15:40:40 -05:00

119 lines
5.2 KiB
C#

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace AutomationTool
{
public partial class CommandUtils
{
/// <summary>
/// Runs msbuild.exe with the specified arguments. Automatically creates a logfile. When
/// no LogName is specified, the executable name is used as logfile base name.
/// </summary>
/// <param name="Env">BuildEnvironment to use.</param>
/// <param name="Project">Path to the project to build.</param>
/// <param name="Arguments">Arguments to pass to msbuild.exe.</param>
/// <param name="LogName">Optional logfile name.</param>
public static void MsBuild(CommandEnvironment Env, string Project, string Arguments, string LogName)
{
if (String.IsNullOrEmpty(Env.MsBuildExe))
{
throw new AutomationException("Unable to find msbuild.exe at: \"{0}\"", Env.MsBuildExe);
}
if (!FileExists(Project))
{
throw new AutomationException("Project {0} does not exist!", Project);
}
var RunArguments = MakePathSafeToUseWithCommandLine(Project);
if (!String.IsNullOrEmpty(Arguments))
{
RunArguments += " " + Arguments;
}
RunAndLog(Env, Env.MsBuildExe, RunArguments, LogName);
}
/// <summary>
/// Builds a Visual Studio solution with MsDevEnv. Automatically creates a logfile. When
/// no LogName is specified, the executable name is used as logfile base name.
/// </summary>
/// <param name="Env">BuildEnvironment to use.</param>
/// <param name="SolutionFile">Path to the solution file</param>
/// <param name="BuildConfig">Configuration to build.</param>
/// <param name="LogName">Optional logfile name.</param>
public static void BuildSolution(CommandEnvironment Env, string SolutionFile, string BuildConfig = "Development", string LogName = null)
{
if (!FileExists(SolutionFile))
{
throw new AutomationException(String.Format("Unabled to build Solution {0}. Solution file not found.", SolutionFile));
}
if (String.IsNullOrEmpty(Env.MsDevExe))
{
throw new AutomationException(String.Format("Unabled to build Solution {0}. devenv.com not found.", SolutionFile));
}
string CmdLine = String.Format("\"{0}\" /build \"{1}\"", SolutionFile, BuildConfig);
using(TelemetryStopwatch CompileStopwatch = new TelemetryStopwatch("Compile.{0}.{1}.{2}", Path.GetFileName(SolutionFile), "WinC#", BuildConfig))
{
RunAndLog(Env, Env.MsDevExe, CmdLine, LogName);
}
}
/// <summary>
/// Builds a CSharp project with msbuild.exe. Automatically creates a logfile. When
/// no LogName is specified, the executable name is used as logfile base name.
/// </summary>
/// <param name="Env">BuildEnvironment to use.</param>
/// <param name="ProjectFile">Path to the project file. Must be a .csproj file.</param>
/// <param name="BuildConfig">Configuration to build.</param>
/// <param name="LogName">Optional logfile name.</param>
public static void BuildCSharpProject(CommandEnvironment Env, string ProjectFile, string BuildConfig = "Development", string LogName = null)
{
if (!ProjectFile.EndsWith(".csproj"))
{
throw new AutomationException(String.Format("Unabled to build Project {0}. Not a valid .csproj file.", ProjectFile));
}
if (!FileExists(ProjectFile))
{
throw new AutomationException(String.Format("Unabled to build Project {0}. Project file not found.", ProjectFile));
}
string CmdLine = String.Format(@"/verbosity:minimal /target:Rebuild /property:Configuration={0} /property:Platform=AnyCPU", BuildConfig);
MsBuild(Env, ProjectFile, CmdLine, LogName);
}
/// <summary>
/// returns true if this is a mac executable using some awful conventions
/// <param name="Filename">Filename</param>
/// </summary>
public static bool IsProbablyAMacOrIOSExe(string Filename)
{
return
Path.GetExtension(Filename) == ".sh" ||
Path.GetExtension(Filename) == ".command" ||
((
CommandUtils.CombinePaths(Filename).ToLower().Contains(CommandUtils.CombinePaths("Binaries", "Mac").ToLower()) ||
CommandUtils.CombinePaths(Filename).ToLower().Contains(CommandUtils.CombinePaths("Binaries", "IOS").ToLower()) ||
CommandUtils.CombinePaths(Filename).ToLower().Contains(CommandUtils.CombinePaths("Binaries", "ThirdParty").ToLower()) ||
CommandUtils.CombinePaths(Filename).ToLower().Contains(".app/Contents/MacOS".ToLower())
) && (Path.GetExtension(Filename) == "" || Path.GetExtension(Filename) == "."));
}
/// <summary>
/// Sets an executable bit for Unix executables and adds read permission for all users plus write permission for owner.
/// <param name="Filename">Filename</param>
/// </summary>
public static void FixUnixFilePermissions(string Filename)
{
string Permissions = IsProbablyAMacOrIOSExe(Filename) ? "0755" : "0644";
var Result = CommandUtils.Run("sh", string.Format("-c 'chmod {0} \"{1}\"'", Permissions, Filename.Replace("'", "'\"'\"'")), Options:ERunOptions.SpewIsVerbose);
if (Result.ExitCode != 0)
{
throw new AutomationException(String.Format("Failed to chmod \"{0}\"", Filename));
}
}
}
}