Files
UnrealEngineUWP/Engine/Source/Programs/UnrealBuildTool/Android/AndroidToolChain.cs
Robert Manuszewski 17538be4f8 Copying //UE4/Dev-Core to //UE4/Dev-Main (Source: //UE4/Dev-Core @ 3151653)
#lockdown Nick.Penwarden

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

Change 2975891 on 2016/05/12 by Gil.Gribb

	merged in new async stuff from dev-rendering.

Change 2976695 on 2016/05/13 by Gil.Gribb

	updated precache list

Change 2977030 on 2016/05/13 by Gil.Gribb

	Added time slicing to CreateAsyncPackagesFromQueue, radically reduced the frequency of "precache trimming" and changed a few things in the test rig and logging

Change 2977090 on 2016/05/13 by Gil.Gribb

	Fixed module manager threading and added cmd line param to force async loading thread.

Change 2977292 on 2016/05/13 by Gil.Gribb

	check for thread safety in looking at asset registry

Change 2977296 on 2016/05/13 by Gil.Gribb

	removed some super-expensive check()s from precacher

Change 2978368 on 2016/05/16 by Gil.Gribb

	Move several exposive bools inside of the basic tests inside of FLinkerLoad::Preload, saves a fraction of second.

Change 2978414 on 2016/05/16 by Gil.Gribb

	Added support and testing for unmounting pak files to the pak precacher.

Change 2978446 on 2016/05/16 by Gil.Gribb

	Allow linker listing in non-shipping builds

Change 2978550 on 2016/05/16 by Gil.Gribb

	Allowed some linker spew in non-shipping builds (instead of debug builds). Some tweak to help track down the music.uasset leak.

Change 2979952 on 2016/05/17 by Robert.Manuszewski

	Merging //UE4/Dev-Core @ 2979938 to Dev-UE-30519-LoadTimes

Change 2984927 on 2016/05/20 by Gil.Gribb

	fix a few bugs with an mcp repro

Change 2984951 on 2016/05/20 by Gil.Gribb

	fixed issues with USE_NEW_ASYNC_IO = 0

Change 2985296 on 2016/05/20 by Gil.Gribb

	Fixed several bugs with the MCP boot test

Change 2987956 on 2016/05/24 by Robert.Manuszewski

	Fixing leaked linkers created by blocking load requests during async loading.

Change 2987959 on 2016/05/24 by Joe.Conley

	Enable load timings in block loading also (in addition to async loading).

Change 3017713 on 2016/06/17 by Robert.Manuszewski

	Removing GUseSeekFreeLoading.

Change 3017722 on 2016/06/17 by Robert.Manuszewski

	Renaming LOAD_SeekFree flag to LOAD_Async to better reflect its current purpose.

Change 3017833 on 2016/06/17 by Robert.Manuszewski

	Merging //UE4/Dev-Core to Dev-UE-30519-LoadTimes (//Tasks/Dev-Core/Dev-UE-30519-LoadTimes)

Change 3017840 on 2016/06/17 by Robert.Manuszewski

	Re-doing Dev-Core changes to Delegates 2/2

Change 3022872 on 2016/06/22 by Gil.Gribb

	reorder memory trim and deleting loaders

Change 3059218 on 2016/07/21 by Robert.Manuszewski

	Fixing compilation errors - adding missing load time tracker stats.

Change 3064508 on 2016/07/26 by Robert.Manuszewski

	Removing blocking loading path in cooked builds. LoadPackage will now use the async path.

Change 3066312 on 2016/07/27 by Gil.Gribb

	Event driven loader, first pass

Change 3066785 on 2016/07/27 by Gil.Gribb

	Removed check...searching forward for export fusion can release a node

Change 3068118 on 2016/07/28 by Gil.Gribb

	critical bug fixes for the event driven loader

Change 3068333 on 2016/07/28 by Gil.Gribb

	correctly handle the case where a file is rejected after loading the summary

Change 3069618 on 2016/07/28 by Robert.Manuszewski

	Merging //UE4/Dev-Core to Dev-UE-30519-LoadTimes (//Tasks/Dev-Core/Dev-UE-30519-LoadTimes)

Change 3069901 on 2016/07/29 by Robert.Manuszewski

	Fixing an hang when loading QA-Blueprints level

Change 3070171 on 2016/07/29 by Gil.Gribb

	fixed CDO cyclic dependencies

Change 3075288 on 2016/08/03 by Gil.Gribb

	misc fixes to the event driven loader

Change 3077332 on 2016/08/04 by Robert.Manuszewski

	Fixing checkSlow asserts caused by new loading code not being flagged as IsInAsyncLoadThread() and CreateSynchEvent deprecation warning.

Change 3078113 on 2016/08/04 by Gil.Gribb

	implemented "nicks rule" and undid some previous material and world hacks needed without it.

Change 3079480 on 2016/08/05 by Gil.Gribb

	fixes and tweaks on event driven loader

Change 3080135 on 2016/08/07 by Gil.Gribb

	misc fixes for event driven loader, now with reasonable memory

Change 3083722 on 2016/08/10 by Robert.Manuszewski

	Fixing hangs when async loading packages.

Change 3091747 on 2016/08/17 by Gil.Gribb

	Fix all hitches in streaming load that were regressions.

Change 3093258 on 2016/08/18 by Gil.Gribb

	Fix bug that caused an assert when packages fail to load for certain reasons (like loading an uncooked file).

Change 3095719 on 2016/08/20 by Gil.Gribb

	reenable async loading thread and cleanup and bug fixes

Change 3096350 on 2016/08/22 by Gil.Gribb

	tweak task priorities a bit to minimize precaching memory

Change 3096355 on 2016/08/22 by Gil.Gribb

	add support for precaching for "loose files" in the generic async layer.

Change 3098091 on 2016/08/23 by Gil.Gribb

	Split header into a separate file and disabled a bad optimization in the bulk data.

Change 3099783 on 2016/08/24 by Gil.Gribb

	rework dependency graph to be much, much faster. About half done.

Change 3100995 on 2016/08/25 by Gil.Gribb

	fixed bugs with streaming texture from .uexp and cook time check that should have been runtime only

Change 3101369 on 2016/08/25 by Gil.Gribb

	fixed bug with blueprints in the new loader.

Change 3102793 on 2016/08/26 by Gil.Gribb

	PS4 - fixed small block memcpy to actually be inline

Change 3103785 on 2016/08/27 by Gil.Gribb

	fixed case bug with pak order. devirtualized flinkerload::serialize, made sure -fileopenlog is not heavily skewed

Change 3104884 on 2016/08/29 by Gil.Gribb

	fixed a BP bug and tweaked the -fileopenlog behavior to do leaf assets DFS

Change 3105266 on 2016/08/29 by Ben.Zeigler

	Editor build compilation fix

Change 3105774 on 2016/08/30 by Gil.Gribb

	add checks to locate cases where we try to use something that isn't loaded yet

Change 3107794 on 2016/08/31 by Gil.Gribb

	fixed abug with BP's not loading the parent CDO soon enough

Change 3114278 on 2016/09/06 by Gil.Gribb

	looping loads for paragon load test

Change 3114311 on 2016/09/06 by Ben.Zeigler

	Fix linux compile

Change 3114350 on 2016/09/06 by Ben.Zeigler

	Linux supports fast unaligned int reads

Change 3116169 on 2016/09/07 by Ben.Zeigler

	Force enable separate bulk data cooking when using split cooked files, end-of-exp-file doesn't make sense with the new cook scheme and will crash at runtime

Change 3116538 on 2016/09/07 by Gil.Gribb

	add dependencies for CDO subobjects

Change 3116596 on 2016/09/07 by Ben.Zeigler

	Change crash to warning when trying to load an import to a missing native class, can happen with editor only classes.

Change 3116855 on 2016/09/07 by Ben.Zeigler

	Move cook dialog down a bit so I can cook without constant dialogs popping up

Change 3117452 on 2016/09/08 by Robert.Manuszewski

	Fixing hang when suspending async loading with the async loading thread enabled.

Change 3119255 on 2016/09/09 by Robert.Manuszewski

	Removing texture allocations from PackageFileSummary as they were not used by anything.

Change 3119303 on 2016/09/09 by Gil.Gribb

	Fixed font issue by making all all bulk data either inline or in a ubulk. Added support for compressed packages.

Change 3120324 on 2016/09/09 by Ben.Zeigler

	Fix Cook warnings. Skip transient and client/server only objects when adding dependencies, and mark ShapeComponent BodySetups as properly transient.

Change 3121960 on 2016/09/12 by Ben.Zeigler

	Add RandomizeLoadOrder CVar to randomize the package serial number it uses for sorting async loads

Change 3122635 on 2016/09/13 by Gil.Gribb

	reworked searching disk warning and minor change to the background tasks used for decompression

Change 3122743 on 2016/09/13 by Gil.Gribb

	added some checks around memory accounting

Change 3123395 on 2016/09/13 by Ben.Zeigler

	Enable MallocBinned2 by default on cooked windows builds, similar to how PS4 works.
	Disabled thread pool cache clearing on windows, the threading function it was using is very slow on windows specifically

Change 3124748 on 2016/09/14 by Gil.Gribb

	Store template in import/export table and refer to it for each export to avoid calling GetArchetypeFromRequiredInfo. Minor fix for some NeedLoadForCLient etc stuff on landscape and CDOs. Fix texture streamer minmips stuff.

Change 3125153 on 2016/09/14 by Gil.Gribb

	don't put transient objects in the import map

Change 3126668 on 2016/09/15 by Gil.Gribb

	Fix critical bug with imports not waiting for the corresponding export to serialize. Fixed paragon test rig to run longer looping by flushing the renderer. Made random mode more random.

