You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#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 Change3128506on 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++. Change3141184on 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 Change3142802on 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]
2449 lines
93 KiB
C#
2449 lines
93 KiB
C#
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Xml;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using Microsoft.Win32;
|
|
using System.Xml.Linq;
|
|
|
|
namespace UnrealBuildTool
|
|
{
|
|
public class UEDeployAndroid : UEBuildDeploy
|
|
{
|
|
/// <summary>
|
|
/// Internal usage for GetApiLevel
|
|
/// </summary>
|
|
private List<string> PossibleApiLevels = null;
|
|
|
|
private FileReference ProjectFile;
|
|
|
|
public UEDeployAndroid(FileReference InProjectFile)
|
|
{
|
|
ProjectFile = InProjectFile;
|
|
}
|
|
|
|
private UnrealPluginLanguage UPL = null;
|
|
|
|
public void SetAndroidPluginData(List<string> Architectures, List<string> inPluginExtraData)
|
|
{
|
|
List<string> NDKArches = new List<string>();
|
|
foreach (var Arch in Architectures)
|
|
{
|
|
NDKArches.Add(GetNDKArch(Arch));
|
|
}
|
|
UPL = new UnrealPluginLanguage(ProjectFile, inPluginExtraData, NDKArches, "http://schemas.android.com/apk/res/android", "xmlns:android=\"http://schemas.android.com/apk/res/android\"", UnrealTargetPlatform.Android);
|
|
// APL.SetTrace();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Simple function to pipe output asynchronously
|
|
/// </summary>
|
|
private void ParseApiLevel(object Sender, DataReceivedEventArgs Event)
|
|
{
|
|
// DataReceivedEventHandler is fired with a null string when the output stream is closed. We don't want to
|
|
// print anything for that event.
|
|
if (!String.IsNullOrEmpty(Event.Data))
|
|
{
|
|
string Line = Event.Data;
|
|
if (Line.StartsWith("id:"))
|
|
{
|
|
// the line should look like: id: 1 or "android-19"
|
|
string[] Tokens = Line.Split("\"".ToCharArray());
|
|
if (Tokens.Length >= 2)
|
|
{
|
|
PossibleApiLevels.Add(Tokens[1]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private Dictionary<string, ConfigCacheIni> ConfigCache = null;
|
|
|
|
private ConfigCacheIni GetConfigCacheIni(string baseIniName)
|
|
{
|
|
if (ConfigCache == null)
|
|
{
|
|
ConfigCache = new Dictionary<string, ConfigCacheIni>();
|
|
}
|
|
|
|
ConfigCacheIni config = null;
|
|
if (!ConfigCache.TryGetValue(baseIniName, out config))
|
|
{
|
|
config = ConfigCacheIni.CreateConfigCacheIni(UnrealTargetPlatform.Android, "Engine", DirectoryReference.FromFile(ProjectFile));
|
|
ConfigCache.Add(baseIniName, config);
|
|
}
|
|
|
|
return config;
|
|
}
|
|
|
|
private string CachedSDKLevel = null;
|
|
private string GetSdkApiLevel(AndroidToolChain ToolChain)
|
|
{
|
|
if (CachedSDKLevel == null)
|
|
{
|
|
// ask the .ini system for what version to use
|
|
ConfigCacheIni Ini = GetConfigCacheIni("Engine");
|
|
string SDKLevel;
|
|
Ini.GetString("/Script/AndroidPlatformEditor.AndroidSDKSettings", "SDKAPILevel", out SDKLevel);
|
|
|
|
// if we want to use whatever version the ndk uses, then use that
|
|
if (SDKLevel == "matchndk")
|
|
{
|
|
SDKLevel = ToolChain.GetNdkApiLevel();
|
|
}
|
|
|
|
// run a command and capture output
|
|
if (SDKLevel == "latest")
|
|
{
|
|
// we expect there to be one, so use the first one
|
|
string AndroidCommandPath = Environment.ExpandEnvironmentVariables("%ANDROID_HOME%/tools/android" + (Utils.IsRunningOnMono ? "" : ".bat"));
|
|
|
|
var ExeInfo = new ProcessStartInfo(AndroidCommandPath, "list targets");
|
|
ExeInfo.UseShellExecute = false;
|
|
ExeInfo.RedirectStandardOutput = true;
|
|
using (var GameProcess = Process.Start(ExeInfo))
|
|
{
|
|
PossibleApiLevels = new List<string>();
|
|
GameProcess.BeginOutputReadLine();
|
|
GameProcess.OutputDataReceived += ParseApiLevel;
|
|
GameProcess.WaitForExit();
|
|
}
|
|
|
|
if (PossibleApiLevels != null && PossibleApiLevels.Count > 0)
|
|
{
|
|
SDKLevel = ToolChain.GetLargestApiLevel(PossibleApiLevels.ToArray());
|
|
}
|
|
else
|
|
{
|
|
throw new BuildException("Can't make an APK without an API installed (see \"android.bat list targets\")");
|
|
}
|
|
}
|
|
|
|
Console.WriteLine("Building Java with SDK API level '{0}'", SDKLevel);
|
|
CachedSDKLevel = SDKLevel;
|
|
}
|
|
|
|
return CachedSDKLevel;
|
|
}
|
|
|
|
private bool IsVulkanSDKAvailable()
|
|
{
|
|
bool bHaveVulkan = false;
|
|
|
|
// First look for VulkanSDK (two possible env variables)
|
|
string VulkanSDKPath = Environment.GetEnvironmentVariable("VULKAN_SDK");
|
|
if (String.IsNullOrEmpty(VulkanSDKPath))
|
|
{
|
|
VulkanSDKPath = Environment.GetEnvironmentVariable("VK_SDK_PATH");
|
|
}
|
|
|
|
// Note: header is the same for all architectures so just use arch-arm
|
|
string NDKPath = Environment.GetEnvironmentVariable("NDKROOT");
|
|
string NDKVulkanIncludePath = NDKPath + "/platforms/android-24/arch-arm/usr/include/vulkan";
|
|
|
|
// Use NDK Vulkan header if discovered, or VulkanSDK if available
|
|
if (File.Exists(NDKVulkanIncludePath + "/vulkan.h"))
|
|
{
|
|
bHaveVulkan = true;
|
|
}
|
|
else
|
|
if (!String.IsNullOrEmpty(VulkanSDKPath))
|
|
{
|
|
bHaveVulkan = true;
|
|
}
|
|
|
|
return bHaveVulkan;
|
|
}
|
|
|
|
public static string GetOBBVersionNumber(int PackageVersion)
|
|
{
|
|
string VersionString = PackageVersion.ToString("0");
|
|
return VersionString;
|
|
}
|
|
|
|
public bool PackageDataInsideApk(bool bDisallowPackagingDataInApk, ConfigCacheIni Ini = null)
|
|
{
|
|
if (bDisallowPackagingDataInApk)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// make a new one if one wasn't passed in
|
|
if (Ini == null)
|
|
{
|
|
Ini = GetConfigCacheIni("Engine");
|
|
}
|
|
|
|
// we check this a lot, so make it easy
|
|
bool bPackageDataInsideApk;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bPackageDataInsideApk", out bPackageDataInsideApk);
|
|
|
|
return bPackageDataInsideApk;
|
|
}
|
|
|
|
public bool DisableVerifyOBBOnStartUp(ConfigCacheIni Ini = null)
|
|
{
|
|
// make a new one if one wasn't passed in
|
|
if (Ini == null)
|
|
{
|
|
Ini = GetConfigCacheIni("Engine");
|
|
}
|
|
|
|
// we check this a lot, so make it easy
|
|
bool bDisableVerifyOBBOnStartUp;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bDisableVerifyOBBOnStartUp", out bDisableVerifyOBBOnStartUp);
|
|
|
|
return bDisableVerifyOBBOnStartUp;
|
|
}
|
|
|
|
private static string GetAntPath()
|
|
{
|
|
// look up an ANT_HOME env var
|
|
string AntHome = Environment.GetEnvironmentVariable("ANT_HOME");
|
|
if (!string.IsNullOrEmpty(AntHome) && Directory.Exists(AntHome))
|
|
{
|
|
string AntPath = AntHome + "/bin/ant" + (Utils.IsRunningOnMono ? "" : ".bat");
|
|
// use it if found
|
|
if (File.Exists(AntPath))
|
|
{
|
|
return AntPath;
|
|
}
|
|
}
|
|
|
|
// otherwise, look in the eclipse install for the ant plugin (matches the unzipped Android ADT from Google)
|
|
string PluginDir = Environment.ExpandEnvironmentVariables("%ANDROID_HOME%/../eclipse/plugins");
|
|
if (Directory.Exists(PluginDir))
|
|
{
|
|
string[] Plugins = Directory.GetDirectories(PluginDir, "org.apache.ant*");
|
|
// use the first one with ant.bat
|
|
if (Plugins.Length > 0)
|
|
{
|
|
foreach (string PluginName in Plugins)
|
|
{
|
|
string AntPath = PluginName + "/bin/ant" + (Utils.IsRunningOnMono ? "" : ".bat");
|
|
// use it if found
|
|
if (File.Exists(AntPath))
|
|
{
|
|
return AntPath;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
throw new BuildException("Unable to find ant.bat (via %ANT_HOME% or %ANDROID_HOME%/../eclipse/plugins/org.apache.ant*");
|
|
}
|
|
|
|
|
|
private static void CopyFileDirectory(string SourceDir, string DestDir, Dictionary<string, string> Replacements)
|
|
{
|
|
if (!Directory.Exists(SourceDir))
|
|
{
|
|
return;
|
|
}
|
|
|
|
string[] Files = Directory.GetFiles(SourceDir, "*.*", SearchOption.AllDirectories);
|
|
foreach (string Filename in Files)
|
|
{
|
|
// skip template files
|
|
if (Path.GetExtension(Filename) == ".template")
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// make the dst filename with the same structure as it was in SourceDir
|
|
string DestFilename = Path.Combine(DestDir, Utils.MakePathRelativeTo(Filename, SourceDir));
|
|
if (File.Exists(DestFilename))
|
|
{
|
|
File.Delete(DestFilename);
|
|
}
|
|
|
|
// make the subdirectory if needed
|
|
string DestSubdir = Path.GetDirectoryName(DestFilename);
|
|
if (!Directory.Exists(DestSubdir))
|
|
{
|
|
Directory.CreateDirectory(DestSubdir);
|
|
}
|
|
|
|
// some files are handled specially
|
|
string Ext = Path.GetExtension(Filename);
|
|
if (Ext == ".xml")
|
|
{
|
|
string Contents = File.ReadAllText(Filename);
|
|
|
|
// replace some varaibles
|
|
foreach (var Pair in Replacements)
|
|
{
|
|
Contents = Contents.Replace(Pair.Key, Pair.Value);
|
|
}
|
|
|
|
// write out file
|
|
File.WriteAllText(DestFilename, Contents);
|
|
}
|
|
else
|
|
{
|
|
File.Copy(Filename, DestFilename);
|
|
|
|
// remove any read only flags
|
|
FileInfo DestFileInfo = new FileInfo(DestFilename);
|
|
DestFileInfo.Attributes = DestFileInfo.Attributes & ~FileAttributes.ReadOnly;
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void DeleteDirectory(string InPath, string SubDirectoryToKeep = "")
|
|
{
|
|
// skip the dir we want to
|
|
if (String.Compare(Path.GetFileName(InPath), SubDirectoryToKeep, true) == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// delete all files in here
|
|
string[] Files;
|
|
try
|
|
{
|
|
Files = Directory.GetFiles(InPath);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
// directory doesn't exist so all is good
|
|
return;
|
|
}
|
|
foreach (string Filename in Files)
|
|
{
|
|
try
|
|
{
|
|
// remove any read only flags
|
|
FileInfo FileInfo = new FileInfo(Filename);
|
|
FileInfo.Attributes = FileInfo.Attributes & ~FileAttributes.ReadOnly;
|
|
FileInfo.Delete();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
Log.TraceInformation("Failed to delete all files in directory {0}. Continuing on...", InPath);
|
|
}
|
|
}
|
|
|
|
string[] Dirs = Directory.GetDirectories(InPath, "*.*", SearchOption.TopDirectoryOnly);
|
|
foreach (string Dir in Dirs)
|
|
{
|
|
DeleteDirectory(Dir, SubDirectoryToKeep);
|
|
// try to delete the directory, but allow it to fail (due to SubDirectoryToKeep still existing)
|
|
try
|
|
{
|
|
Directory.Delete(Dir);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
// do nothing
|
|
}
|
|
}
|
|
}
|
|
|
|
public string GetUE4BuildFilePath(String EngineDirectory)
|
|
{
|
|
return Path.GetFullPath(Path.Combine(EngineDirectory, "Build/Android/Java"));
|
|
}
|
|
|
|
public string GetUE4JavaSrcPath()
|
|
{
|
|
return Path.Combine("src", "com", "epicgames", "ue4");
|
|
}
|
|
|
|
public string GetUE4JavaFilePath(String EngineDirectory)
|
|
{
|
|
return Path.GetFullPath(Path.Combine(GetUE4BuildFilePath(EngineDirectory), GetUE4JavaSrcPath()));
|
|
}
|
|
|
|
public string GetUE4JavaBuildSettingsFileName(String EngineDirectory)
|
|
{
|
|
return Path.Combine(GetUE4JavaFilePath(EngineDirectory), "JavaBuildSettings.java");
|
|
}
|
|
|
|
public string GetUE4JavaDownloadShimFileName(string Directory)
|
|
{
|
|
return Path.Combine(Directory, "DownloadShim.java");
|
|
}
|
|
|
|
public string GetUE4TemplateJavaSourceDir(string Directory)
|
|
{
|
|
return Path.Combine(GetUE4BuildFilePath(Directory), "JavaTemplates");
|
|
}
|
|
|
|
public string GetUE4TemplateJavaDestination(string Directory, string FileName)
|
|
{
|
|
return Path.Combine(Directory, FileName);
|
|
}
|
|
|
|
public string GetUE4JavaOBBDataFileName(string Directory)
|
|
{
|
|
return Path.Combine(Directory, "OBBData.java");
|
|
}
|
|
|
|
public class TemplateFile
|
|
{
|
|
public string SourceFile;
|
|
public string DestinationFile;
|
|
}
|
|
|
|
private void MakeDirectoryIfRequired(string DestFilename)
|
|
{
|
|
string DestSubdir = Path.GetDirectoryName(DestFilename);
|
|
if (!Directory.Exists(DestSubdir))
|
|
{
|
|
Directory.CreateDirectory(DestSubdir);
|
|
}
|
|
}
|
|
|
|
public void WriteJavaOBBDataFile(string FileName, string PackageName, List<string> ObbSources)
|
|
{
|
|
|
|
Log.TraceInformation("\n==== Writing to OBB data file {0} ====", FileName);
|
|
|
|
var Ini = GetConfigCacheIni("Engine");
|
|
int StoreVersion;
|
|
Ini.GetInt32("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "StoreVersion", out StoreVersion);
|
|
|
|
string[] obbDataFile = File.Exists(FileName) ? File.ReadAllLines(FileName) : null;
|
|
|
|
StringBuilder obbData = new StringBuilder("package " + PackageName + ";\n\n");
|
|
obbData.Append("public class OBBData\n{\n");
|
|
obbData.Append("public static class XAPKFile {\npublic final boolean mIsMain;\npublic final String mFileVersion;\n");
|
|
obbData.Append("public final long mFileSize;\nXAPKFile(boolean isMain, String fileVersion, long fileSize) {\nmIsMain = isMain;\nmFileVersion = fileVersion;\nmFileSize = fileSize;\n");
|
|
obbData.Append("}\n}\n\n");
|
|
|
|
// write the data here
|
|
obbData.Append("public static final XAPKFile[] xAPKS = {\n");
|
|
// For each obb file... but we only have one... for now anyway.
|
|
bool first = ObbSources.Count > 1;
|
|
foreach (string ObbSource in ObbSources)
|
|
{
|
|
obbData.Append("new XAPKFile(\ntrue, // true signifies a main file\n");
|
|
obbData.AppendFormat("\"{0}\", // the version of the APK that the file was uploaded against\n", GetOBBVersionNumber(StoreVersion));
|
|
obbData.AppendFormat("{0}L // the length of the file in bytes\n", File.Exists(ObbSource) ? new FileInfo(ObbSource).Length : 0);
|
|
obbData.AppendFormat("){0}\n", first ? "," : "");
|
|
first = false;
|
|
}
|
|
obbData.Append("};\n"); // close off data
|
|
|
|
//
|
|
obbData.Append("};\n"); // close class definition off
|
|
|
|
if (obbDataFile == null || !obbDataFile.SequenceEqual((obbData.ToString()).Split('\n')))
|
|
{
|
|
MakeDirectoryIfRequired(FileName);
|
|
using (StreamWriter outputFile = new StreamWriter(FileName, false))
|
|
{
|
|
var obbSrc = obbData.ToString().Split('\n');
|
|
foreach (var line in obbSrc)
|
|
{
|
|
outputFile.WriteLine(line);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Log.TraceInformation("\n==== OBB data file up to date so not writing. ====");
|
|
}
|
|
}
|
|
|
|
public void WriteJavaDownloadSupportFiles(string ShimFileName, IEnumerable<TemplateFile> TemplateFiles, Dictionary<string, string> replacements)
|
|
{
|
|
// Deal with the Shim first as that is a known target and is easy to deal with
|
|
// If it exists then read it
|
|
string[] DestFileContent = File.Exists(ShimFileName) ? File.ReadAllLines(ShimFileName) : null;
|
|
|
|
StringBuilder ShimFileContent = new StringBuilder("package com.epicgames.ue4;\n\n");
|
|
ShimFileContent.AppendFormat("import {0}.OBBDownloaderService;\n", replacements["$$PackageName$$"]);
|
|
ShimFileContent.AppendFormat("import {0}.DownloaderActivity;\n", replacements["$$PackageName$$"]);
|
|
ShimFileContent.Append("\n\npublic class DownloadShim\n{\n");
|
|
ShimFileContent.Append("\tpublic static OBBDownloaderService DownloaderService;\n");
|
|
ShimFileContent.Append("\tpublic static DownloaderActivity DownloadActivity;\n");
|
|
ShimFileContent.Append("\tpublic static Class<DownloaderActivity> GetDownloaderType() { return DownloaderActivity.class; }\n");
|
|
ShimFileContent.Append("}\n");
|
|
|
|
Log.TraceInformation("\n==== Writing to shim file {0} ====", ShimFileName);
|
|
|
|
// If they aren't the same then dump out the settings
|
|
if (DestFileContent == null || !DestFileContent.SequenceEqual((ShimFileContent.ToString()).Split('\n')))
|
|
{
|
|
MakeDirectoryIfRequired(ShimFileName);
|
|
using (StreamWriter outputFile = new StreamWriter(ShimFileName, false))
|
|
{
|
|
var shimSrc = ShimFileContent.ToString().Split('\n');
|
|
foreach (var line in shimSrc)
|
|
{
|
|
outputFile.WriteLine(line);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Log.TraceInformation("\n==== Shim data file up to date so not writing. ====");
|
|
}
|
|
|
|
// Now we move on to the template files
|
|
foreach (var template in TemplateFiles)
|
|
{
|
|
string[] templateSrc = File.ReadAllLines(template.SourceFile);
|
|
string[] templateDest = File.Exists(template.DestinationFile) ? File.ReadAllLines(template.DestinationFile) : null;
|
|
|
|
for (int i = 0; i < templateSrc.Length; ++i)
|
|
{
|
|
string srcLine = templateSrc[i];
|
|
bool changed = false;
|
|
foreach (var kvp in replacements)
|
|
{
|
|
if (srcLine.Contains(kvp.Key))
|
|
{
|
|
srcLine = srcLine.Replace(kvp.Key, kvp.Value);
|
|
changed = true;
|
|
}
|
|
}
|
|
if (changed)
|
|
{
|
|
templateSrc[i] = srcLine;
|
|
}
|
|
}
|
|
|
|
Log.TraceInformation("\n==== Writing to template target file {0} ====", template.DestinationFile);
|
|
|
|
if (templateDest == null || templateSrc.Length != templateDest.Length || !templateSrc.SequenceEqual(templateDest))
|
|
{
|
|
MakeDirectoryIfRequired(template.DestinationFile);
|
|
using (StreamWriter outputFile = new StreamWriter(template.DestinationFile, false))
|
|
{
|
|
foreach (var line in templateSrc)
|
|
{
|
|
outputFile.WriteLine(line);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Log.TraceInformation("\n==== Template target file up to date so not writing. ====");
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private static string GetNDKArch(string UE4Arch)
|
|
{
|
|
switch (UE4Arch)
|
|
{
|
|
case "-armv7": return "armeabi-v7a";
|
|
case "-arm64": return "arm64-v8a";
|
|
case "-x64": return "x86_64";
|
|
case "-x86": return "x86";
|
|
|
|
default: throw new BuildException("Unknown UE4 architecture {0}", UE4Arch);
|
|
}
|
|
}
|
|
|
|
public static string GetUE4Arch(string NDKArch)
|
|
{
|
|
switch (NDKArch)
|
|
{
|
|
case "armeabi-v7a": return "-armv7";
|
|
case "arm64-v8a": return "-arm64";
|
|
case "x86": return "-x86";
|
|
case "arm64": return "-arm64";
|
|
case "x86_64":
|
|
case "x64": return "-x64";
|
|
|
|
// default: throw new BuildException("Unknown NDK architecture '{0}'", NDKArch);
|
|
// future-proof by returning armv7 for unknown
|
|
default: return "-armv7";
|
|
}
|
|
}
|
|
|
|
private static void StripDebugSymbols(string SourceFileName, string TargetFileName, string UE4Arch)
|
|
{
|
|
// Copy the file and remove read-only if necessary
|
|
File.Copy(SourceFileName, TargetFileName, true);
|
|
FileAttributes Attribs = File.GetAttributes(TargetFileName);
|
|
if (Attribs.HasFlag(FileAttributes.ReadOnly))
|
|
{
|
|
File.SetAttributes(TargetFileName, Attribs & ~FileAttributes.ReadOnly);
|
|
}
|
|
|
|
ProcessStartInfo StartInfo = new ProcessStartInfo();
|
|
StartInfo.FileName = AndroidToolChain.GetStripExecutablePath(UE4Arch);
|
|
StartInfo.Arguments = "--strip-debug \"" + TargetFileName + "\"";
|
|
StartInfo.UseShellExecute = false;
|
|
StartInfo.CreateNoWindow = true;
|
|
Utils.RunLocalProcessAndLogOutput(StartInfo);
|
|
}
|
|
|
|
private static void CopySTL(AndroidToolChain ToolChain, string UE4BuildPath, string UE4Arch, string NDKArch, bool bForDistribution)
|
|
{
|
|
string GccVersion = "4.6";
|
|
if (Directory.Exists(Environment.ExpandEnvironmentVariables("%NDKROOT%/sources/cxx-stl/gnu-libstdc++/4.9")))
|
|
{
|
|
GccVersion = "4.9";
|
|
}
|
|
else if (Directory.Exists(Environment.ExpandEnvironmentVariables("%NDKROOT%/sources/cxx-stl/gnu-libstdc++/4.8")))
|
|
{
|
|
GccVersion = "4.8";
|
|
}
|
|
|
|
// copy it in!
|
|
string SourceSTLSOName = Environment.ExpandEnvironmentVariables("%NDKROOT%/sources/cxx-stl/gnu-libstdc++/") + GccVersion + "/libs/" + NDKArch + "/libgnustl_shared.so";
|
|
string FinalSTLSOName = UE4BuildPath + "/libs/" + NDKArch + "/libgnustl_shared.so";
|
|
|
|
// check to see if libgnustl_shared.so is newer than last time we copied (or needs stripping for distribution)
|
|
bool bFileExists = File.Exists(FinalSTLSOName);
|
|
TimeSpan Diff = File.GetLastWriteTimeUtc(FinalSTLSOName) - File.GetLastWriteTimeUtc(SourceSTLSOName);
|
|
if (bForDistribution || !bFileExists || Diff.TotalSeconds < -1 || Diff.TotalSeconds > 1)
|
|
{
|
|
if (bFileExists)
|
|
{
|
|
File.Delete(FinalSTLSOName);
|
|
}
|
|
Directory.CreateDirectory(Path.GetDirectoryName(FinalSTLSOName));
|
|
if (bForDistribution)
|
|
{
|
|
// Strip debug symbols for distribution builds
|
|
StripDebugSymbols(SourceSTLSOName, FinalSTLSOName, UE4Arch);
|
|
}
|
|
else
|
|
{
|
|
File.Copy(SourceSTLSOName, FinalSTLSOName, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
//@TODO: To enable the NVIDIA Gfx Debugger - these paths need to be standardized
|
|
private static void CopyGfxDebugger(string UE4BuildPath, string UE4Arch, string NDKArch)
|
|
{
|
|
/*
|
|
Directory.CreateDirectory(UE4BuildPath + "/libs/" + NDKArch);
|
|
File.Copy("F:/NVPACK/android-kk-egl-t124-a32/Stripped_libNvPmApi.Core.so", UE4BuildPath + "/libs/" + NDKArch + "/libNvPmApi.Core.so", true);
|
|
File.Copy("F:/NVPACK/android-kk-egl-t124-a32/Stripped_libNvidia_gfx_debugger.so", UE4BuildPath + "/libs/" + NDKArch + "/libNvidia_gfx_debugger.so", true);
|
|
*/
|
|
}
|
|
|
|
private static int RunCommandLineProgramAndReturnResult(string WorkingDirectory, string Command, string Params, string OverrideDesc = null, bool bUseShellExecute = false)
|
|
{
|
|
if (OverrideDesc == null)
|
|
{
|
|
Log.TraceInformation("\nRunning: " + Command + " " + Params);
|
|
}
|
|
else if (OverrideDesc != "")
|
|
{
|
|
Log.TraceInformation(OverrideDesc);
|
|
Log.TraceVerbose("\nRunning: " + Command + " " + Params);
|
|
}
|
|
|
|
ProcessStartInfo StartInfo = new ProcessStartInfo();
|
|
StartInfo.WorkingDirectory = WorkingDirectory;
|
|
StartInfo.FileName = Command;
|
|
StartInfo.Arguments = Params;
|
|
StartInfo.UseShellExecute = bUseShellExecute;
|
|
StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
|
|
|
|
Process Proc = new Process();
|
|
Proc.StartInfo = StartInfo;
|
|
Proc.Start();
|
|
Proc.WaitForExit();
|
|
|
|
return Proc.ExitCode;
|
|
}
|
|
|
|
private static void RunCommandLineProgramWithException(string WorkingDirectory, string Command, string Params, string OverrideDesc = null, bool bUseShellExecute = false)
|
|
{
|
|
if (OverrideDesc == null)
|
|
{
|
|
Log.TraceInformation("\nRunning: " + Command + " " + Params);
|
|
}
|
|
else if (OverrideDesc != "")
|
|
{
|
|
Log.TraceInformation(OverrideDesc);
|
|
Log.TraceVerbose("\nRunning: " + Command + " " + Params);
|
|
}
|
|
|
|
ProcessStartInfo StartInfo = new ProcessStartInfo();
|
|
StartInfo.WorkingDirectory = WorkingDirectory;
|
|
StartInfo.FileName = Command;
|
|
StartInfo.Arguments = Params;
|
|
StartInfo.UseShellExecute = bUseShellExecute;
|
|
StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
|
|
|
|
Process Proc = new Process();
|
|
Proc.StartInfo = StartInfo;
|
|
Proc.Start();
|
|
Proc.WaitForExit();
|
|
|
|
// android bat failure
|
|
if (Proc.ExitCode != 0)
|
|
{
|
|
throw new BuildException("{0} failed with args {1}", Command, Params);
|
|
}
|
|
}
|
|
|
|
private bool CheckApplicationName(string UE4BuildPath, string ProjectName, out string ApplicationDisplayName)
|
|
{
|
|
string StringsXMLPath = Path.Combine(UE4BuildPath, "res/values/strings.xml");
|
|
|
|
ApplicationDisplayName = null;
|
|
ConfigCacheIni Ini = GetConfigCacheIni("Engine");
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "ApplicationDisplayName", out ApplicationDisplayName);
|
|
|
|
// use project name if display name is left blank
|
|
if (String.IsNullOrWhiteSpace(ApplicationDisplayName))
|
|
{
|
|
ApplicationDisplayName = ProjectName;
|
|
}
|
|
|
|
// replace escaped characters (note: changes &# pattern before &, then patches back to allow escaped character codes in the string)
|
|
ApplicationDisplayName = ApplicationDisplayName.Replace("&#", "$@#$").Replace("&", "&").Replace("'", "\\'").Replace("\"", "\\\"").Replace("<", "<").Replace(">", ">").Replace("$@#$", "&#");
|
|
|
|
// if it doesn't exist, need to repackage
|
|
if (!File.Exists(StringsXMLPath))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// read it and see if needs to be updated
|
|
string Contents = File.ReadAllText(StringsXMLPath);
|
|
|
|
// find the key
|
|
string AppNameTag = "<string name=\"app_name\">";
|
|
int KeyIndex = Contents.IndexOf(AppNameTag);
|
|
|
|
// if doesn't exist, need to repackage
|
|
if (KeyIndex < 0)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// get the current value
|
|
KeyIndex += AppNameTag.Length;
|
|
int TagEnd = Contents.IndexOf("</string>", KeyIndex);
|
|
if (TagEnd < 0)
|
|
{
|
|
return true;
|
|
}
|
|
string CurrentApplicationName = Contents.Substring(KeyIndex, TagEnd - KeyIndex);
|
|
|
|
// no need to do anything if matches
|
|
if (CurrentApplicationName == ApplicationDisplayName)
|
|
{
|
|
// name matches, no need to force a repackage
|
|
return false;
|
|
}
|
|
|
|
// need to repackage
|
|
return true;
|
|
}
|
|
|
|
private void UpdateProjectProperties(AndroidToolChain ToolChain, string UE4BuildPath, string ProjectName)
|
|
{
|
|
Log.TraceInformation("\n===={0}====UPDATING BUILD CONFIGURATION FILES====================================================", DateTime.Now.ToString());
|
|
|
|
// get all of the libs (from engine + project)
|
|
string JavaLibsDir = Path.Combine(UE4BuildPath, "JavaLibs");
|
|
string[] LibDirs = Directory.GetDirectories(JavaLibsDir);
|
|
|
|
// get existing project.properties lines (if any)
|
|
string ProjectPropertiesFile = Path.Combine(UE4BuildPath, "project.properties");
|
|
string[] PropertiesLines = new string[] { };
|
|
if (File.Exists(ProjectPropertiesFile))
|
|
{
|
|
PropertiesLines = File.ReadAllLines(ProjectPropertiesFile);
|
|
}
|
|
|
|
// figure out how many libraries were already listed (if there were more than this listed, then we need to start the file over, because we need to unreference a library)
|
|
int NumOutstandingAlreadyReferencedLibs = 0;
|
|
foreach (string Line in PropertiesLines)
|
|
{
|
|
if (Line.StartsWith("android.library.reference."))
|
|
{
|
|
NumOutstandingAlreadyReferencedLibs++;
|
|
}
|
|
}
|
|
|
|
// now go through each one and verify they are listed in project properties, and if not, add them
|
|
List<string> LibsToBeAdded = new List<string>();
|
|
foreach (string LibDir in LibDirs)
|
|
{
|
|
// put it in terms of the subdirectory that would be in the project.properties
|
|
string RelativePath = "JavaLibs/" + Path.GetFileName(LibDir);
|
|
|
|
// now look for this in the existing file
|
|
bool bWasReferencedAlready = false;
|
|
foreach (string Line in PropertiesLines)
|
|
{
|
|
if (Line.StartsWith("android.library.reference.") && Line.EndsWith(RelativePath))
|
|
{
|
|
// this lib was already referenced, don't need to readd
|
|
bWasReferencedAlready = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (bWasReferencedAlready)
|
|
{
|
|
// if it was, no further action needed, and count it off
|
|
NumOutstandingAlreadyReferencedLibs--;
|
|
}
|
|
else
|
|
{
|
|
// otherwise, we need to add it to the project properties
|
|
LibsToBeAdded.Add(RelativePath);
|
|
}
|
|
}
|
|
|
|
// now at this point, if there are any outstanding already referenced libs, we have too many, so we have to start over
|
|
if (NumOutstandingAlreadyReferencedLibs > 0)
|
|
{
|
|
// @todo android: If a user had a project.properties in the game, NEVER do this
|
|
Log.TraceInformation("There were too many libs already referenced in project.properties, tossing it");
|
|
File.Delete(ProjectPropertiesFile);
|
|
|
|
LibsToBeAdded.Clear();
|
|
foreach (string LibDir in LibDirs)
|
|
{
|
|
// put it in terms of the subdirectory that would be in the project.properties
|
|
LibsToBeAdded.Add("JavaLibs/" + Path.GetFileName(LibDir));
|
|
}
|
|
}
|
|
|
|
// now update the project for each library
|
|
string AndroidCommandPath = Environment.ExpandEnvironmentVariables("%ANDROID_HOME%/tools/android" + (Utils.IsRunningOnMono ? "" : ".bat"));
|
|
string UpdateCommandLine = "--silent update project --subprojects --name " + ProjectName + " --path . --target " + GetSdkApiLevel(ToolChain);
|
|
foreach (string Lib in LibsToBeAdded)
|
|
{
|
|
string LocalUpdateCommandLine = UpdateCommandLine + " --library " + Lib;
|
|
|
|
// make sure each library has a build.xml - --subprojects doesn't create build.xml files, but it will create project.properties
|
|
// and later code needs each lib to have a build.xml
|
|
RunCommandLineProgramWithException(UE4BuildPath, AndroidCommandPath, "--silent update lib-project --path " + Lib + " --target " + GetSdkApiLevel(ToolChain), "");
|
|
RunCommandLineProgramWithException(UE4BuildPath, AndroidCommandPath, LocalUpdateCommandLine, "Updating project.properties, local.properties, and build.xml for " + Path.GetFileName(Lib) + "...");
|
|
}
|
|
|
|
}
|
|
|
|
|
|
private string GetAllBuildSettings(AndroidToolChain ToolChain, string BuildPath, bool bForDistribution, bool bMakeSeparateApks, bool bPackageDataInsideApk, bool bDisableVerifyOBBOnStartUp)
|
|
{
|
|
// make the settings string - this will be char by char compared against last time
|
|
StringBuilder CurrentSettings = new StringBuilder();
|
|
CurrentSettings.AppendLine(string.Format("NDKROOT={0}", Environment.GetEnvironmentVariable("NDKROOT")));
|
|
CurrentSettings.AppendLine(string.Format("ANDROID_HOME={0}", Environment.GetEnvironmentVariable("ANDROID_HOME")));
|
|
CurrentSettings.AppendLine(string.Format("ANT_HOME={0}", Environment.GetEnvironmentVariable("ANT_HOME")));
|
|
CurrentSettings.AppendLine(string.Format("JAVA_HOME={0}", Environment.GetEnvironmentVariable("JAVA_HOME")));
|
|
CurrentSettings.AppendLine(string.Format("SDKVersion={0}", GetSdkApiLevel(ToolChain)));
|
|
CurrentSettings.AppendLine(string.Format("bForDistribution={0}", bForDistribution));
|
|
CurrentSettings.AppendLine(string.Format("bMakeSeparateApks={0}", bMakeSeparateApks));
|
|
CurrentSettings.AppendLine(string.Format("bPackageDataInsideApk={0}", bPackageDataInsideApk));
|
|
CurrentSettings.AppendLine(string.Format("bDisableVerifyOBBOnStartUp={0}", bDisableVerifyOBBOnStartUp));
|
|
|
|
// all AndroidRuntimeSettings ini settings in here
|
|
ConfigCacheIni Ini = GetConfigCacheIni("Engine");
|
|
ConfigCacheIni.IniSection Section = Ini.FindSection("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings");
|
|
if (Section != null)
|
|
{
|
|
foreach (string Key in Section.Keys)
|
|
{
|
|
List<string> Values = Section[Key];
|
|
foreach (string Value in Values)
|
|
{
|
|
CurrentSettings.AppendLine(string.Format("{0}={1}", Key, Value));
|
|
}
|
|
}
|
|
}
|
|
|
|
Section = Ini.FindSection("/Script/AndroidPlatformEditor.AndroidSDKSettings");
|
|
if (Section != null)
|
|
{
|
|
foreach (string Key in Section.Keys)
|
|
{
|
|
List<string> Values = Section[Key];
|
|
foreach (string Value in Values)
|
|
{
|
|
CurrentSettings.AppendLine(string.Format("{0}={1}", Key, Value));
|
|
}
|
|
}
|
|
}
|
|
|
|
var Arches = ToolChain.GetAllArchitectures();
|
|
foreach (string Arch in Arches)
|
|
{
|
|
CurrentSettings.AppendFormat("Arch={0}{1}", Arch, Environment.NewLine);
|
|
}
|
|
|
|
var GPUArchitectures = ToolChain.GetAllGPUArchitectures();
|
|
foreach (string GPUArch in GPUArchitectures)
|
|
{
|
|
CurrentSettings.AppendFormat("GPUArch={0}{1}", GPUArch, Environment.NewLine);
|
|
}
|
|
|
|
return CurrentSettings.ToString();
|
|
}
|
|
|
|
private bool CheckDependencies(AndroidToolChain ToolChain, string ProjectName, string ProjectDirectory, string UE4BuildFilesPath, string GameBuildFilesPath, string EngineDirectory, List<string> SettingsFiles,
|
|
string CookFlavor, string OutputPath, string UE4BuildPath, bool bMakeSeparateApks, bool bPackageDataInsideApk)
|
|
{
|
|
var Arches = ToolChain.GetAllArchitectures();
|
|
var GPUArchitectures = ToolChain.GetAllGPUArchitectures();
|
|
|
|
// check all input files (.so, java files, .ini files, etc)
|
|
bool bAllInputsCurrent = true;
|
|
foreach (string Arch in Arches)
|
|
{
|
|
foreach (string GPUArch in GPUArchitectures)
|
|
{
|
|
string SourceSOName = AndroidToolChain.InlineArchName(OutputPath, Arch, GPUArch);
|
|
// if the source binary was UE4Game, replace it with the new project name, when re-packaging a binary only build
|
|
string ApkFilename = Path.GetFileNameWithoutExtension(OutputPath).Replace("UE4Game", ProjectName);
|
|
string DestApkName = Path.Combine(ProjectDirectory, "Binaries/Android/") + ApkFilename + ".apk";
|
|
|
|
// if we making multiple Apks, we need to put the architecture into the name
|
|
if (bMakeSeparateApks)
|
|
{
|
|
DestApkName = AndroidToolChain.InlineArchName(DestApkName, Arch, GPUArch);
|
|
}
|
|
|
|
// check to see if it's out of date before trying the slow make apk process (look at .so and all Engine and Project build files to be safe)
|
|
List<String> InputFiles = new List<string>();
|
|
InputFiles.Add(SourceSOName);
|
|
InputFiles.AddRange(Directory.EnumerateFiles(UE4BuildFilesPath, "*.*", SearchOption.AllDirectories));
|
|
if (Directory.Exists(GameBuildFilesPath))
|
|
{
|
|
InputFiles.AddRange(Directory.EnumerateFiles(GameBuildFilesPath, "*.*", SearchOption.AllDirectories));
|
|
}
|
|
|
|
// make sure changed java files will rebuild apk
|
|
InputFiles.AddRange(SettingsFiles);
|
|
|
|
// rebuild if .pak files exist for OBB in APK case
|
|
if (bPackageDataInsideApk)
|
|
{
|
|
string PAKFileLocation = ProjectDirectory + "/Saved/StagedBuilds/Android" + CookFlavor + "/" + ProjectName + "/Content/Paks";
|
|
if (Directory.Exists(PAKFileLocation))
|
|
{
|
|
var PakFiles = Directory.EnumerateFiles(PAKFileLocation, "*.pak", SearchOption.TopDirectoryOnly);
|
|
foreach (var Name in PakFiles)
|
|
{
|
|
InputFiles.Add(Name);
|
|
}
|
|
}
|
|
}
|
|
|
|
// look for any newer input file
|
|
DateTime ApkTime = File.GetLastWriteTimeUtc(DestApkName);
|
|
foreach (var InputFileName in InputFiles)
|
|
{
|
|
if (File.Exists(InputFileName))
|
|
{
|
|
// skip .log files
|
|
if (Path.GetExtension(InputFileName) == ".log")
|
|
{
|
|
continue;
|
|
}
|
|
DateTime InputFileTime = File.GetLastWriteTimeUtc(InputFileName);
|
|
if (InputFileTime.CompareTo(ApkTime) > 0)
|
|
{
|
|
bAllInputsCurrent = false;
|
|
Log.TraceInformation("{0} is out of date due to newer input file {1}", DestApkName, InputFileName);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return bAllInputsCurrent;
|
|
}
|
|
|
|
private int ConvertDepthBufferIniValue(string IniValue)
|
|
{
|
|
switch (IniValue.ToLower())
|
|
{
|
|
case "bits16":
|
|
return 16;
|
|
case "bits24":
|
|
return 24;
|
|
case "bits32":
|
|
return 32;
|
|
default:
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
private string ConvertOrientationIniValue(string IniValue)
|
|
{
|
|
switch (IniValue.ToLower())
|
|
{
|
|
case "portrait":
|
|
return "portrait";
|
|
case "reverseportrait":
|
|
return "reversePortrait";
|
|
case "sensorportrait":
|
|
return "sensorPortrait";
|
|
case "landscape":
|
|
return "landscape";
|
|
case "reverselandscape":
|
|
return "reverseLandscape";
|
|
case "sensorlandscape":
|
|
return "sensorLandscape";
|
|
case "sensor":
|
|
return "sensor";
|
|
case "fullsensor":
|
|
return "fullSensor";
|
|
default:
|
|
return "landscape";
|
|
}
|
|
}
|
|
|
|
private void DetermineScreenOrientationRequirements(out bool bNeedPortrait, out bool bNeedLandscape)
|
|
{
|
|
ConfigCacheIni Ini = GetConfigCacheIni("Engine");
|
|
string Orientation;
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "Orientation", out Orientation);
|
|
|
|
bNeedLandscape = false;
|
|
bNeedPortrait = false;
|
|
|
|
switch (Orientation.ToLower())
|
|
{
|
|
case "portrait":
|
|
bNeedPortrait = true;
|
|
break;
|
|
case "reverseportrait":
|
|
bNeedPortrait = true;
|
|
break;
|
|
case "sensorportrait":
|
|
bNeedPortrait = true;
|
|
break;
|
|
|
|
case "landscape":
|
|
bNeedLandscape = true;
|
|
break;
|
|
case "reverselandscape":
|
|
bNeedLandscape = true;
|
|
break;
|
|
case "sensorlandscape":
|
|
bNeedLandscape = true;
|
|
break;
|
|
|
|
case "sensor":
|
|
bNeedPortrait = true;
|
|
bNeedLandscape = true;
|
|
break;
|
|
case "fullsensor":
|
|
bNeedPortrait = true;
|
|
bNeedLandscape = true;
|
|
break;
|
|
|
|
default:
|
|
bNeedPortrait = true;
|
|
bNeedLandscape = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void PickDownloaderScreenOrientation(string UE4BuildPath, bool bNeedPortrait, bool bNeedLandscape)
|
|
{
|
|
// Remove unused downloader_progress.xml to prevent missing resource
|
|
if (!bNeedPortrait)
|
|
{
|
|
string LayoutPath = UE4BuildPath + "/res/layout-port/downloader_progress.xml";
|
|
if (File.Exists(LayoutPath))
|
|
{
|
|
File.Delete(LayoutPath);
|
|
}
|
|
}
|
|
if (!bNeedLandscape)
|
|
{
|
|
string LayoutPath = UE4BuildPath + "/res/layout-land/downloader_progress.xml";
|
|
if (File.Exists(LayoutPath))
|
|
{
|
|
File.Delete(LayoutPath);
|
|
}
|
|
}
|
|
|
|
// Loop through each of the resolutions (only /res/drawable/ is required, others are optional)
|
|
string[] Resolutions = new string[] { "/res/drawable/", "/res/drawable-ldpi/", "/res/drawable-mdpi/", "/res/drawable-hdpi/", "/res/drawable-xhdpi/" };
|
|
foreach (string ResolutionPath in Resolutions)
|
|
{
|
|
string PortraitFilename = UE4BuildPath + ResolutionPath + "downloadimagev.png";
|
|
if (bNeedPortrait)
|
|
{
|
|
if (!File.Exists(PortraitFilename) && (ResolutionPath == "/res/drawable/"))
|
|
{
|
|
Log.TraceWarning("Warning: Downloader screen source image {0} not available, downloader screen will not function properly!", PortraitFilename);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Remove unused image
|
|
if (File.Exists(PortraitFilename))
|
|
{
|
|
File.Delete(PortraitFilename);
|
|
}
|
|
}
|
|
|
|
string LandscapeFilename = UE4BuildPath + ResolutionPath + "downloadimageh.png";
|
|
if (bNeedLandscape)
|
|
{
|
|
if (!File.Exists(LandscapeFilename) && (ResolutionPath == "/res/drawable/"))
|
|
{
|
|
Log.TraceWarning("Warning: Downloader screen source image {0} not available, downloader screen will not function properly!", LandscapeFilename);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Remove unused image
|
|
if (File.Exists(LandscapeFilename))
|
|
{
|
|
File.Delete(LandscapeFilename);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void PickSplashScreenOrientation(string UE4BuildPath, bool bNeedPortrait, bool bNeedLandscape)
|
|
{
|
|
ConfigCacheIni Ini = GetConfigCacheIni("Engine");
|
|
bool bShowLaunchImage = false;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bShowLaunchImage", out bShowLaunchImage);
|
|
bool bPackageForGearVR;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bPackageForGearVR", out bPackageForGearVR);
|
|
|
|
//override the parameters if we are not showing a launch image or are packaging for GearVR
|
|
if (bPackageForGearVR || !bShowLaunchImage)
|
|
{
|
|
bNeedPortrait = bNeedLandscape = false;
|
|
}
|
|
|
|
// Remove unused styles.xml to prevent missing resource
|
|
if (!bNeedPortrait)
|
|
{
|
|
string StylesPath = UE4BuildPath + "/res/values-port/styles.xml";
|
|
if (File.Exists(StylesPath))
|
|
{
|
|
File.Delete(StylesPath);
|
|
}
|
|
}
|
|
if (!bNeedLandscape)
|
|
{
|
|
string StylesPath = UE4BuildPath + "/res/values-land/styles.xml";
|
|
if (File.Exists(StylesPath))
|
|
{
|
|
File.Delete(StylesPath);
|
|
}
|
|
}
|
|
|
|
// Loop through each of the resolutions (only /res/drawable/ is required, others are optional)
|
|
string[] Resolutions = new string[] { "/res/drawable/", "/res/drawable-ldpi/", "/res/drawable-mdpi/", "/res/drawable-hdpi/", "/res/drawable-xhdpi/" };
|
|
foreach (string ResolutionPath in Resolutions)
|
|
{
|
|
string PortraitFilename = UE4BuildPath + ResolutionPath + "splashscreen_portrait.png";
|
|
if (bNeedPortrait)
|
|
{
|
|
if (!File.Exists(PortraitFilename) && (ResolutionPath == "/res/drawable/"))
|
|
{
|
|
Log.TraceWarning("Warning: Splash screen source image {0} not available, splash screen will not function properly!", PortraitFilename);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Remove unused image
|
|
if (File.Exists(PortraitFilename))
|
|
{
|
|
File.Delete(PortraitFilename);
|
|
}
|
|
}
|
|
|
|
string LandscapeFilename = UE4BuildPath + ResolutionPath + "splashscreen_landscape.png";
|
|
if (bNeedLandscape)
|
|
{
|
|
if (!File.Exists(LandscapeFilename) && (ResolutionPath == "/res/drawable/"))
|
|
{
|
|
Log.TraceWarning("Warning: Splash screen source image {0} not available, splash screen will not function properly!", LandscapeFilename);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Remove unused image
|
|
if (File.Exists(LandscapeFilename))
|
|
{
|
|
File.Delete(LandscapeFilename);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private string GetPackageName(string ProjectName)
|
|
{
|
|
ConfigCacheIni Ini = GetConfigCacheIni("Engine");
|
|
string PackageName;
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "PackageName", out PackageName);
|
|
// replace some variables
|
|
PackageName = PackageName.Replace("[PROJECT]", ProjectName);
|
|
PackageName = PackageName.Replace("-", "_");
|
|
return PackageName;
|
|
}
|
|
|
|
private string GetPublicKey()
|
|
{
|
|
ConfigCacheIni Ini = GetConfigCacheIni("Engine");
|
|
string PlayLicenseKey = "";
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "GooglePlayLicenseKey", out PlayLicenseKey);
|
|
return PlayLicenseKey;
|
|
}
|
|
|
|
|
|
|
|
private string GenerateManifest(AndroidToolChain ToolChain, string ProjectName, bool bIsForDistribution, bool bPackageDataInsideApk, string GameBuildFilesPath, bool bHasOBBFiles, bool bDisableVerifyOBBOnStartUp, string UE4Arch, string GPUArch, string CookFlavor)
|
|
{
|
|
string Arch = GetNDKArch(UE4Arch);
|
|
int NDKLevelInt = ToolChain.GetNdkApiLevelInt();
|
|
|
|
// 64-bit targets must be android-21 or higher
|
|
if (NDKLevelInt < 21)
|
|
{
|
|
if (UE4Arch == "-arm64" || UE4Arch == "-x64")
|
|
{
|
|
NDKLevelInt = 21;
|
|
}
|
|
}
|
|
|
|
// ini file to get settings from
|
|
ConfigCacheIni Ini = GetConfigCacheIni("Engine");
|
|
string PackageName = GetPackageName(ProjectName);
|
|
bool bEnableGooglePlaySupport;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bEnableGooglePlaySupport", out bEnableGooglePlaySupport);
|
|
string DepthBufferPreference;
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "DepthBufferPreference", out DepthBufferPreference);
|
|
int MinSDKVersion;
|
|
Ini.GetInt32("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "MinSDKVersion", out MinSDKVersion);
|
|
int TargetSDKVersion = MinSDKVersion;
|
|
Ini.GetInt32("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "TargetSDKVersion", out TargetSDKVersion);
|
|
int StoreVersion;
|
|
Ini.GetInt32("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "StoreVersion", out StoreVersion);
|
|
string VersionDisplayName;
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "VersionDisplayName", out VersionDisplayName);
|
|
string Orientation;
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "Orientation", out Orientation);
|
|
bool EnableFullScreen;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bFullScreen", out EnableFullScreen);
|
|
List<string> ExtraManifestNodeTags;
|
|
Ini.GetArray("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "ExtraManifestNodeTags", out ExtraManifestNodeTags);
|
|
List<string> ExtraApplicationNodeTags;
|
|
Ini.GetArray("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "ExtraApplicationNodeTags", out ExtraApplicationNodeTags);
|
|
List<string> ExtraActivityNodeTags;
|
|
Ini.GetArray("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "ExtraActivityNodeTags", out ExtraActivityNodeTags);
|
|
string ExtraActivitySettings;
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "ExtraActivitySettings", out ExtraActivitySettings);
|
|
string ExtraApplicationSettings;
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "ExtraApplicationSettings", out ExtraApplicationSettings);
|
|
List<string> ExtraPermissions;
|
|
Ini.GetArray("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "ExtraPermissions", out ExtraPermissions);
|
|
bool bPackageForGearVR;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bPackageForGearVR", out bPackageForGearVR);
|
|
bool bSupportsVulkan;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bSupportsVulkan", out bSupportsVulkan);
|
|
if (bSupportsVulkan)
|
|
{
|
|
bSupportsVulkan = IsVulkanSDKAvailable();
|
|
}
|
|
bool bEnableIAP = false;
|
|
Ini.GetBool("OnlineSubsystemGooglePlay.Store", "bSupportsInAppPurchasing", out bEnableIAP);
|
|
bool bShowLaunchImage = false;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bShowLaunchImage", out bShowLaunchImage);
|
|
|
|
string InstallLocation;
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "InstallLocation", out InstallLocation);
|
|
switch(InstallLocation.ToLower())
|
|
{
|
|
case "preferexternal":
|
|
InstallLocation = "preferExternal";
|
|
break;
|
|
case "auto":
|
|
InstallLocation = "auto";
|
|
break;
|
|
default:
|
|
InstallLocation = "internalOnly";
|
|
break;
|
|
}
|
|
|
|
// fix up the MinSdkVersion
|
|
if (NDKLevelInt > 19)
|
|
{
|
|
if (MinSDKVersion < 21)
|
|
{
|
|
MinSDKVersion = 21;
|
|
Log.TraceInformation("Fixing minSdkVersion; NDK level above 19 requires minSdkVersion of 21 (arch={0})", UE4Arch.Substring(1));
|
|
}
|
|
}
|
|
|
|
// disable GearVR if not supported platform (in this case only armv7 for now)
|
|
if (UE4Arch != "-armv7")
|
|
{
|
|
if (bPackageForGearVR)
|
|
{
|
|
Log.TraceInformation("Disabling Package For GearVR for unsupported architecture {0}", UE4Arch);
|
|
bPackageForGearVR = false;
|
|
}
|
|
}
|
|
|
|
// disable splash screen for GearVR (for now)
|
|
if (bPackageForGearVR)
|
|
{
|
|
if (bShowLaunchImage)
|
|
{
|
|
Log.TraceInformation("Disabling Show Launch Image for GearVR enabled application");
|
|
bShowLaunchImage = false;
|
|
}
|
|
}
|
|
|
|
//figure out which texture compressions are supported
|
|
bool bETC1Enabled, bETC2Enabled, bDXTEnabled, bATCEnabled, bPVRTCEnabled, bASTCEnabled;
|
|
bETC1Enabled = bETC2Enabled = bDXTEnabled = bATCEnabled = bPVRTCEnabled = bASTCEnabled = false;
|
|
if (CookFlavor.Length < 1)
|
|
{
|
|
//All values supproted
|
|
bETC1Enabled = bETC2Enabled = bDXTEnabled = bATCEnabled = bPVRTCEnabled = bASTCEnabled = true;
|
|
}
|
|
else
|
|
{
|
|
switch(CookFlavor)
|
|
{
|
|
case "_Multi":
|
|
//need to check ini to determine which are supported
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bMultiTargetFormat_ETC1", out bETC1Enabled);
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bMultiTargetFormat_ETC2", out bETC2Enabled);
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bMultiTargetFormat_DXT", out bDXTEnabled);
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bMultiTargetFormat_ATC", out bATCEnabled);
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bMultiTargetFormat_PVRTC", out bPVRTCEnabled);
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bMultiTargetFormat_ASTC", out bASTCEnabled);
|
|
break;
|
|
case "_ETC1":
|
|
bETC1Enabled = true;
|
|
break;
|
|
case "_ETC2":
|
|
bETC2Enabled = true;
|
|
break;
|
|
case "_DXT":
|
|
bDXTEnabled = true;
|
|
break;
|
|
case "_ATC":
|
|
bATCEnabled = true;
|
|
break;
|
|
case "_PVRTC":
|
|
bPVRTCEnabled = true;
|
|
break;
|
|
case "_ASTC":
|
|
bASTCEnabled = true;
|
|
break;
|
|
default:
|
|
Log.TraceWarning("Invalid or unknown CookFlavor used in GenerateManifest: {0}", CookFlavor);
|
|
break;
|
|
}
|
|
}
|
|
|
|
StringBuilder Text = new StringBuilder();
|
|
Text.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
|
Text.AppendLine("<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"");
|
|
Text.AppendLine(string.Format(" package=\"{0}\"", PackageName));
|
|
if (ExtraManifestNodeTags != null)
|
|
{
|
|
foreach (string Line in ExtraManifestNodeTags)
|
|
{
|
|
Text.AppendLine(" " + Line);
|
|
}
|
|
}
|
|
Text.AppendLine(string.Format(" android:installLocation=\"{0}\"", InstallLocation));
|
|
Text.AppendLine(string.Format(" android:versionCode=\"{0}\"", StoreVersion));
|
|
Text.AppendLine(string.Format(" android:versionName=\"{0}\">", VersionDisplayName));
|
|
|
|
Text.AppendLine("");
|
|
|
|
Text.AppendLine("\t<!-- Application Definition -->");
|
|
Text.AppendLine("\t<application android:label=\"@string/app_name\"");
|
|
Text.AppendLine("\t android:icon=\"@drawable/icon\"");
|
|
if (ExtraApplicationNodeTags != null)
|
|
{
|
|
foreach (string Line in ExtraApplicationNodeTags)
|
|
{
|
|
Text.AppendLine("\t " + Line);
|
|
}
|
|
}
|
|
Text.AppendLine("\t android:hasCode=\"true\">");
|
|
if (bShowLaunchImage)
|
|
{
|
|
// normal application settings
|
|
Text.AppendLine("\t\t<activity android:name=\"com.epicgames.ue4.SplashActivity\"");
|
|
Text.AppendLine("\t\t android:label=\"@string/app_name\"");
|
|
Text.AppendLine("\t\t android:theme=\"@style/UE4SplashTheme\"");
|
|
Text.AppendLine("\t\t android:launchMode=\"singleTask\"");
|
|
Text.AppendLine(string.Format("\t\t android:screenOrientation=\"{0}\"", ConvertOrientationIniValue(Orientation)));
|
|
Text.AppendLine(string.Format("\t\t android:debuggable=\"{0}\">", bIsForDistribution ? "false" : "true"));
|
|
Text.AppendLine("\t\t\t<intent-filter>");
|
|
Text.AppendLine("\t\t\t\t<action android:name=\"android.intent.action.MAIN\" />");
|
|
Text.AppendLine(string.Format("\t\t\t\t<category android:name=\"android.intent.category.LAUNCHER\" />"));
|
|
Text.AppendLine("\t\t\t</intent-filter>");
|
|
Text.AppendLine("\t\t</activity>");
|
|
Text.AppendLine("\t\t<activity android:name=\"com.epicgames.ue4.GameActivity\"");
|
|
Text.AppendLine("\t\t android:label=\"@string/app_name\"");
|
|
Text.AppendLine("\t\t android:theme=\"@style/UE4SplashTheme\"");
|
|
Text.AppendLine("\t\t android:configChanges=\"screenSize|orientation|keyboardHidden|keyboard\"");
|
|
}
|
|
else
|
|
{
|
|
Text.AppendLine("\t\t<activity android:name=\"com.epicgames.ue4.GameActivity\"");
|
|
Text.AppendLine("\t\t android:label=\"@string/app_name\"");
|
|
Text.AppendLine("\t\t android:theme=\"@android:style/Theme.Black.NoTitleBar.Fullscreen\"");
|
|
Text.AppendLine("\t\t android:configChanges=\"screenSize|orientation|keyboardHidden|keyboard\"");
|
|
}
|
|
Text.AppendLine("\t\t android:launchMode=\"singleTask\"");
|
|
Text.AppendLine(string.Format("\t\t android:screenOrientation=\"{0}\"", ConvertOrientationIniValue(Orientation)));
|
|
if (ExtraActivityNodeTags != null)
|
|
{
|
|
foreach (string Line in ExtraActivityNodeTags)
|
|
{
|
|
Text.AppendLine("\t\t " + Line);
|
|
}
|
|
}
|
|
Text.AppendLine(string.Format("\t\t android:debuggable=\"{0}\">", bIsForDistribution ? "false" : "true"));
|
|
Text.AppendLine("\t\t\t<meta-data android:name=\"android.app.lib_name\" android:value=\"UE4\"/>");
|
|
if (!bShowLaunchImage)
|
|
{
|
|
Text.AppendLine("\t\t\t<intent-filter>");
|
|
Text.AppendLine("\t\t\t\t<action android:name=\"android.intent.action.MAIN\" />");
|
|
Text.AppendLine(string.Format("\t\t\t\t<category android:name=\"android.intent.category.LAUNCHER\" />"));
|
|
Text.AppendLine("\t\t\t</intent-filter>");
|
|
}
|
|
if (!string.IsNullOrEmpty(ExtraActivitySettings))
|
|
{
|
|
ExtraActivitySettings = ExtraActivitySettings.Replace("\\n", "\n");
|
|
foreach (string Line in ExtraActivitySettings.Split("\r\n".ToCharArray()))
|
|
{
|
|
Text.AppendLine("\t\t\t" + Line);
|
|
}
|
|
}
|
|
string ActivityAdditionsFile = Path.Combine(GameBuildFilesPath, "ManifestActivityAdditions.txt");
|
|
if (File.Exists(ActivityAdditionsFile))
|
|
{
|
|
foreach (string Line in File.ReadAllLines(ActivityAdditionsFile))
|
|
{
|
|
Text.AppendLine("\t\t\t" + Line);
|
|
}
|
|
}
|
|
Text.AppendLine("\t\t</activity>");
|
|
|
|
// For OBB download support
|
|
if (bShowLaunchImage)
|
|
{
|
|
Text.AppendLine("\t\t<activity android:name=\".DownloaderActivity\"");
|
|
Text.AppendLine(string.Format("\t\t android:screenOrientation=\"{0}\"", ConvertOrientationIniValue(Orientation)));
|
|
Text.AppendLine("\t\t android:configChanges=\"screenSize|orientation|keyboardHidden|keyboard\"");
|
|
Text.AppendLine("\t\t android:theme=\"@style/UE4SplashTheme\" />");
|
|
}
|
|
else
|
|
{
|
|
Text.AppendLine("\t\t<activity android:name=\".DownloaderActivity\" />");
|
|
}
|
|
|
|
Text.AppendLine(string.Format("\t\t<meta-data android:name=\"com.epicgames.ue4.GameActivity.DepthBufferPreference\" android:value=\"{0}\"/>", ConvertDepthBufferIniValue(DepthBufferPreference)));
|
|
Text.AppendLine(string.Format("\t\t<meta-data android:name=\"com.epicgames.ue4.GameActivity.bPackageDataInsideApk\" android:value=\"{0}\"/>", bPackageDataInsideApk ? "true" : "false"));
|
|
Text.AppendLine(string.Format("\t\t<meta-data android:name=\"com.epicgames.ue4.GameActivity.bVerifyOBBOnStartUp\" android:value=\"{0}\"/>", (bIsForDistribution && !bDisableVerifyOBBOnStartUp) ? "true" : "false"));
|
|
Text.AppendLine(string.Format("\t\t<meta-data android:name=\"com.epicgames.ue4.GameActivity.bShouldHideUI\" android:value=\"{0}\"/>", EnableFullScreen ? "true" : "false"));
|
|
Text.AppendLine(string.Format("\t\t<meta-data android:name=\"com.epicgames.ue4.GameActivity.ProjectName\" android:value=\"{0}\"/>", ProjectName));
|
|
Text.AppendLine(string.Format("\t\t<meta-data android:name=\"com.epicgames.ue4.GameActivity.bHasOBBFiles\" android:value=\"{0}\"/>", bHasOBBFiles ? "true" : "false"));
|
|
Text.AppendLine(string.Format("\t\t<meta-data android:name=\"com.epicgames.ue4.GameActivity.bSupportsVulkan\" android:value=\"{0}\"/>", bSupportsVulkan ? "true" : "false"));
|
|
Text.AppendLine("\t\t<meta-data android:name=\"com.google.android.gms.games.APP_ID\"");
|
|
Text.AppendLine("\t\t android:value=\"@string/app_id\" />");
|
|
Text.AppendLine("\t\t<meta-data android:name=\"com.google.android.gms.version\"");
|
|
Text.AppendLine("\t\t android:value=\"@integer/google_play_services_version\" />");
|
|
Text.AppendLine("\t\t<activity android:name=\"com.google.android.gms.ads.AdActivity\"");
|
|
Text.AppendLine("\t\t android:configChanges=\"keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize\"/>");
|
|
if (!string.IsNullOrEmpty(ExtraApplicationSettings))
|
|
{
|
|
ExtraApplicationSettings = ExtraApplicationSettings.Replace("\\n", "\n");
|
|
foreach (string Line in ExtraApplicationSettings.Split("\r\n".ToCharArray()))
|
|
{
|
|
Text.AppendLine("\t\t" + Line);
|
|
}
|
|
}
|
|
string ApplicationAdditionsFile = Path.Combine(GameBuildFilesPath, "ManifestApplicationAdditions.txt");
|
|
if (File.Exists(ApplicationAdditionsFile))
|
|
{
|
|
foreach (string Line in File.ReadAllLines(ApplicationAdditionsFile))
|
|
{
|
|
Text.AppendLine("\t\t" + Line);
|
|
}
|
|
}
|
|
|
|
// Required for OBB download support
|
|
Text.AppendLine("\t\t<service android:name=\"OBBDownloaderService\" />");
|
|
Text.AppendLine("\t\t<receiver android:name=\"AlarmReceiver\" />");
|
|
|
|
Text.AppendLine("\t\t<receiver android:name=\"com.epicgames.ue4.LocalNotificationReceiver\" />");
|
|
|
|
Text.AppendLine("\t</application>");
|
|
|
|
Text.AppendLine("");
|
|
Text.AppendLine("\t<!-- Requirements -->");
|
|
|
|
// check for an override for the requirements section of the manifest
|
|
string RequirementsOverrideFile = Path.Combine(GameBuildFilesPath, "ManifestRequirementsOverride.txt");
|
|
if (File.Exists(RequirementsOverrideFile))
|
|
{
|
|
foreach (string Line in File.ReadAllLines(RequirementsOverrideFile))
|
|
{
|
|
Text.AppendLine("\t" + Line);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// need just the number part of the sdk
|
|
Text.AppendLine(string.Format("\t<uses-sdk android:minSdkVersion=\"{0}\" android:targetSdkVersion=\"{1}\"/>", MinSDKVersion, TargetSDKVersion));
|
|
Text.AppendLine("\t<uses-feature android:glEsVersion=\"" + AndroidToolChain.GetGLESVersionFromGPUArch(GPUArch) + "\" android:required=\"true\" />");
|
|
Text.AppendLine("\t<uses-permission android:name=\"android.permission.INTERNET\"/>");
|
|
Text.AppendLine("\t<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>");
|
|
Text.AppendLine("\t<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>");
|
|
Text.AppendLine("\t<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>");
|
|
Text.AppendLine("\t<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>");
|
|
Text.AppendLine("\t<uses-permission android:name=\"com.android.vending.CHECK_LICENSE\"/>");
|
|
Text.AppendLine("\t<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>");
|
|
Text.AppendLine("\t<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>");
|
|
Text.AppendLine("\t<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>");
|
|
Text.AppendLine("\t<uses-permission android:name=\"android.permission.VIBRATE\"/>");
|
|
// Text.AppendLine("\t<uses-permission android:name=\"android.permission.DISABLE_KEYGUARD\"/>");
|
|
|
|
if (bEnableIAP)
|
|
{
|
|
Text.AppendLine("\t<uses-permission android:name=\"com.android.vending.BILLING\"/>");
|
|
}
|
|
if (ExtraPermissions != null)
|
|
{
|
|
foreach (string Permission in ExtraPermissions)
|
|
{
|
|
Text.AppendLine(string.Format("\t<uses-permission android:name=\"{0}\"/>", Permission));
|
|
}
|
|
}
|
|
string RequirementsAdditionsFile = Path.Combine(GameBuildFilesPath, "ManifestRequirementsAdditions.txt");
|
|
if (File.Exists(RequirementsAdditionsFile))
|
|
{
|
|
foreach (string Line in File.ReadAllLines(RequirementsAdditionsFile))
|
|
{
|
|
Text.AppendLine("\t" + Line);
|
|
}
|
|
}
|
|
|
|
Text.AppendLine("\t<!-- Supported texture compression formats (cooked) -->");
|
|
if (bETC1Enabled)
|
|
{
|
|
Text.AppendLine("\t<supports-gl-texture android:name=\"GL_OES_compressed_ETC1_RGB8_texture\" />");
|
|
}
|
|
if (bETC2Enabled)
|
|
{
|
|
Text.AppendLine("\t<supports-gl-texture android:name=\"GL_COMPRESSED_RGB8_ETC2\" />");
|
|
Text.AppendLine("\t<supports-gl-texture android:name=\"GL_COMPRESSED_RGBA8_ETC2_EAC\" />");
|
|
}
|
|
if (bATCEnabled)
|
|
{
|
|
Text.AppendLine("\t<supports-gl-texture android:name=\"GL_AMD_compressed_ATC_texture\" />");
|
|
Text.AppendLine("\t<supports-gl-texture android:name=\"GL_ATI_texture_compression_atitc\" />");
|
|
}
|
|
if (bDXTEnabled)
|
|
{
|
|
Text.AppendLine("\t<supports-gl-texture android:name=\"GL_EXT_texture_compression_dxt1\" />");
|
|
Text.AppendLine("\t<supports-gl-texture android:name=\"GL_EXT_texture_compression_s3tc\" />");
|
|
Text.AppendLine("\t<supports-gl-texture android:name=\"GL_NV_texture_compression_s3tc\" />");
|
|
}
|
|
if (bPVRTCEnabled)
|
|
{
|
|
Text.AppendLine("\t<supports-gl-texture android:name=\"GL_IMG_texture_compression_pvrtc\" />");
|
|
}
|
|
if (bASTCEnabled)
|
|
{
|
|
Text.AppendLine("\t<supports-gl-texture android:name=\"GL_KHR_texture_compression_astc_ldr\" />");
|
|
}
|
|
}
|
|
|
|
Text.AppendLine("</manifest>");
|
|
|
|
// allow plugins to modify final manifest HERE
|
|
XDocument XDoc;
|
|
try
|
|
{
|
|
XDoc = XDocument.Parse(Text.ToString());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new BuildException("AndroidManifest.xml is invalid {0}\n{1}", e, Text.ToString());
|
|
}
|
|
|
|
UPL.ProcessPluginNode(Arch, "androidManifestUpdates", "", ref XDoc);
|
|
return XDoc.ToString();
|
|
}
|
|
|
|
private string GenerateProguard(string Arch, string EngineSourcePath, string GameBuildFilesPath)
|
|
{
|
|
StringBuilder Text = new StringBuilder();
|
|
|
|
string ProguardFile = Path.Combine(EngineSourcePath, "proguard-project.txt");
|
|
if (File.Exists(ProguardFile))
|
|
{
|
|
foreach (string Line in File.ReadAllLines(ProguardFile))
|
|
{
|
|
Text.AppendLine(Line);
|
|
}
|
|
}
|
|
|
|
string ProguardAdditionsFile = Path.Combine(GameBuildFilesPath, "ProguardAdditions.txt");
|
|
if (File.Exists(ProguardAdditionsFile))
|
|
{
|
|
foreach (string Line in File.ReadAllLines(ProguardAdditionsFile))
|
|
{
|
|
Text.AppendLine(Line);
|
|
}
|
|
}
|
|
|
|
// add plugin additions
|
|
return UPL.ProcessPluginNode(Arch, "proguardAdditions", Text.ToString());
|
|
}
|
|
|
|
private void ValidateGooglePlay(string UE4BuildPath)
|
|
{
|
|
ConfigCacheIni Ini = GetConfigCacheIni("Engine");
|
|
bool bEnableGooglePlaySupport;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bEnableGooglePlaySupport", out bEnableGooglePlaySupport);
|
|
|
|
if (!bEnableGooglePlaySupport)
|
|
{
|
|
// do not need to do anything; it is fine
|
|
return;
|
|
}
|
|
|
|
string IniAppId;
|
|
bool bInvalidIniAppId = false;
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "GamesAppID", out IniAppId);
|
|
|
|
//validate the value found in the AndroidRuntimeSettings
|
|
Int64 Value;
|
|
if (IniAppId.Length == 0 || !Int64.TryParse(IniAppId, out Value))
|
|
{
|
|
bInvalidIniAppId = true;
|
|
}
|
|
|
|
bool bInvalid = false;
|
|
string ReplacementId = "";
|
|
String Filename = Path.Combine(UE4BuildPath, "res", "values", "GooglePlayAppID.xml");
|
|
if (File.Exists(Filename))
|
|
{
|
|
string[] FileContent = File.ReadAllLines(Filename);
|
|
int LineIndex = -1;
|
|
foreach (string Line in FileContent)
|
|
{
|
|
++LineIndex;
|
|
|
|
int StartIndex = Line.IndexOf("\"app_id\">");
|
|
if (StartIndex < 0)
|
|
continue;
|
|
|
|
StartIndex += 9;
|
|
int EndIndex = Line.IndexOf("</string>");
|
|
if (EndIndex < 0)
|
|
continue;
|
|
|
|
string XmlAppId = Line.Substring(StartIndex, EndIndex - StartIndex);
|
|
|
|
//validate that the AppId matches the .ini value for the GooglePlay AppId, assuming it's valid
|
|
if (!bInvalidIniAppId && IniAppId.CompareTo(XmlAppId) != 0)
|
|
{
|
|
Log.TraceInformation("Replacing Google Play AppID in GooglePlayAppID.xml with AndroidRuntimeSettings .ini value");
|
|
|
|
bInvalid = true;
|
|
ReplacementId = IniAppId;
|
|
|
|
}
|
|
else if(XmlAppId.Length == 0 || !Int64.TryParse(XmlAppId, out Value))
|
|
{
|
|
Log.TraceWarning("\nWARNING: GooglePlay Games App ID is invalid! Replacing it with \"1\"");
|
|
|
|
//write file with something which will fail but not cause an exception if executed
|
|
bInvalid = true;
|
|
ReplacementId = "1";
|
|
}
|
|
|
|
if(bInvalid)
|
|
{
|
|
// remove any read only flags if invalid so it can be replaced
|
|
FileInfo DestFileInfo = new FileInfo(Filename);
|
|
DestFileInfo.Attributes = DestFileInfo.Attributes & ~FileAttributes.ReadOnly;
|
|
|
|
//preserve the rest of the file, just fix up this line
|
|
string NewLine = Line.Replace("\"app_id\">" + XmlAppId + "</string>", "\"app_id\">" + ReplacementId + "</string>");
|
|
FileContent[LineIndex] = NewLine;
|
|
|
|
File.WriteAllLines(Filename, FileContent);
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string NewAppId;
|
|
// if we don't have an appID to use from the config, write file with something which will fail but not cause an exception if executed
|
|
if (bInvalidIniAppId)
|
|
{
|
|
Log.TraceWarning("\nWARNING: Creating GooglePlayAppID.xml using a Google Play AppID of \"1\" because there was no valid AppID in AndroidRuntimeSettings!");
|
|
NewAppId = "1";
|
|
}
|
|
else
|
|
{
|
|
Log.TraceInformation("Creating GooglePlayAppID.xml with AndroidRuntimeSettings .ini value");
|
|
NewAppId = IniAppId;
|
|
}
|
|
|
|
File.WriteAllText(Filename, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\t<string name=\"app_id\">" + NewAppId + "</string>\n</resources>\n");
|
|
}
|
|
}
|
|
|
|
private bool FilesAreDifferent(string SourceFilename, string DestFilename)
|
|
{
|
|
// source must exist
|
|
FileInfo SourceInfo = new FileInfo(SourceFilename);
|
|
if (!SourceInfo.Exists)
|
|
{
|
|
throw new BuildException("Can't make an APK without file [{0}]", SourceFilename);
|
|
}
|
|
|
|
// different if destination doesn't exist
|
|
FileInfo DestInfo = new FileInfo(DestFilename);
|
|
if (!DestInfo.Exists)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// file lengths differ?
|
|
if (SourceInfo.Length != DestInfo.Length)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// validate timestamps
|
|
TimeSpan Diff = DestInfo.LastWriteTimeUtc - SourceInfo.LastWriteTimeUtc;
|
|
if (Diff.TotalSeconds < -1 || Diff.TotalSeconds > 1)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// could check actual bytes just to be sure, but good enough
|
|
return false;
|
|
}
|
|
|
|
private bool RequiresOBB(bool bDisallowPackageInAPK, string OBBLocation)
|
|
{
|
|
if (bDisallowPackageInAPK)
|
|
{
|
|
Log.TraceInformation("APK contains data.");
|
|
return false;
|
|
}
|
|
else if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("uebp_LOCAL_ROOT")))
|
|
{
|
|
Log.TraceInformation("On build machine.");
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
Log.TraceInformation("Looking for OBB.");
|
|
return File.Exists(OBBLocation);
|
|
}
|
|
}
|
|
|
|
private void MakeApk(AndroidToolChain ToolChain, string ProjectName, string ProjectDirectory, string OutputPath, string EngineDirectory, bool bForDistribution, string CookFlavor, bool bMakeSeparateApks, bool bIncrementalPackage, bool bDisallowPackagingDataInApk)
|
|
{
|
|
Log.TraceInformation("\n===={0}====PREPARING TO MAKE APK=================================================================", DateTime.Now.ToString());
|
|
|
|
// cache some tools paths
|
|
string NDKBuildPath = Environment.ExpandEnvironmentVariables("%NDKROOT%/ndk-build" + (Utils.IsRunningOnMono ? "" : ".cmd"));
|
|
|
|
// set up some directory info
|
|
string IntermediateAndroidPath = Path.Combine(ProjectDirectory, "Intermediate/Android/");
|
|
string UE4BuildPath = Path.Combine(IntermediateAndroidPath, "APK");
|
|
string UE4JavaFilePath = Path.Combine(ProjectDirectory, "Build", "Android", GetUE4JavaSrcPath());
|
|
string UE4BuildFilesPath = GetUE4BuildFilePath(EngineDirectory);
|
|
string GameBuildFilesPath = Path.Combine(ProjectDirectory, "Build/Android");
|
|
|
|
// Generate Java files
|
|
string PackageName = GetPackageName(ProjectName);
|
|
string TemplateDestinationBase = Path.Combine(ProjectDirectory, "Build", "Android", "src", PackageName.Replace('.', Path.DirectorySeparatorChar));
|
|
MakeDirectoryIfRequired(TemplateDestinationBase);
|
|
|
|
// We'll be writing the OBB data into the same location as the download service files
|
|
string UE4OBBDataFileName = GetUE4JavaOBBDataFileName(TemplateDestinationBase);
|
|
string UE4DownloadShimFileName = GetUE4JavaDownloadShimFileName(UE4JavaFilePath);
|
|
|
|
// Template generated files
|
|
string JavaTemplateSourceDir = GetUE4TemplateJavaSourceDir(EngineDirectory);
|
|
var templates = from template in Directory.EnumerateFiles(JavaTemplateSourceDir, "*.template")
|
|
let RealName = Path.GetFileNameWithoutExtension(template)
|
|
select new TemplateFile { SourceFile = template, DestinationFile = GetUE4TemplateJavaDestination(TemplateDestinationBase, RealName) };
|
|
|
|
// Generate the OBB and Shim files here
|
|
string ObbFileLocation = ProjectDirectory + "/Saved/StagedBuilds/Android" + CookFlavor + ".obb";
|
|
|
|
// This is kind of a small hack to get around a rewrite problem
|
|
// We need to make sure the file is there but if the OBB file doesn't exist then we don't want to replace it
|
|
if (File.Exists(ObbFileLocation) || !File.Exists(UE4OBBDataFileName))
|
|
{
|
|
WriteJavaOBBDataFile(UE4OBBDataFileName, PackageName, new List<string> { ObbFileLocation });
|
|
}
|
|
|
|
// Make sure any existing proguard file in project is NOT used (back it up)
|
|
string ProjectBuildProguardFile = Path.Combine(GameBuildFilesPath, "proguard-project.txt");
|
|
if (File.Exists(ProjectBuildProguardFile))
|
|
{
|
|
string ProjectBackupProguardFile = Path.Combine(GameBuildFilesPath, "proguard-project.backup");
|
|
File.Move(ProjectBuildProguardFile, ProjectBackupProguardFile);
|
|
}
|
|
|
|
WriteJavaDownloadSupportFiles(UE4DownloadShimFileName, templates, new Dictionary<string, string>{
|
|
{ "$$GameName$$", ProjectName },
|
|
{ "$$PublicKey$$", GetPublicKey() },
|
|
{ "$$PackageName$$",PackageName }
|
|
});
|
|
|
|
// Sometimes old files get left behind if things change, so we'll do a clean up pass
|
|
{
|
|
string CleanUpBaseDir = Path.Combine(ProjectDirectory, "Build", "Android", "src");
|
|
var files = Directory.EnumerateFiles(CleanUpBaseDir, "*.java", SearchOption.AllDirectories);
|
|
|
|
Log.TraceInformation("Cleaning up files based on template dir {0}", TemplateDestinationBase);
|
|
|
|
// Make a set of files that are okay to clean up
|
|
var cleanFiles = new HashSet<string>();
|
|
cleanFiles.Add("OBBData.java");
|
|
foreach (var template in templates)
|
|
{
|
|
cleanFiles.Add(Path.GetFileName(template.DestinationFile));
|
|
}
|
|
|
|
foreach (var filename in files)
|
|
{
|
|
if (filename == UE4DownloadShimFileName) // we always need the shim, and it'll get rewritten if needed anyway
|
|
continue;
|
|
|
|
string filePath = Path.GetDirectoryName(filename); // grab the file's path
|
|
if (filePath != TemplateDestinationBase) // and check to make sure it isn't the same as the Template directory we calculated earlier
|
|
{
|
|
// Only delete the files in the cleanup set
|
|
if (!cleanFiles.Contains(Path.GetFileName(filename)))
|
|
continue;
|
|
|
|
Log.TraceInformation("Cleaning up file {0} with path {1}", filename, filePath);
|
|
File.Delete(filename);
|
|
|
|
// Check to see if this file also exists in our target destination, and if so nuke it too
|
|
string DestFilename = Path.Combine(UE4BuildPath, Utils.MakePathRelativeTo(filePath, UE4BuildFilesPath));
|
|
if (File.Exists(filename))
|
|
{
|
|
File.Delete(filename);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Directory clean up code
|
|
var directories = Directory.EnumerateDirectories(CleanUpBaseDir, "*", SearchOption.AllDirectories).OrderByDescending(x => x);
|
|
foreach (var directory in directories)
|
|
{
|
|
if (Directory.Exists(directory) && Directory.GetFiles(directory, "*.*", SearchOption.AllDirectories).Count() == 0)
|
|
{
|
|
Log.TraceInformation("Cleaning Directory {0} as empty.", directory);
|
|
Directory.Delete(directory, true);
|
|
}
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
// cache if we want data in the Apk
|
|
bool bPackageDataInsideApk = PackageDataInsideApk(bDisallowPackagingDataInApk);
|
|
bool bDisableVerifyOBBOnStartUp = DisableVerifyOBBOnStartUp();
|
|
|
|
// check to see if any "meta information" is newer than last time we build
|
|
string CurrentBuildSettings = GetAllBuildSettings(ToolChain, UE4BuildPath, bForDistribution, bMakeSeparateApks, bPackageDataInsideApk, bDisableVerifyOBBOnStartUp);
|
|
string BuildSettingsCacheFile = Path.Combine(UE4BuildPath, "UEBuildSettings.txt");
|
|
|
|
// do we match previous build settings?
|
|
bool bBuildSettingsMatch = true;
|
|
|
|
// get application name and whether it changed, needing to force repackage
|
|
string ApplicationDisplayName;
|
|
if (CheckApplicationName(UE4BuildPath, ProjectName, out ApplicationDisplayName))
|
|
{
|
|
bBuildSettingsMatch = false;
|
|
Log.TraceInformation("Application display name is different than last build, forcing repackage.");
|
|
}
|
|
|
|
// if the manifest matches, look at other settings stored in a file
|
|
if (bBuildSettingsMatch)
|
|
{
|
|
if (File.Exists(BuildSettingsCacheFile))
|
|
{
|
|
string PreviousBuildSettings = File.ReadAllText(BuildSettingsCacheFile);
|
|
if (PreviousBuildSettings != CurrentBuildSettings)
|
|
{
|
|
bBuildSettingsMatch = false;
|
|
Log.TraceInformation("Previous .apk file(s) were made with different build settings, forcing repackage.");
|
|
}
|
|
}
|
|
}
|
|
|
|
// only check input dependencies if the build settings already match
|
|
if (bBuildSettingsMatch)
|
|
{
|
|
// check if so's are up to date against various inputs
|
|
var JavaFiles = new List<string>{
|
|
UE4OBBDataFileName,
|
|
UE4DownloadShimFileName
|
|
};
|
|
// Add the generated files too
|
|
JavaFiles.AddRange(from t in templates select t.SourceFile);
|
|
JavaFiles.AddRange(from t in templates select t.DestinationFile);
|
|
|
|
bBuildSettingsMatch = CheckDependencies(ToolChain, ProjectName, ProjectDirectory, UE4BuildFilesPath, GameBuildFilesPath,
|
|
EngineDirectory, JavaFiles, CookFlavor, OutputPath, UE4BuildPath, bMakeSeparateApks, bPackageDataInsideApk);
|
|
|
|
}
|
|
|
|
var Arches = ToolChain.GetAllArchitectures();
|
|
var GPUArchitectures = ToolChain.GetAllGPUArchitectures();
|
|
|
|
// Initialize APL contexts for each architecture enabled
|
|
List<string> NDKArches = new List<string>();
|
|
foreach (var Arch in Arches)
|
|
{
|
|
string NDKArch = GetNDKArch(Arch);
|
|
if (!NDKArches.Contains(NDKArch))
|
|
{
|
|
NDKArches.Add(NDKArch);
|
|
}
|
|
}
|
|
UPL.Init(NDKArches, bForDistribution, EngineDirectory, UE4BuildPath);
|
|
|
|
IEnumerable<Tuple<string, string, string>> BuildList = null;
|
|
|
|
if (!bBuildSettingsMatch)
|
|
{
|
|
BuildList = from Arch in Arches
|
|
from GPUArch in GPUArchitectures
|
|
let manifest = GenerateManifest(ToolChain, ProjectName, bForDistribution, bPackageDataInsideApk, GameBuildFilesPath, RequiresOBB(bDisallowPackagingDataInApk, ObbFileLocation), bDisableVerifyOBBOnStartUp, Arch, GPUArch, CookFlavor)
|
|
select Tuple.Create(Arch, GPUArch, manifest);
|
|
}
|
|
else
|
|
{
|
|
BuildList = from Arch in Arches
|
|
from GPUArch in GPUArchitectures
|
|
let manifestFile = Path.Combine(IntermediateAndroidPath, Arch + "_" + GPUArch + "_AndroidManifest.xml")
|
|
let manifest = GenerateManifest(ToolChain, ProjectName, bForDistribution, bPackageDataInsideApk, GameBuildFilesPath, RequiresOBB(bDisallowPackagingDataInApk, ObbFileLocation), bDisableVerifyOBBOnStartUp, Arch, GPUArch, CookFlavor)
|
|
let OldManifest = File.Exists(manifestFile) ? File.ReadAllText(manifestFile) : ""
|
|
where manifest != OldManifest
|
|
select Tuple.Create(Arch, GPUArch, manifest);
|
|
}
|
|
|
|
// Now we have to spin over all the arch/gpu combinations to make sure they all match
|
|
int BuildListComboTotal = BuildList.Count();
|
|
if (BuildListComboTotal == 0)
|
|
{
|
|
Log.TraceInformation("Output .apk file(s) are up to date (dependencies and build settings are up to date)");
|
|
return;
|
|
}
|
|
|
|
|
|
// Once for all arches code:
|
|
|
|
// make up a dictionary of strings to replace in xml files (strings.xml)
|
|
Dictionary<string, string> Replacements = new Dictionary<string, string>();
|
|
Replacements.Add("${EXECUTABLE_NAME}", ApplicationDisplayName);
|
|
|
|
if (!bIncrementalPackage)
|
|
{
|
|
// Wipe the Intermediate/Build/APK directory first, except for dexedLibs, because Google Services takes FOREVER to predex, and it almost never changes
|
|
// so allow the ANT checking to win here - if this grows a bit with extra libs, it's fine, it _should_ only pull in dexedLibs it needs
|
|
Log.TraceInformation("Performing complete package - wiping {0}, except for predexedLibs", UE4BuildPath);
|
|
DeleteDirectory(UE4BuildPath, "dexedLibs");
|
|
}
|
|
|
|
// If we are packaging for Amazon then we need to copy the file to the correct location
|
|
Log.TraceInformation("bPackageDataInsideApk = {0}", bPackageDataInsideApk);
|
|
if (bPackageDataInsideApk)
|
|
{
|
|
Console.WriteLine("Obb location {0}", ObbFileLocation);
|
|
string ObbFileDestination = UE4BuildPath + "/assets";
|
|
Console.WriteLine("Obb destination location {0}", ObbFileDestination);
|
|
if (File.Exists(ObbFileLocation))
|
|
{
|
|
Directory.CreateDirectory(UE4BuildPath);
|
|
Directory.CreateDirectory(ObbFileDestination);
|
|
Console.WriteLine("Obb file exists...");
|
|
var DestFileName = Path.Combine(ObbFileDestination, "main.obb.png"); // Need a rename to turn off compression
|
|
var SrcFileName = ObbFileLocation;
|
|
if (!File.Exists(DestFileName) || File.GetLastWriteTimeUtc(DestFileName) < File.GetLastWriteTimeUtc(SrcFileName))
|
|
{
|
|
Console.WriteLine("Copying {0} to {1}", SrcFileName, DestFileName);
|
|
File.Copy(SrcFileName, DestFileName);
|
|
}
|
|
}
|
|
}
|
|
else // try to remove the file it we aren't packaging inside the APK
|
|
{
|
|
string ObbFileDestination = UE4BuildPath + "/assets";
|
|
var DestFileName = Path.Combine(ObbFileDestination, "main.obb.png");
|
|
if (File.Exists(DestFileName))
|
|
{
|
|
File.Delete(DestFileName);
|
|
}
|
|
}
|
|
|
|
//Copy build files to the intermediate folder in this order (later overrides earlier):
|
|
// - Shared Engine
|
|
// - Shared Engine NoRedist (for Epic secret files)
|
|
// - Game
|
|
// - Game NoRedist (for Epic secret files)
|
|
CopyFileDirectory(UE4BuildFilesPath, UE4BuildPath, Replacements);
|
|
CopyFileDirectory(UE4BuildFilesPath + "/NotForLicensees", UE4BuildPath, Replacements);
|
|
CopyFileDirectory(UE4BuildFilesPath + "/NoRedist", UE4BuildPath, Replacements);
|
|
CopyFileDirectory(GameBuildFilesPath, UE4BuildPath, Replacements);
|
|
CopyFileDirectory(GameBuildFilesPath + "/NotForLicensees", UE4BuildPath, Replacements);
|
|
CopyFileDirectory(GameBuildFilesPath + "/NoRedist", UE4BuildPath, Replacements);
|
|
|
|
//Extract AAR and Jar files with dependencies
|
|
ExtractAARAndJARFiles(EngineDirectory, UE4BuildPath, NDKArches);
|
|
|
|
//Now validate GooglePlay app_id if enabled
|
|
ValidateGooglePlay(UE4BuildPath);
|
|
|
|
//determine which orientation requirements this app has
|
|
bool bNeedLandscape = false;
|
|
bool bNeedPortrait = false;
|
|
DetermineScreenOrientationRequirements(out bNeedPortrait, out bNeedLandscape);
|
|
|
|
//Now keep the splash screen images matching orientation requested
|
|
PickSplashScreenOrientation(UE4BuildPath, bNeedPortrait, bNeedLandscape);
|
|
|
|
//Similarly, keep only the downloader screen image matching the orientation requested
|
|
PickDownloaderScreenOrientation(UE4BuildPath, bNeedPortrait, bNeedLandscape);
|
|
|
|
// at this point, we can write out the cached build settings to compare for a next build
|
|
File.WriteAllText(BuildSettingsCacheFile, CurrentBuildSettings);
|
|
|
|
// at this point, we can write out the cached build settings to compare for a next build
|
|
File.WriteAllText(BuildSettingsCacheFile, CurrentBuildSettings);
|
|
|
|
///////////////
|
|
// in case the game had an AndroidManifest.xml file, we overwrite it now with the generated one
|
|
//File.WriteAllText(ManifestFile, NewManifest);
|
|
///////////////
|
|
|
|
Log.TraceInformation("\n===={0}====PREPARING NATIVE CODE=================================================================", DateTime.Now.ToString());
|
|
bool HasNDKPath = File.Exists(NDKBuildPath);
|
|
|
|
// get Ant verbosity level
|
|
ConfigCacheIni Ini = GetConfigCacheIni("Engine");
|
|
string AntVerbosity;
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "AntVerbosity", out AntVerbosity);
|
|
|
|
foreach (var build in BuildList)
|
|
{
|
|
string Arch = build.Item1;
|
|
string GPUArchitecture = build.Item2;
|
|
string Manifest = build.Item3;
|
|
string NDKArch = GetNDKArch(Arch);
|
|
|
|
string SourceSOName = AndroidToolChain.InlineArchName(OutputPath, Arch, GPUArchitecture);
|
|
// if the source binary was UE4Game, replace it with the new project name, when re-packaging a binary only build
|
|
string ApkFilename = Path.GetFileNameWithoutExtension(OutputPath).Replace("UE4Game", ProjectName);
|
|
string DestApkName = Path.Combine(ProjectDirectory, "Binaries/Android/") + ApkFilename + ".apk";
|
|
|
|
// As we are always making seperate APKs we need to put the architecture into the name
|
|
DestApkName = AndroidToolChain.InlineArchName(DestApkName, Arch, GPUArchitecture);
|
|
|
|
// Write the manifest to the correct locations (cache and real)
|
|
String ManifestFile = Path.Combine(IntermediateAndroidPath, Arch + "_" + GPUArchitecture + "_AndroidManifest.xml");
|
|
File.WriteAllText(ManifestFile, Manifest);
|
|
ManifestFile = Path.Combine(UE4BuildPath, "AndroidManifest.xml");
|
|
File.WriteAllText(ManifestFile, Manifest);
|
|
|
|
// copy prebuild plugin files
|
|
UPL.ProcessPluginNode(NDKArch, "prebuildCopies", "");
|
|
|
|
// update metadata files (like project.properties, build.xml) if we are missing a build.xml or if we just overwrote project.properties with a bad version in it (from game/engine dir)
|
|
UpdateProjectProperties(ToolChain, UE4BuildPath, ProjectName);
|
|
|
|
// update GameActivity.java if out of date
|
|
UpdateGameActivity(Arch, NDKArch, EngineDirectory, UE4BuildPath);
|
|
|
|
// Copy the generated .so file from the binaries directory to the jni folder
|
|
if (!File.Exists(SourceSOName))
|
|
{
|
|
throw new BuildException("Can't make an APK without the compiled .so [{0}]", SourceSOName);
|
|
}
|
|
if (!Directory.Exists(UE4BuildPath + "/jni"))
|
|
{
|
|
throw new BuildException("Can't make an APK without the jni directory [{0}/jni]", UE4BuildFilesPath);
|
|
}
|
|
|
|
String FinalSOName;
|
|
|
|
if (HasNDKPath)
|
|
{
|
|
string LibDir = UE4BuildPath + "/jni/" + GetNDKArch(Arch);
|
|
FinalSOName = LibDir + "/libUE4.so";
|
|
|
|
// check to see if libUE4.so needs to be copied
|
|
if (BuildListComboTotal > 1 || FilesAreDifferent(SourceSOName, FinalSOName))
|
|
{
|
|
Log.TraceInformation("\nCopying new .so {0} file to jni folder...", SourceSOName);
|
|
Directory.CreateDirectory(LibDir);
|
|
// copy the binary to the standard .so location
|
|
File.Copy(SourceSOName, FinalSOName, true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// if no NDK, we don't need any of the debugger stuff, so we just copy the .so to where it will end up
|
|
FinalSOName = UE4BuildPath + "/libs/" + GetNDKArch(Arch) + "/libUE4.so";
|
|
|
|
// check to see if libUE4.so needs to be copied
|
|
if (BuildListComboTotal > 1 || FilesAreDifferent(SourceSOName, FinalSOName))
|
|
{
|
|
Log.TraceInformation("\nCopying .so {0} file to jni folder...", SourceSOName);
|
|
Directory.CreateDirectory(Path.GetDirectoryName(FinalSOName));
|
|
File.Copy(SourceSOName, FinalSOName, true);
|
|
}
|
|
}
|
|
|
|
// remove any read only flags
|
|
FileInfo DestFileInfo = new FileInfo(FinalSOName);
|
|
DestFileInfo.Attributes = DestFileInfo.Attributes & ~FileAttributes.ReadOnly;
|
|
File.SetLastWriteTimeUtc(FinalSOName, File.GetLastWriteTimeUtc(SourceSOName));
|
|
|
|
// if we need to run ndk-build, do it now
|
|
if (HasNDKPath)
|
|
{
|
|
string LibSOName = UE4BuildPath + "/libs/" + GetNDKArch(Arch) + "/libUE4.so";
|
|
// always delete libs up to this point so fat binaries and incremental builds work together (otherwise we might end up with multiple
|
|
// so files in an apk that doesn't want them)
|
|
// note that we don't want to delete all libs, just the ones we copied
|
|
TimeSpan Diff = File.GetLastWriteTimeUtc(LibSOName) - File.GetLastWriteTimeUtc(FinalSOName);
|
|
if (!File.Exists(LibSOName) || Diff.TotalSeconds < -1 || Diff.TotalSeconds > 1)
|
|
{
|
|
foreach (string Lib in Directory.EnumerateFiles(UE4BuildPath + "/libs", "libUE4*.so", SearchOption.AllDirectories))
|
|
{
|
|
File.Delete(Lib);
|
|
}
|
|
|
|
string CommandLine = "APP_ABI=\"" + GetNDKArch(Arch) + " " + "\"";
|
|
if (!bForDistribution)
|
|
{
|
|
CommandLine += " NDK_DEBUG=1";
|
|
}
|
|
RunCommandLineProgramWithException(UE4BuildPath, NDKBuildPath, CommandLine, "Preparing native code for debugging...", true);
|
|
|
|
File.SetLastWriteTimeUtc(LibSOName, File.GetLastWriteTimeUtc(FinalSOName));
|
|
}
|
|
}
|
|
|
|
// after ndk-build is called, we can now copy in the stl .so (ndk-build deletes old files)
|
|
// copy libgnustl_shared.so to library (use 4.8 if possible, otherwise 4.6)
|
|
CopySTL(ToolChain, UE4BuildPath, Arch, NDKArch, bForDistribution);
|
|
CopyGfxDebugger(UE4BuildPath, Arch, NDKArch);
|
|
|
|
// copy postbuild plugin files
|
|
UPL.ProcessPluginNode(NDKArch, "resourceCopies", "");
|
|
|
|
Log.TraceInformation("\n===={0}====PERFORMING FINAL APK PACKAGE OPERATION================================================", DateTime.Now.ToString());
|
|
|
|
string AntBuildType = "debug";
|
|
string AntOutputSuffix = "-debug";
|
|
if (bForDistribution)
|
|
{
|
|
// Generate the Proguard file contents and write it
|
|
string ProguardContents = GenerateProguard(NDKArch, UE4BuildFilesPath, GameBuildFilesPath);
|
|
string ProguardFilename = Path.Combine(UE4BuildPath, "proguard-project.txt");
|
|
if (File.Exists(ProguardFilename))
|
|
{
|
|
File.Delete(ProguardFilename);
|
|
}
|
|
File.WriteAllText(ProguardFilename, ProguardContents);
|
|
|
|
// this will write out ant.properties with info needed to sign a distribution build
|
|
PrepareToSignApk(UE4BuildPath);
|
|
AntBuildType = "release";
|
|
AntOutputSuffix = "-release";
|
|
}
|
|
|
|
// Use ant to build the .apk file
|
|
string ShellExecutable = Utils.IsRunningOnMono ? "/bin/sh" : "cmd.exe";
|
|
string ShellParametersBegin = Utils.IsRunningOnMono ? "-c '" : "/c ";
|
|
string ShellParametersEnd = Utils.IsRunningOnMono ? "'" : "";
|
|
switch (AntVerbosity.ToLower())
|
|
{
|
|
default:
|
|
case "quiet":
|
|
if (RunCommandLineProgramAndReturnResult(UE4BuildPath, ShellExecutable, ShellParametersBegin + "\"" + GetAntPath() + "\" -quiet " + AntBuildType + ShellParametersEnd, "Making .apk with Ant... (note: it's safe to ignore javac obsolete warnings)") != 0)
|
|
{
|
|
RunCommandLineProgramAndReturnResult(UE4BuildPath, ShellExecutable, ShellParametersBegin + "\"" + GetAntPath() + "\" " + AntBuildType + ShellParametersEnd, "Making .apk with Ant again to show errors");
|
|
}
|
|
break;
|
|
|
|
case "normal":
|
|
RunCommandLineProgramAndReturnResult(UE4BuildPath, ShellExecutable, ShellParametersBegin + "\"" + GetAntPath() + "\" " + AntBuildType + ShellParametersEnd, "Making .apk with Ant again to show errors");
|
|
break;
|
|
|
|
case "verbose":
|
|
RunCommandLineProgramAndReturnResult(UE4BuildPath, ShellExecutable, ShellParametersBegin + "\"" + GetAntPath() + "\" -verbose " + AntBuildType + ShellParametersEnd, "Making .apk with Ant again to show errors");
|
|
break;
|
|
}
|
|
|
|
// make sure destination exists
|
|
Directory.CreateDirectory(Path.GetDirectoryName(DestApkName));
|
|
|
|
// now copy to the final location
|
|
File.Copy(UE4BuildPath + "/bin/" + ProjectName + AntOutputSuffix + ".apk", DestApkName, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void PrepareToSignApk(string BuildPath)
|
|
{
|
|
// ini file to get settings from
|
|
ConfigCacheIni Ini = GetConfigCacheIni("Engine");
|
|
string KeyAlias, KeyStore, KeyStorePassword, KeyPassword;
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "KeyAlias", out KeyAlias);
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "KeyStore", out KeyStore);
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "KeyStorePassword", out KeyStorePassword);
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "KeyPassword", out KeyPassword);
|
|
|
|
if (string.IsNullOrEmpty(KeyAlias) || string.IsNullOrEmpty(KeyStore) || string.IsNullOrEmpty(KeyStorePassword))
|
|
{
|
|
throw new BuildException("DistributionSigning settings are not all set. Check the DistributionSettings section in the Andriod tab of Project Settings");
|
|
}
|
|
|
|
string[] AntPropertiesLines = new string[4];
|
|
AntPropertiesLines[0] = "key.store=" + KeyStore;
|
|
AntPropertiesLines[1] = "key.alias=" + KeyAlias;
|
|
AntPropertiesLines[2] = "key.store.password=" + KeyStorePassword;
|
|
AntPropertiesLines[3] = "key.alias.password=" + ((string.IsNullOrEmpty(KeyPassword) || KeyPassword == "_sameaskeystore_") ? KeyStorePassword : KeyPassword);
|
|
|
|
// now write out the properties
|
|
File.WriteAllLines(Path.Combine(BuildPath, "ant.properties"), AntPropertiesLines);
|
|
}
|
|
|
|
private List<string> CollectPluginDataPaths(TargetReceipt Receipt)
|
|
{
|
|
List<string> PluginExtras = new List<string>();
|
|
if (Receipt == null)
|
|
{
|
|
Log.TraceInformation("Receipt is NULL");
|
|
return PluginExtras;
|
|
}
|
|
|
|
// collect plugin extra data paths from target receipt
|
|
var Results = Receipt.AdditionalProperties.Where(x => x.Name == "AndroidPlugin");
|
|
foreach (var Property in Results)
|
|
{
|
|
// Keep only unique paths
|
|
string PluginPath = Property.Value;
|
|
if (PluginExtras.FirstOrDefault(x => x == PluginPath) == null)
|
|
{
|
|
PluginExtras.Add(PluginPath);
|
|
Log.TraceInformation("AndroidPlugin: {0}", PluginPath);
|
|
}
|
|
}
|
|
return PluginExtras;
|
|
}
|
|
|
|
public override bool PrepTargetForDeployment(UEBuildTarget InTarget)
|
|
{
|
|
//Log.TraceInformation("$$$$$$$$$$$$$$ PrepTargetForDeployment $$$$$$$$$$$$$$$$$");
|
|
AndroidToolChain ToolChain = new AndroidToolChain(InTarget.ProjectFile);
|
|
|
|
// we need to strip architecture from any of the output paths
|
|
string BaseSoName = ToolChain.RemoveArchName(InTarget.OutputPaths[0].FullName);
|
|
|
|
// get the receipt
|
|
UnrealTargetPlatform Platform = InTarget.Platform;
|
|
UnrealTargetConfiguration Configuration = InTarget.Configuration;
|
|
string ProjectBaseName = Path.GetFileName(BaseSoName).Replace("-" + Platform, "").Replace("-" + Configuration, "").Replace(".so", "");
|
|
string ReceiptFilename = TargetReceipt.GetDefaultPath(InTarget.ProjectDirectory.FullName, ProjectBaseName, Platform, Configuration, "");
|
|
Log.TraceInformation("Receipt Filename: {0}", ReceiptFilename);
|
|
SetAndroidPluginData(ToolChain.GetAllArchitectures(), CollectPluginDataPaths(TargetReceipt.Read(ReceiptFilename)));
|
|
|
|
// make an apk at the end of compiling, so that we can run without packaging (debugger, cook on the fly, etc)
|
|
MakeApk(ToolChain, InTarget.AppName, InTarget.ProjectDirectory.FullName, BaseSoName, BuildConfiguration.RelativeEnginePath, bForDistribution: false, CookFlavor: "",
|
|
bMakeSeparateApks: ShouldMakeSeparateApks(), bIncrementalPackage: true, bDisallowPackagingDataInApk: false);
|
|
|
|
// if we made any non-standard .apk files, the generated debugger settings may be wrong
|
|
if (ShouldMakeSeparateApks() && (InTarget.OutputPaths.Count > 1 || !InTarget.OutputPaths[0].FullName.Contains("-armv7-es2")))
|
|
{
|
|
Console.WriteLine("================================================================================================================================");
|
|
Console.WriteLine("Non-default apk(s) have been made: If you are debugging, you will need to manually select one to run in the debugger properties!");
|
|
Console.WriteLine("================================================================================================================================");
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static bool ShouldMakeSeparateApks()
|
|
{
|
|
// @todo android fat binary: Currently, there isn't much utility in merging multiple .so's into a single .apk except for debugging,
|
|
// but we can't properly handle multiple GPU architectures in a single .apk, so we are disabling the feature for now
|
|
// The user will need to manually select the apk to run in their Visual Studio debugger settings (see Override APK in TADP, for instance)
|
|
// If we change this, pay attention to <OverrideAPKPath> in AndroidProjectGenerator
|
|
return true;
|
|
|
|
// check to see if the project wants separate apks
|
|
// ConfigCacheIni Ini = nGetConfigCacheIni("Engine");
|
|
// bool bSeparateApks = false;
|
|
// Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bSplitIntoSeparateApks", out bSeparateApks);
|
|
//
|
|
// return bSeparateApks;
|
|
}
|
|
|
|
public override bool PrepForUATPackageOrDeploy(FileReference ProjectFile, string ProjectName, string ProjectDirectory, string ExecutablePath, string EngineDirectory, bool bForDistribution, string CookFlavor, bool bIsDataDeploy)
|
|
{
|
|
//Log.TraceInformation("$$$$$$$$$$$$$$ PrepForUATPackageOrDeploy $$$$$$$$$$$$$$$$$");
|
|
|
|
// note that we cannot allow the data packaged into the APK if we are doing something like Launch On that will not make an obb
|
|
// file and instead pushes files directly via deploy
|
|
AndroidToolChain ToolChain = new AndroidToolChain(ProjectFile);
|
|
MakeApk(ToolChain, ProjectName, ProjectDirectory, ExecutablePath, EngineDirectory, bForDistribution: bForDistribution, CookFlavor: CookFlavor,
|
|
bMakeSeparateApks: ShouldMakeSeparateApks(), bIncrementalPackage: false, bDisallowPackagingDataInApk: bIsDataDeploy);
|
|
return true;
|
|
}
|
|
|
|
public static void OutputReceivedDataEventHandler(Object Sender, DataReceivedEventArgs Line)
|
|
{
|
|
if ((Line != null) && (Line.Data != null))
|
|
{
|
|
Log.TraceInformation(Line.Data);
|
|
}
|
|
}
|
|
|
|
private void UpdateGameActivity(string UE4Arch, string NDKArch, string EngineDir, string UE4BuildPath)
|
|
{
|
|
string SourceFilename = Path.Combine(EngineDir, "Build", "Android", "Java", "src", "com", "epicgames", "ue4", "GameActivity.java");
|
|
string DestFilename = Path.Combine(UE4BuildPath, "src", "com", "epicgames", "ue4", "GameActivity.java");
|
|
|
|
Dictionary<string, string> Replacements = new Dictionary<string, string>{
|
|
{ "//$${gameActivityImportAdditions}$$", UPL.ProcessPluginNode(NDKArch, "gameActivityImportAdditions", "")},
|
|
{ "//$${gameActivityClassAdditions}$$", UPL.ProcessPluginNode(NDKArch, "gameActivityClassAdditions", "")},
|
|
{ "//$${gameActivityReadMetadataAdditions}$$", UPL.ProcessPluginNode(NDKArch, "gameActivityReadMetadataAdditions", "")},
|
|
{ "//$${gameActivityOnCreateAdditions}$$", UPL.ProcessPluginNode(NDKArch, "gameActivityOnCreateAdditions", "")},
|
|
{ "//$${gameActivityOnDestroyAdditions}$$", UPL.ProcessPluginNode(NDKArch, "gameActivityOnDestroyAdditions", "")},
|
|
{ "//$${gameActivityOnStartAdditions}$$", UPL.ProcessPluginNode(NDKArch, "gameActivityOnStartAdditions", "")},
|
|
{ "//$${gameActivityOnStopAdditions}$$", UPL.ProcessPluginNode(NDKArch, "gameActivityOnStopAdditions", "")},
|
|
{ "//$${gameActivityOnPauseAdditions}$$", UPL.ProcessPluginNode(NDKArch, "gameActivityOnPauseAdditions", "")},
|
|
{ "//$${gameActivityOnResumeAdditions}$$", UPL.ProcessPluginNode(NDKArch, "gameActivityOnResumeAdditions", "")},
|
|
{ "//$${gameActivityOnActivityResultAdditions}$$", UPL.ProcessPluginNode(NDKArch, "gameActivityOnActivityResultAdditions", "")},
|
|
{ "//$${soLoadLibrary}$$", UPL.ProcessPluginNode(NDKArch, "soLoadLibrary", "")}
|
|
};
|
|
|
|
string[] TemplateSrc = File.ReadAllLines(SourceFilename);
|
|
string[] TemplateDest = File.Exists(DestFilename) ? File.ReadAllLines(DestFilename) : null;
|
|
|
|
for (int LineIndex = 0; LineIndex < TemplateSrc.Length; ++LineIndex)
|
|
{
|
|
string SrcLine = TemplateSrc[LineIndex];
|
|
bool Changed = false;
|
|
foreach (var KVP in Replacements)
|
|
{
|
|
if(SrcLine.Contains(KVP.Key))
|
|
{
|
|
SrcLine = SrcLine.Replace(KVP.Key, KVP.Value);
|
|
Changed = true;
|
|
}
|
|
}
|
|
if (Changed)
|
|
{
|
|
TemplateSrc[LineIndex] = SrcLine;
|
|
}
|
|
}
|
|
|
|
if (TemplateDest == null || TemplateSrc.Length != TemplateDest.Length || !TemplateSrc.SequenceEqual(TemplateDest))
|
|
{
|
|
Log.TraceInformation("\n==== Writing new GameActivity.java file to {0} ====", DestFilename);
|
|
File.WriteAllLines(DestFilename, TemplateSrc);
|
|
}
|
|
}
|
|
|
|
private void ExtractAARAndJARFiles(string EngineDir, string UE4BuildPath, List<string> NDKArches)
|
|
{
|
|
AndroidAARHandler AARHandler = new AndroidAARHandler();
|
|
string ImportList = "";
|
|
|
|
// Get some common paths
|
|
string AndroidHome = Environment.ExpandEnvironmentVariables("%ANDROID_HOME%").TrimEnd('/', '\\');
|
|
EngineDir = EngineDir.TrimEnd('/', '\\');
|
|
|
|
// Add the AARs from the default aar-imports.txt
|
|
// format: Package,Name,Version
|
|
string ImportsFile = Path.Combine(UE4BuildPath, "aar-imports.txt");
|
|
if (File.Exists(ImportsFile))
|
|
{
|
|
ImportList = File.ReadAllText(ImportsFile);
|
|
}
|
|
|
|
// Run the UPL imports section for each architecture and add any new imports (duplicates will be removed)
|
|
foreach (string NDKArch in NDKArches)
|
|
{
|
|
ImportList = UPL.ProcessPluginNode(NDKArch, "AARImports", ImportList);
|
|
}
|
|
|
|
// Add the final list of imports and get dependencies
|
|
foreach (string Line in ImportList.Split('\n'))
|
|
{
|
|
string Trimmed = Line.Trim(' ', '\r');
|
|
|
|
if (Trimmed.StartsWith("repository "))
|
|
{
|
|
string DirectoryPath = Trimmed.Substring(11).Trim(' ').TrimEnd('/', '\\');
|
|
DirectoryPath = DirectoryPath.Replace("$(ENGINEDIR)", EngineDir);
|
|
DirectoryPath = DirectoryPath.Replace("$(ANDROID_HOME)", AndroidHome);
|
|
DirectoryPath = DirectoryPath.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar);
|
|
AARHandler.AddRepository(DirectoryPath);
|
|
}
|
|
else if (Trimmed.StartsWith("repositories "))
|
|
{
|
|
string DirectoryPath = Trimmed.Substring(13).Trim(' ').TrimEnd('/', '\\');
|
|
DirectoryPath = DirectoryPath.Replace("$(ENGINEDIR)", EngineDir);
|
|
DirectoryPath = DirectoryPath.Replace("$(ANDROID_HOME)", AndroidHome);
|
|
DirectoryPath = DirectoryPath.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar);
|
|
AARHandler.AddRepositories(DirectoryPath, "m2repository");
|
|
}
|
|
else
|
|
{
|
|
string[] Sections = Trimmed.Split(',');
|
|
if (Sections.Length == 3)
|
|
{
|
|
string PackageName = Sections[0].Trim(' ');
|
|
string BaseName = Sections[1].Trim(' ');
|
|
string Version = Sections[2].Trim(' ');
|
|
Log.TraceInformation("AARImports: {0}, {1}, {2}", PackageName, BaseName, Version);
|
|
AARHandler.AddNewAAR(PackageName, BaseName, Version);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Finally, extract the AARs and copy the JARs
|
|
AARHandler.ExtractAARs(UE4BuildPath);
|
|
AARHandler.CopyJARs(UE4BuildPath);
|
|
}
|
|
}
|
|
}
|