Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/BuildGraph/BuildGraph.cs
Josh Adams 61ae6f6329 Copying //UE4/Dev-Platform to //UE4/Dev-Main (Source: //UE4/Dev-Platform @ 3147796)
#lockdown Nick.Penwarden
#rb none

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

Change 2948319 on 2016/04/19 by Nick.Shin

	update zlib to v1.2.8

	part 1 of 4 - doing this in stages for tracking purposes

	#jira UEPLAT-1246  -  Update libWebsockets
	#jira UEPLAT-1221  -  update websocket library

Change 2948322 on 2016/04/19 by Nick.Shin

	update libwebsockets to v1.7.4

	part 4 of 4 - doing this in stages for tracking purposes

	#jira UEPLAT-1246  -  Update libWebsockets
	#jira UEPLAT-1221  -  update websocket library
	#jira UEPLAT-1204  -  Rebuild libwebsockets with SSL

Change 2948661 on 2016/04/19 by Nick.Shin

	keep using old zlibs until they are recompiled with the newer version

Change 2948737 on 2016/04/19 by Nick.Shin

	build warning fix

Change 2949334 on 2016/04/20 by Nick.Shin

	fix library path

	for some reason, NetworkFileSystem and HttpNetworkReplayStreaming on Mac platform needs full path - even though lib path was set...

Change 2951556 on 2016/04/21 by Nick.Shin

	static libs double checked

	#jira UE-29674 - Editor fails to open in Dev-Platform

Change 2951559 on 2016/04/21 by Nick.Shin

	static libs double checked

	forgot these files - they were in another changelist

	#jira UE-29674 - Editor fails to open in Dev-Platform

Change 2952411 on 2016/04/22 by Nick.Shin

	add win32 build targets for zlib openssl libcurl libwebsockets

	part 1 of 2: these are the C# build scripts

Change 2970016 on 2016/05/07 by Nick.Shin

	undo all of the following upgrades:
	- zlib
	- openssl
	- libcurl
	- libwebsockets

	and reset webrtc

	#jira UE-30298 - Fortnite and Orion crash on login

Change 3118163 on 2016/09/08 by Josh.Adams

	perm test 2, not a useful file at all

Change 3121142 on 2016/09/12 by Daniel.Lamb

	Attempt to fix deterministic cooking issue for particlelodlevel.
	Ensure the spawn module has had postload called on it before using.
	#test Paragon cook

Change 3121150 on 2016/09/12 by Daniel.Lamb

	Added warning logs to help track down issue UE-33453.

Change 3121201 on 2016/09/12 by Keith.Judge

	Xbox One - Replicate CL 3114357 from 4.13 branch. ESRAM clear on create fix.

Change 3121302 on 2016/09/12 by Joe.Graf

	Fixed up the IMPLEMENT_MODULE macro usage to avoid the link errors

Change 3121379 on 2016/09/12 by Dmitry.Rekman

	Linux: only link libraries that export needed symbols (UE-35720).

	- Fixes very long startup times of modular builds.
	- Includes PR #2778 by slonopotamus.

	#jira UE-35720