Change 3126755 on 2016/09/15 by Gil.Gribb

	ooops, test rig fix

Change 3127408 on 2016/09/15 by Ben.Zeigler

	Back out changelist 3123395, restoring windows memory to 4.13 setup

Change 3127409 on 2016/09/15 by Ben.Zeigler

	Remove Memory trim from FlushAsyncLoading, because it gets called much more often in new flow and is slow on some platforms

Change 3127948 on 2016/09/16 by Gil.Gribb

	Added a check() on any attempt to serialize a pointer to something that hasn't been created yet. This will help us find missing dependencies. There is an exception to this related to CDOs.

Change 3128094 on 2016/09/16 by Robert.Manuszewski

	Fixing exports referenced by weak object pointers not being added to the preload dependency list of of the exports that depend on them.

	+ Moved weak object pointer serialization to FArchive operator << to be able to override its behavior when cooking.

Change 3128148 on 2016/09/16 by Robert.Manuszewski

	Gil's mod to how we detect exports with missing dependencies

Change 3129052 on 2016/09/16 by Ben.Zeigler

	Add Missing Serialize helpers for WeakObjectPtrs, fixes crash with replicating weak objects

Change 3129053 on 2016/09/16 by Ben.Zeigler

	Fake integrate CL #3123581 from Dev-Framework, to correctly handle detecting components as editor only even when they have collision. Fixes crashes with blueprint editor only components that depend on native templates

Change 3129630 on 2016/09/17 by Gil.Gribb

	better logging for missing dependencies and properly ifdef'd the CDO primitive comp hack

Change 3130178 on 2016/09/19 by Robert.Manuszewski

	Use the correct macro (COOK_FOR_EVENT_DRIVEN_LOAD instead of USE_NEW_ASYNC_IO) for SavePackage changes from CL #3128094

Change 3130224 on 2016/09/19 by Robert.Manuszewski

	Compile error fix

Change 3130391 on 2016/09/19 by Gil.Gribb

	Add cook time fatal errors, and undid a previous change we don't seem to need relating to editor only CDOs

Change 3130484 on 2016/09/19 by Gil.Gribb

	fixed botched GetArchetypeFromRequiredInfo

Change 3131966 on 2016/09/20 by Robert.Manuszewski

	Making the new event driven loader disabled by default. It's now also configurable via project settings (under Streaming Settings -> Event Driven Loader Enabled).

	Enabled the event driven loader for a few internal projects.

Change 3132035 on 2016/09/20 by Gil.Gribb

	fix dynamic switch on new loader

Change 3132041 on 2016/09/20 by Robert.Manuszewski

	Fix for packages not being saved to disk when cooking with event driven loader disabled.

Change 3132195 on 2016/09/20 by Robert.Manuszewski

	Enabling the event driven loader for Zen

Change 3133870 on 2016/09/21 by Graeme.Thornton

	Config files now enable the event driven loader with the correct cvar name

Change 3135812 on 2016/09/22 by Gil.Gribb

	fixed some bugs with GC during streaming

Change 3136102 on 2016/09/22 by Robert.Manuszewski

	Release GC lock when FlushingAsyncLoading when running GC.

Change 3136633 on 2016/09/22 by Gil.Gribb

	fix bug with linkers finsihing before other things linked their imports

Change 3138002 on 2016/09/23 by Robert.Manuszewski

	Added an assert that will prevent content cooked for the event driven loader to be loaded by game builds that have the EDL disabled.

Change 3138012 on 2016/09/23 by Gil.Gribb

	Improved the fix to prevent packages from finishing before external imports have linked. Async load object libraries.

Change 3138031 on 2016/09/23 by Gil.Gribb

	do not preload obj libs in editor

Change 3139176 on 2016/09/24 by Gil.Gribb

	fixed another bug with an attempt to call GetArchetypeFromRequiredInfo

Change 3139459 on 2016/09/26 by Robert.Manuszewski

	Merging //UE4/Release-4.13 to Dev-LoadTimes (//Tasks/UE4/Dev-LoadTimes)

Change 3139668 on 2016/09/26 by Gil.Gribb

	change some checks to errors on bad bulk data loads

Change 3141127 on 2016/09/27 by Robert.Manuszewski

	Preventing linkers from being detached too early when async loading.

Change 3141129 on 2016/09/27 by Robert.Manuszewski

	Releasing GC Lock before calling post GC callbacks to allow StaticFindObject use in these callbacks

Change 3142048 on 2016/09/27 by Robert.Manuszewski

	Changing async loading code to not close DelayedLinkerClosePackages linkers until the async package that triggered their creation has finished loading.

Change 3143132 on 2016/09/28 by Gil.Gribb

	fixed text render comp, which has some editor only issues. Fixes a runtime crash and adds a cooktime warning.

Change 3143198 on 2016/09/28 by Gil.Gribb

	fixed it so that bogus loads of bulk data are warned but do not crash

Change 3143287 on 2016/09/28 by Robert.Manuszewski

	UBT will now invalidate its makefiles if ini files are newer than the makefile (ini files may contains global build settings).

	+ Android toolchain will add hashed command line values to the action reposnse filenames to actually allow it to detect compiler command line changes when detecting actions to execute

Change 3143344 on 2016/09/28 by Robert.Manuszewski

	Make UAT pass the project filename to UBT when build non-code projects so that UBT can parse all ini files.

Change 3143865 on 2016/09/28 by Gil.Gribb

	iffy fix for the net load assert in paragon, plus a few checks and one bit of code removed that should never be hit in the EDL, but makes no sense

Change 3144683 on 2016/09/29 by Graeme.Thornton

	Minor refactor of pak file non-filename stuff
	 - Don't check for file existing before running through the security delegate
	 - Default behaviour when using new IO is to reject uasset/umap/ubulk/uexp files immediately. Can be disabled by setting EXCLUDE_NONPAK_UE_EXTENSIONS to 0 in project .build.cs

Change 3144745 on 2016/09/29 by Graeme.Thornton

	Orion non-pak file whitelisting is enabled for all cooked game only builds now, rather than just clients

Change 3144780 on 2016/09/29 by Gil.Gribb

	use poison proxy on non-test/shipping builds

Change 3144819 on 2016/09/29 by Gil.Gribb

	added a few asserts and added an improved fix for the net crash

Change 3145414 on 2016/09/29 by Gil.Gribb

	fixed android assert....not sure why I need that block of code.

Change 3146502 on 2016/09/30 by Robert.Manuszewski

	Fix for GPU hang from MarcusW

Change 3146774 on 2016/09/30 by Robert.Manuszewski

	Fixing a crash when constantly streaming levels in and out caused by keeping references to objects (levels) that were requested to be streamed out.

	- Removed FAsyncObjectsReferencer. References will now be owned by FAsyncPackage
	- UGCObjectReferencer is now more thread safe

Change 3148008 on 2016/10/01 by Gil.Gribb

	add additional error for attempting to create an object from a class that needs to be loaded

Change 3148009 on 2016/10/01 by Gil.Gribb

	fix very old threading bug whereby the ASL and GT would attempt to use the same static array

Change 3148222 on 2016/10/02 by Robert.Manuszewski

	Fix for an assert when an FGCObject is removed when purging UObjects

Change 3148229 on 2016/10/02 by Gil.Gribb

	disable assert that was crashing paragon ps4

Change 3148409 on 2016/10/03 by Robert.Manuszewski

	Allow another case for removing FGCObjects while in GC.

Change 3148416 on 2016/10/03 by Robert.Manuszewski

	Merging //UE4/Release-4.13 to Dev-LoadTimes (//Tasks/UE4/Dev-LoadTimes)

Change 3149566 on 2016/10/03 by Ben.Zeigler

	#jira UE-36664 Fix issue where objects loaded during async loading could be added to the wrong package's object list, if a time slice ended at the wrong point

Change 3149913 on 2016/10/04 by Gil.Gribb

	better broadcast

Change 2889560 on 2016/03/02 by Steven.Hutton

	Packages for scheduled tasks.

Change 2889566 on 2016/03/02 by Steven.Hutton

	Remaining nuget packages for hangfire, unity and scheduled tasks.

Change 2980458 on 2016/05/17 by Chris.Wood

	Attempt to fix crash report submission problems from CRP to CR website
	[UE-30257] - Crashreports are sometimes missing file attachments

	Passing crash GUID so that website can easily check for duplicates in future
	Increased request timeout for AddCrash to be longer than website database timeout
	Logging retries for future visibility
	CRP v.1.1.6

Change 3047870 on 2016/07/13 by Steven.Hutton

	Updated CRW to entity framework with repository models. #rb none

Change 3126265 on 2016/09/15 by Steve.Robb

	Fix for TCString::Strspn.

Change 3126266 on 2016/09/15 by Steve.Robb

	Alternative fix for GitHub 2698: Fix one bug : Parsing command "Enable True" is invalid.

	#jira UE-34670

Change 3126268 on 2016/09/15 by Steve.Robb

	UWorld can no longer be extended by users.
	UHT now handles final class declarations.

	#jira UE-35708

Change 3126273 on 2016/09/15 by Steve.Robb

	A further attempt to catch uninitialized pointers supplied to the GC.

	#jira UE-34361

Change 3130042 on 2016/09/19 by Steve.Robb

	Super for USTRUCTs.

	Suggested here: https://udn.unrealengine.com/questions/310461/automatically-typedef-super-for-ustructs.html

Change 3131861 on 2016/09/20 by Steven.Hutton

	Reconciling work for view engine changes #rb none

Change 3131862 on 2016/09/20 by Steve.Robb

	Removal of THasOperatorEquals and THasOperatorNotEquals from Platform.h, which should have happened as part of CL# 3045963.

Change 3131863 on 2016/09/20 by Steven.Hutton

	Adding packages #rb none

