Files
UnrealEngineUWP/Engine/Source/Programs/UnrealBuildTool/System/ActionGraph.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

1632 lines
60 KiB
C#

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Serialization;
namespace UnrealBuildTool
{
/// <summary>
/// Enumerates build action types.
/// </summary>
public enum ActionType
{
BuildProject,
Compile,
CreateAppBundle,
GenerateDebugInfo,
Link,
}
/// <summary>
/// A build action.
/// </summary>
[Serializable]
public class Action : ISerializable
{
///
/// Preparation and Assembly (serialized)
///
/// <summary>
/// The type of this action (for debugging purposes).
/// </summary>
public ActionType ActionType;
/// <summary>
/// Every file this action depends on. These files need to exist and be up to date in order for this action to even be considered
/// </summary>
public List<FileItem> PrerequisiteItems = new List<FileItem>();
/// <summary>
/// The files that this action produces after completing
/// </summary>
public List<FileItem> ProducedItems = new List<FileItem>();
/// <summary>
/// Directory from which to execute the program to create produced items
/// </summary>
public string WorkingDirectory = null;
/// <summary>
/// True if we should log extra information when we run a program to create produced items
/// </summary>
public bool bPrintDebugInfo = false;
/// <summary>
/// The command to run to create produced items
/// </summary>
public string CommandPath = null;
/// <summary>
/// Command-line parameters to pass to the program
/// </summary>
public string CommandArguments = null;
/// <summary>
/// Optional friendly description of the type of command being performed, for example "Compile" or "Link". Displayed by some executors.
/// </summary>
public string CommandDescription = null;
/// <summary>
/// Human-readable description of this action that may be displayed as status while invoking the action. This is often the name of the file being compiled, or an executable file name being linked. Displayed by some executors.
/// </summary>
public string StatusDescription = "...";
/// <summary>
/// True if this action is allowed to be run on a remote machine when a distributed build system is being used, such as XGE
/// </summary>
public bool bCanExecuteRemotely = false;
/// <summary>
/// True if this action is using the GCC compiler. Some build systems may be able to optimize for this case.
/// </summary>
public bool bIsGCCCompiler = false;
/// <summary>
/// Whether the action is using a pre-compiled header to speed it up.
/// </summary>
public bool bIsUsingPCH = false;
/// <summary>
/// Whether the files in ProducedItems should be deleted before executing this action, when the action is outdated
/// </summary>
public bool bShouldDeleteProducedItems = false;
/// <summary>
/// Whether we should log this action, whether executed locally or remotely. This is useful for actions that take time
/// but invoke tools without any console output.
/// </summary>
public bool bShouldOutputStatusDescription = true;
/// <summary>
/// True if any libraries produced by this action should be considered 'import libraries'
/// </summary>
public bool bProducesImportLibrary = false;
/// <summary>
/// Optional custom event handler for standard output.
/// </summary>
public DataReceivedEventHandler OutputEventHandler = null; // @todo ubtmake urgent: Delegate variables are not saved, but we are comparing against this in ExecuteActions() for XGE!
/// <summary>
/// Callback used to perform a special action instead of a generic command line
/// </summary>
public delegate void BlockingActionHandler(Action Action, out int ExitCode, out string Output);
public BlockingActionHandler ActionHandler = null; // @todo ubtmake urgent: Delegate variables are not saved, but we are comparing against this in ExecuteActions() for XGE!
///
/// Preparation only (not serialized)
///
/// <summary>
/// Unique action identifier. Used for displaying helpful info about detected cycles in the graph.
/// </summary>
public int UniqueId;
/// <summary>
/// Always-incremented unique id
/// </summary>
private static int NextUniqueId = 0;
/// <summary>
/// Total number of actions depending on this one.
/// </summary>
public int NumTotalDependentActions = 0;
/// <summary>
/// Relative cost of producing items for this action.
/// </summary>
public long RelativeCost = 0;
///
/// Assembly only (not serialized)
///
/// <summary>
/// Start time of action, optionally set by executor.
/// </summary>
public DateTimeOffset StartTime = DateTimeOffset.MinValue;
/// <summary>
/// End time of action, optionally set by executor.
/// </summary>
public DateTimeOffset EndTime = DateTimeOffset.MinValue;
public Action(ActionType InActionType)
{
ActionType = InActionType;
ActionGraph.AllActions.Add(this);
UniqueId = ++NextUniqueId;
}
public Action(SerializationInfo SerializationInfo, StreamingContext StreamingContext)
{
ActionType = (ActionType)SerializationInfo.GetByte("at");
WorkingDirectory = SerializationInfo.GetString("wd");
bPrintDebugInfo = SerializationInfo.GetBoolean("di");
CommandPath = SerializationInfo.GetString("cp");
CommandArguments = SerializationInfo.GetString("ca");
CommandDescription = SerializationInfo.GetString("cd");
StatusDescription = SerializationInfo.GetString("sd");
bCanExecuteRemotely = SerializationInfo.GetBoolean("ce");
bIsGCCCompiler = SerializationInfo.GetBoolean("ig");
bIsUsingPCH = SerializationInfo.GetBoolean("iu");
bShouldDeleteProducedItems = SerializationInfo.GetBoolean("dp");
bShouldOutputStatusDescription = SerializationInfo.GetBoolean("os");
bProducesImportLibrary = SerializationInfo.GetBoolean("il");
PrerequisiteItems = (List<FileItem>)SerializationInfo.GetValue("pr", typeof(List<FileItem>));
ProducedItems = (List<FileItem>)SerializationInfo.GetValue("pd", typeof(List<FileItem>));
}
/// <summary>
/// ISerializable: Called when serialized to report additional properties that should be saved
/// </summary>
public void GetObjectData(SerializationInfo SerializationInfo, StreamingContext StreamingContext)
{
SerializationInfo.AddValue("at", (byte)ActionType);
SerializationInfo.AddValue("wd", WorkingDirectory);
SerializationInfo.AddValue("di", bPrintDebugInfo);
SerializationInfo.AddValue("cp", CommandPath);
SerializationInfo.AddValue("ca", CommandArguments);
SerializationInfo.AddValue("cd", CommandDescription);
SerializationInfo.AddValue("sd", StatusDescription);
SerializationInfo.AddValue("ce", bCanExecuteRemotely);
SerializationInfo.AddValue("ig", bIsGCCCompiler);
SerializationInfo.AddValue("iu", bIsUsingPCH);
SerializationInfo.AddValue("dp", bShouldDeleteProducedItems);
SerializationInfo.AddValue("os", bShouldOutputStatusDescription);
SerializationInfo.AddValue("il", bProducesImportLibrary);
SerializationInfo.AddValue("pr", PrerequisiteItems);
SerializationInfo.AddValue("pd", ProducedItems);
}
/// <summary>
/// Compares two actions based on total number of dependent items, descending.
/// </summary>
/// <param name="A">Action to compare</param>
/// <param name="B">Action to compare</param>
public static int Compare(Action A, Action B)
{
// Primary sort criteria is total number of dependent files, up to max depth.
if (B.NumTotalDependentActions != A.NumTotalDependentActions)
{
return Math.Sign(B.NumTotalDependentActions - A.NumTotalDependentActions);
}
// Secondary sort criteria is relative cost.
if (B.RelativeCost != A.RelativeCost)
{
return Math.Sign(B.RelativeCost - A.RelativeCost);
}
// Tertiary sort criteria is number of pre-requisites.
else
{
return Math.Sign(B.PrerequisiteItems.Count - A.PrerequisiteItems.Count);
}
}
public override string ToString()
{
string ReturnString = "";
if (CommandPath != null)
{
ReturnString += CommandPath + " - ";
}
if (CommandArguments != null)
{
ReturnString += CommandArguments;
}
return ReturnString;
}
/// <summary>
/// Returns the amount of time that this action is or has been executing in.
/// </summary>
public TimeSpan Duration
{
get
{
if (EndTime == DateTimeOffset.MinValue)
{
return DateTimeOffset.Now - StartTime;
}
return EndTime - StartTime;
}
}
};
class ActionGraph
{
public static List<Action> AllActions = new List<Action>();
public static void ResetAllActions()
{
AllActions = new List<Action>();
}
public static void FinalizeActionGraph()
{
// Link producing actions to the items they produce.
LinkActionsAndItems();
// Detect cycles in the action graph.
DetectActionGraphCycles();
// Sort action list by "cost" in descending order to improve parallelism.
SortActionList();
}
/// <summary>
/// Builds a list of actions that need to be executed to produce the specified output items.
/// </summary>
public static List<Action> GetActionsToExecute(Action[] PrerequisiteActions, List<UEBuildTarget> Targets, out Dictionary<UEBuildTarget, List<FileItem>> TargetToOutdatedPrerequisitesMap)
{
DateTime CheckOutdatednessStartTime = DateTime.UtcNow;
// Build a set of all actions needed for this target.
Dictionary<Action, bool> IsActionOutdatedMap = new Dictionary<Action, bool>();
foreach (Action Action in PrerequisiteActions)
{
IsActionOutdatedMap.Add(Action, true);
}
// For all targets, build a set of all actions that are outdated.
Dictionary<Action, bool> OutdatedActionDictionary = new Dictionary<Action, bool>();
List<ActionHistory> HistoryList = new List<ActionHistory>();
HashSet<FileReference> OpenHistoryFiles = new HashSet<FileReference>();
TargetToOutdatedPrerequisitesMap = new Dictionary<UEBuildTarget, List<FileItem>>();
foreach (UEBuildTarget BuildTarget in Targets) // @todo ubtmake: Optimization: Ideally we don't even need to know about targets for ubtmake -- everything would come from the files
{
FileReference HistoryFilename = ActionHistory.GeneratePathForTarget(BuildTarget);
if (!OpenHistoryFiles.Contains(HistoryFilename)) // @todo ubtmake: Optimization: We should be able to move the command-line outdatedness and build product deletion over to the 'gather' phase, as the command-lines won't change between assembler runs
{
ActionHistory History = new ActionHistory(HistoryFilename.FullName);
HistoryList.Add(History);
OpenHistoryFiles.Add(HistoryFilename);
GatherAllOutdatedActions(BuildTarget, History, ref OutdatedActionDictionary, TargetToOutdatedPrerequisitesMap);
}
}
// If we're only compiling a single file, we should always compile and should never link.
if (!string.IsNullOrEmpty(BuildConfiguration.SingleFileToCompile))
{
// Never do anything but compile the target file
AllActions.RemoveAll(x => x.ActionType != ActionType.Compile);
// Check all of the leftover compilation actions for the one we want... that one is always outdated.
FileItem SingleFileToCompile = FileItem.GetExistingItemByPath(BuildConfiguration.SingleFileToCompile);
foreach (Action Action in AllActions)
{
bool bIsSingleFileAction = Action.PrerequisiteItems.Contains(SingleFileToCompile);
OutdatedActionDictionary[Action] = bIsSingleFileAction;
}
// Don't save the history of a single file compilation.
HistoryList.Clear();
}
// Delete produced items that are outdated.
DeleteOutdatedProducedItems(OutdatedActionDictionary, BuildConfiguration.bShouldDeleteAllOutdatedProducedItems);
// Save the action history.
// This must happen after deleting outdated produced items to ensure that the action history on disk doesn't have
// command-lines that don't match the produced items on disk.
foreach (ActionHistory TargetHistory in HistoryList)
{
TargetHistory.Save();
}
// Create directories for the outdated produced items.
CreateDirectoriesForProducedItems(OutdatedActionDictionary);
// Build a list of actions that are both needed for this target and outdated.
HashSet<Action> ActionsToExecute = AllActions.Where(Action => Action.CommandPath != null && IsActionOutdatedMap.ContainsKey(Action) && OutdatedActionDictionary[Action]).ToHashSet();
// Remove link actions if asked to
if (UEBuildConfiguration.bSkipLinkingWhenNothingToCompile)
{
// Get all items produced by a compile action
HashSet<FileItem> ProducedItems = ActionsToExecute.Where(Action => Action.ActionType == ActionType.Compile).SelectMany(x => x.ProducedItems).ToHashSet();
// Get all link actions which have no out-of-date prerequisites
HashSet<Action> UnlinkedActions = ActionsToExecute.Where(Action => Action.ActionType == ActionType.Link && !ProducedItems.Overlaps(Action.PrerequisiteItems)).ToHashSet();
// Don't regard an action as unlinked if there is an associated 'failed.hotreload' file.
UnlinkedActions.RemoveWhere(Action => Action.ProducedItems.Any(Item => File.Exists(Path.Combine(Path.GetDirectoryName(Item.AbsolutePath), "failed.hotreload"))));
HashSet<Action> UnlinkedActionsWithFailedHotreload = ActionsToExecute.Where(Action => Action.ActionType == ActionType.Link && !ProducedItems.Overlaps(Action.PrerequisiteItems)).ToHashSet();
// Remove unlinked items
ActionsToExecute.ExceptWith(UnlinkedActions);
// Re-add unlinked items which produce things which are dependencies of other actions
for (;;)
{
// Get all prerequisite items of a link action
HashSet<Action> PrerequisiteLinkActions = ActionsToExecute.Where(Action => Action.ActionType == ActionType.Link).SelectMany(x => x.PrerequisiteItems).Select(Item => Item.ProducingAction).ToHashSet();
// Find all unlinked actions that need readding
HashSet<Action> UnlinkedActionsToReadd = UnlinkedActions.Where(Action => PrerequisiteLinkActions.Contains(Action)).ToHashSet();
if (UnlinkedActionsToReadd.Count == 0)
{
break;
}
ActionsToExecute.UnionWith(UnlinkedActionsToReadd);
UnlinkedActions.ExceptWith(UnlinkedActionsToReadd);
// Break early if there are no more unlinked actions to readd
if (UnlinkedActions.Count == 0)
{
break;
}
}
// Remove actions that are wholly dependent on unlinked actions
ActionsToExecute = ActionsToExecute.Where(Action => Action.PrerequisiteItems.Count == 0 || !Action.PrerequisiteItems.Select(Item => Item.ProducingAction).ToHashSet().IsSubsetOf(UnlinkedActions)).ToHashSet();
}
if (BuildConfiguration.bPrintPerformanceInfo)
{
double CheckOutdatednessTime = (DateTime.UtcNow - CheckOutdatednessStartTime).TotalSeconds;
Log.TraceInformation("Checking outdatedness took " + CheckOutdatednessTime + "s");
}
return ActionsToExecute.ToList();
}
/// <summary>
/// Executes a list of actions.
/// </summary>
public static bool ExecuteActions(List<Action> ActionsToExecute, out string ExecutorName, string TargetInfoForTelemetry, bool bIsHotReload = false)
{
bool Result = true;
bool bUsedXGE = false;
ExecutorName = "";
if (ActionsToExecute.Count > 0)
{
DateTime StartTime = DateTime.UtcNow;
if (BuildConfiguration.bAllowXGE || BuildConfiguration.bXGEExport)
{
XGE.ExecutionResult XGEResult = XGE.ExecutionResult.TasksSucceeded;
// Batch up XGE execution by actions with the same output event handler.
List<Action> ActionBatch = new List<Action>();
ActionBatch.Add(ActionsToExecute[0]);
for (int ActionIndex = 1; ActionIndex < ActionsToExecute.Count && XGEResult == XGE.ExecutionResult.TasksSucceeded; ++ActionIndex)
{
Action CurrentAction = ActionsToExecute[ActionIndex];
if (CurrentAction.OutputEventHandler == ActionBatch[0].OutputEventHandler)
{
ActionBatch.Add(CurrentAction);
}
else
{
XGEResult = XGE.ExecuteActions(ActionBatch);
ActionBatch.Clear();
ActionBatch.Add(CurrentAction);
}
}
if (ActionBatch.Count > 0 && XGEResult == XGE.ExecutionResult.TasksSucceeded)
{
XGEResult = XGE.ExecuteActions(ActionBatch);
ActionBatch.Clear();
}
if (XGEResult != XGE.ExecutionResult.Unavailable)
{
ExecutorName = "XGE";
Result = (XGEResult == XGE.ExecutionResult.TasksSucceeded);
// don't do local compilation
bUsedXGE = true;
}
}
if (!bUsedXGE && BuildConfiguration.bAllowDistcc)
{
ExecutorName = "Distcc";
Result = Distcc.ExecuteActions(ActionsToExecute);
// don't do local compilation
bUsedXGE = true;
}
if (!bUsedXGE && BuildConfiguration.bAllowSNDBS)
{
SNDBS.ExecutionResult SNDBSResult = SNDBS.ExecuteActions(ActionsToExecute);
if (SNDBSResult != SNDBS.ExecutionResult.Unavailable)
{
ExecutorName = "SNDBS";
Result = (SNDBSResult == SNDBS.ExecutionResult.TasksSucceeded);
// don't do local compilation
bUsedXGE = true;
}
}
// If XGE is disallowed or unavailable, execute the commands locally.
if (!bUsedXGE)
{
ExecutorName = "Local";
Result = LocalExecutor.ExecuteActions(ActionsToExecute);
}
if(Telemetry.IsAvailable() && !BuildConfiguration.bXGEExport)
{
Telemetry.SendEvent("BuildTime",
"ExecutorType", ExecutorName,
"OS", Environment.OSVersion.ToString(),
"MachineName", Environment.MachineName,
"NumLogicalCores", Environment.ProcessorCount.ToString(),
"NumPhysicalCores", (bUsedXGE? -1 : Utils.GetPhysicalProcessorCount()).ToString(),
"Targets", TargetInfoForTelemetry,
"NumActions", ActionsToExecute.Count.ToString(),
"NumCompileActions", ActionsToExecute.Count(x => x.ActionType == ActionType.Compile).ToString(),
"NumPchCompileActions", ActionsToExecute.Count(x => x.ActionType == ActionType.Compile && x.ProducedItems.Any(y => y.Reference.HasExtension(".pch") || y.Reference.HasExtension(".gch"))).ToString(),
"NumLinkActions", ActionsToExecute.Count(x => x.ActionType == ActionType.Link).ToString(),
"ElapsedTime", (DateTime.UtcNow - StartTime).TotalSeconds.ToString());
}
if (bUsedXGE && BuildConfiguration.bXGEExport)
{
// we exported xge here, we do not test build products
}
else
{
// Verify the link outputs were created (seems to happen with Win64 compiles)
foreach (Action BuildAction in ActionsToExecute)
{
if (BuildAction.ActionType == ActionType.Link)
{
foreach (FileItem Item in BuildAction.ProducedItems)
{
bool bExists;
if (Item.bIsRemoteFile)
{
DateTime UnusedTime;
long UnusedLength;
bExists = RPCUtilHelper.GetRemoteFileInfo(Item.AbsolutePath, out UnusedTime, out UnusedLength);
}
else
{
// allow output to be a directory
bExists = File.Exists(Item.AbsolutePath) || Directory.Exists(Item.AbsolutePath);
}
if (bIsHotReload)
{
string FailedFilename = Path.Combine(Path.GetDirectoryName(Item.AbsolutePath), "failed.hotreload");
if (!bExists)
{
// Create a failed.hotreload file here to indicate that we need to attempt another hotreload link
// step in future, even though no source files have changed.
// This is necessary because we also don't want to link a brand new instance of a module every time
// a user hits the Compile button when nothing has changed.
FileItem.CreateIntermediateTextFile(new FileReference(FailedFilename), "");
}
else
{
try
{
File.Delete(FailedFilename);
}
catch
{
// Ignore but log failed deletions
Log.TraceVerbose("Failed to delete failed.hotreload file \"{0}\" - this may cause redundant hotreloads", FailedFilename);
}
}
}
if (!bExists)
{
throw new BuildException("UBT ERROR: Failed to produce item: " + Item.AbsolutePath);
}
}
}
}
}
}
// Nothing to execute.
else
{
ExecutorName = "NoActionsToExecute";
Log.TraceInformation("Target is up to date");
}
return Result;
}
/// <summary>
/// Links actions with their prerequisite and produced items into an action graph.
/// </summary>
static void LinkActionsAndItems()
{
foreach (Action Action in AllActions)
{
foreach (FileItem ProducedItem in Action.ProducedItems)
{
ProducedItem.ProducingAction = Action;
Action.RelativeCost += ProducedItem.RelativeCost;
}
}
}
static string SplitFilename(string Filename, out string PlatformSuffix, out string ConfigSuffix, out string ProducedItemExtension)
{
string WorkingString = Filename;
ProducedItemExtension = Path.GetExtension(WorkingString);
if (!WorkingString.EndsWith(ProducedItemExtension))
{
throw new BuildException("Bogus extension");
}
WorkingString = WorkingString.Substring(0, WorkingString.Length - ProducedItemExtension.Length);
ConfigSuffix = "";
foreach (UnrealTargetConfiguration CurConfig in Enum.GetValues(typeof(UnrealTargetConfiguration)))
{
if (CurConfig != UnrealTargetConfiguration.Unknown)
{
string Test = "-" + CurConfig;
if (WorkingString.EndsWith(Test))
{
WorkingString = WorkingString.Substring(0, WorkingString.Length - Test.Length);
ConfigSuffix = Test;
break;
}
}
}
PlatformSuffix = "";
foreach (object CurPlatform in Enum.GetValues(typeof(UnrealTargetPlatform)))
{
string Test = "-" + CurPlatform;
if (WorkingString.EndsWith(Test))
{
WorkingString = WorkingString.Substring(0, WorkingString.Length - Test.Length);
PlatformSuffix = Test;
break;
}
}
return WorkingString;
}
/// <summary>
/// Finds and deletes stale hot reload DLLs.
/// </summary>
public static void DeleteStaleHotReloadDLLs()
{
DateTime DeleteStartTime = DateTime.UtcNow;
foreach (Action BuildAction in AllActions)
{
if (BuildAction.ActionType == ActionType.Link)
{
foreach (FileItem Item in BuildAction.ProducedItems)
{
if (Item.bNeedsHotReloadNumbersDLLCleanUp)
{
string PlatformSuffix, ConfigSuffix, ProducedItemExtension;
string Base = SplitFilename(Item.AbsolutePath, out PlatformSuffix, out ConfigSuffix, out ProducedItemExtension);
String WildCard = Base + "-*" + PlatformSuffix + ConfigSuffix + ProducedItemExtension;
// Log.TraceInformation("Deleting old hot reload wildcard: \"{0}\".", WildCard);
// Wildcard search and delete
string DirectoryToLookIn = Path.GetDirectoryName(WildCard);
string FileName = Path.GetFileName(WildCard);
if (Directory.Exists(DirectoryToLookIn))
{
// Delete all files within the specified folder
string[] FilesToDelete = Directory.GetFiles(DirectoryToLookIn, FileName, SearchOption.TopDirectoryOnly);
foreach (string JunkFile in FilesToDelete)
{
string JunkPlatformSuffix, JunkConfigSuffix, JunkProducedItemExtension;
SplitFilename(JunkFile, out JunkPlatformSuffix, out JunkConfigSuffix, out JunkProducedItemExtension);
// now make sure that this file has the same config and platform
if (JunkPlatformSuffix == PlatformSuffix && JunkConfigSuffix == ConfigSuffix)
{
try
{
Log.TraceInformation("Deleting old hot reload file: \"{0}\".", JunkFile);
File.Delete(JunkFile);
}
catch (Exception Ex)
{
// Ignore all exceptions
Log.TraceInformation("Unable to delete old hot reload file: \"{0}\". Error: {0}", JunkFile, Ex.Message);
}
// Delete the PDB file.
string JunkPDBFile = JunkFile.Replace(ProducedItemExtension, ".pdb");
if (System.IO.File.Exists(JunkPDBFile))
{
try
{
Log.TraceInformation("Deleting old hot reload file: \"{0}\".", JunkPDBFile);
File.Delete(JunkPDBFile);
}
catch (Exception Ex)
{
// Ignore all exceptions
Log.TraceInformation("Unable to delete old hot reload file: \"{0}\". Error: {0}", JunkPDBFile, Ex.Message);
}
}
}
}
}
}
}
}
}
if (BuildConfiguration.bPrintPerformanceInfo)
{
double DeleteTime = (DateTime.UtcNow - DeleteStartTime).TotalSeconds;
Log.TraceInformation("Deleting stale hot reload DLLs took " + DeleteTime + "s");
}
}
/// <summary>
/// Sorts the action list for improved parallelism with local execution.
/// </summary>
public static void SortActionList()
{
// Mapping from action to a list of actions that directly or indirectly depend on it (up to a certain depth).
Dictionary<Action, HashSet<Action>> ActionToDependentActionsMap = new Dictionary<Action, HashSet<Action>>();
// Perform multiple passes over all actions to propagate dependencies.
const int MaxDepth = 5;
for (int Pass = 0; Pass < MaxDepth; Pass++)
{
foreach (Action DependendAction in AllActions)
{
foreach (FileItem PrerequisiteItem in DependendAction.PrerequisiteItems)
{
Action PrerequisiteAction = PrerequisiteItem.ProducingAction;
if (PrerequisiteAction != null)
{
HashSet<Action> DependentActions = null;
if (ActionToDependentActionsMap.ContainsKey(PrerequisiteAction))
{
DependentActions = ActionToDependentActionsMap[PrerequisiteAction];
}
else
{
DependentActions = new HashSet<Action>();
ActionToDependentActionsMap[PrerequisiteAction] = DependentActions;
}
// Add dependent action...
DependentActions.Add(DependendAction);
// ... and all actions depending on it.
if (ActionToDependentActionsMap.ContainsKey(DependendAction))
{
DependentActions.UnionWith(ActionToDependentActionsMap[DependendAction]);
}
}
}
}
}
// At this point we have a list of dependent actions for each action, up to MaxDepth layers deep.
foreach (KeyValuePair<Action, HashSet<Action>> ActionMap in ActionToDependentActionsMap)
{
ActionMap.Key.NumTotalDependentActions = ActionMap.Value.Count;
}
// Sort actions by number of actions depending on them, descending. Secondary sort criteria is file size.
AllActions.Sort(Action.Compare);
}
/// <summary>
/// Checks for cycles in the action graph.
/// </summary>
static void DetectActionGraphCycles()
{
// Starting with actions that only depend on non-produced items, iteratively expand a set of actions that are only dependent on
// non-cyclical actions.
Dictionary<Action, bool> ActionIsNonCyclical = new Dictionary<Action, bool>();
Dictionary<Action, List<Action>> CyclicActions = new Dictionary<Action, List<Action>>();
while (true)
{
bool bFoundNewNonCyclicalAction = false;
foreach (Action Action in AllActions)
{
if (!ActionIsNonCyclical.ContainsKey(Action))
{
// Determine if the action depends on only actions that are already known to be non-cyclical.
bool bActionOnlyDependsOnNonCyclicalActions = true;
foreach (FileItem PrerequisiteItem in Action.PrerequisiteItems)
{
if (PrerequisiteItem.ProducingAction != null)
{
if (!ActionIsNonCyclical.ContainsKey(PrerequisiteItem.ProducingAction))
{
bActionOnlyDependsOnNonCyclicalActions = false;
if (!CyclicActions.ContainsKey(Action))
{
CyclicActions.Add(Action, new List<Action>());
}
List<Action> CyclicPrereq = CyclicActions[Action];
if (!CyclicPrereq.Contains(PrerequisiteItem.ProducingAction))
{
CyclicPrereq.Add(PrerequisiteItem.ProducingAction);
}
}
}
}
// If the action only depends on known non-cyclical actions, then add it to the set of known non-cyclical actions.
if (bActionOnlyDependsOnNonCyclicalActions)
{
ActionIsNonCyclical.Add(Action, true);
bFoundNewNonCyclicalAction = true;
}
}
}
// If this iteration has visited all actions without finding a new non-cyclical action, then all non-cyclical actions have
// been found.
if (!bFoundNewNonCyclicalAction)
{
break;
}
}
// If there are any cyclical actions, throw an exception.
if (ActionIsNonCyclical.Count < AllActions.Count)
{
// Describe the cyclical actions.
string CycleDescription = "";
foreach (Action Action in AllActions)
{
if (!ActionIsNonCyclical.ContainsKey(Action))
{
CycleDescription += string.Format("Action #{0}: {1}\n", Action.UniqueId, Action.CommandPath);
CycleDescription += string.Format("\twith arguments: {0}\n", Action.CommandArguments);
foreach (FileItem PrerequisiteItem in Action.PrerequisiteItems)
{
CycleDescription += string.Format("\tdepends on: {0}\n", PrerequisiteItem.AbsolutePath);
}
foreach (FileItem ProducedItem in Action.ProducedItems)
{
CycleDescription += string.Format("\tproduces: {0}\n", ProducedItem.AbsolutePath);
}
CycleDescription += string.Format("\tDepends on cyclic actions:\n");
if (CyclicActions.ContainsKey(Action))
{
foreach (Action CyclicPrerequisiteAction in CyclicActions[Action])
{
if (CyclicPrerequisiteAction.ProducedItems.Count == 1)
{
CycleDescription += string.Format("\t\t{0} (produces: {1})\n", CyclicPrerequisiteAction.UniqueId, CyclicPrerequisiteAction.ProducedItems[0].AbsolutePath);
}
else
{
CycleDescription += string.Format("\t\t{0}\n", CyclicPrerequisiteAction.UniqueId);
foreach (FileItem CyclicProducedItem in CyclicPrerequisiteAction.ProducedItems)
{
CycleDescription += string.Format("\t\t\tproduces: {0}\n", CyclicProducedItem.AbsolutePath);
}
}
}
CycleDescription += "\n";
}
else
{
CycleDescription += string.Format("\t\tNone?? Coding error!\n");
}
CycleDescription += "\n\n";
}
}
throw new BuildException("Action graph contains cycle!\n\n{0}", CycleDescription);
}
}
/// <summary>
/// Determines the full set of actions that must be built to produce an item.
/// </summary>
/// <param name="OutputItem">- The item to be built.</param>
/// <param name="PrerequisiteActions">- The actions that must be built and the root action are</param>
public static void GatherPrerequisiteActions(
FileItem OutputItem,
ref HashSet<Action> PrerequisiteActions
)
{
if (OutputItem != null && OutputItem.ProducingAction != null)
{
if (!PrerequisiteActions.Contains(OutputItem.ProducingAction))
{
PrerequisiteActions.Add(OutputItem.ProducingAction);
foreach (FileItem PrerequisiteItem in OutputItem.ProducingAction.PrerequisiteItems)
{
GatherPrerequisiteActions(PrerequisiteItem, ref PrerequisiteActions);
}
}
}
}
/// <summary>
/// Determines whether an action is outdated based on the modification times for its prerequisite
/// and produced items.
/// </summary>
/// <param name="RootAction">- The action being considered.</param>
/// <param name="OutdatedActionDictionary">-</param>
/// <returns>true if outdated</returns>
static public bool IsActionOutdated(UEBuildTarget Target, Action RootAction, ref Dictionary<Action, bool> OutdatedActionDictionary, ActionHistory ActionHistory, Dictionary<UEBuildTarget, List<FileItem>> TargetToOutdatedPrerequisitesMap)
{
// Only compute the outdated-ness for actions that don't aren't cached in the outdated action dictionary.
bool bIsOutdated = false;
if (!OutdatedActionDictionary.TryGetValue(RootAction, out bIsOutdated))
{
// Determine the last time the action was run based on the write times of its produced files.
string LatestUpdatedProducedItemName = null;
DateTimeOffset LastExecutionTime = DateTimeOffset.MaxValue;
foreach (FileItem ProducedItem in RootAction.ProducedItems)
{
// Optionally skip the action history check, as this only works for local builds
if (BuildConfiguration.bUseActionHistory)
{
// Check if the command-line of the action previously used to produce the item is outdated.
string OldProducingCommandLine = "";
string NewProducingCommandLine = RootAction.CommandPath + " " + RootAction.CommandArguments;
if (!ActionHistory.GetProducingCommandLine(ProducedItem, out OldProducingCommandLine)
|| !String.Equals(OldProducingCommandLine, NewProducingCommandLine, StringComparison.InvariantCultureIgnoreCase))
{
Log.TraceVerbose(
"{0}: Produced item \"{1}\" was produced by outdated command-line.\nOld command-line: {2}\nNew command-line: {3}",
RootAction.StatusDescription,
Path.GetFileName(ProducedItem.AbsolutePath),
OldProducingCommandLine,
NewProducingCommandLine
);
bIsOutdated = true;
// Update the command-line used to produce this item in the action history.
ActionHistory.SetProducingCommandLine(ProducedItem, NewProducingCommandLine);
}
}
// If the produced file doesn't exist or has zero size, consider it outdated. The zero size check is to detect cases
// where aborting an earlier compile produced invalid zero-sized obj files, but that may cause actions where that's
// legitimate output to always be considered outdated.
if (ProducedItem.bExists && (ProducedItem.bIsRemoteFile || ProducedItem.Length > 0 || ProducedItem.IsDirectory))
{
// When linking incrementally, don't use LIB, EXP pr PDB files when checking for the oldest produced item,
// as those files aren't always touched.
if (BuildConfiguration.bUseIncrementalLinking)
{
String ProducedItemExtension = Path.GetExtension(ProducedItem.AbsolutePath).ToUpperInvariant();
if (ProducedItemExtension == ".LIB" || ProducedItemExtension == ".EXP" || ProducedItemExtension == ".PDB")
{
continue;
}
}
// Use the oldest produced item's time as the last execution time.
if (ProducedItem.LastWriteTime < LastExecutionTime)
{
LastExecutionTime = ProducedItem.LastWriteTime;
LatestUpdatedProducedItemName = ProducedItem.AbsolutePath;
}
}
else
{
// If any of the produced items doesn't exist, the action is outdated.
Log.TraceVerbose(
"{0}: Produced item \"{1}\" doesn't exist.",
RootAction.StatusDescription,
Path.GetFileName(ProducedItem.AbsolutePath)
);
bIsOutdated = true;
}
}
Log.WriteLineIf(BuildConfiguration.bLogDetailedActionStats && !String.IsNullOrEmpty(LatestUpdatedProducedItemName),
LogEventType.Verbose, "{0}: Oldest produced item is {1}", RootAction.StatusDescription, LatestUpdatedProducedItemName);
bool bCheckIfIncludedFilesAreNewer = false;
bool bPerformExhaustiveIncludeSearchAndUpdateCache = false;
if (RootAction.ActionType == ActionType.Compile)
{
// Outdated targets don't need their headers scanned yet, because presumably they would already be out of dated based on already-cached
// includes before getting this far. However, if we find them to be outdated after processing includes, we'll do a deep scan later
// on and cache all of the includes so that we have them for a quick outdatedness check the next run.
if (!bIsOutdated &&
BuildConfiguration.bUseUBTMakefiles &&
UnrealBuildTool.IsAssemblingBuild &&
RootAction.ActionType == ActionType.Compile)
{
bCheckIfIncludedFilesAreNewer = true;
}
// Were we asked to force an update of our cached includes BEFORE we try to build? This may be needed if our cache can no longer
// be trusted and we need to fill it with perfectly valid data (even if we're in assembler only mode)
if (BuildConfiguration.bUseUBTMakefiles &&
UnrealBuildTool.bNeedsFullCPPIncludeRescan)
{
// This will be slow!
bPerformExhaustiveIncludeSearchAndUpdateCache = true;
}
}
if (bCheckIfIncludedFilesAreNewer || bPerformExhaustiveIncludeSearchAndUpdateCache)
{
// Scan this file for included headers that may be out of date. Note that it's OK if we break out early because we found
// the action to be outdated. For outdated actions, we kick off a separate include scan in a background thread later on to
// catch all of the other includes and form an exhaustive set.
UEBuildPlatform BuildPlatform = UEBuildPlatform.GetBuildPlatform(Target.Platform);
foreach (FileItem PrerequisiteItem in RootAction.PrerequisiteItems)
{
// @todo ubtmake: Make sure we are catching RC files here too. Anything that the toolchain would have tried it on. Logic should match the CACHING stuff below
if (PrerequisiteItem.CachedCPPIncludeInfo != null)
{
List<FileItem> IncludedFileList = CPPEnvironment.FindAndCacheAllIncludedFiles(Target, PrerequisiteItem, BuildPlatform, PrerequisiteItem.CachedCPPIncludeInfo, bOnlyCachedDependencies: !bPerformExhaustiveIncludeSearchAndUpdateCache);
if (IncludedFileList != null)
{
foreach (FileItem IncludedFile in IncludedFileList)
{
if (IncludedFile.bExists)
{
// allow a 1 second slop for network copies
TimeSpan TimeDifference = IncludedFile.LastWriteTime - LastExecutionTime;
bool bPrerequisiteItemIsNewerThanLastExecution = TimeDifference.TotalSeconds > 1;
if (bPrerequisiteItemIsNewerThanLastExecution)
{
Log.TraceVerbose(
"{0}: Included file {1} is newer than the last execution of the action: {2} vs {3}",
RootAction.StatusDescription,
Path.GetFileName(IncludedFile.AbsolutePath),
IncludedFile.LastWriteTime.LocalDateTime,
LastExecutionTime.LocalDateTime
);
bIsOutdated = true;
// Don't bother checking every single include if we've found one that is out of date
break;
}
}
}
}
}
if (bIsOutdated)
{
break;
}
}
}
if (!bIsOutdated)
{
// Check if any of the prerequisite items are produced by outdated actions, or have changed more recently than
// the oldest produced item.
foreach (FileItem PrerequisiteItem in RootAction.PrerequisiteItems)
{
// Only check for outdated import libraries if we were configured to do so. Often, a changed import library
// won't affect a dependency unless a public header file was also changed, in which case we would be forced
// to recompile anyway. This just allows for faster iteration when working on a subsystem in a DLL, as we
// won't have to wait for dependent targets to be relinked after each change.
bool bIsImportLibraryFile = false;
if (PrerequisiteItem.ProducingAction != null && PrerequisiteItem.ProducingAction.bProducesImportLibrary)
{
bIsImportLibraryFile = PrerequisiteItem.AbsolutePath.EndsWith(".LIB", StringComparison.InvariantCultureIgnoreCase);
}
if (!bIsImportLibraryFile || !BuildConfiguration.bIgnoreOutdatedImportLibraries)
{
// If the prerequisite is produced by an outdated action, then this action is outdated too.
if (PrerequisiteItem.ProducingAction != null)
{
if (IsActionOutdated(Target, PrerequisiteItem.ProducingAction, ref OutdatedActionDictionary, ActionHistory, TargetToOutdatedPrerequisitesMap))
{
Log.TraceVerbose(
"{0}: Prerequisite {1} is produced by outdated action.",
RootAction.StatusDescription,
Path.GetFileName(PrerequisiteItem.AbsolutePath)
);
bIsOutdated = true;
}
}
if (PrerequisiteItem.bExists)
{
// allow a 1 second slop for network copies
TimeSpan TimeDifference = PrerequisiteItem.LastWriteTime - LastExecutionTime;
bool bPrerequisiteItemIsNewerThanLastExecution = TimeDifference.TotalSeconds > 1;
if (bPrerequisiteItemIsNewerThanLastExecution)
{
Log.TraceVerbose(
"{0}: Prerequisite {1} is newer than the last execution of the action: {2} vs {3}",
RootAction.StatusDescription,
Path.GetFileName(PrerequisiteItem.AbsolutePath),
PrerequisiteItem.LastWriteTime.LocalDateTime,
LastExecutionTime.LocalDateTime
);
bIsOutdated = true;
}
}
// GatherAllOutdatedActions will ensure all actions are checked for outdated-ness, so we don't need to recurse with
// all this action's prerequisites once we've determined it's outdated.
if (bIsOutdated)
{
break;
}
}
}
}
// For compile actions, we have C++ files that are actually dependent on header files that could have been changed. We only need to
// know about the set of header files that are included for files that are already determined to be out of date (such as if the file
// is missing or was modified.) In the case that the file is out of date, we'll perform a deep scan to update our cached set of
// includes for this file, so that we'll be able to determine whether it is out of date next time very quickly.
if (BuildConfiguration.bUseUBTMakefiles)
{
DateTime DeepIncludeScanStartTime = DateTime.UtcNow;
// @todo ubtmake: we may be scanning more files than we need to here -- indirectly outdated files are bIsOutdated=true by this point (for example basemost includes when deeper includes are dirty)
if (bIsOutdated && RootAction.ActionType == ActionType.Compile) // @todo ubtmake: Does this work with RC files? See above too.
{
Log.TraceVerbose("Outdated action: {0}", RootAction.StatusDescription);
foreach (FileItem PrerequisiteItem in RootAction.PrerequisiteItems)
{
if (PrerequisiteItem.CachedCPPIncludeInfo != null)
{
if (!IsCPPFile(PrerequisiteItem))
{
throw new BuildException("Was only expecting C++ files to have CachedCPPEnvironments!");
}
Log.TraceVerbose(" -> DEEP include scan: {0}", PrerequisiteItem.AbsolutePath);
List<FileItem> OutdatedPrerequisites;
if (!TargetToOutdatedPrerequisitesMap.TryGetValue(Target, out OutdatedPrerequisites))
{
OutdatedPrerequisites = new List<FileItem>();
TargetToOutdatedPrerequisitesMap.Add(Target, OutdatedPrerequisites);
}
OutdatedPrerequisites.Add(PrerequisiteItem);
}
else if (IsCPPImplementationFile(PrerequisiteItem) || IsCPPResourceFile(PrerequisiteItem))
{
if (PrerequisiteItem.CachedCPPIncludeInfo == null)
{
Log.TraceVerbose(" -> WARNING: No CachedCPPEnvironment: {0}", PrerequisiteItem.AbsolutePath);
}
}
}
}
if (BuildConfiguration.bPrintPerformanceInfo)
{
double DeepIncludeScanTime = (DateTime.UtcNow - DeepIncludeScanStartTime).TotalSeconds;
UnrealBuildTool.TotalDeepIncludeScanTime += DeepIncludeScanTime;
}
}
// Cache the outdated-ness of this action.
OutdatedActionDictionary.Add(RootAction, bIsOutdated);
}
return bIsOutdated;
}
/// <summary>
/// Builds a dictionary containing the actions from AllActions that are outdated by calling
/// IsActionOutdated.
/// </summary>
static void GatherAllOutdatedActions(UEBuildTarget Target, ActionHistory ActionHistory, ref Dictionary<Action, bool> OutdatedActions, Dictionary<UEBuildTarget, List<FileItem>> TargetToOutdatedPrerequisitesMap)
{
DateTime CheckOutdatednessStartTime = DateTime.UtcNow;
foreach (Action Action in AllActions)
{
IsActionOutdated(Target, Action, ref OutdatedActions, ActionHistory, TargetToOutdatedPrerequisitesMap);
}
if (BuildConfiguration.bPrintPerformanceInfo)
{
double CheckOutdatednessTime = (DateTime.UtcNow - CheckOutdatednessStartTime).TotalSeconds;
Log.TraceInformation("Checking actions for " + Target.GetTargetName() + " took " + CheckOutdatednessTime + "s");
}
}
/// <summary>
/// Deletes all the items produced by actions in the provided outdated action dictionary.
/// </summary>
/// <param name="OutdatedActionDictionary">Dictionary of outdated actions</param>
/// <param name="bShouldDeleteAllFiles"> Whether to delete all files associated with outdated items or just ones required</param>
static void DeleteOutdatedProducedItems(Dictionary<Action, bool> OutdatedActionDictionary, bool bShouldDeleteAllFiles)
{
foreach (KeyValuePair<Action, bool> OutdatedActionInfo in OutdatedActionDictionary)
{
if (OutdatedActionInfo.Value)
{
Action OutdatedAction = OutdatedActionInfo.Key;
foreach (FileItem ProducedItem in OutdatedActionInfo.Key.ProducedItems)
{
if (ProducedItem.bExists
&& (bShouldDeleteAllFiles
// Delete PDB files as incremental updates are slower than full ones.
|| (!BuildConfiguration.bUseIncrementalLinking && ProducedItem.AbsolutePath.EndsWith(".PDB", StringComparison.InvariantCultureIgnoreCase))
|| OutdatedAction.bShouldDeleteProducedItems))
{
Log.TraceVerbose("Deleting outdated item: {0}", ProducedItem.AbsolutePath);
ProducedItem.Delete();
}
}
}
}
}
/// <summary>
/// Creates directories for all the items produced by actions in the provided outdated action
/// dictionary.
/// </summary>
static void CreateDirectoriesForProducedItems(Dictionary<Action, bool> OutdatedActionDictionary)
{
foreach (KeyValuePair<Action, bool> OutdatedActionInfo in OutdatedActionDictionary)
{
if (OutdatedActionInfo.Value)
{
foreach (FileItem ProducedItem in OutdatedActionInfo.Key.ProducedItems)
{
if (ProducedItem.bIsRemoteFile)
{
// we don't need to do this in the SSH mode, the action will have an output file, and it will use that to make the directory while executing the command
if (RemoteToolChain.bUseRPCUtil)
{
try
{
RPCUtilHelper.MakeDirectory(Path.GetDirectoryName(ProducedItem.AbsolutePath).Replace("\\", "/"));
}
catch (System.Exception Ex)
{
throw new BuildException(Ex, "Error while creating remote directory for '{0}'. (Exception: {1})", ProducedItem.AbsolutePath, Ex.Message);
}
}
}
else
{
string DirectoryPath = Path.GetDirectoryName(ProducedItem.AbsolutePath);
if (!Directory.Exists(DirectoryPath))
{
Log.TraceVerbose("Creating directory for produced item: {0}", DirectoryPath);
Directory.CreateDirectory(DirectoryPath);
}
}
}
}
}
}
/// <summary>
/// Checks if the specified file is a C++ source implementation file (e.g., .cpp)
/// </summary>
/// <param name="FileItem">The file to check</param>
/// <returns>True if this is a C++ source file</returns>
private static bool IsCPPImplementationFile(FileItem FileItem)
{
return (FileItem.AbsolutePath.EndsWith(".cpp", StringComparison.InvariantCultureIgnoreCase) ||
FileItem.AbsolutePath.EndsWith(".c", StringComparison.InvariantCultureIgnoreCase) ||
FileItem.AbsolutePath.EndsWith(".mm", StringComparison.InvariantCultureIgnoreCase));
}
/// <summary>
/// Checks if the specified file is a C++ source header file (e.g., .h or .inl)
/// </summary>
/// <param name="FileItem">The file to check</param>
/// <returns>True if this is a C++ source file</returns>
private static bool IsCPPIncludeFile(FileItem FileItem)
{
return (FileItem.AbsolutePath.EndsWith(".h", StringComparison.InvariantCultureIgnoreCase) ||
FileItem.AbsolutePath.EndsWith(".hpp", StringComparison.InvariantCultureIgnoreCase) ||
FileItem.AbsolutePath.EndsWith(".inl", StringComparison.InvariantCultureIgnoreCase));
}
/// <summary>
/// Checks if the specified file is a C++ resource file (e.g., .rc)
/// </summary>
/// <param name="FileItem">The file to check</param>
/// <returns>True if this is a C++ source file</returns>
private static bool IsCPPResourceFile(FileItem FileItem)
{
return (FileItem.AbsolutePath.EndsWith(".rc", StringComparison.InvariantCultureIgnoreCase));
}
/// <summary>
/// Checks if the specified file is a C++ source file
/// </summary>
/// <param name="FileItem">The file to check</param>
/// <returns>True if this is a C++ source file</returns>
private static bool IsCPPFile(FileItem FileItem)
{
return IsCPPImplementationFile(FileItem) || IsCPPIncludeFile(FileItem) || IsCPPResourceFile(FileItem);
}
/// <summary>
/// Types of action graph visualizations that we can emit
/// </summary>
public enum ActionGraphVisualizationType
{
OnlyActions,
ActionsWithFiles,
ActionsWithFilesAndHeaders,
OnlyFilesAndHeaders,
OnlyCPlusPlusFilesAndHeaders
}
/// <summary>
/// Saves the action graph (and include dependency network) to a graph gile
/// </summary>
/// <param name="Filename">File name to emit</param>
/// <param name="Description">Description to be stored in graph metadata</param>
/// <param name="VisualizationType">Type of graph to create</param>
/// <param name="Actions">All actions</param>
/// <param name="IncludeCompileActions">True if we should include compile actions. If disabled, only the static link actions will be shown, which is useful to see module relationships</param>
public static void SaveActionGraphVisualization(UEBuildTarget Target, string Filename, string Description, ActionGraphVisualizationType VisualizationType, List<Action> Actions, bool IncludeCompileActions = true)
{
// True if we should include individual files in the graph network, or false to include only the build actions
bool IncludeFiles = VisualizationType != ActionGraphVisualizationType.OnlyActions;
bool OnlyIncludeCPlusPlusFiles = VisualizationType == ActionGraphVisualizationType.OnlyCPlusPlusFilesAndHeaders;
// True if want to show actions in the graph, otherwise we're only showing files
bool IncludeActions = VisualizationType != ActionGraphVisualizationType.OnlyFilesAndHeaders && VisualizationType != ActionGraphVisualizationType.OnlyCPlusPlusFilesAndHeaders;
// True if C++ header dependencies should be expanded into the graph, or false to only have .cpp files
bool ExpandCPPHeaderDependencies = IncludeFiles && (VisualizationType == ActionGraphVisualizationType.ActionsWithFilesAndHeaders || VisualizationType == ActionGraphVisualizationType.OnlyFilesAndHeaders || VisualizationType == ActionGraphVisualizationType.OnlyCPlusPlusFilesAndHeaders);
DateTime TimerStartTime = DateTime.UtcNow;
List<GraphNode> GraphNodes = new List<GraphNode>();
Dictionary<FileItem, GraphNode> FileToGraphNodeMap = new Dictionary<FileItem, GraphNode>();
// Filter our list of actions
List<Action> FilteredActions = new List<Action>();
{
for (int ActionIndex = 0; ActionIndex < Actions.Count; ++ActionIndex)
{
Action Action = Actions[ActionIndex];
if (!IncludeActions || IncludeCompileActions || (Action.ActionType != ActionType.Compile))
{
FilteredActions.Add(Action);
}
}
}
HashSet<FileItem> FilesToCreateNodesFor = new HashSet<FileItem>();
for (int ActionIndex = 0; ActionIndex < FilteredActions.Count; ++ActionIndex)
{
Action Action = FilteredActions[ActionIndex];
if (IncludeActions)
{
GraphNode GraphNode = new GraphNode()
{
Id = GraphNodes.Count,
// Don't bother including "Link" text if we're excluding compile actions
Label = IncludeCompileActions ? (Action.ActionType.ToString() + " " + Action.StatusDescription) : Action.StatusDescription
};
switch (Action.ActionType)
{
case ActionType.BuildProject:
GraphNode.Color = new GraphColor() { R = 0.3f, G = 1.0f, B = 1.0f, A = 1.0f };
GraphNode.Size = 1.1f;
break;
case ActionType.Compile:
GraphNode.Color = new GraphColor() { R = 0.3f, G = 1.0f, B = 0.3f, A = 1.0f };
break;
case ActionType.Link:
GraphNode.Color = new GraphColor() { R = 0.3f, G = 0.3f, B = 1.0f, A = 1.0f };
GraphNode.Size = 1.2f;
break;
}
GraphNodes.Add(GraphNode);
}
if (IncludeFiles)
{
foreach (FileItem ProducedFileItem in Action.ProducedItems)
{
if (!OnlyIncludeCPlusPlusFiles || IsCPPFile(ProducedFileItem))
{
FilesToCreateNodesFor.Add(ProducedFileItem);
}
}
foreach (FileItem PrerequisiteFileItem in Action.PrerequisiteItems)
{
if (!OnlyIncludeCPlusPlusFiles || IsCPPFile(PrerequisiteFileItem))
{
FilesToCreateNodesFor.Add(PrerequisiteFileItem);
}
}
}
}
Dictionary<FileItem, List<FileItem>> OverriddenPrerequisites = new Dictionary<FileItem, List<FileItem>>();
// Determine the average size of all of the C++ source files
Int64 AverageCPPFileSize;
{
Int64 TotalFileSize = 0;
int CPPFileCount = 0;
foreach (FileItem FileItem in FilesToCreateNodesFor)
{
if (IsCPPFile(FileItem))
{
++CPPFileCount;
TotalFileSize += new FileInfo(FileItem.AbsolutePath).Length;
}
}
if (CPPFileCount > 0)
{
AverageCPPFileSize = TotalFileSize / CPPFileCount;
}
else
{
AverageCPPFileSize = 1;
}
}
UEBuildPlatform BuildPlatform = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.Win64);
foreach (FileItem FileItem in FilesToCreateNodesFor)
{
GraphNode FileGraphNode = new GraphNode()
{
Id = GraphNodes.Count,
Label = Path.GetFileName(FileItem.AbsolutePath)
};
if (FileItem.AbsolutePath.EndsWith(".h", StringComparison.InvariantCultureIgnoreCase) ||
FileItem.AbsolutePath.EndsWith(".inl", StringComparison.InvariantCultureIgnoreCase))
{
// Header file
FileGraphNode.Color = new GraphColor() { R = 0.9f, G = 0.2f, B = 0.9f, A = 1.0f };
}
else if (FileItem.AbsolutePath.EndsWith(".cpp", StringComparison.InvariantCultureIgnoreCase) ||
FileItem.AbsolutePath.EndsWith(".c", StringComparison.InvariantCultureIgnoreCase) ||
FileItem.AbsolutePath.EndsWith(".mm", StringComparison.InvariantCultureIgnoreCase))
{
// C++ file
FileGraphNode.Color = new GraphColor() { R = 1.0f, G = 1.0f, B = 0.3f, A = 1.0f };
}
else
{
// Other file
FileGraphNode.Color = new GraphColor() { R = 0.4f, G = 0.4f, B = 0.1f, A = 1.0f };
}
// Set the size of the file node based on the size of the file on disk
bool bIsCPPFile = IsCPPFile(FileItem);
if (bIsCPPFile)
{
float MinNodeSize = 0.25f;
float MaxNodeSize = 2.0f;
long FileSize = new FileInfo(FileItem.AbsolutePath).Length;
float FileSizeScale = (float)((double)FileSize / (double)AverageCPPFileSize);
float SourceFileSizeScaleFactor = 0.1f; // How much to make nodes for files bigger or larger based on their difference from the average file's size
FileGraphNode.Size = Math.Min(Math.Max(1.0f + SourceFileSizeScaleFactor * FileSizeScale, MinNodeSize), MaxNodeSize);
}
//@todo: Testing out attribute support. Replace with an attribute that is actually useful!
//if( FileItem.PrecompiledHeaderIncludeFilename != null )
//{
//FileGraphNode.Attributes[ "PCHFile" ] = Path.GetFileNameWithoutExtension( FileItem.PrecompiledHeaderIncludeFilename );
//}
FileToGraphNodeMap[FileItem] = FileGraphNode;
GraphNodes.Add(FileGraphNode);
if (ExpandCPPHeaderDependencies && bIsCPPFile)
{
List<DependencyInclude> DirectlyIncludedFilenames = CPPEnvironment.GetDirectIncludeDependencies(Target, FileItem, BuildPlatform, bOnlyCachedDependencies: false);
// Resolve the included file name to an actual file.
List<FileItem> DirectlyIncludedFiles =
DirectlyIncludedFilenames
.Where(DirectlyIncludedFilename => (DirectlyIncludedFilename.IncludeResolvedNameIfSuccessful != null))
.Select(DirectlyIncludedFilename => DirectlyIncludedFilename.IncludeResolvedNameIfSuccessful)
// Skip same include over and over (.inl files)
.Distinct()
.Select(FileItem.GetItemByFileReference)
.ToList();
OverriddenPrerequisites[FileItem] = DirectlyIncludedFiles;
}
}
// Connect everything together
List<GraphEdge> GraphEdges = new List<GraphEdge>();
if (IncludeActions)
{
for (int ActionIndex = 0; ActionIndex < FilteredActions.Count; ++ActionIndex)
{
Action Action = FilteredActions[ActionIndex];
GraphNode ActionGraphNode = GraphNodes[ActionIndex];
List<FileItem> ActualPrerequisiteItems = Action.PrerequisiteItems;
if (IncludeFiles && ExpandCPPHeaderDependencies && Action.ActionType == ActionType.Compile)
{
// The first prerequisite is always the .cpp file to compile
FileItem CPPFile = Action.PrerequisiteItems[0];
if (!IsCPPFile(CPPFile))
{
throw new BuildException("Was expecting a C++ file as the first prerequisite for a Compile action");
}
ActualPrerequisiteItems = new List<FileItem>();
ActualPrerequisiteItems.Add(CPPFile);
}
foreach (FileItem PrerequisiteFileItem in ActualPrerequisiteItems)
{
if (IncludeFiles)
{
GraphNode PrerequisiteFileGraphNode;
if (FileToGraphNodeMap.TryGetValue(PrerequisiteFileItem, out PrerequisiteFileGraphNode))
{
// Connect a file our action is dependent on, to our action itself
GraphEdge GraphEdge = new GraphEdge()
{
Id = GraphEdges.Count,
Source = PrerequisiteFileGraphNode,
Target = ActionGraphNode,
};
GraphEdges.Add(GraphEdge);
}
else
{
// Not a file we were tracking
// Console.WriteLine( "Unknown file: " + PrerequisiteFileItem.AbsolutePath );
}
}
else if (PrerequisiteFileItem.ProducingAction != null)
{
// Not showing files, so connect the actions together
int ProducingActionIndex = FilteredActions.IndexOf(PrerequisiteFileItem.ProducingAction);
if (ProducingActionIndex != -1)
{
GraphNode SourceGraphNode = GraphNodes[ProducingActionIndex];
GraphEdge GraphEdge = new GraphEdge()
{
Id = GraphEdges.Count,
Source = SourceGraphNode,
Target = ActionGraphNode,
};
GraphEdges.Add(GraphEdge);
}
else
{
// Our producer action was filtered out
}
}
}
foreach (FileItem ProducedFileItem in Action.ProducedItems)
{
if (IncludeFiles)
{
if (!OnlyIncludeCPlusPlusFiles || IsCPPFile(ProducedFileItem))
{
GraphNode ProducedFileGraphNode = FileToGraphNodeMap[ProducedFileItem];
GraphEdge GraphEdge = new GraphEdge()
{
Id = GraphEdges.Count,
Source = ActionGraphNode,
Target = ProducedFileGraphNode,
};
GraphEdges.Add(GraphEdge);
}
}
}
}
}
if (IncludeFiles && ExpandCPPHeaderDependencies)
{
// Fill in overridden prerequisites
foreach (KeyValuePair<FileItem, List<FileItem>> FileAndPrerequisites in OverriddenPrerequisites)
{
FileItem FileItem = FileAndPrerequisites.Key;
List<FileItem> FilePrerequisites = FileAndPrerequisites.Value;
GraphNode FileGraphNode = FileToGraphNodeMap[FileItem];
foreach (FileItem PrerequisiteFileItem in FilePrerequisites)
{
GraphNode PrerequisiteFileGraphNode;
if (FileToGraphNodeMap.TryGetValue(PrerequisiteFileItem, out PrerequisiteFileGraphNode))
{
GraphEdge GraphEdge = new GraphEdge()
{
Id = GraphEdges.Count,
Source = PrerequisiteFileGraphNode,
Target = FileGraphNode,
};
GraphEdges.Add(GraphEdge);
}
else
{
// Some other header that we don't track directly
//Console.WriteLine( "File not known: " + PrerequisiteFileItem.AbsolutePath );
}
}
}
}
GraphVisualization.WriteGraphFile(Filename, Description, GraphNodes, GraphEdges);
if (BuildConfiguration.bPrintPerformanceInfo)
{
TimeSpan TimerDuration = DateTime.UtcNow - TimerStartTime;
Log.TraceInformation("Generating and saving ActionGraph took " + TimerDuration.TotalSeconds + "s");
}
}
};
}