Change 3121383 on 2016/09/12 by Dmitry.Rekman

	Linux: added some missing _API declarations on symbols used externally.

	- Compiling editor with -fvisibility=hidden works after this fix (although running still doesn't).

Change 3121456 on 2016/09/12 by Daniel.Lamb

	Attempt to fix deterministic cooking issue for particlelodlevel.
	Ensure the spawn module has had postload called on it before using.
	#test Paragon cook

Change 3122939 on 2016/09/13 by Luke.Thatcher

	[PLATFORM] [PS4] [!] Skip orbismemdmp files in the PS4 crash handler web service.
	 - Writing these files to disk causes orbis-tm.exe to take a file lock on them, which means we can't move the crash directory to the landing zone.

Change 3123040 on 2016/09/13 by Brent.Pease

	 + Fix VS compile error by removing ENGINE_API from virtual method decls since ENGINE_API is defined for the entire class now.

Change 3123664 on 2016/09/13 by Nick.Shin

	this was originally checked into: release 4.13.1
	bringing here to dev-platform

	-- original submit comments --
	first, safari has a problem with firing off "window resized" events - causing an infinite loop of the window "resizing"

	next, retina has "bigger" size calculations going off -- so y-delta checks greater than 2 are done to prevent resize event firing off in an infinite loop

	jira UE-35363 - Huge game window when launching onto Safari 9.1.2

Change 3125282 on 2016/09/14 by Michael.Trepka

	Fixed iOS and tvOS code indexing in Xcode project

Change 3126812 on 2016/09/15 by Josh.Adams

	Merged Wolf support into Dev-Platform (hidden from almost all people still). Non-Wolf-specific changes:
	- Added Parse function to JsonObject.cs to be able to parse a string
	- Replaced some hacky post-reflection-capture functions with RHISubmitCommandsAndFlushGPU()
	- Split PLATFORM_HAS_BSD_SOCKET_FEATURE_GETADDRINFO off from PLATFORM_HAS_BSD_SOCKET_FEATURE_GETHOSTNAME
	- Converted the PS4MallocCrash class into a generic one (that Wolf is now also using)
	- Added AddGenericToInQueueOnlineThread(), useful running a delegate on Online thread instead of game thread
	- Refactored the GL shader compiler to allow Wolf to modify behavior without a lot of if WOLF checks everywhere
	- Added ability in the cross compiler to convert the global uniform arrays into named uniform buffer objects
	- Added ability for GL shader compiler to output original resources names ("VertColor" instead of "u_v[3]" or whatever)
	- Added "FORCELODGROUP" console command that will apply a StaticMesh LODGroup to selected meshes in the editor. This can batch-Simplygonify all meshes in a level. Should maybe become an editor tool.
	- Added ability for arrays of structs to specify a property to be the key. So, with LODGroups, the Name key inside the struct can be the unique key, so when you have multiple .ini files in the hierarchy overriding the same LODGroup by name, it will repalce the first with the second, instead of adding two entries with the same name. Set by @ArrayName=KeyPropertyName. Per Object Config sections need a little different handling, which uses * (see BaseDeviceProfiles.ini)
	- Added ability to change DeviceProfiles at runtime. Use "dp.override <name>". If you do it again to another one, it will reset the settings to what they were originally, before applying the second new DP. This is because the second DP may not set all settings the first one did, but we want to undo the first settings that the second doesn't contain.
	- Added FRHICommandListImmediate::IsStalled() - returns true while FRHICommandListImmediate::StallRHIThread is happening
	- Changed runtime GetFeatureLevelMaxTextureSamplers() calls to the new GetMaxTextureSamplers() which can now be handled by the platform. Renamed GetFeatureLevelMaxTextureSamplers to GetExpectedFeatureLevelMaxTextureSamplers() (only used by the shader editor) to guess at what maybe the samplers count will be - but it's not guaranteed correct.
	- Renamed a UT copy of a global function to not linker-conflict
	- Changed the OOMBackupMemoryPool to allow each platform to set how much memory to allocate. See FPlatformMemory::GetBackMemoryPoolSize(). Defaults to 0, which was the previous behavior with the now removed FPlatformMemory::SupportBackupMemoryPool(), which was only true in Windows and PS4.
	- Added an OOM delegate so other systems can get a callback after OOM occurs (after deleting the backup memory pool if it exists)
	- Changed SetQualityLevels() (in Scalability.cpp) to no longer change the SetBy priority when setting CVars, and now keeps the SetBy the same as it was. Helps with conflicts between game settings and device profiles. See SetWithCurrentPriority()
	- Added GetRenderingThreadPriority to FPlatformAffinity to allow a platform override priority. Not sure about this one, so may remove it, or maybe add more priorities for all the threads?
	- Added a new file into the ini hierarchy to begin fixing the Engine/Base -> Project/Default -> Engine/Platform -> Project/Platform mess. We now have Engine/Base -> Engine/BasePlatform -> Project/Default -> Engine/Platform -> Project/Platform. However, Engine/Platform will soonm be deprecated as we move things over to Engine/BasePlatform, that are safe to move.

Change 3126842 on 2016/09/15 by Michael.Trepka

	Make SAssertPicker's search box the default widget to focus on activate so that it doesn't get deactivated on Mac, where we get the window activation event in a tick after SAssertPicker creation.

Change 3126956 on 2016/09/15 by Michael.Trepka

	Added support for compiling Vulkan shaders for Android on Mac

Change 3127206 on 2016/09/15 by Michael.Trepka

	PR #2604: Remove some warnings. (Contributed by reapazor)

Change 3127324 on 2016/09/15 by Michael.Trepka

	Allow third party dylibs on Mac to be loaded from plugin subfolders

Change 3127924 on 2016/09/16 by Josh.Adams

	Merging //UE4/Dev-Main to Dev-Platform (//UE4/Dev-Platform)

Change 3128369 on 2016/09/16 by Nick.Shin

	zlib 1.2.8

	headers and lib updates

	part of [ zlib openssl libcurl libwebsockets webrtc ] updates

Change 3128377 on 2016/09/16 by Nick.Shin

	openssl 1_0_2h

	headers and lib updates

	part of [ zlib openssl libcurl libwebsockets webrtc ] updates

Change 3128383 on 2016/09/16 by Nick.Shin

	libcurl 7_48_0

	headers and lib updates

	part of [ zlib openssl libcurl libwebsockets webrtc ] updates

Change 3128384 on 2016/09/16 by Nick.Shin

	libwebsockets 1.7.4

	headers and lib updates

	part of [ zlib openssl libcurl libwebsockets webrtc ] updates

Change 3128464 on 2016/09/16 by Nick.Shin

	webRTC rev.12643

	NOTE: VS2015
	- only Win64 is available
	- Win32 versions is crashing (e.g. EpicGamesLauncher) at the moment

	NOTE: VS2013
	- not tested (i'm working on getting a VS2013 pro license) - so not checking in with this changelist
	- also, VS2013 is no longer supported by webRTC build scripts, so it will be old anyways

	FUTURE NOTE:
	- will continue to try to get VS2015 Win32 functional
	- and am working on trying to get VS2013 tested

	headers and lib updates

	part of [ zlib openssl libcurl libwebsockets webrtc ] updates

Change 3128500 on 2016/09/16 by Nick.Shin

	zlib 1.2.8 - OSX

	headers and lib updates

	part of [ zlib openssl libcurl libwebsockets webrtc ] updates

Change 3128504 on 2016/09/16 by Nick.Shin

	openssl 1_0_2h - OSX

	headers and lib updates

	part of [ zlib openssl libcurl libwebsockets webrtc ] updates

Change 3128506 on 2016/09/16 by Nick.Shin

	libcurl 7_48_0 - OSX

	headers and lib updates

	part of [ zlib openssl libcurl libwebsockets webrtc ] updates

Change 3128508 on 2016/09/16 by Nick.Shin

	libwebsockets 1.7.4 - OSX

	headers and lib updates

	part of [ zlib openssl libcurl libwebsockets webrtc ] updates

Change 3128513 on 2016/09/16 by Nick.Shin

	webRTC rev.12643 - OSX

	headers and lib updates

	part of [ zlib openssl libcurl libwebsockets webrtc ] updates

Change 3128602 on 2016/09/16 by Nick.Shin

	webRTC rev.9862 - Win64 VS2013

	NOTE:
	- not tested (i'm working on getting a VS2013 pro license)
	- checking in for testing purposes

	WARNING:
	- VS2013 is no longer supported by webRTC latest

	headers and lib updates

	part of [ zlib openssl libcurl libwebsockets webrtc ] updates

Change 3128605 on 2016/09/16 by Nick.Shin

	re-enabling updated ThirdParySoftware libs:

	- zlib (v.1.2.8)
	- openssl (1.0.2h)
	- libcurl (7_48_0)
	- libwebsocket (v.1.7.4)
	- webRTC (rev.12643)

	to the codereviewers, in my attempt to ensure the older libs are still used for console, mobile and linux -- please refer to this checkin if i broke the build...

Change 3128651 on 2016/09/16 by Nick.Shin

	fix Win32 build error from CL: #3128605

Change 3128704 on 2016/09/16 by Nick.Shin

	fix Win32 build error from CL: #3128605 - this time actually compiling it...

Change 3128825 on 2016/09/16 by Dmitry.Rekman

	Linux: proper fix for too slow startup times (UE-35967).

	- Pull request #2793 by slonopotamus.
	- Now without stripping dependencies on libraries specified before.
	- Contains a work around for ld bug <2.25.

Change 3128972 on 2016/09/16 by Nick.Shin

	fix to local build error.

Change 3129283 on 2016/09/16 by Brent.Pease

	 + Add Android local notification support based on existing system used for iOS
	 + Initial API has been added for cancelling local notifications but the actual platform implementation will be done in the next release

Change 3129494 on 2016/09/17 by Nick.Shin

	fix CIS build errors

Change 3129503 on 2016/09/17 by Dmitry.Rekman

	Fix Linux build (case sensitivity issue).

Change 3129514 on 2016/09/17 by Nick.Shin

	fix CIS build errors for consoles - missing zlib include path

	special thanks to Dmitry.Rekman for pointing me in the right direction

Change 3129647 on 2016/09/17 by Dmitry.Rekman

	Linux: fix non-unity build.

Change 3131043 on 2016/09/19 by Nick.Shin

	archiving build instructions/steps when building:

	- zlib (v.1.2.8)
	win: #3128369
	osx: #3128500

	- openssl (1.0.2h)
	win: #3128377
	osx: #3128504

	- libcurl (7_48_0)
	win: #3128383
	osx: #3128506

	- libwebsocket (v.1.7.4)
	win: #3128384
	osx: #3128508

	- webRTC
	win: #3128464 (rev.12643 for vs2015) + 3128602 (rev:9862 for vs2013) -- NOTE: win32 is WiP
	osx: #3128513

Change 3132801 on 2016/09/20 by Dmitry.Rekman

	Linux: support specifying default OpenGL version via configs (UE-34777).

	- The first targeted RHI is going to be used.

Change 3132905 on 2016/09/20 by Josh.Adams

	- Fixed up some paths with the WolfPlat rename

Change 3133148 on 2016/09/20 by Josh.Adams

	- Only show UT EULA if PLATFORM_DESKTOP

Change 3133152 on 2016/09/20 by Josh.Adams

	- Beginning support for applets. Disabled unless you have a special SDK with applet support.

Change 3133169 on 2016/09/20 by Josh.Adams

	- Fixed issue with Wolf access but no SDK installed

Change 3133344 on 2016/09/20 by Daniel.Lamb

	Fixed issue with Iterative cooking not detecting changes to ini files which are loaded using LoadLocalFile.
	Added new flag to limit number of concurrent shader compiles.
	#test Cook QAGame, Cook Paragon

Change 3133345 on 2016/09/20 by Daniel.Lamb

	FRedirectCollector collects string asset references all the time when running the editor.
	#test Cook paragon cook QAGame.

Change 3133852 on 2016/09/21 by Luke.Thatcher

	[PLATFORM] [PS4] [^] Performing merge between 3.508.201 LCUE files in CarefullyRedist and Dev-Platform to populate integration history. No files have actually changed in this CL, only Perforce metadata is updated.

Change 3133875 on 2016/09/21 by Luke.Thatcher

	[PLATFORM] [PS4] [^] Performing merge between 3.508.201 LCUE files in CarefullyRedist and Dev-Platform to populate integration history. No files have actually changed in this CL, only Perforce metadata is updated. (Attempt 2)

Change 3134403 on 2016/09/21 by Jonathan.Fitzpatrick

	Per PS4 documentation, app_type requires the alternate spelling of 'upgradeable', 'upgradable'.

Change 3134544 on 2016/09/21 by Josh.Adams

	- Reduced UT textures for Wolf

Change 3134915 on 2016/09/21 by Jonathan.Fitzpatrick

	FPS4Time::SystemTime now calculates the local machine time, instead of UTC.

	#jira UE-35170

Change 3135036 on 2016/09/21 by Michael.Trepka

	Quit the UE4EditorServices app when quitting the Launcher if it was the launcher that spawned the services process

Change 3135142 on 2016/09/21 by Jonathan.Fitzpatrick

	GetBackMemoryPoolSize returned bool on PS4 by accident, should be uint32

Change 3135292 on 2016/09/21 by Jeff.Campeau

	Change include order to favor the XDK edition specific headers where available.

Change 3136414 on 2016/09/22 by Josh.Adams

	- Fixed a checkf() that had the case reversed
	#jira ue-36311

Change 3137082 on 2016/09/22 by Dmitry.Rekman

	Added support for Linux installed builds to 4.14

Change 3137220 on 2016/09/22 by Dmitry.Rekman

	Linux: do not rebuild hlslcc on each setup.

	- Now that hlslcc is set to use bundled libc++ there should be no STL binary compatibility conflicts between the engine and hlslcc binary.

Change 3137227 on 2016/09/22 by Josh.Adams

	Merging //UE4/Dev-Main to Dev-Platform (//UE4/Dev-Platform)

Change 3137259 on 2016/09/22 by Dmitry.Rekman

	Linux installed build: fix CIS (missed one .csproj)

Change 3137290 on 2016/09/22 by Dmitry.Rekman

	Linux installed builds: fix for the resulting directory.

Change 3137291 on 2016/09/22 by Chris.Babcock

	Restore texture filtering mode properly when movie played on Android
	#jira UE-36342
	#ue4
	#android

Change 3137376 on 2016/09/22 by Dmitry.Rekman

	Linux: re-enabled crash handler stack smash protection.

	- Race condition in FRunnableThreadPThread has been previously fixed.

Change 3138498 on 2016/09/23 by Dmitry.Rekman

	Linux: add missed package for installed builds.

	- mono-devel package for resgen2.

Change 3138523 on 2016/09/23 by Dmitry.Rekman

	Linux: Update hlslcc now that we're not rebuilding it each time.

Change 3138658 on 2016/09/23 by Josh.Adams

	- Moved UT's Social Plugin into NotForLicensees

Change 3139042 on 2016/09/23 by Dmitry.Rekman

	Linux: more robust check of installed packages.

	- Also added mono-devel to the list of packages installed on 14.04.

Change 3139674 on 2016/09/26 by Dmitry.Rekman

	Fix crash when editing widget blueprints (UE-35185).

	- Caused by name collision due to copy/pasted code; aliased classes diverged and this resulted in all kinds of weird memory stomping.
	- Renamed the class and also applied the same workaround (removing static) to prevent likely crashes on exit as happened with the original class (see UE-30795).

Change 3140203 on 2016/09/26 by Josh.Adams

	- Wolf Fix for SHIPPING

Change 3140206 on 2016/09/26 by Josh.Adams

	- NEX work, still in progress

Change 3140276 on 2016/09/26 by Josh.Adams

	- Fixed Wolf compile error

Change 3140485 on 2016/09/26 by Josh.Adams

	Merging //UE4/Dev-Main to Dev-Platform (//UE4/Dev-Platform)

Change 3140570 on 2016/09/26 by Dmitry.Rekman

	SDL2: Delete obsolete files.

	- We now have local changes to SDL2, so this tarball is no longer accurate and just takes unnecessary space.

Change 3140577 on 2016/09/26 by Dmitry.Rekman

	Fix CudaTest monolithic build.

	- Not the best fix, the better fix is to build against bundled libc++.

Change 3141184 on 2016/09/27 by Keith.Judge

	Add FXboxOneApplication::GetXboxOneApplication to fix a save/load game assert.

	#jira UE-35973

Change 3141623 on 2016/09/27 by Chris.Babcock

	Support hiding virtual keyboard on Android
	#jira UE-34201
	#ue4
	#android

Change 3141887 on 2016/09/27 by Joe.Graf

	Added support for additional plugin directories that are specified by the .uproject file
	New plugin wizard adds to the additional plugin directories if the user specifies a directory outside of Engine/Plugins or Game/Plugins

Change 3141916 on 2016/09/27 by Josh.Adams

	- Worked around compile issues (at least with Wolf UT). This is well documented in a Jira (UE-29925)

Change 3141926 on 2016/09/27 by Josh.Adams

	- Support for skipping Wolf user selector (-nologinui)

Change 3141938 on 2016/09/27 by Chris.Babcock

	Allow Android media player to seek past 999ms (contributed by rcywongaa)
	#jira UE-36453
	#PR #2797
	#ue4
	#android

Change 3142207 on 2016/09/27 by Josh.Adams

	Merging //UE4/Dev-Main to Dev-Platform (//UE4/Dev-Platform)

Change 3142219 on 2016/09/27 by Josh.Adams

	- Wolf PhysX 3.4 libs and includes

Change 3142220 on 2016/09/27 by Josh.Adams

	- File that had to be fixed up after main merge (missed adding it to the huge integrate CL)

Change 3142314 on 2016/09/27 by Chase.McAllister

	#jira UE-35011 fixes to some assets to remove redundancies/output log spam

Change 3142510 on 2016/09/27 by Daniel.Lamb

	Fixed up resave lightmaps commandlet so that world transforms don't get applied twice.
	#jira UE-35942

Change 3142650 on 2016/09/27 by Chris.Babcock

	Android support for Linux by yaakuro
	- requires CodeWorks for Android Linux installed and OpenJDK 1.8
	- need to set Android SDK paths manually in Project Settings
	#jira UE-32752
	#jira UE-32753
	#PR #2564
	#PR #2565
	#ue4
	#android
	#linux

Change 3142802 on 2016/09/27 by Dmitry.Rekman

	Upgrade to SDL 2.0.5-ish (still technically 2.0.4).

	- Upstream revision 10374:dccf51aee79b.
	- Merged all our changes hopefully.

Change 3143075 on 2016/09/28 by Luke.Thatcher

	[RENDERING] [~] Add check to FBatchedElements::AddSprite to catch null textures. If the texture is null here, we will crash later in the RHI. At least now we'll get the callstack of the code adding the null textured sprite, since I don't have a repro.
	#jira UE-33077

Change 3143219 on 2016/09/28 by Daniel.Lamb

	Added new is compiling function which tells you if it's really compiling instead of lying.
	If def out additional logging for debugging shader compilation issue for 4.14 release.

Change 3143428 on 2016/09/28 by Luke.Thatcher

	[PLATFORM] [PS4] [+] Use PS4 SDK 4.008.061

Change 3143488 on 2016/09/28 by Daniel.Lamb

	Changed defaults for skip cooking editor content to true.

Change 3143526 on 2016/09/28 by Daniel.Lamb

	Increased the concurrent shader compile limit while in the cooker.
	#test Cook paragon

Change 3143874 on 2016/09/28 by Chris.Babcock

	Read Android environment variables from .bashrc on Linux
	#jira UE-36565
	#ue4
	#android
	#linux

Change 3143911 on 2016/09/28 by Dmitry.Rekman

	Fix SDL EGL API binding (UE-18979).

	- Contains PR #1398 by x414e54.
	- Also fixes offscreen backend that needed to provide a global mouse state after the SDL upgrade.

Change 3143929 on 2016/09/28 by Daniel.Lamb

	Removed some more temporary logging.
	#test Cook paragon

Change 3143959 on 2016/09/28 by Jeff.Campeau

	Media Player for Xbox One

Change 3143997 on 2016/09/28 by Dmitry.Rekman

	Linux: faster linking in Debug.

	- Do not apply --as-needed to Debug build since taking a hit of several tens of seconds on startup is better than linking for ~4 more minutes when iterating.

Change 3144004 on 2016/09/28 by Dmitry.Rekman

	Linux: make SCW dump core on crash in debug builds.

	- If the editor (not SCW itself) is built in Debug, make SCW dump cores if they ever crash. This makes it debug easier (at the risk of running of disk space).

Change 3144007 on 2016/09/28 by Dmitry.Rekman

	Linux: Allow equals character in command line parameter value (UE-26406).

	- PR #2019 by bozzaro.
	- Allows passing parameters like -Switch=Key=Value.

Change 3144042 on 2016/09/28 by Jeff.Campeau

	Add tag for DX12 support being experimental in target settings.

	#jira UE-36150

Change 3144068 on 2016/09/28 by Dmitry.Rekman

	Linux: enable using xgConsole in UAT (UE-28096).

	- PR #2144 by bozzaro.
	- Picks correct xgConsole binary.
	- Allegedly fixes crash in CombineXGEItemFile on mono.

Change 3144120 on 2016/09/28 by Michael.Trepka

	Copying //Tasks/UE4/Dev-HighDPI/... to //UE4/Dev-Platform/...

Change 3144172 on 2016/09/28 by Chris.Babcock

	Add libpng 1.5.27 for Android
	#jira UE-36573
	#ue4
	#android

Change 3144318 on 2016/09/28 by Chris.Babcock

	Correct logic for checking .bashrc on Linux
	#ue4
	#android

Change 3144331 on 2016/09/28 by Dmitry.Rekman

	Linux: repair ARM server builds.

	- Also: print info about C++ library being used and allow the override via environment variable UE4_LINUX_USE_LIBCXX (either 0 or 1).

Change 3144354 on 2016/09/28 by Josh.Adams

	Merging //UE4/Dev-Main to Dev-Platform (//UE4/Dev-Platform)
	this is intermediate, not fully working

Change 3144368 on 2016/09/28 by Josh.Adams

	- Moved the new Social files into NFL

Change 3144395 on 2016/09/28 by Chris.Babcock

	Add missing functions for AndroidWebBrowserWindow
	#ue4
	#android

Change 3144417 on 2016/09/28 by Josh.Adams

	- Probable fix for FWebBrowserWindow missing virtuals

Change 3144438 on 2016/09/28 by Jeff.Campeau

	XDK updated to 160802

Change 3144569 on 2016/09/29 by Dmitry.Rekman

	Linux: allow a selectable clock source (UE-36564).

	- The engine will now select the best performing clock on start instead of hard-coding CLOCK_REALTIME. This will happen as part of global initialization before main() to prevent clock skew.
	- Also fixes a problem of the engine not being able to start on Windows 10 since previously hard-coded clock id was not supported there.

	#tests Compiled and ran a few targets (including non-monolithic). Tried bogus clock sources. Haven't actually tried on Win10 (don't have a machine atm).

Change 3145108 on 2016/09/29 by Joe.Graf

	Fixed cases where path relative external plugin paths would generate the wrong path when running Unreal Header Tool (and probably other tools)

Change 3145245 on 2016/09/29 by Joe.Graf

	#wolf
	Checking in removal of plugin use on Win64 per Josh's request

Change 3145514 on 2016/09/29 by Will.Fissler

	Updated Mac Info.plist files to disable high DPI on macOS 10.12

Change 3145538 on 2016/09/29 by Josh.Adams

	- Worked around a physics task graph issue with using the new lock free stuff on Wolf, joining PS4 and XboxOne. Wolf was crashing on some boots.

Change 3145540 on 2016/09/29 by Josh.Adams

	- Fix for checking some Wolf dev tool installation existence
	- Fix for various Wolf build issues
	- Fix for Wolf devices not showing up in Launch on

Change 3145542 on 2016/09/29 by Josh.Adams

	- Pulled over Wolf changes from Wolf branch into Dev-Platform

Change 3145572 on 2016/09/29 by Josh.Adams

	- Cleaned up Wolf SDK error logs which really messed up GenProjectFiles for some class of people.
	#jira UE-36591

Change 3145769 on 2016/09/29 by Chris.Babcock

	Remove duplicate platforms from deploy list in UFE
	#jira UE-36636
	#ue4

Change 3146061 on 2016/09/29 by Chris.Babcock

	Linux: be less spammy in log when launching external procs
	#jira UE-36638
	#ue4
	#linux

Change 3146208 on 2016/09/29 by Dmitry.Rekman

	Linux: fix PhysX crash (UE-36613).

	- PX_RESTRICT was unwarrantedly applied to memMove, allowing clang to replace the memmove() call to memcpy() at -O2 and above.
	- This caused PxArray::remove() to duplicate the elements of its array (in POD case) and this opened doors to all kinds of fun.

	#jira UE-36613

Change 3146476 on 2016/09/30 by Josh.Adams

	- Moved a UBT log that could pollute QA logs with Wolf secrets to Verbose

Change 3146554 on 2016/09/30 by Josh.Adams

	- Removed another wolf secret log

Change 3146626 on 2016/09/30 by Josh.Adams

	Merging //UE4/Dev-Main to Dev-Platform (//UE4/Dev-Platform)

Change 3146712 on 2016/09/30 by Josh.Adams

	- Fixed case for building Android on Linux
	#jira #UE-36652

Change 3146844 on 2016/09/30 by Josh.Adams

	- Removed ES2 shader compiling from TVOS, and force Metal compiling
	#jira UE-36306

Change 3146865 on 2016/09/30 by Daniel.Lamb

	Removed temp logging for materials
	#test Launch on paragon

Change 3146874 on 2016/09/30 by Dmitry.Rekman

	Linux: add rpath for libTextureConverter.so (UE-36620).

Change 3147030 on 2016/09/30 by Josh.Adams

	- Version check workaround for IOS9.3/TVOS9.2 defining __IPHONE_10_0 which breaks our IOS10 code checks
	#jira UE-36623

Change 3147151 on 2016/09/30 by Josh.Adams

	- Fixed zlib.build.cs for XboxOne, which came in from another branch without an include path, yet somehow main is compiling?

Change 3147621 on 2016/09/30 by Michael.Trepka

	Fix for setting up RPATHs for third party dylibs for packaged code-based games on Mac

Change 3147712 on 2016/09/30 by Josh.Adams

	- Fixed metal crash StrategyGame crash. Recent code was checking IsES2Platform for HDR decoding in scene capture, and Metal hasn't been IsES2 since may. Changed to IsMobilePlatform.
	#jira UE-36225

Change 3147725 on 2016/09/30 by Josh.Adams

	- Fixed yet another Wolf log for people with Wolf access but no SDK

[CL 3147801 by Josh Adams in Main branch]
2016-09-30 21:21:09 -04:00

937 lines
36 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnrealBuildTool;
using BuildGraph;
using System.Reflection;
using System.Collections;
using System.IO;
using System.Xml;
namespace AutomationTool
{
/// <summary>
/// Tool to execute build automation scripts for UE4 projects, which can be run locally or in parallel across a build farm (assuming synchronization and resource allocation implemented by a separate system).
///
/// Build graphs are declared using an XML script using syntax similar to MSBuild, ANT or NAnt, and consist of the following components:
///
/// - Tasks: Building blocks which can be executed as part of the build process. Many predefined tasks are provided ('Cook', 'Compile', 'Copy', 'Stage', 'Log', 'PakFile', etc...), and additional tasks may be
/// added be declaring classes derived from AutomationTool.CustomTask in other UAT modules.
/// - Nodes: A named sequence of tasks which are executed in order to produce outputs. Nodes may have dependencies on other nodes for their outputs before they can be executed. Declared with the 'Node' element.
/// - Agents: A machine which can execute a sequence of nodes, if running as part of a build system. Has no effect when building locally. Declared with the 'Agent' element.
/// - Triggers: Container for agents which should only be executed when explicitly triggered (using the -Trigger=... or -SkipTriggers command line argument). Declared with the 'Trigger' element.
/// - Notifiers: Specifies email recipients for failures in one or more nodes, whether they should receive notifications on warnings, and so on.
///
/// Scripts may set properties with the &lt;Property Name="Foo" Value="Bar"/&gt; syntax. Properties referenced with the $(Property Name) notation are valid within all strings, and will be expanded as macros when the
/// script is read. If a property name is not set explicitly, it defaults to the contents of an environment variable with the same name. Properties may be sourced from environment variables or the command line using
/// the &lt;EnvVar&gt; and &lt;Option&gt; elements respectively.
///
/// Any elements can be conditionally defined via the "If" attribute. A full grammar for conditions is written up in Condition.cs.
///
/// File manipulation is done using wildcards and tags. Any attribute that accepts a list of files may consist of: a Perforce-style wildcard (matching any number of "...", "*" and "?" patterns in any location), a
/// full path name, or a reference to a tagged collection of files, denoted by prefixing with a '#' character. Files may be added to a tag set using the &lt;Tag&gt; Task, which also allows performing set union/difference
/// style operations. Each node can declare multiple outputs in the form of a list of named tags, which other nodes can then depend on.
///
/// Build graphs may be executed in parallel as part build system. To do so, the initial graph configuration is generated by running with the -Export=... argument (producing a JSON file listing the nodes
/// and dependencies to execute). Each participating agent should be synced to the same changelist, and UAT should be re-run with the appropriate -Node=... argument. Outputs from different nodes are transferred between
/// agents via shared storage, typically a network share, the path to which can be specified on the command line using the -SharedStorageDir=... argument. Note that the allocation of machines, and coordination between
/// them, is assumed to be managed by an external system based on the contents of the script generated by -Export=....
///
/// A schema for the known set of tasks can be generated by running UAT with the -Schema=... option. Generating a schema and referencing it from a BuildGraph script allows Visual Studio to validate and auto-complete
/// elements as you type.
/// </summary>
[Help("Tool for creating extensible build processes in UE4 which can be run locally or in parallel across a build farm.")]
[Help("Script=<FileName>", "Path to the script describing the graph")]
[Help("Target=<Name>", "Name of the node or output tag to be built")]
[Help("Schema=<FileName>", "Generate a schema describing valid script documents, including all the known tasks")]
[Help("Set:<Property>=<Value>", "Sets a named property to the given value")]
[Help("Clean", "Cleans all cached state of completed build nodes before running")]
[Help("CleanNode=<Name>[+<Name>...]", "Cleans just the given nodes before running")]
[Help("ListOnly", "Shows the contents of the preprocessed graph, but does not execute it")]
[Help("ShowDeps", "Show node dependencies in the graph output")]
[Help("ShowNotifications", "Show notifications that will be sent for each node in the output")]
[Help("Trigger=<Name>", "Executes only nodes behind the given trigger")]
[Help("SkipTrigger=<Name>[+<Name>...]", "Skips the given triggers, including all the nodes behind them in the graph")]
[Help("SkipTriggers", "Skips all triggers")]
[Help("TokenSignature=<Name>", "Specifies the signature identifying the current job, to be written to tokens for nodes that require them. Tokens are ignored if this parameter is not specified.")]
[Help("SkipTargetsWithoutTokens", "Excludes targets which we can't acquire tokens for, rather than failing")]
[Help("Preprocess=<FileName>", "Writes the preprocessed graph to the given file")]
[Help("Export=<FileName>", "Exports a JSON file containing the preprocessed build graph, for use as part of a build system")]
[Help("PublicTasksOnly", "Only include built-in tasks in the schema, excluding any other UAT modules")]
[Help("SharedStorageDir=<DirName>", "Sets the directory to use to transfer build products between agents in a build farm")]
[Help("SingleNode=<Name>", "Run only the given node. Intended for use on a build system after running with -Export.")]
[Help("WriteToSharedStorage", "Allow writing to shared storage. If not set, but -SharedStorageDir is specified, build products will read but not written")]
public class BuildGraph : BuildCommand
{
/// <summary>
/// Main entry point for the BuildGraph command
/// </summary>
public override ExitCode Execute()
{
// Parse the command line parameters
string ScriptFileName = ParseParamValue("Script", null);
string TargetNames = ParseParamValue("Target", null);
string DocumentationFileName = ParseParamValue("Documentation", null);
string SchemaFileName = ParseParamValue("Schema", null);
string ExportFileName = ParseParamValue("Export", null);
string PreprocessedFileName = ParseParamValue("Preprocess", null);
string SharedStorageDir = ParseParamValue("SharedStorageDir", null);
string SingleNodeName = ParseParamValue("SingleNode", null);
string TriggerName = ParseParamValue("Trigger", null);
string[] SkipTriggerNames = ParseParamValue("SkipTrigger", "").Split(new char[]{ '+', ';' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
bool bSkipTriggers = ParseParam("SkipTriggers");
string TokenSignature = ParseParamValue("TokenSignature", null);
bool bSkipTargetsWithoutTokens = ParseParam("SkipTargetsWithoutTokens");
bool bClearHistory = ParseParam("Clean") || ParseParam("ClearHistory");
bool bListOnly = ParseParam("ListOnly");
bool bWriteToSharedStorage = ParseParam("WriteToSharedStorage") || CommandUtils.IsBuildMachine;
bool bPublicTasksOnly = ParseParam("PublicTasksOnly");
string ReportName = ParseParamValue("ReportName", null);
GraphPrintOptions PrintOptions = GraphPrintOptions.ShowCommandLineOptions;
if(ParseParam("ShowDeps"))
{
PrintOptions |= GraphPrintOptions.ShowDependencies;
}
if(ParseParam("ShowNotifications"))
{
PrintOptions |= GraphPrintOptions.ShowNotifications;
}
// Parse any specific nodes to clean
List<string> CleanNodes = new List<string>();
foreach(string NodeList in ParseParamValues("CleanNode"))
{
foreach(string NodeName in NodeList.Split('+', ';'))
{
CleanNodes.Add(NodeName);
}
}
// Set up the standard properties which build scripts might need
Dictionary<string, string> DefaultProperties = new Dictionary<string,string>(StringComparer.InvariantCultureIgnoreCase);
DefaultProperties["Branch"] = P4Enabled ? P4Env.BuildRootP4 : "Unknown";
DefaultProperties["EscapedBranch"] = P4Enabled ? P4Env.BuildRootEscaped : "Unknown";
DefaultProperties["Change"] = P4Enabled ? P4Env.Changelist.ToString() : "0";
DefaultProperties["CodeChange"] = P4Enabled ? P4Env.CodeChangelist.ToString() : "0";
DefaultProperties["RootDir"] = CommandUtils.RootDirectory.FullName;
DefaultProperties["IsBuildMachine"] = IsBuildMachine ? "true" : "false";
DefaultProperties["HostPlatform"] = HostPlatform.Current.HostEditorPlatform.ToString();
// Attempt to read existing Build Version information
BuildVersion Version;
if (BuildVersion.TryRead(FileReference.Combine(CommandUtils.RootDirectory, "Engine", "Build", "Build.version").FullName, out Version))
{
DefaultProperties["EngineMajorVersion"] = Version.MajorVersion.ToString();
DefaultProperties["EngineMinorVersion"] = Version.MinorVersion.ToString();
DefaultProperties["EnginePatchVersion"] = Version.PatchVersion.ToString();
}
// Add any additional custom arguments from the command line (of the form -Set:X=Y)
Dictionary<string, string> Arguments = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
foreach (string Param in Params)
{
const string Prefix = "set:";
if(Param.StartsWith(Prefix, StringComparison.InvariantCultureIgnoreCase))
{
int EqualsIdx = Param.IndexOf('=');
if(EqualsIdx >= 0)
{
Arguments[Param.Substring(Prefix.Length, EqualsIdx - Prefix.Length)] = Param.Substring(EqualsIdx + 1);
}
else
{
LogWarning("Missing value for '{0}'", Param.Substring(Prefix.Length));
}
}
}
// Find all the tasks from the loaded assemblies
Dictionary<string, ScriptTask> NameToTask = new Dictionary<string,ScriptTask>();
if(!FindAvailableTasks(NameToTask, bPublicTasksOnly))
{
return ExitCode.Error_Unknown;
}
// Generate documentation
if(DocumentationFileName != null)
{
GenerateDocumentation(NameToTask, new FileReference(DocumentationFileName));
return ExitCode.Success;
}
// Create a schema for the given tasks
ScriptSchema Schema = new ScriptSchema(NameToTask);
if(SchemaFileName != null)
{
FileReference FullSchemaFileName = new FileReference(SchemaFileName);
Log("Writing schema to {0}...", FullSchemaFileName.FullName);
Schema.Export(FullSchemaFileName);
if(ScriptFileName == null)
{
return ExitCode.Success;
}
}
// Check there was a script specified
if(ScriptFileName == null)
{
LogError("Missing -Script= parameter for BuildGraph");
return ExitCode.Error_Unknown;
}
// Read the script from disk
Graph Graph;
if(!ScriptReader.TryRead(new FileReference(ScriptFileName), Arguments, DefaultProperties, Schema, out Graph))
{
return ExitCode.Error_Unknown;
}
// Create the temp storage handler
DirectoryReference RootDir = new DirectoryReference(CommandUtils.CmdEnv.LocalRoot);
TempStorage Storage = new TempStorage(RootDir, DirectoryReference.Combine(RootDir, "Engine", "Saved", "BuildGraph"), (SharedStorageDir == null)? null : new DirectoryReference(SharedStorageDir), bWriteToSharedStorage);
if(bClearHistory)
{
Storage.CleanLocal();
}
foreach(string CleanNode in CleanNodes)
{
Storage.CleanLocalNode(CleanNode);
}
// Convert the supplied target references into nodes
HashSet<Node> TargetNodes = new HashSet<Node>();
if(TargetNames == null)
{
if(!bListOnly)
{
LogError("Missing -Target= parameter for BuildGraph");
return ExitCode.Error_Unknown;
}
TargetNodes.UnionWith(Graph.Agents.SelectMany(x => x.Nodes));
}
else
{
foreach(string TargetName in TargetNames.Split(new char[]{ '+', ';' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()))
{
Node[] Nodes;
if(!Graph.TryResolveReference(TargetName, out Nodes))
{
LogError("Target '{0}' is not in graph", TargetName);
return ExitCode.Error_Unknown;
}
TargetNodes.UnionWith(Nodes);
}
}
// Try to acquire tokens for all the target nodes we want to build
if(TokenSignature != null)
{
// Find all the lock files
HashSet<FileReference> RequiredTokens = new HashSet<FileReference>(TargetNodes.SelectMany(x => x.RequiredTokens));
// List out all the required tokens
if(SingleNodeName == null)
{
CommandUtils.Log("Required tokens:");
foreach(Node Node in TargetNodes)
{
foreach(FileReference RequiredToken in Node.RequiredTokens)
{
CommandUtils.Log(" '{0}' requires {1}", Node, RequiredToken);
}
}
}
// Try to create all the lock files
List<FileReference> CreatedTokens = new List<FileReference>();
if(!bListOnly)
{
CreatedTokens.AddRange(RequiredTokens.Where(x => WriteTokenFile(x, TokenSignature)));
}
// Find all the tokens that we don't have
Dictionary<FileReference, string> MissingTokens = new Dictionary<FileReference, string>();
foreach(FileReference RequiredToken in RequiredTokens)
{
string CurrentOwner = ReadTokenFile(RequiredToken);
if(CurrentOwner != null && CurrentOwner != TokenSignature)
{
MissingTokens.Add(RequiredToken, CurrentOwner);
}
}
// If we want to skip all the nodes with missing locks, adjust the target nodes to account for it
if(MissingTokens.Count > 0)
{
if(bSkipTargetsWithoutTokens)
{
// Find all the nodes we're going to skip
HashSet<Node> SkipNodes = new HashSet<Node>();
foreach(IGrouping<string, FileReference> MissingTokensForBuild in MissingTokens.GroupBy(x => x.Value, x => x.Key))
{
Log("Skipping the following nodes due to {0}:", MissingTokensForBuild.Key);
foreach(FileReference MissingToken in MissingTokensForBuild)
{
foreach(Node SkipNode in TargetNodes.Where(x => x.RequiredTokens.Contains(MissingToken) && SkipNodes.Add(x)))
{
Log(" {0}", SkipNode);
}
}
}
// Write a list of everything left over
if(SkipNodes.Count > 0)
{
TargetNodes.ExceptWith(SkipNodes);
Log("Remaining target nodes:");
foreach(Node TargetNode in TargetNodes)
{
Log(" {0}", TargetNode);
}
if(TargetNodes.Count == 0)
{
Log(" None.");
}
}
}
else
{
foreach(KeyValuePair<FileReference, string> Pair in MissingTokens)
{
List<Node> SkipNodes = TargetNodes.Where(x => x.RequiredTokens.Contains(Pair.Key)).ToList();
LogError("Cannot run {0} due to previous build: {1}", String.Join(", ", SkipNodes), Pair.Value);
}
foreach(FileReference CreatedToken in CreatedTokens)
{
CreatedToken.Delete();
}
return ExitCode.Error_Unknown;
}
}
}
// Cull the graph to include only those nodes
Graph.Select(TargetNodes);
// Collapse any triggers in the graph which are marked to be skipped
HashSet<ManualTrigger> SkipTriggers = new HashSet<ManualTrigger>();
if(bSkipTriggers)
{
SkipTriggers.UnionWith(Graph.NameToTrigger.Values);
}
else
{
foreach(string SkipTriggerName in SkipTriggerNames)
{
ManualTrigger SkipTrigger;
if(!Graph.NameToTrigger.TryGetValue(TriggerName, out SkipTrigger))
{
LogError("Couldn't find trigger '{0}'", TriggerName);
return ExitCode.Error_Unknown;
}
SkipTriggers.Add(SkipTrigger);
}
}
Graph.SkipTriggers(SkipTriggers);
// If a report for the whole build was requested, insert it into the graph
if (ReportName != null)
{
Report NewReport = new Report(ReportName);
NewReport.Nodes.UnionWith(Graph.Agents.SelectMany(x => x.Nodes));
Graph.NameToReport.Add(ReportName, NewReport);
}
// Write out the preprocessed script
if (PreprocessedFileName != null)
{
Graph.Write(new FileReference(PreprocessedFileName), (SchemaFileName != null)? new FileReference(SchemaFileName) : null);
}
// Find the triggers which we are explicitly running.
ManualTrigger Trigger = null;
if(TriggerName != null && !Graph.NameToTrigger.TryGetValue(TriggerName, out Trigger))
{
LogError("Couldn't find trigger '{0}'", TriggerName);
return ExitCode.Error_Unknown;
}
// If we're just building a single node, find it
Node SingleNode = null;
if(SingleNodeName != null && !Graph.NameToNode.TryGetValue(SingleNodeName, out SingleNode))
{
LogError("Node '{0}' is not in the trimmed graph", SingleNodeName);
return ExitCode.Error_Unknown;
}
// If we just want to show the contents of the graph, do so and exit.
if(bListOnly)
{
HashSet<Node> CompletedNodes = FindCompletedNodes(Graph, Storage);
Graph.Print(CompletedNodes, PrintOptions);
return ExitCode.Success;
}
// Print out all the diagnostic messages which still apply, unless we're running a step as part of a build system or just listing the contents of the file.
if(SingleNode == null)
{
IEnumerable<GraphDiagnostic> Diagnostics = Graph.Diagnostics.Where(x => x.EnclosingTrigger == Trigger);
foreach(GraphDiagnostic Diagnostic in Diagnostics)
{
if(Diagnostic.EventType == LogEventType.Warning)
{
CommandUtils.LogWarning(Diagnostic.Message);
}
else
{
CommandUtils.LogError(Diagnostic.Message);
}
}
if(Diagnostics.Any(x => x.EventType == LogEventType.Error))
{
return ExitCode.Error_Unknown;
}
}
// Execute the command
if(ExportFileName != null)
{
HashSet<Node> CompletedNodes = FindCompletedNodes(Graph, Storage);
Graph.Print(CompletedNodes, PrintOptions);
Graph.Export(new FileReference(ExportFileName), Trigger, CompletedNodes);
}
else if(SingleNode != null)
{
if(!BuildNode(new JobContext(this), Graph, SingleNode, Storage, bWithBanner: true))
{
return ExitCode.Error_Unknown;
}
}
else
{
if(!BuildAllNodes(new JobContext(this), Graph, Storage))
{
return ExitCode.Error_Unknown;
}
}
return ExitCode.Success;
}
/// <summary>
/// Find all the tasks which are available from the loaded assemblies
/// </summary>
/// <param name="NameToTask">Mapping from task name to information about how to serialize it</param>
/// <param name="bPublicTasksOnly">Whether to include just public tasks, or all the tasks in any loaded assemblies</param>
static bool FindAvailableTasks(Dictionary<string, ScriptTask> NameToTask, bool bPublicTasksOnly)
{
Assembly[] LoadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
if(bPublicTasksOnly)
{
LoadedAssemblies = LoadedAssemblies.Where(x => IsPublicAssembly(new FileReference(x.Location))).ToArray();
}
foreach (Assembly LoadedAssembly in LoadedAssemblies)
{
Type[] Types;
try
{
Types = LoadedAssembly.GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
LogWarning("Exception {0} while trying to get types from assembly {1}", ex, LoadedAssembly);
continue;
}
foreach(Type Type in Types)
{
foreach(TaskElementAttribute ElementAttribute in Type.GetCustomAttributes<TaskElementAttribute>())
{
if(!Type.IsSubclassOf(typeof(CustomTask)))
{
CommandUtils.LogError("Class '{0}' has TaskElementAttribute, but is not derived from 'Task'", Type.Name);
return false;
}
if(NameToTask.ContainsKey(ElementAttribute.Name))
{
CommandUtils.LogError("Found multiple handlers for task elements called '{0}'", ElementAttribute.Name);
return false;
}
NameToTask.Add(ElementAttribute.Name, new ScriptTask(ElementAttribute.Name, Type, ElementAttribute.ParametersType));
}
}
}
return true;
}
/// <summary>
/// Reads the contents of the given token
/// </summary>
/// <returns>Contents of the token, or null if it does not exist</returns>
public string ReadTokenFile(FileReference Location)
{
return Location.Exists()? File.ReadAllText(Location.FullName) : null;
}
/// <summary>
/// Attempts to write an owner to a token file transactionally
/// </summary>
/// <returns>True if the lock was acquired, false otherwise</returns>
public bool WriteTokenFile(FileReference Location, string Signature)
{
// Check it doesn't already exist
if(Location.Exists())
{
return false;
}
// Make sure the directory exists
Location.Directory.CreateDirectory();
// Create a temp file containing the owner name
string TempFileName;
for(int Idx = 0;;Idx++)
{
TempFileName = String.Format("{0}.{1}.tmp", Location.FullName, Idx);
try
{
byte[] Bytes = Encoding.UTF8.GetBytes(Signature);
using (FileStream Stream = File.Open(TempFileName, FileMode.CreateNew, FileAccess.Write, FileShare.None))
{
Stream.Write(Bytes, 0, Bytes.Length);
}
break;
}
catch(IOException)
{
if(!File.Exists(TempFileName))
{
throw;
}
}
}
// Try to move the temporary file into place.
try
{
File.Move(TempFileName, Location.FullName);
return true;
}
catch
{
if(!File.Exists(TempFileName))
{
throw;
}
return false;
}
}
/// <summary>
/// Checks whether the given assembly is a publically distributed engine assembly.
/// </summary>
/// <param name="File">Assembly location</param>
/// <returns>True if the assembly is distributed publically</returns>
static bool IsPublicAssembly(FileReference File)
{
DirectoryReference EngineDirectory = UnrealBuildTool.UnrealBuildTool.EngineDirectory;
if(File.IsUnderDirectory(EngineDirectory))
{
string[] PathFragments = File.MakeRelativeTo(EngineDirectory).Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
if(PathFragments.All(x => !x.Equals("NotForLicensees", StringComparison.InvariantCultureIgnoreCase) && !x.Equals("NoRedist", StringComparison.InvariantCultureIgnoreCase)))
{
return true;
}
}
return false;
}
/// <summary>
/// Find all the nodes in the graph which are already completed
/// </summary>
/// <param name="Graph">The graph instance</param>
/// <param name="Storage">The temp storage backend which stores the shared state</param>
HashSet<Node> FindCompletedNodes(Graph Graph, TempStorage Storage)
{
HashSet<Node> CompletedNodes = new HashSet<Node>();
foreach(Node Node in Graph.Agents.SelectMany(x => x.Nodes))
{
if(Storage.IsComplete(Node.Name))
{
CompletedNodes.Add(Node);
}
}
return CompletedNodes;
}
/// <summary>
/// Builds all the nodes in the graph
/// </summary>
/// <param name="Job">Information about the current job</param>
/// <param name="Graph">The graph instance</param>
/// <param name="Storage">The temp storage backend which stores the shared state</param>
/// <returns>True if everything built successfully</returns>
bool BuildAllNodes(JobContext Job, Graph Graph, TempStorage Storage)
{
// Build a flat list of nodes to execute, in order
Node[] NodesToExecute = Graph.Agents.SelectMany(x => x.Nodes).ToArray();
// Check the integrity of any local nodes that have been completed. It's common to run formal builds locally between regular development builds, so we may have
// stale local state. Rather than failing later, detect and clean them up now.
HashSet<Node> CleanedNodes = new HashSet<Node>();
foreach(Node NodeToExecute in NodesToExecute)
{
if(NodeToExecute.InputDependencies.Any(x => CleanedNodes.Contains(x)) || !Storage.CheckLocalIntegrity(NodeToExecute.Name, NodeToExecute.Outputs.Select(x => x.TagName)))
{
Storage.CleanLocalNode(NodeToExecute.Name);
CleanedNodes.Add(NodeToExecute);
}
}
// Execute them in order
int NodeIdx = 0;
foreach(Node NodeToExecute in NodesToExecute)
{
Log("****** [{0}/{1}] {2}", ++NodeIdx, NodesToExecute.Length, NodeToExecute.Name);
if(!Storage.IsComplete(NodeToExecute.Name))
{
Log("");
if(!BuildNode(Job, Graph, NodeToExecute, Storage, false))
{
return false;
}
Log("");
}
}
return true;
}
/// <summary>
/// Build a node
/// </summary>
/// <param name="Job">Information about the current job</param>
/// <param name="Graph">The graph to which the node belongs. Used to determine which outputs need to be transferred to temp storage.</param>
/// <param name="Node">The node to build</param>
/// <param name="Storage">The temp storage backend which stores the shared state</param>
/// <param name="bWithBanner">Whether to write a banner before and after this node's log output</param>
/// <returns>True if the node built successfully, false otherwise.</returns>
bool BuildNode(JobContext Job, Graph Graph, Node Node, TempStorage Storage, bool bWithBanner)
{
DirectoryReference RootDir = new DirectoryReference(CommandUtils.CmdEnv.LocalRoot);
// Create the mapping of tag names to file sets
Dictionary<string, HashSet<FileReference>> TagNameToFileSet = new Dictionary<string,HashSet<FileReference>>();
// Read all the input tags for this node, and build a list of referenced input storage blocks
HashSet<TempStorageBlock> InputStorageBlocks = new HashSet<TempStorageBlock>();
foreach(NodeOutput Input in Node.Inputs)
{
TempStorageFileList FileList = Storage.ReadFileList(Input.ProducingNode.Name, Input.TagName);
TagNameToFileSet[Input.TagName] = FileList.ToFileSet(RootDir);
InputStorageBlocks.UnionWith(FileList.Blocks);
}
// Read all the input storage blocks, keeping track of which block each file came from
Dictionary<FileReference, TempStorageBlock> FileToStorageBlock = new Dictionary<FileReference, TempStorageBlock>();
foreach(TempStorageBlock InputStorageBlock in InputStorageBlocks)
{
TempStorageManifest Manifest = Storage.Retreive(InputStorageBlock.NodeName, InputStorageBlock.OutputName);
foreach(FileReference File in Manifest.Files.Select(x => x.ToFileReference(RootDir)))
{
TempStorageBlock CurrentStorageBlock;
if(FileToStorageBlock.TryGetValue(File, out CurrentStorageBlock))
{
LogError("File '{0}' was produced by {1} and {2}", File, InputStorageBlock, CurrentStorageBlock);
}
FileToStorageBlock[File] = InputStorageBlock;
}
}
// Add placeholder outputs for the current node
foreach(NodeOutput Output in Node.Outputs)
{
TagNameToFileSet.Add(Output.TagName, new HashSet<FileReference>());
}
// Execute the node
if(bWithBanner)
{
Console.WriteLine();
CommandUtils.Log("========== Starting: {0} ==========", Node.Name);
}
if(!Node.Build(Job, TagNameToFileSet))
{
return false;
}
if(bWithBanner)
{
CommandUtils.Log("========== Finished: {0} ==========", Node.Name);
Console.WriteLine();
}
// Determine all the output files which are required to be copied to temp storage (because they're referenced by nodes in another agent)
HashSet<FileReference> ReferencedOutputFiles = new HashSet<FileReference>();
foreach(Agent Agent in Graph.Agents)
{
bool bSameAgent = Agent.Nodes.Contains(Node);
foreach(Node OtherNode in Agent.Nodes)
{
if(!bSameAgent || Node.ControllingTrigger != OtherNode.ControllingTrigger)
{
foreach(NodeOutput Input in OtherNode.Inputs.Where(x => x.ProducingNode == Node))
{
ReferencedOutputFiles.UnionWith(TagNameToFileSet[Input.TagName]);
}
}
}
}
// Find a block name for all new outputs
Dictionary<FileReference, string> FileToOutputName = new Dictionary<FileReference, string>();
foreach(NodeOutput Output in Node.Outputs)
{
HashSet<FileReference> Files = TagNameToFileSet[Output.TagName];
foreach(FileReference File in Files)
{
if(!FileToStorageBlock.ContainsKey(File) && File.IsUnderDirectory(RootDir))
{
if(Output == Node.DefaultOutput)
{
if(!FileToOutputName.ContainsKey(File))
{
FileToOutputName[File] = "";
}
}
else
{
string OutputName;
if(FileToOutputName.TryGetValue(File, out OutputName) && OutputName.Length > 0)
{
FileToOutputName[File] = String.Format("{0}+{1}", OutputName, Output.TagName.Substring(1));
}
else
{
FileToOutputName[File] = Output.TagName.Substring(1);
}
}
}
}
}
// Invert the dictionary to make a mapping of storage block to the files each contains
Dictionary<string, HashSet<FileReference>> OutputStorageBlockToFiles = new Dictionary<string, HashSet<FileReference>>();
foreach(KeyValuePair<FileReference, string> Pair in FileToOutputName)
{
HashSet<FileReference> Files;
if(!OutputStorageBlockToFiles.TryGetValue(Pair.Value, out Files))
{
Files = new HashSet<FileReference>();
OutputStorageBlockToFiles.Add(Pair.Value, Files);
}
Files.Add(Pair.Key);
}
// Write all the storage blocks, and update the mapping from file to storage block
foreach(KeyValuePair<string, HashSet<FileReference>> Pair in OutputStorageBlockToFiles)
{
TempStorageBlock OutputBlock = new TempStorageBlock(Node.Name, Pair.Key);
foreach(FileReference File in Pair.Value)
{
FileToStorageBlock.Add(File, OutputBlock);
}
Storage.Archive(Node.Name, Pair.Key, Pair.Value.ToArray(), Pair.Value.Any(x => ReferencedOutputFiles.Contains(x)));
}
// Publish all the output tags
foreach(NodeOutput Output in Node.Outputs)
{
HashSet<FileReference> Files = TagNameToFileSet[Output.TagName];
HashSet<TempStorageBlock> StorageBlocks = new HashSet<TempStorageBlock>();
foreach(FileReference File in Files)
{
TempStorageBlock StorageBlock;
if(FileToStorageBlock.TryGetValue(File, out StorageBlock))
{
StorageBlocks.Add(StorageBlock);
}
}
Storage.WriteFileList(Node.Name, Output.TagName, Files, StorageBlocks.ToArray());
}
// Mark the node as succeeded
Storage.MarkAsComplete(Node.Name);
return true;
}
/// <summary>
/// Generate HTML documentation for all the tasks
/// </summary>
/// <param name="NameToTask">Map of task name to implementation</param>
/// <param name="OutputFile">Output file</param>
static void GenerateDocumentation(Dictionary<string, ScriptTask> NameToTask, FileReference OutputFile)
{
// Find all the assemblies containing tasks
Assembly[] TaskAssemblies = NameToTask.Values.Select(x => x.ParametersClass.Assembly).Distinct().ToArray();
// Read documentation for each of them
Dictionary<string, XmlElement> MemberNameToElement = new Dictionary<string, XmlElement>();
foreach(Assembly TaskAssembly in TaskAssemblies)
{
string XmlFileName = Path.ChangeExtension(TaskAssembly.Location, ".xml");
if(File.Exists(XmlFileName))
{
// Read the document
XmlDocument Document = new XmlDocument();
Document.Load(XmlFileName);
// Parse all the members, and add them to the map
foreach(XmlElement Element in Document.SelectNodes("/doc/members/member"))
{
string Name = Element.GetAttribute("name");
MemberNameToElement.Add(Name, Element);
}
}
}
// Create the output directory
OutputFile.Directory.CreateDirectory();
Log("Writing {0}...", OutputFile);
// Parse the engine version
BuildVersion Version;
if(!BuildVersion.TryRead(out Version))
{
throw new AutomationException("Couldn't read Build.version");
}
// Write the output file
using (StreamWriter Writer = new StreamWriter(OutputFile.FullName))
{
Writer.WriteLine("Availability: NoPublish");
Writer.WriteLine("Title: BuildGraph Predefined Tasks");
Writer.WriteLine("Crumbs: %ROOT%, Programming, Programming/Development, Programming/Development/BuildGraph, Programming/Development/BuildGraph/BuildGraphScriptTasks");
Writer.WriteLine("Description: This is a procedurally generated markdown page.");
Writer.WriteLine("version: {0}.{1}", Version.MajorVersion, Version.MinorVersion);
Writer.WriteLine("parent:Programming/Development/BuildGraph/BuildGraphScriptTasks");
Writer.WriteLine();
foreach(string TaskName in NameToTask.Keys.OrderBy(x => x))
{
// Get the task object
ScriptTask Task = NameToTask[TaskName];
// Get the documentation for this task
XmlElement TaskElement;
if(MemberNameToElement.TryGetValue("T:" + Task.TaskClass.FullName, out TaskElement))
{
// Write the task heading
Writer.WriteLine("### {0}", TaskName);
Writer.WriteLine();
Writer.WriteLine(ConvertToMarkdown(TaskElement.SelectSingleNode("summary")));
Writer.WriteLine();
// Document the parameters
List<string[]> Rows = new List<string[]>();
foreach(string ParameterName in Task.NameToParameter.Keys)
{
// Get the parameter data
ScriptTaskParameter Parameter = Task.NameToParameter[ParameterName];
// Get the documentation for this parameter
XmlElement ParameterElement;
if(MemberNameToElement.TryGetValue("F:" + Parameter.FieldInfo.DeclaringType.FullName + "." + Parameter.Name, out ParameterElement))
{
string TypeName = Parameter.FieldInfo.FieldType.Name;
if(Parameter.ValidationType != TaskParameterValidationType.Default)
{
StringBuilder NewTypeName = new StringBuilder(Parameter.ValidationType.ToString());
for(int Idx = 1; Idx < NewTypeName.Length; Idx++)
{
if(Char.IsLower(NewTypeName[Idx - 1]) && Char.IsUpper(NewTypeName[Idx]))
{
NewTypeName.Insert(Idx, ' ');
}
}
TypeName = NewTypeName.ToString();
}
string[] Columns = new string[4];
Columns[0] = ParameterName;
Columns[1] = TypeName;
Columns[2] = Parameter.bOptional? "Optional" : "Required";
Columns[3] = ConvertToMarkdown(ParameterElement.SelectSingleNode("summary"));
Rows.Add(Columns);
}
}
// Always include the "If" attribute
string[] IfColumns = new string[4];
IfColumns[0] = "If";
IfColumns[1] = "Condition";
IfColumns[2] = "Optional";
IfColumns[3] = "Whether to execute this task. It is ignored if this condition evaluates to false.";
Rows.Add(IfColumns);
// Get the width of each column
int[] Widths = new int[4];
for(int Idx = 0; Idx < 4; Idx++)
{
Widths[Idx] = Rows.Max(x => x[Idx].Length);
}
// Format the markdown table
string Format = String.Format("| {{0,-{0}}} | {{1,-{1}}} | {{2,-{2}}} | {{3,-{3}}} |", Widths[0], Widths[1], Widths[2], Widths[3]);
Writer.WriteLine(Format, "", "", "", "");
Writer.WriteLine(Format, new string('-', Widths[0]), new string('-', Widths[1]), new string('-', Widths[2]), new string('-', Widths[3]));
for(int Idx = 0; Idx < Rows.Count; Idx++)
{
Writer.WriteLine(Format, Rows[Idx][0], Rows[Idx][1], Rows[Idx][2], Rows[Idx][3]);
}
// Blank line before next task
Writer.WriteLine();
}
}
}
}
/// <summary>
/// Converts an XML documentation node to markdown
/// </summary>
/// <param name="Node">The node to read</param>
/// <returns>Text in markdown format</returns>
static string ConvertToMarkdown(XmlNode Node)
{
string Text = Node.InnerXml;
StringBuilder Result = new StringBuilder();
for(int Idx = 0; Idx < Text.Length; Idx++)
{
if(Char.IsWhiteSpace(Text[Idx]))
{
Result.Append(' ');
while(Idx + 1 < Text.Length && Char.IsWhiteSpace(Text[Idx + 1]))
{
Idx++;
}
}
else
{
Result.Append(Text[Idx]);
}
}
return Result.ToString().Trim();
}
}
/// <summary>
/// Legacy command name for compatibility.
/// </summary>
public class Build : BuildGraph
{
}
}