Change 3131869 on 2016/09/20 by Steve.Robb

	Improved error message for enum classes with a missing base:

	Error: Missing base specifier for enum class 'EMyEnum' - did you mean ': uint8'?

Change 3132046 on 2016/09/20 by Graeme.Thornton

	Fix for cvar thread access assert in FLandscapeComponentGrassData serialization function
	 - This function can be called from the async thread so access CVarGrassDiscardDataOnLoad with GetValueOnAnyThread() rather than GetValueOnGameThread()

Change 3133201 on 2016/09/20 by Ben.Zeigler

	Reorganize WindowsPlatformMemory and MacPlatformMemory to work like LinuxPlatformMemory where there is an enum to select the allocator, and move some of it up to GenericPlatformMemory
	Add command line options to select malloc at runtime for Windows and Linux, I don't know how Mac options work
	Improve the performance of BroadcastSlow_OnlyUseForSpecialPurposes on windows, but there are cases where it occaisionally stalls for a few seconds waiting for the flush
	Add MallocBinned2 as an option for mac, linux, and windows, but default to off due to some threading issues

Change 3133722 on 2016/09/21 by Graeme.Thornton

	Cooker forces a shader compilation flush when it detects that it has passed the max memory budget

Change 3133756 on 2016/09/21 by Steve.Robb

	Refactor of TrimPrecedingAndTrailing to avoid a call to FString::Mid with a negative count, which is now illegal.

	#jira UE-36163

Change 3134182 on 2016/09/21 by Steve.Robb

	GitHub #1986: Don't show warnings and erros in console twice with UCommandlet::LogToConsole == true

	#jira UE-25915

Change 3134306 on 2016/09/21 by Ben.Zeigler

	Fix it so FMallocBinned2::Trim skips task threads on desktop platforms, they are too slow and don't allocate much memory
	Enable MallocBinned2 as default binned malloc on Windows
	Remove the -Run command line check as it was removed from the old version as well

Change 3135569 on 2016/09/22 by Graeme.Thornton

	Don't create material resources if we are in a build that can never render
	 - Saves a few MB of memory

Change 3135652 on 2016/09/22 by Steve.Robb

	New async-loading-thread-safe IsA implementation.

	#jira UECORE-298

Change 3135692 on 2016/09/22 by Steven.Hutton

	Minor bug fixes to view pages #rb none

Change 3135990 on 2016/09/22 by Robert.Manuszewski

	Adding ENGINE_API to FStripDataFlags sp that it can be used outside of the Engine module.

Change 3136020 on 2016/09/22 by Steve.Robb

	Display a meaningful error and shutdown if Core modules fail to load.

	https://udn.unrealengine.com/questions/312063/mac-unrealheadertool-failing-randomly.html

Change 3136107 on 2016/09/22 by Chris.Wood

	Added S3 file upload to output stage of Crash Report Process (v.1.1.26)
	[UE-35991] - Crash Report Process to write crash files to S3

	Also adds OOM alerts to CRP.
	Also disk space alerts changed to 5% free space and repeat once every 30 minutes instead of 10 minutes.

Change 3137562 on 2016/09/23 by Steve.Robb

	TUniquePtr<T[]> support.

Change 3138030 on 2016/09/23 by Steve.Robb

	Virtual UProperty functions moved out of headers into .cpp files to ease iteration.

Change 3140381 on 2016/09/26 by Chris.Wood

	Disabled uploads via CRRs while leaving services switched on to avoid crashes in some clients.
	[UETOOL-1005] - Turn off CrashReportReceivers

Change 3141150 on 2016/09/27 by Steve.Robb

	Invoke support for TFunction.

Change 3141151 on 2016/09/27 by Steve.Robb

	UBoolProperty now supports hashing and is therefore usable as a TSet element or TMap key.
	FText is now prevented from being a TSet element or TMap key.
	UTextProperty::GetCPPTypeForwardDeclaration implementation moved to the .cpp file.

	#jira UE-36051
	#jira UE-36053

Change 3141440 on 2016/09/27 by Chris.Wood

	Removed legacy queues and unnecessary duplication checks from Crash Report Process (v1.2.0)
	[UE-36246] - CRP scalability: Simplify CRP inputs to DataRouter/S3 only

Change 3142999 on 2016/09/28 by Chris.Wood

	Added dedicated PS4 crash queue to Crash Report Process (v1.2.1)

Change 3144831 on 2016/09/29 by Steve.Robb

	InternalPrecache now flags the archive as in-error so that it can be checked by a caller, rather than popping up a dialog box and asserting.

	#jira https://jira.it.epicgames.net/browse/OPP-6036

Change 3145184 on 2016/09/29 by Robert.Manuszewski

	FScopedCreateImportCounter will now always store the current linker and restore the previous one when it exits.

Change 3148432 on 2016/10/03 by Robert.Manuszewski

	Thread safety fixes for the async log writer + made the async log writer flush its archive more often.

Change 3148661 on 2016/10/03 by Graeme.Thornton

	Fixing merge of IsNonPakFilenameAllowed()
	 - Removed directory search stuff... we pass everything to the delegate now anyway

Change 3149669 on 2016/10/03 by Ben.Zeigler

	Lower verbosity of warnings from deleting native properties. These cases do not cause any problems and are not fixable without resaving the content after it has started warning. I checked Jira history and neither of these warnings has ever found a real bug, but has caused a lot of content to be resaved unnecessarily.

Change 3149670 on 2016/10/03 by Ben.Zeigler

	Merge CL #3149566 from Dev-LoadTimes
	#jira UE-36664 Fix issue where objects loaded during async loading could be added to the wrong package's object list, if a time slice ended at the wrong point

Change 3149835 on 2016/10/04 by Graeme.Thornton

	Thread safety fix for SkyLightComponent
	 - Add to global update list from PostLoad rather than PostInitProperties so that it happens on the game thread, and not the async loading thread (if enabled)

Change 3149836 on 2016/10/04 by Graeme.Thornton

	Thread safety fix for ReflectionCaptureComponent
	 - Add to global update list from PostLoad rather than PostInitProperties so that it happens on the game thread, and not the async loading thread (if enabled)

Change 3149959 on 2016/10/04 by Robert.Manuszewski

	Allow import packages to be missing if they're on the KnownMissingPackages list

Change 3150023 on 2016/10/04 by Steven.Hutton

	Updating jira strings. #rb none

Change 3150050 on 2016/10/04 by Steve.Robb

	MakeShared now returns a TSharedRef (which is implicitly convertible to TSharedPtr) rather than a TSharedPtr (which is not implicitly convertible to TSharedRef), for ease of use and because MakeShared can't return a null pointer anyway.

Change 3150110 on 2016/10/04 by Robert.Manuszewski

	Allow UGCObjectReferencer::AddObjects to happen during BeginDestry and FinishDestroy. It's fine as long as we're not adding new objects during reachability analysis.

Change 3150120 on 2016/10/04 by Gil.Gribb

	fix task graph/binned2 broadcast for PS4

Change 3150195 on 2016/10/04 by Robert.Manuszewski

	Fixing WEX crash
	#jira UE-36801

Change 3150212 on 2016/10/04 by Robert.Manuszewski

	Increasing compiler memory limit to fix CIS errors
	#jira UE-36795

Change 3151583 on 2016/10/05 by Robert.Manuszewski

	Temporarily switching to the old IsA path

	#jria UE-36803

Change 3151642 on 2016/10/05 by Steve.Robb

	Dependency fixes for GameFeedback modules.

Change 3151653 on 2016/10/05 by Robert.Manuszewski

	Maybe fix for crash on the Mac

	#jira UE-36846

[CL 3152539 by Robert Manuszewski in Main branch]
2016-10-05 16:51:01 -04:00

1331 lines
49 KiB
C#

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Microsoft.Win32;
namespace UnrealBuildTool
{
public class AndroidToolChain : UEToolChain
{
private FileReference ProjectFile;
// the number of the clang version being used to compile
private float ClangVersionFloat = 0;
// the list of architectures we will compile for
private List<string> Arches = null;
// the list of GPU architectures we will compile for
private List<string> GPUArchitectures = null;
// a list of all architecture+GPUArchitecture names (-armv7-es2, etc)
private List<string> AllComboNames = null;
static private Dictionary<string, string[]> AllArchNames = new Dictionary<string, string[]> {
{ "-armv7", new string[] { "armv7", "armeabi-v7a", } },
{ "-arm64", new string[] { "arm64", "arm64-v8a", } },
{ "-x86", new string[] { "x86", } },
{ "-x64", new string[] { "x64", "x86_64", } },
};
static private Dictionary<string, string[]> LibrariesToSkip = new Dictionary<string, string[]> {
{ "-armv7", new string[] { } },
{ "-arm64", new string[] { "nvToolsExt", "nvToolsExtStub", "oculus", "vrapi", "ovrkernel", "systemutils", "openglloader", } },
{ "-x86", new string[] { "nvToolsExt", "nvToolsExtStub", "oculus", "vrapi", "ovrkernel", "systemutils", "openglloader", } },
{ "-x64", new string[] { "nvToolsExt", "nvToolsExtStub", "oculus", "vrapi", "ovrkernel", "systemutils", "openglloader", "gpg", } },
};
static private Dictionary<string, string[]> ModulesToSkip = new Dictionary<string, string[]> {
{ "-armv7", new string[] { } },
{ "-arm64", new string[] { } },
{ "-x86", new string[] { } },
{ "-x64", new string[] { "OnlineSubsystemGooglePlay", } },
};
public AndroidToolChain(FileReference InProjectFile)
: base(CPPTargetPlatform.Android)
{
ProjectFile = InProjectFile;
string NDKPath = Environment.GetEnvironmentVariable("NDKROOT");
// don't register if we don't have an NDKROOT specified
if (String.IsNullOrEmpty(NDKPath))
{
throw new BuildException("NDKROOT is not specified; cannot use Android toolchain.");
}
NDKPath = NDKPath.Replace("\"", "");
string ClangVersion = "";
string GccVersion = "";
string ArchitecturePath = "";
string ArchitecturePathWindows32 = @"prebuilt/windows";
string ArchitecturePathWindows64 = @"prebuilt/windows-x86_64";
string ArchitecturePathMac = @"prebuilt/darwin-x86_64";
string ArchitecturePathLinux = @"prebuilt/linux-x86_64";
string ExeExtension = ".exe";
if (Directory.Exists(Path.Combine(NDKPath, ArchitecturePathWindows64)))
{
Log.TraceVerbose(" Found Windows 64 bit versions of toolchain");
ArchitecturePath = ArchitecturePathWindows64;
}
else if (Directory.Exists(Path.Combine(NDKPath, ArchitecturePathWindows32)))
{
Log.TraceVerbose(" Found Windows 32 bit versions of toolchain");
ArchitecturePath = ArchitecturePathWindows32;
}
else if (Directory.Exists(Path.Combine(NDKPath, ArchitecturePathMac)))
{
Log.TraceVerbose(" Found Mac versions of toolchain");
ArchitecturePath = ArchitecturePathMac;
ExeExtension = "";
}
else if (Directory.Exists(Path.Combine(NDKPath, ArchitecturePathLinux)))
{
Log.TraceVerbose(" Found Linux versions of toolchain");
ArchitecturePath = ArchitecturePathLinux;
ExeExtension = "";
}
else
{
throw new BuildException("Couldn't find 32-bit or 64-bit versions of the Android toolchain");
}
// prefer clang 3.6, but fall back if needed for now
if (Directory.Exists(Path.Combine(NDKPath, @"toolchains/llvm-3.6")))
{
ClangVersionFloat = 3.6f;
ClangVersion = "-3.6";
GccVersion = "4.9";
}
else if (Directory.Exists(Path.Combine(NDKPath, @"toolchains/llvm-3.5")))
{
ClangVersionFloat = 3.5f;
ClangVersion = "-3.5";
GccVersion = "4.9";
}
else if (Directory.Exists(Path.Combine(NDKPath, @"toolchains/llvm-3.3")))
{
ClangVersionFloat = 3.3f;
ClangVersion = "-3.3";
GccVersion = "4.8";
}
else if (Directory.Exists(Path.Combine(NDKPath, @"toolchains/llvm-3.1")))
{
ClangVersionFloat = 3.1f;
ClangVersion = "-3.1";
GccVersion = "4.6";
}
else if (Directory.Exists(Path.Combine(NDKPath, @"toolchains/llvm")))
{
// look for version in AndroidVersion.txt (fail if not found)
string VersionFilename = Path.Combine(NDKPath, @"toolchains/llvm/", ArchitecturePath, @"AndroidVersion.txt");
if (!File.Exists(VersionFilename))
{
throw new BuildException("Cannot find supported Android toolchain");
}
string[] VersionFile = File.ReadAllLines(VersionFilename);
string[] VersionParts = VersionFile[0].Split('.');
ClangVersionFloat = float.Parse(VersionParts[0] + "." + VersionParts[1], System.Globalization.CultureInfo.InvariantCulture);
ClangVersion = "";
GccVersion = "4.9";
}
else
{
throw new BuildException("Cannot find supported Android toolchain");
}
// set up the path to our toolchains
ClangPath = Path.Combine(NDKPath, @"toolchains/llvm" + ClangVersion, ArchitecturePath, @"bin/clang++" + ExeExtension);
ArPathArm = Path.Combine(NDKPath, @"toolchains/arm-linux-androideabi-" + GccVersion, ArchitecturePath, @"bin/arm-linux-androideabi-ar" + ExeExtension); //@todo android: use llvm-ar.exe instead?
ArPathArm64 = Path.Combine(NDKPath, @"toolchains/aarch64-linux-android-" + GccVersion, ArchitecturePath, @"bin/aarch64-linux-android-ar" + ExeExtension); //@todo android: use llvm-ar.exe instead?
ArPathx86 = Path.Combine(NDKPath, @"toolchains/x86-" + GccVersion, ArchitecturePath, @"bin/i686-linux-android-ar" + ExeExtension); //@todo android: verify x86 toolchain
ArPathx64 = Path.Combine(NDKPath, @"toolchains/x86_64-" + GccVersion, ArchitecturePath, @"bin/x86_64-linux-android-ar" + ExeExtension); //@todo android: verify x64 toolchain
// NDK setup (use no less than 21 for 64-bit targets)
int NDKApiLevelInt = GetNdkApiLevelInt();
string NDKApiLevel32Bit = GetNdkApiLevel();
string NDKApiLevel64Bit = NDKApiLevel32Bit;
if (NDKApiLevelInt < 21)
{
NDKApiLevel64Bit = "android-21";
}
// toolchain params
ToolchainParamsArm = " -target armv7-none-linux-androideabi" +
" --sysroot=\"" + Path.Combine(NDKPath, "platforms", NDKApiLevel32Bit, "arch-arm") + "\"" +
" -gcc-toolchain \"" + Path.Combine(NDKPath, @"toolchains/arm-linux-androideabi-" + GccVersion, ArchitecturePath) + "\"";
ToolchainParamsArm64 = " -target aarch64-none-linux-android" +
" --sysroot=\"" + Path.Combine(NDKPath, "platforms", NDKApiLevel64Bit, "arch-arm64") + "\"" +
" -gcc-toolchain \"" + Path.Combine(NDKPath, @"toolchains/aarch64-linux-android-" + GccVersion, ArchitecturePath) + "\"";
ToolchainParamsx86 = " -target i686-none-linux-android" +
" --sysroot=\"" + Path.Combine(NDKPath, "platforms", NDKApiLevel32Bit, "arch-x86") + "\"" +
" -gcc-toolchain \"" + Path.Combine(NDKPath, @"toolchains/x86-" + GccVersion, ArchitecturePath) + "\"";
ToolchainParamsx64 = " -target x86_64-none-linux-android" +
" --sysroot=\"" + Path.Combine(NDKPath, "platforms", NDKApiLevel64Bit, "arch-x86_64") + "\"" +
" -gcc-toolchain \"" + Path.Combine(NDKPath, @"toolchains\x86_64-" + GccVersion, ArchitecturePath) + "\"";
}
public void ParseArchitectures()
{
// look in ini settings for what platforms to compile for
ConfigCacheIni Ini = ConfigCacheIni.CreateConfigCacheIni(UnrealTargetPlatform.Android, "Engine", DirectoryReference.FromFile(ProjectFile));
Arches = new List<string>();
bool bBuild = true;
if (Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bBuildForArmV7", out bBuild) && bBuild
|| UEBuildConfiguration.Architectures.Contains("armv7", StringComparer.OrdinalIgnoreCase))
{
Arches.Add("-armv7");
}
if (Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bBuildForArm64", out bBuild) && bBuild
|| UEBuildConfiguration.Architectures.Contains("arm64", StringComparer.OrdinalIgnoreCase))
{
Arches.Add("-arm64");
}
if (Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bBuildForx86", out bBuild) && bBuild
|| UEBuildConfiguration.Architectures.Contains("x86", StringComparer.OrdinalIgnoreCase))
{
Arches.Add("-x86");
}
if (Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bBuildForx8664", out bBuild) && bBuild
|| UEBuildConfiguration.Architectures.Contains("x64", StringComparer.OrdinalIgnoreCase))
{
Arches.Add("-x64");
}
// force armv7 if something went wrong
if (Arches.Count == 0)
{
Arches.Add("-armv7");
}
// Parse selected GPU architectures
GPUArchitectures = new List<string>();
if (Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bBuildForES2", out bBuild) && bBuild
|| UEBuildConfiguration.GPUArchitectures.Contains("es2", StringComparer.OrdinalIgnoreCase))
{
GPUArchitectures.Add("-es2");
}
if (Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bBuildForESDeferred", out bBuild) && bBuild
|| UEBuildConfiguration.GPUArchitectures.Contains("esdeferred", StringComparer.OrdinalIgnoreCase))
{
GPUArchitectures.Add("-esdeferred");
}
if (GPUArchitectures.Count == 0)
{
GPUArchitectures.Add("-es2");
}
AllComboNames = (from Arch in Arches
from GPUArch in GPUArchitectures
select Arch + GPUArch).ToList();
}
static public string GetGLESVersionFromGPUArch(string GPUArch)
{
GPUArch = GPUArch.Substring(1); // drop the '-' from the start
string GLESversion = "";
switch (GPUArch)
{
case "es2":
GLESversion = "0x00020000";
break;
case "esdeferred":
GLESversion = "0x00030001";
break;
default:
GLESversion = "0x00020000";
break;
}
return GLESversion;
}
public override void SetUpGlobalEnvironment()
{
base.SetUpGlobalEnvironment();
ParseArchitectures();
}
public List<string> GetAllArchitectures()
{
if (Arches == null)
{
ParseArchitectures();
}
return Arches;
}
public List<string> GetAllGPUArchitectures()
{
if (GPUArchitectures == null)
{
ParseArchitectures();
}
return GPUArchitectures;
}
public int GetNdkApiLevelInt(int MinNdk = 19)
{
string NDKVersion = GetNdkApiLevel();
int NDKVersionInt = MinNdk;
if (NDKVersion.Contains("-"))
{
int Version;
if (int.TryParse(NDKVersion.Substring(NDKVersion.LastIndexOf('-') + 1), out Version))
{
if (Version > NDKVersionInt)
NDKVersionInt = Version;
}
}
return NDKVersionInt;
}
public string GetNdkApiLevel()
{
// ask the .ini system for what version to use
ConfigCacheIni Ini = ConfigCacheIni.CreateConfigCacheIni(UnrealTargetPlatform.Android, "Engine", DirectoryReference.FromFile(ProjectFile));
string NDKLevel;
Ini.GetString("/Script/AndroidPlatformEditor.AndroidSDKSettings", "NDKAPILevel", out NDKLevel);
if (NDKLevel == "latest")
{
// get a list of NDK platforms
string PlatformsDir = Environment.ExpandEnvironmentVariables("%NDKROOT%/platforms");
if (!Directory.Exists(PlatformsDir))
{
throw new BuildException("No platforms found in {0}", PlatformsDir);
}
// return the largest of them
NDKLevel = GetLargestApiLevel(Directory.GetDirectories(PlatformsDir));
}
return NDKLevel;
}
public string GetLargestApiLevel(string[] ApiLevels)
{
int LargestLevel = 0;
string LargestString = null;
// look for largest integer
foreach (string Level in ApiLevels)
{
string LocalLevel = Path.GetFileName(Level);
string[] Tokens = LocalLevel.Split("-".ToCharArray());
if (Tokens.Length >= 2)
{
try
{
int ParsedLevel = int.Parse(Tokens[1]);
// bigger? remember it
if (ParsedLevel > LargestLevel)
{
LargestLevel = ParsedLevel;
LargestString = LocalLevel;
}
}
catch (Exception)
{
// ignore poorly formed string
}
}
}
return LargestString;
}
string GetCLArguments_Global(CPPEnvironment CompileEnvironment, string Architecture)
{
string Result = "";
switch (Architecture)
{
case "-armv7": Result += ToolchainParamsArm; break;
case "-arm64": Result += ToolchainParamsArm64; break;
case "-x86": Result += ToolchainParamsx86; break;
case "-x64": Result += ToolchainParamsx64; break;
default: Result += ToolchainParamsArm; break;
}
// build up the commandline common to C and C++
Result += " -c";
Result += " -fdiagnostics-format=msvc";
Result += " -Wall";
Result += " -Wno-unused-variable";
// this will hide the warnings about static functions in headers that aren't used in every single .cpp file
Result += " -Wno-unused-function";
// this hides the "enumeration value 'XXXXX' not handled in switch [-Wswitch]" warnings - we should maybe remove this at some point and add UE_LOG(, Fatal, ) to default cases
Result += " -Wno-switch";
// this hides the "warning : comparison of unsigned expression < 0 is always false" type warnings due to constant comparisons, which are possible with template arguments
Result += " -Wno-tautological-compare";
//This will prevent the issue of warnings for unused private variables.
Result += " -Wno-unused-private-field";
Result += " -Wno-local-type-template-args"; // engine triggers this
Result += " -Wno-return-type-c-linkage"; // needed for PhysX
Result += " -Wno-reorder"; // member initialization order
Result += " -Wno-unknown-pragmas"; // probably should kill this one, sign of another issue in PhysX?
Result += " -Wno-invalid-offsetof"; // needed to suppress warnings about using offsetof on non-POD types.
Result += " -Wno-logical-op-parentheses"; // needed for external headers we can't change
if (CompileEnvironment.Config.bEnableShadowVariableWarning)
{
Result += " -Wshadow -Wno-error=shadow";
}
// new for clang4.5 warnings:
if (ClangVersionFloat >= 3.5f)
{
Result += " -Wno-undefined-bool-conversion"; // 'this' pointer cannot be null in well-defined C++ code; pointer may be assumed to always convert to true (if (this))
// we use this feature to allow static FNames.
Result += " -Wno-gnu-string-literal-operator-template";
}
if (ClangVersionFloat >= 3.6f)
{
Result += " -Wno-unused-local-typedef"; // clang is being overly strict here? PhysX headers trigger this.
Result += " -Wno-inconsistent-missing-override"; // these have to be suppressed for UE 4.8, should be fixed later.
}
// shipping builds will cause this warning with "ensure", so disable only in those case
if (CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Shipping)
{
Result += " -Wno-unused-value";
}
// debug info
if (CompileEnvironment.Config.bCreateDebugInfo)
{
Result += " -g2 -gdwarf-4";
}
// optimization level
if (CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Debug)
{
Result += " -O0";
}
else
{
if (UEBuildConfiguration.bCompileForSize)
{
Result += " -Oz";
}
else
{
Result += " -O3";
}
}
//@todo android: these are copied verbatim from UE3 and probably need adjustment
if (Architecture == "-armv7")
{
// Result += " -mthumb-interwork"; // Generates code which supports calling between ARM and Thumb instructions, w/o it you can't reliability use both together
Result += " -funwind-tables"; // Just generates any needed static data, affects no code
Result += " -fstack-protector"; // Emits extra code to check for buffer overflows
// Result += " -mlong-calls"; // Perform function calls by first loading the address of the function into a reg and then performing the subroutine call
Result += " -fno-strict-aliasing"; // Prevents unwanted or invalid optimizations that could produce incorrect code
Result += " -fpic"; // Generates position-independent code (PIC) suitable for use in a shared library
Result += " -fno-exceptions"; // Do not enable exception handling, generates extra code needed to propagate exceptions
Result += " -fno-rtti"; //
Result += " -fno-short-enums"; // Do not allocate to an enum type only as many bytes as it needs for the declared range of possible values
// Result += " -finline-limit=64"; // GCC limits the size of functions that can be inlined, this flag allows coarse control of this limit
// Result += " -Wno-psabi"; // Warn when G++ generates code that is probably not compatible with the vendor-neutral C++ ABI
Result += " -march=armv7-a";
Result += " -mfloat-abi=softfp";
Result += " -mfpu=vfpv3-d16"; //@todo android: UE3 was just vfp. arm7a should all support v3 with 16 registers
// Add flags for on-device debugging
if (CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Debug)
{
Result += " -fno-omit-frame-pointer"; // Disable removing the save/restore frame pointer for better debugging
if (ClangVersionFloat >= 3.6f)
{
Result += " -fno-function-sections"; // Improve breakpoint location
}
}
// Some switches interfere with on-device debugging
if (CompileEnvironment.Config.Target.Configuration != CPPTargetConfiguration.Debug)
{
Result += " -ffunction-sections"; // Places each function in its own section of the output file, linker may be able to perform opts to improve locality of reference
}
Result += " -fsigned-char"; // Treat chars as signed //@todo android: any concerns about ABI compatibility with libs here?
}
else if (Architecture == "-arm64")
{
Result += " -funwind-tables"; // Just generates any needed static data, affects no code
Result += " -fstack-protector"; // Emits extra code to check for buffer overflows
Result += " -fno-strict-aliasing"; // Prevents unwanted or invalid optimizations that could produce incorrect code
Result += " -fpic"; // Generates position-independent code (PIC) suitable for use in a shared library
Result += " -fno-exceptions"; // Do not enable exception handling, generates extra code needed to propagate exceptions
Result += " -fno-rtti"; //
Result += " -fno-short-enums"; // Do not allocate to an enum type only as many bytes as it needs for the declared range of possible values
Result += " -D__arm64__"; // for some reason this isn't defined and needed for PhysX
Result += " -march=armv8-a";
//Result += " -mfloat-abi=softfp";
//Result += " -mfpu=vfpv3-d16"; //@todo android: UE3 was just vfp. arm7a should all support v3 with 16 registers
// Some switches interfere with on-device debugging
if (CompileEnvironment.Config.Target.Configuration != CPPTargetConfiguration.Debug)
{
Result += " -ffunction-sections"; // Places each function in its own section of the output file, linker may be able to perform opts to improve locality of reference
}
Result += " -fsigned-char"; // Treat chars as signed //@todo android: any concerns about ABI compatibility with libs here?
}
else if (Architecture == "-x86")
{
Result += " -fstrict-aliasing";
Result += " -fno-omit-frame-pointer";
Result += " -fno-strict-aliasing";
Result += " -fno-short-enums";
Result += " -fno-exceptions";
Result += " -fno-rtti";
Result += " -march=atom";
}
else if (Architecture == "-x64")
{
Result += " -fstrict-aliasing";
Result += " -fno-omit-frame-pointer";
Result += " -fno-strict-aliasing";
Result += " -fno-short-enums";
Result += " -fno-exceptions";
Result += " -fno-rtti";
Result += " -march=atom";
}
return Result;
}
static string GetCompileArguments_CPP(bool bDisableOptimizations)
{
string Result = "";
Result += " -x c++";
Result += " -std=c++11";
// optimization level
if (bDisableOptimizations)
{
Result += " -O0";
}
else
{
Result += " -O3";
}
return Result;
}
static string GetCompileArguments_C(bool bDisableOptimizations)
{
string Result = "";
Result += " -x c";
// optimization level
if (bDisableOptimizations)
{
Result += " -O0";
}
else
{
Result += " -O3";
}
return Result;
}
static string GetCompileArguments_PCH(bool bDisableOptimizations)
{
string Result = "";
Result += " -x c++-header";
Result += " -std=c++11";
// optimization level
if (bDisableOptimizations)
{
Result += " -O0";
}
else
{
Result += " -O3";
}
return Result;
}
string GetLinkArguments(LinkEnvironment LinkEnvironment, string Architecture)
{
string Result = "";
Result += " -nostdlib";
Result += " -Wl,-shared,-Bsymbolic";
Result += " -Wl,--no-undefined";
if (Architecture == "-arm64")
{
Result += ToolchainParamsArm64;
Result += " -march=armv8-a";
}
else if (Architecture == "-x86")
{
Result += ToolchainParamsx86;
Result += " -march=atom";
}
else if (Architecture == "-x64")
{
Result += ToolchainParamsx64;
Result += " -march=atom";
}
else // if (Architecture == "-armv7")
{
Result += ToolchainParamsArm;
Result += " -march=armv7-a";
Result += " -Wl,--fix-cortex-a8"; // required to route around a CPU bug in some Cortex-A8 implementations
}
if (BuildConfiguration.bUseUnityBuild && ClangVersionFloat >= 3.6f && ClangVersionFloat < 3.8f)
{
Result += " -fuse-ld=gold"; // ld.gold is available in r10e (clang 3.6)
}
// make sure the DT_SONAME field is set properly (or we can a warning toast at startup on new Android)
Result += " -Wl,-soname,libUE4.so";
// verbose output from the linker
// Result += " -v";
return Result;
}
static string GetArArguments(LinkEnvironment LinkEnvironment)
{
string Result = "";
Result += " -r";
return Result;
}
static bool IsDirectoryForArch(string Dir, string Arch)
{
// make sure paths use one particular slash
Dir = Dir.Replace("\\", "/").ToLowerInvariant();
// look for other architectures in the Dir path, and fail if it finds it
foreach (var Pair in AllArchNames)
{
if (Pair.Key != Arch)
{
foreach (var ArchName in Pair.Value)
{
// if there's a directory in the path with a bad architecture name, reject it
if (Regex.IsMatch(Dir, "/" + ArchName + "$") || Regex.IsMatch(Dir, "/" + ArchName + "/"))
{
return false;
}
}
}
}
// if nothing was found, we are okay
return true;
}
static bool ShouldSkipModule(string ModuleName, string Arch)
{
foreach (var ModName in ModulesToSkip[Arch])
{
if (ModName == ModuleName)
{
return true;
}
}
// if nothing was found, we are okay
return false;
}
bool ShouldSkipLib(string Lib, string Arch, string GPUArchitecture)
{
// reject any libs we outright don't want to link with
foreach (var LibName in LibrariesToSkip[Arch])
{
if (LibName == Lib)
{
return true;
}
}
// if another architecture is in the filename, reject it
foreach (string ComboName in AllComboNames)
{
if (ComboName != Arch + GPUArchitecture)
{
if (Path.GetFileNameWithoutExtension(Lib).EndsWith(ComboName))
{
return true;
}
}
}
// if nothing was found, we are okay
return false;
}
static void ConditionallyAddNDKSourceFiles(List<FileItem> SourceFiles, string ModuleName)
{
// We need to add the extra glue and cpu code only to Launch module.
if (ModuleName.Equals("Launch"))
{
SourceFiles.Add(FileItem.GetItemByPath(Environment.GetEnvironmentVariable("NDKROOT") + "/sources/android/native_app_glue/android_native_app_glue.c"));
// Newer NDK cpu_features.c uses getauxval() which causes a SIGSEGV in libhoudini.so (ARM on Intel translator) in older versions of Houdini
// so we patch the file to use alternative methods of detecting CPU features if libhoudini.so is detected
// The basis for this patch is from here: https://android-review.googlesource.com/#/c/110650/
string CpuFeaturesPath = Environment.GetEnvironmentVariable("NDKROOT") + "/sources/android/cpufeatures/";
string CpuFeaturesPatchedFile = CpuFeaturesPath + "cpu-features-patched.c";
if (!File.Exists(CpuFeaturesPatchedFile))
{
// Either make a copy or patch it
string[] CpuFeaturesLines = File.ReadAllLines(CpuFeaturesPath + "cpu-features.c");
// Look for get_elf_hwcap_from_getauxval in the file
bool NeedsPatch = false;
int LineIndex;
for (LineIndex = 0; LineIndex < CpuFeaturesLines.Length; ++LineIndex)
{
if (CpuFeaturesLines[LineIndex].Contains("get_elf_hwcap_from_getauxval"))
{
NeedsPatch = true;
// Make sure it doesn't already have the patch (r10c and 10d have it already, but removed in 10e)
for (int LineIndex2 = LineIndex; LineIndex2 < CpuFeaturesLines.Length; ++LineIndex2)
{
if (CpuFeaturesLines[LineIndex2].Contains("has_houdini_binary_translator(void)"))
{
NeedsPatch = false;
break;
}
}
break;
}
}
// Apply patch or write unchanged
if (NeedsPatch)
{
List<string> CpuFeaturesList = new List<string>(CpuFeaturesLines);
// Skip down to section to add Houdini check function for arm
while (!CpuFeaturesList[++LineIndex].StartsWith("#if defined(__arm__)")) ;
CpuFeaturesList.Insert(++LineIndex, "/* Check Houdini Binary Translator is installed on the system.");
CpuFeaturesList.Insert(++LineIndex, " *");
CpuFeaturesList.Insert(++LineIndex, " * If this function returns 1, get_elf_hwcap_from_getauxval() function");
CpuFeaturesList.Insert(++LineIndex, " * will causes SIGSEGV while calling getauxval() function.");
CpuFeaturesList.Insert(++LineIndex, " */");
CpuFeaturesList.Insert(++LineIndex, "static int");
CpuFeaturesList.Insert(++LineIndex, "has_houdini_binary_translator(void) {");
CpuFeaturesList.Insert(++LineIndex, " int found = 0;");
CpuFeaturesList.Insert(++LineIndex, " if (access(\"/system/lib/libhoudini.so\", F_OK) != -1) {");
CpuFeaturesList.Insert(++LineIndex, " D(\"Found Houdini binary translator\\n\");");
CpuFeaturesList.Insert(++LineIndex, " found = 1;");
CpuFeaturesList.Insert(++LineIndex, " }");
CpuFeaturesList.Insert(++LineIndex, " return found;");
CpuFeaturesList.Insert(++LineIndex, "}");
CpuFeaturesList.Insert(++LineIndex, "");
// Add the Houdini check call
while (!CpuFeaturesList[++LineIndex].Contains("/* Extract the list of CPU features from ELF hwcaps */")) ;
CpuFeaturesList.Insert(LineIndex++, " /* Check Houdini binary translator is installed */");
CpuFeaturesList.Insert(LineIndex++, " int has_houdini = has_houdini_binary_translator();");
CpuFeaturesList.Insert(LineIndex++, "");
// Make the get_elf_hwcap_from_getauxval() calls conditional
while (!CpuFeaturesList[++LineIndex].Contains("hwcaps = get_elf_hwcap_from_getauxval(AT_HWCAP);")) ;
CpuFeaturesList.Insert(LineIndex++, " if (!has_houdini) {");
CpuFeaturesList.Insert(++LineIndex, " }");
while (!CpuFeaturesList[++LineIndex].Contains("hwcaps2 = get_elf_hwcap_from_getauxval(AT_HWCAP2);")) ;
CpuFeaturesList.Insert(LineIndex++, " if (!has_houdini) {");
CpuFeaturesList.Insert(++LineIndex, " }");
File.WriteAllLines(CpuFeaturesPatchedFile, CpuFeaturesList.ToArray());
}
else
{
File.WriteAllLines(CpuFeaturesPatchedFile, CpuFeaturesLines);
}
}
SourceFiles.Add(FileItem.GetItemByPath(CpuFeaturesPatchedFile));
}
}
void GenerateEmptyLinkFunctionsForRemovedModules(List<FileItem> SourceFiles, string ModuleName, DirectoryReference OutputDirectory)
{
// Only add to UELinkerFixups module
if (!ModuleName.Equals("Launch"))
{
return;
}
string LinkerExceptionsName = "../UELinkerExceptions";
FileReference LinkerExceptionsCPPFilename = FileReference.Combine(OutputDirectory, LinkerExceptionsName + ".cpp");
// Create the cpp filename
if (!LinkerExceptionsCPPFilename.Exists())
{
// Create a dummy file in case it doesn't exist yet so that the module does not complain it's not there
ResponseFile.Create(LinkerExceptionsCPPFilename, new List<string>());
}
var Result = new List<string>();
foreach (string Arch in Arches)
{
switch (Arch)
{
case "-armv7": Result.Add("#if PLATFORM_ANDROID_ARM"); break;
case "-arm64": Result.Add("#if PLATFORM_ANDROID_ARM64"); break;
case "-x86": Result.Add("#if PLATFORM_ANDROID_X86"); break;
case "-x64": Result.Add("#if PLATFORM_ANDROID_X64"); break;
default: Result.Add("#if PLATFORM_ANDROID_ARM"); break;
}
foreach (var ModName in ModulesToSkip[Arch])
{
Result.Add(" void EmptyLinkFunctionForStaticInitialization" + ModName + "(){}");
}
Result.Add("#endif");
}
// Determine if the file changed. Write it if it either doesn't exist or the contents are different.
bool bShouldWriteFile = true;
if (LinkerExceptionsCPPFilename.Exists())
{
string[] ExistingExceptionText = File.ReadAllLines(LinkerExceptionsCPPFilename.FullName);
string JoinedNewContents = string.Join("", Result.ToArray());
string JoinedOldContents = string.Join("", ExistingExceptionText);
bShouldWriteFile = (JoinedNewContents != JoinedOldContents);
}
// If we determined that we should write the file, write it now.
if (bShouldWriteFile)
{
ResponseFile.Create(LinkerExceptionsCPPFilename, Result);
}
SourceFiles.Add(FileItem.GetItemByFileReference(LinkerExceptionsCPPFilename));
}
// cache the location of NDK tools
static string ClangPath;
static string ToolchainParamsArm;
static string ToolchainParamsArm64;
static string ToolchainParamsx86;
static string ToolchainParamsx64;
static string ArPathArm;
static string ArPathArm64;
static string ArPathx86;
static string ArPathx64;
static public string GetStripExecutablePath(string UE4Arch)
{
string StripPath;
switch (UE4Arch)
{
case "-armv7": StripPath = ArPathArm; break;
case "-arm64": StripPath = ArPathArm64; break;
case "-x86": StripPath = ArPathx86; break;
case "-x64": StripPath = ArPathx64; break;
default: StripPath = ArPathArm; break;
}
return StripPath.Replace("-ar", "-strip");
}
static private bool bHasPrintedApiLevel = false;
public override CPPOutput CompileCPPFiles(UEBuildTarget Target, CPPEnvironment CompileEnvironment, List<FileItem> SourceFiles, string ModuleName)
{
if (Arches.Count == 0)
{
throw new BuildException("At least one architecture (armv7, x86, etc) needs to be selected in the project settings to build");
}
if (!bHasPrintedApiLevel)
{
Console.WriteLine("Compiling Native code with NDK API '{0}'", GetNdkApiLevel());
bHasPrintedApiLevel = true;
}
string BaseArguments = "";
if (CompileEnvironment.Config.PrecompiledHeaderAction != PrecompiledHeaderAction.Create)
{
BaseArguments += " -Werror";
}
// Directly added NDK files for NDK extensions
ConditionallyAddNDKSourceFiles(SourceFiles, ModuleName);
// Deal with dynamic modules removed by architecture
GenerateEmptyLinkFunctionsForRemovedModules(SourceFiles, ModuleName, CompileEnvironment.Config.OutputDirectory);
// Add preprocessor definitions to the argument list.
foreach (string Definition in CompileEnvironment.Config.Definitions)
{
BaseArguments += string.Format(" -D \"{0}\"", Definition);
}
var BuildPlatform = UEBuildPlatform.GetBuildPlatformForCPPTargetPlatform(CompileEnvironment.Config.Target.Platform);
var NDKRoot = Environment.GetEnvironmentVariable("NDKROOT").Replace("\\", "/");
string BasePCHName = "";
var PCHExtension = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.Android).GetBinaryExtension(UEBuildBinaryType.PrecompiledHeader);
if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Include)
{
BasePCHName = RemoveArchName(CompileEnvironment.PrecompiledHeaderFile.AbsolutePath).Replace(PCHExtension, "");
}
// Create a compile action for each source file.
CPPOutput Result = new CPPOutput();
foreach (string Arch in Arches)
{
if (ShouldSkipModule(ModuleName, Arch))
{
continue;
}
foreach (string GPUArchitecture in GPUArchitectures)
{
// which toolchain to use
string Arguments = GetCLArguments_Global(CompileEnvironment, Arch) + BaseArguments;
switch (Arch)
{
case "-armv7": Arguments += " -DPLATFORM_64BITS=0 -DPLATFORM_ANDROID_ARM=1"; break;
case "-arm64": Arguments += " -DPLATFORM_64BITS=1 -DPLATFORM_ANDROID_ARM64=1"; break;
case "-x86": Arguments += " -DPLATFORM_64BITS=0 -DPLATFORM_ANDROID_X86=1"; break;
case "-x64": Arguments += " -DPLATFORM_64BITS=1 -DPLATFORM_ANDROID_X64=1"; break;
default: Arguments += " -DPLATFORM_64BITS=0 -DPLATFORM_ANDROID_ARM=1"; break;
}
if (GPUArchitecture == "-esdeferred")
{
Arguments += " -DPLATFORM_ANDROIDESDEFERRED=1";
}
// which PCH file to include
string PCHArguments = "";
if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Include)
{
// Add the precompiled header file's path to the include path so Clang can find it.
// This needs to be before the other include paths to ensure Clang uses it instead of the source header file.
PCHArguments += string.Format(" -include \"{0}\"", InlineArchName(BasePCHName, Arch, GPUArchitecture));
}
// Add include paths to the argument list (filtered by architecture)
foreach (string IncludePath in CompileEnvironment.Config.CPPIncludeInfo.SystemIncludePaths)
{
if (IsDirectoryForArch(IncludePath, Arch))
{
Arguments += string.Format(" -I\"{0}\"", IncludePath);
}
}
foreach (string IncludePath in CompileEnvironment.Config.CPPIncludeInfo.IncludePaths)
{
if (IsDirectoryForArch(IncludePath, Arch))
{
Arguments += string.Format(" -I\"{0}\"", IncludePath);
}
}
foreach (FileItem SourceFile in SourceFiles)
{
Action CompileAction = new Action(ActionType.Compile);
string FileArguments = "";
bool bIsPlainCFile = Path.GetExtension(SourceFile.AbsolutePath).ToUpperInvariant() == ".C";
bool bDisableShadowWarning = false;
// should we disable optimizations on this file?
// @todo android - We wouldn't need this if we could disable optimizations per function (via pragma)
bool bDisableOptimizations = false;// SourceFile.AbsolutePath.ToUpperInvariant().IndexOf("\\SLATE\\") != -1;
if (bDisableOptimizations && CompileEnvironment.Config.Target.Configuration != CPPTargetConfiguration.Debug)
{
Log.TraceWarning("Disabling optimizations on {0}", SourceFile.AbsolutePath);
}
bDisableOptimizations = bDisableOptimizations || CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Debug;
// Add C or C++ specific compiler arguments.
if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Create)
{
FileArguments += GetCompileArguments_PCH(bDisableOptimizations);
}
else if (bIsPlainCFile)
{
FileArguments += GetCompileArguments_C(bDisableOptimizations);
// remove shadow variable warnings for NDK files
if (SourceFile.AbsolutePath.Replace("\\", "/").StartsWith(NDKRoot))
{
bDisableShadowWarning = true;
}
}
else
{
FileArguments += GetCompileArguments_CPP(bDisableOptimizations);
// only use PCH for .cpp files
FileArguments += PCHArguments;
}
// Add the C++ source file and its included files to the prerequisite item list.
AddPrerequisiteSourceFile(Target, BuildPlatform, CompileEnvironment, SourceFile, CompileAction.PrerequisiteItems);
if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Create)
{
// Add the precompiled header file to the produced item list.
FileItem PrecompiledHeaderFile = FileItem.GetItemByFileReference(
FileReference.Combine(
CompileEnvironment.Config.OutputDirectory,
Path.GetFileName(InlineArchName(SourceFile.AbsolutePath, Arch, GPUArchitecture) + PCHExtension)
)
);
CompileAction.ProducedItems.Add(PrecompiledHeaderFile);
Result.PrecompiledHeaderFile = PrecompiledHeaderFile;
// Add the parameters needed to compile the precompiled header file to the command-line.
FileArguments += string.Format(" -o \"{0}\"", PrecompiledHeaderFile.AbsolutePath, false);
}
else
{
if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Include)
{
CompileAction.bIsUsingPCH = true;
FileItem ArchPrecompiledHeaderFile = FileItem.GetItemByPath(InlineArchName(BasePCHName, Arch, GPUArchitecture) + PCHExtension);
CompileAction.PrerequisiteItems.Add(ArchPrecompiledHeaderFile);
}
var ObjectFileExtension = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.Android).GetBinaryExtension(UEBuildBinaryType.Object);
// Add the object file to the produced item list.
FileItem ObjectFile = FileItem.GetItemByFileReference(
FileReference.Combine(
CompileEnvironment.Config.OutputDirectory,
InlineArchName(Path.GetFileName(SourceFile.AbsolutePath) + ObjectFileExtension, Arch, GPUArchitecture)
)
);
CompileAction.ProducedItems.Add(ObjectFile);
Result.ObjectFiles.Add(ObjectFile);
FileArguments += string.Format(" -o \"{0}\"", ObjectFile.AbsolutePath, false);
}
// Add the source file path to the command-line.
FileArguments += string.Format(" \"{0}\"", SourceFile.AbsolutePath);
// Build a full argument list
string AllArguments = Arguments + FileArguments + CompileEnvironment.Config.AdditionalArguments;
AllArguments = ActionThread.ExpandEnvironmentVariables(AllArguments);
AllArguments = AllArguments.Replace("\\", "/");
// Remove shadow warning for this file if requested
if (bDisableShadowWarning)
{
int WarningIndex = AllArguments.IndexOf(" -Wshadow");
if (WarningIndex > 0)
{
AllArguments = AllArguments.Remove(WarningIndex, 9);
}
}
// Create the response file
FileReference ResponseFileName = CompileAction.ProducedItems[0].Reference + "_" + AllArguments.GetHashCode().ToString("X") + ".response";
string ResponseArgument = string.Format("@\"{0}\"", ResponseFile.Create(ResponseFileName, new List<string> { AllArguments }).FullName);
CompileAction.WorkingDirectory = UnrealBuildTool.EngineSourceDirectory.FullName;
CompileAction.CommandPath = ClangPath;
CompileAction.CommandArguments = ResponseArgument;
CompileAction.StatusDescription = string.Format("{0} [{1}-{2}]", Path.GetFileName(SourceFile.AbsolutePath), Arch.Replace("-", ""), GPUArchitecture.Replace("-", ""));
// VC++ always outputs the source file name being compiled, so we don't need to emit this ourselves
CompileAction.bShouldOutputStatusDescription = true;
// Don't farm out creation of pre-compiled headers as it is the critical path task.
CompileAction.bCanExecuteRemotely =
CompileEnvironment.Config.PrecompiledHeaderAction != PrecompiledHeaderAction.Create ||
BuildConfiguration.bAllowRemotelyCompiledPCHs;
}
}
}
return Result;
}
public override FileItem LinkFiles(LinkEnvironment LinkEnvironment, bool bBuildImportLibraryOnly)
{
return null;
}
static public string InlineArchName(string Pathname, string Arch, string GPUArchitecture)
{
return Path.Combine(Path.GetDirectoryName(Pathname), Path.GetFileNameWithoutExtension(Pathname) + Arch + GPUArchitecture + Path.GetExtension(Pathname));
}
public string RemoveArchName(string Pathname)
{
// remove all architecture names
foreach (string Arch in GetAllArchitectures())
{
foreach (string GPUArchitecture in GetAllGPUArchitectures())
{
Pathname = Path.Combine(Path.GetDirectoryName(Pathname), Path.GetFileName(Pathname).Replace(Arch + GPUArchitecture, ""));
}
}
return Pathname;
}
public override FileItem[] LinkAllFiles(LinkEnvironment LinkEnvironment, bool bBuildImportLibraryOnly)
{
List<FileItem> Outputs = new List<FileItem>();
var NDKRoot = Environment.GetEnvironmentVariable("NDKROOT").Replace("\\", "/");
int NDKApiLevelInt = GetNdkApiLevelInt();
string OptionalLinkArguments;
for (int ArchIndex = 0; ArchIndex < Arches.Count; ArchIndex++)
{
string Arch = Arches[ArchIndex];
// 32-bit ABI may need fixup for removed bsd_signal in NDK11 for android-21+
OptionalLinkArguments = "";
if (NDKApiLevelInt >= 21)
{
// this file was added in NDK11 so use existence to detect (RELEASE.TXT no longer present)
if (File.Exists(Path.Combine(NDKRoot, "source.properties")))
{
switch (Arch)
{
case "-armv7":
OptionalLinkArguments = string.Format(" \"{0}\"", Path.Combine(UnrealBuildTool.EngineDirectory.FullName, "Build/Android/Prebuilt/bsdsignal/lib/armeabi-v7a/libbsdsignal.a"));
break;
case "-x86":
OptionalLinkArguments = string.Format(" \"{0}\"", Path.Combine(UnrealBuildTool.EngineDirectory.FullName, "Build/Android/Prebuilt/bsdsignal/lib/x86/libbsdsignal.a"));
break;
}
}
}
for (int GPUArchIndex = 0; GPUArchIndex < GPUArchitectures.Count; GPUArchIndex++)
{
string GPUArchitecture = GPUArchitectures[GPUArchIndex];
int OutputPathIndex = ArchIndex * GPUArchitectures.Count + GPUArchIndex;
// Android will have an array of outputs
if (LinkEnvironment.Config.OutputFilePaths.Count < OutputPathIndex ||
!LinkEnvironment.Config.OutputFilePaths[OutputPathIndex].GetFileNameWithoutExtension().EndsWith(Arch + GPUArchitecture))
{
throw new BuildException("The OutputFilePaths array didn't match the Arches array in AndroidToolChain.LinkAllFiles");
}
// Create an action that invokes the linker.
Action LinkAction = new Action(ActionType.Link);
LinkAction.WorkingDirectory = UnrealBuildTool.EngineSourceDirectory.FullName;
if (LinkEnvironment.Config.bIsBuildingLibrary)
{
switch (Arch)
{
case "-armv7": LinkAction.CommandPath = ArPathArm; break;
case "-arm64": LinkAction.CommandPath = ArPathArm64; break;
case "-x86": LinkAction.CommandPath = ArPathx86; ; break;
case "-x64": LinkAction.CommandPath = ArPathx64; ; break;
default: LinkAction.CommandPath = ArPathArm; ; break;
}
}
else
{
LinkAction.CommandPath = ClangPath;
}
string LinkerPath = LinkAction.WorkingDirectory;
LinkAction.WorkingDirectory = LinkEnvironment.Config.IntermediateDirectory.FullName;
// Get link arguments.
LinkAction.CommandArguments = LinkEnvironment.Config.bIsBuildingLibrary ? GetArArguments(LinkEnvironment) : GetLinkArguments(LinkEnvironment, Arch);
// Add the output file as a production of the link action.
FileItem OutputFile;
OutputFile = FileItem.GetItemByFileReference(LinkEnvironment.Config.OutputFilePaths[OutputPathIndex]);
Outputs.Add(OutputFile);
LinkAction.ProducedItems.Add(OutputFile);
LinkAction.StatusDescription = string.Format("{0}", Path.GetFileName(OutputFile.AbsolutePath));
// LinkAction.bPrintDebugInfo = true;
// Add the output file to the command-line.
if (LinkEnvironment.Config.bIsBuildingLibrary)
{
LinkAction.CommandArguments += string.Format(" \"{0}\"", OutputFile.AbsolutePath);
}
else
{
LinkAction.CommandArguments += string.Format(" -o \"{0}\"", OutputFile.AbsolutePath);
}
// Add the input files to a response file, and pass the response file on the command-line.
List<string> InputFileNames = new List<string>();
foreach (FileItem InputFile in LinkEnvironment.InputFiles)
{
// make sure it's for current Arch
if (Path.GetFileNameWithoutExtension(InputFile.AbsolutePath).EndsWith(Arch + GPUArchitecture))
{
string AbsolutePath = InputFile.AbsolutePath.Replace("\\", "/");
AbsolutePath = AbsolutePath.Replace(LinkEnvironment.Config.IntermediateDirectory.FullName.Replace("\\", "/"), "");
AbsolutePath = AbsolutePath.TrimStart(new char[] { '/' });
InputFileNames.Add(string.Format("\"{0}\"", AbsolutePath));
LinkAction.PrerequisiteItems.Add(InputFile);
}
}
FileReference ResponseFileName = GetResponseFileName(LinkEnvironment, OutputFile);
LinkAction.CommandArguments += string.Format(" @\"{0}\"", ResponseFile.Create(ResponseFileName, InputFileNames));
// libs don't link in other libs
if (!LinkEnvironment.Config.bIsBuildingLibrary)
{
// Add the library paths to the argument list.
foreach (string LibraryPath in LinkEnvironment.Config.LibraryPaths)
{
// LinkerPaths could be relative or absolute
string AbsoluteLibraryPath = ActionThread.ExpandEnvironmentVariables(LibraryPath);
if (IsDirectoryForArch(AbsoluteLibraryPath, Arch))
{
// environment variables aren't expanded when using the $( style
if (Path.IsPathRooted(AbsoluteLibraryPath) == false)
{
AbsoluteLibraryPath = Path.Combine(LinkerPath, AbsoluteLibraryPath);
}
LinkAction.CommandArguments += string.Format(" -L\"{0}\"", AbsoluteLibraryPath);
}
}
// add libraries in a library group
LinkAction.CommandArguments += string.Format(" -Wl,--start-group");
foreach (string AdditionalLibrary in LinkEnvironment.Config.AdditionalLibraries)
{
if (!ShouldSkipLib(AdditionalLibrary, Arch, GPUArchitecture))
{
if (String.IsNullOrEmpty(Path.GetDirectoryName(AdditionalLibrary)))
{
LinkAction.CommandArguments += string.Format(" \"-l{0}\"", AdditionalLibrary);
}
else
{
// full pathed libs are compiled by us, so we depend on linking them
LinkAction.CommandArguments += string.Format(" \"{0}\"", Path.GetFullPath(AdditionalLibrary));
LinkAction.PrerequisiteItems.Add(FileItem.GetItemByPath(AdditionalLibrary));
}
}
}
LinkAction.CommandArguments += OptionalLinkArguments;
LinkAction.CommandArguments += string.Format(" -Wl,--end-group");
}
// Add the additional arguments specified by the environment.
LinkAction.CommandArguments += LinkEnvironment.Config.AdditionalArguments;
LinkAction.CommandArguments = LinkAction.CommandArguments.Replace("\\", "/");
// Only execute linking on the local PC.
LinkAction.bCanExecuteRemotely = false;
}
}
return Outputs.ToArray();
}
public override void ModifyBuildProducts(UEBuildBinary Binary, Dictionary<FileReference, BuildProductType> BuildProducts)
{
// the binary will have all of the .so's in the output files, we need to trim down to the shared apk (which is what needs to go into the manifest)
if (Binary.Config.Type != UEBuildBinaryType.StaticLibrary)
{
foreach (FileReference BinaryPath in Binary.Config.OutputFilePaths)
{
FileReference ApkFile = BinaryPath.ChangeExtension(".apk");
BuildProducts.Add(ApkFile, BuildProductType.Executable);
}
}
}
public override void CompileCSharpProject(CSharpEnvironment CompileEnvironment, FileReference ProjectFileName, FileReference DestinationFile)
{
throw new BuildException("Android cannot compile C# files");
}
public static void OutputReceivedDataEventHandler(Object Sender, DataReceivedEventArgs Line)
{
if ((Line != null) && (Line.Data != null))
{
Log.TraceInformation(Line.Data);
}
}
public override void StripSymbols(string SourceFileName, string TargetFileName)
{
File.Copy(SourceFileName, TargetFileName, true);
ProcessStartInfo StartInfo = new ProcessStartInfo();
if (SourceFileName.Contains("-armv7"))
{
StartInfo.FileName = ArPathArm.Replace("-ar.exe", "-strip.exe");
}
else
if (SourceFileName.Contains("-arm64"))
{
StartInfo.FileName = ArPathArm64.Replace("-ar.exe", "-strip.exe");
}
else
if (SourceFileName.Contains("-x86"))
{
StartInfo.FileName = ArPathx86.Replace("-ar.exe", "-strip.exe");
}
else
if (SourceFileName.Contains("-x64"))
{
StartInfo.FileName = ArPathx64.Replace("-ar.exe", "-strip.exe");
}
else
{
throw new BuildException("Couldn't determine Android architecture to strip symbols from {0}", SourceFileName);
}
StartInfo.Arguments = "--strip-debug " + TargetFileName;
StartInfo.UseShellExecute = false;
StartInfo.CreateNoWindow = true;
Utils.RunLocalProcessAndLogOutput(StartInfo);
}
};
}