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 ========================== MAJOR FEATURES + CHANGES ========================== Change 3292174 on 2017/02/08 by Nick.Shin HTML5 emscripten: wasm and webgl2 support - Linux toolchain #jira UEPLAT-1437 Switch [to] web assembly Change 3292193 on 2017/02/08 by Nick.Shin HTML5 emscripten: wasm and webgl2 support - ThirdParty libs compiled with new toolchain with wasm support #jira UEPLAT-1437 Switch [to] web assembly Change 3292215 on 2017/02/08 by Nick.Shin HTML5 emscripten: wasm and wbegl2 support - emscripten toolchain #jira UEPLAT-1437 Switch [to] web assembly Change 3292222 on 2017/02/08 by Nick.Shin HTML5 emscripten: wasm support - ENGINE changes (c# & cpp files) #jira UEPLAT-1437 Switch [to] web assembly Change 3292223 on 2017/02/08 by Nick.Shin HTML5 merge ThirdParty lib build scripts from Dev-Platform to Dev-Mobile Change 3292228 on 2017/02/08 by Nick.Shin HTML5 emscripten: webgl support - webgl patches - and a lot of UE4 patches to package HTML5 on LINUX - mostly from mozilla's jukka -- thx jukka! #jira UEPLAT-828 (4.16) Support ES3 / WebGL2 in HTML5 Change 3292285 on 2017/02/08 by Nick.Shin HTML5 emscripten: wasm and webgl2 support - Windows toolchain #jira UEPLAT-1437 Switch [to] web assembly Change 3293994 on 2017/02/09 by Nick.Shin HTML5 emscripten: wasm and webgl2 support - OSX toolchain #jira UEPLAT-1437 Switch [to] web assembly Change 3294391 on 2017/02/09 by Nick.Shin HTML5 "black box issues" revisited - jukka rewrote the window resize handler -- much cleaner and more straightforward #jira UE-36341 HTML5 - View is incorrectly drawn #jira UE-32311 Templates on Firefox/Chrome on HTML5 are not full screen during Launch On Change 3296421 on 2017/02/10 by Jack.Porter Fix landscape spline segment splitting placing when using streaming levels Change 3296587 on 2017/02/10 by Jack.Porter Additional fix for landscape spline segment splitting when using streaming levels Change 3301241 on 2017/02/14 by Mi.Wang Fixed DeviceProfileEditor bug for incorrect clamp the Texture Mip LOD size. #jira UE-36237 #rb jack.porter Change 3301387 on 2017/02/14 by Nick.Shin HTML5 emscripten: webgl support - webgl patches from mozilla's jukka + hardware instancing + glBlitFramebuffer + GL AlaphaBlendOperation #jira UEPLAT-828 (4.16) Support ES3 / WebGL2 in HTML5 Change 3301405 on 2017/02/14 by Nick.Shin HTML5 plugin fix when blueprint projects are promoted to code projects automatically. #jira UE-41710 HTML5 - Package Failure - Failed to Produce item ProjectName-OnlineSubsystemNull.bc Change 3302278 on 2017/02/14 by Omar.Rodriguez UE-36651: Mac Vulkan Android Projects crash on launch. * Glslang library has been built for Mac but flag was not updated * Set GlslangAvailable to true for Mac when building an Android project with vulkan #jira UE-36651 Change 3302773 on 2017/02/14 by Chris.Babcock Add a dropdown with some common console commands on Android (contributed by rafortis) #jira UE-40834 #PR #3143 #ue4 #android Change 3305604 on 2017/02/16 by Nick.Shin HTML5 webgl2 shader- turn on: instance static mesh vertex factory #jira UEPLAT-828 (4.16) Support ES3 / WebGL2 in HTML5 Change 3308154 on 2017/02/16 by Nick.Shin HTML5 GitHub PR #jira UE-42019 GitHub 3258 : Added suport for emscripten --pre-js and --post-js option when building for HTML5 Change 3308510 on 2017/02/16 by Nick.Shin HTML5 webgl2 shader fixes #jria UEMOB-201 Support ES3 / WebGL2 in HTML5 Change 3308971 on 2017/02/17 by Jack.Porter Fix for landscape painting when height<0 in the Ortho viewports Change 3309075 on 2017/02/17 by Allan.Bentham Include static subject meshes when masking out modulated shadow casters. #jira UE-41581 Change 3309531 on 2017/02/17 by Chris.Babcock Handle large OBB files in APK #jira UE-41443 #ue4 #android Change 3311320 on 2017/02/19 by Dmitriy.Dyomin Fixed: Particle Cutout Crashes On Mobile Devices That Don't Support Hardware Instancing (Mali-400 GPU) #jira UE-41970 Change 3311347 on 2017/02/20 by Dmitriy.Dyomin Fixed: Engine Crashes When Previewing ES3_1 With Material Using World Position Offset (Need Custom Stencil) #jira UE-41976 Change 3311398 on 2017/02/20 by Dmitriy.Dyomin Fixed: Landscapes do not render on PowerVR device #jira UE-35530 Change 3311428 on 2017/02/20 by Dmitriy.Dyomin Fixed: Exposure Is More Extreme In High-End Mobile Preview Modes #jira UE-42036 Change 3311448 on 2017/02/20 by Dmitriy.Dyomin Fixed: Packaged game Crashes on android after entering "Help" command twice #jira UE-41956 Change 3311587 on 2017/02/20 by Allan.Bentham ES2 GLSL - Silently swap all uint to ints #jira UE-41548 Change 3313930 on 2017/02/21 by Allan.Bentham Print literal uints as ints when generating ES2 code. #jira UE-41548 Change 3317924 on 2017/02/22 by Nick.Shin HTML5 emscripten: wasm & webgl2 support - RC1 - Linux toolchain #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 Change 3317929 on 2017/02/22 by Nick.Shin HTML5 emscripten: wasm & webgl2 support - RC1 - ThirdParty libs compiled with new toolchain with wasm and webgl2 support #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 Change 3317951 on 2017/02/22 by Nick.Shin HTML5 emscripten: wasm & webgl2 support - RC1 - emscripten toolchain WARNING: emscripten/incoming/source/include/libc/bit (the file) might need to be deleted first #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 Change 3318004 on 2017/02/22 by Nick.Shin HTML5 emscripten: wasm & webgl2 support - RC1 - windows toolchain #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 Change 3318669 on 2017/02/23 by Nick.Shin HTML5 emscripten: wasm & webgl2 support - RC1 - OSX toolchain #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 Change 3318672 on 2017/02/23 by Nick.Shin HTML5 webgl2 shader fixes #jria UEMOB-201 Support ES3 / WebGL2 in HTML5 Change 3318819 on 2017/02/23 by Dmitriy.Dyomin Fixed: Rendering artifacts with bloom on iPhone7 Metal #jira UE-40978 Change 3319702 on 2017/02/23 by Chris.Babcock Disable eglSwapInterval since it can cause issues with some drivers #ue4 #android Change 3320880 on 2017/02/24 by Dmitriy.Dyomin Added r.Mobile.TonemapperFilm cvar which can be used to enable/disable filmic tonemapper on mobile, independently from desktop (disabled by default) #jira UEMOB-195 Change 3321042 on 2017/02/24 by Jack.Porter Fixed incorrect sizeof in Vulkan pipleine cache pointed out here: http://coconutlizard.co.uk/blog/ue4/ue4-its-a-size-jim/ #code_review: rolando.caloca Change 3322383 on 2017/02/24 by Chris.Babcock Fix issue with ad banner on Android 7.0 devices #jira UE-42390 #ue4 #android Change 3322479 on 2017/02/24 by Omar.Rodriguez UEMOB-199 - WEX: Improved virtual keyboard for Android * Calculating the area covered by the virtual keyboard * Calling OnVirtualKeyboardShown and OnVirtualKeyboardHidden events * Passing the Rect of the area covered by the virtual keyboard OnVirtualKeyboardShown event #jira UEMOB-199 Change 3323353 on 2017/02/27 by Allan.Bentham Fix broken mobile scene captures when !mobileHDR and RHINeedsToSwitchVerticalAxis #jira UE-42191 Change 3323431 on 2017/02/27 by Allan.Bentham CIS fix Change 3323687 on 2017/02/27 by Allan.Bentham Disable GRHINeedsUnatlasedCSMDepthsWorkaround for mobile devices. #jira UE-42131 Change 3324652 on 2017/02/28 by Dmitriy.Dyomin Fixed: Canvas elements appear darker on iOS Metal Change 3324885 on 2017/02/28 by Jack.Porter Fixed "Minimum iOS Version" setting display name #jira UE-42270 Change 3324899 on 2017/02/28 by Jack.Porter GitHub 3063 : removed duplicate gc.MaxObjectsInGame setting in IOSEngine.ini #jira UE-40018 #3063 Change 3324932 on 2017/02/28 by Jack.Porter GitHub 3257 : iPhonePackager errors in output log when opening project settings on Windows #jira UE-41984 #3257 #codereview: Peter.Sauerbrei Change 3324956 on 2017/02/28 by Jack.Porter FOpenGLFrontend::GetMaxSamplers incorrect for IOS #jira UE-42038 #3264 Change 3325478 on 2017/02/28 by Allan.Bentham PR # 3188 : Fix far distance bug with cascaded shadows on mobile (Metal) and PC mobile preview (Contributed by ufna) #jira UE-41442 Change 3327300 on 2017/03/01 by Allan.Bentham PR #3175 : Fixes high quality reflection blending seams (Contributed by kallehamalainen) #jira UE-41257 Change 3328917 on 2017/03/02 by Nick.Shin HTML5 project settings expose ini settings to edtior HTML5 project settings panel #jira UE-42331 Project Settings - HTML5 SDK - HTML Device population should be moved to an .ini #jira UE-41584 Editor locks up when adding an element for HTML5 devices on Mac #jira UE-41701 Editor freezes when setting browser filepath for inserted element in project settings Change 3329169 on 2017/03/02 by Allan.Bentham increase render thread timeout to 1 minute for suntemple / android. Prevents low end devices timing out during load. #jira UE-40696 Change 3330849 on 2017/03/02 by Nick.Shin HTML5 project settings expose ini settings to edtior HTML5 project settings panel #jira UE-42331 Project Settings - HTML5 SDK - HTML Device population should be moved to an .ini Change 3331078 on 2017/03/03 by Dmitriy.Dyomin Fixed: Device output log partial lines integrated from WEX (3250488) Change 3331112 on 2017/03/03 by Dmitriy.Dyomin Reduced state setup for slate draw calls (saves about 4ms RT time on mobile) integrated from WEX (3256584) Change 3331117 on 2017/03/03 by Dmitriy.Dyomin Fixed redundant blend state changes in opengl integrated from WEX (3256586) Change 3331173 on 2017/03/03 by Dmitriy.Dyomin Slate pixel shaders will use half precision where possible on mobile integrated from WEX (3256656) Change 3332865 on 2017/03/06 by Dmitriy.Dyomin Better MobileContentScaleFactor defaults for iOS devices #jira UEMOB-330 Change3333129on 2017/03/06 by Peter.Sauerbrei move to Library/Caches instead of documents for saved files re-enable iterative deploy on TVOS #jira UEMOB-284 Change 3334692 on 2017/03/06 by Jack.Porter Allow r.MobileContentScaleFactor to be changed at runtime on Android #jira UEMOB-173 Change 3336255 on 2017/03/07 by Nick.Shin HTML5 project settings marking SIMD and multithreading as experimental - these do not play nice with WASM builds currently... #jira UE-42331 Project Settings - HTML5 SDK - HTML Device population should be moved to an .ini Change 3337094 on 2017/03/08 by Nick.Shin HTML5 project settings marking SIMD and multithreading as experimental - these do not play nice with WASM builds currently... #jira UE-42331 Project Settings - HTML5 SDK - HTML Device population should be moved to an .ini Change 3338800 on 2017/03/08 by Chris.Babcock Update AAR handling to deal with versioning, subproject dependencies for resources, and scope #jira UE-42677 #ue4 #android Change 3338813 on 2017/03/08 by Chris.Babcock Pass build configuration to UPL for access during packaging as $S(Configuration) #jira UE-42678 #ue4 #android #ios Change 3339401 on 2017/03/09 by Alicia.Cano Android runtime permissions - Fix for WRITE_EXTERNAL_STORAGE if it is not granted at time of onCreate for non-shipping builds - Fix for Location Services - Fix for if target sdk is not set to 23+ #jira UE-38512 #android #rb: chris.babcock Change 3340736 on 2017/03/09 by Chris.Babcock Implement support for new controllers (Xbox Wireless, SteelSeries Stratus XL, PS4) (contributed by TRS-justing) #jira UE-41965 #PR #3254 #ue4 #android Change 3340744 on 2017/03/09 by Jack.Porter Expose Custom Depth to Foliage #jira UE-6061 Change 3340849 on 2017/03/09 by Dmitriy.Dyomin Fixed: iOS movie become laggy and crashes when played in iPhone 6/6s. #jira UE-42351 Change 3341268 on 2017/03/10 by Alicia.Cano PR #2894: Initial VoiceModuleAndroid support. (Contributed by devbm) #jira UE-37945 #android #rb: chris.babcock, jack.porter Change 3341303 on 2017/03/10 by Allan.Bentham Remove optimisation that prevents full specular occulsion on mobile. PR #3186 : Specular can't be blocked on high-end mobile. #jira UE-41393 Change 3342304 on 2017/03/10 by Alicia.Cano build fix #rb: chris.babcock Change 3343344 on 2017/03/13 by Alicia.Cano build fix #rb: chris.babcock Change 3343591 on 2017/03/13 by Brent.Pease iOS multiplayer fix part 1. Correct byte ordering. #jira UE-34875 Change 3343669 on 2017/03/13 by Chris.Babcock Update carefullyredist script version #jira UE-42832 Change 3344212 on 2017/03/13 by Will.Fissler Various compile fixes for Xcode 8.3. These fixes must also be added to //UE4/Release-4.15. #jira UE-41313 Change 3344396 on 2017/03/13 by Chris.Babcock Fix Java 1.5 obsolete warnings #jira UE-42851 #ue4 #android Change 3345132 on 2017/03/14 by Will.Fissler Added ifdef wrapper to check clang version for presentDrawable. Change 3345336 on 2017/03/14 by Will.Fissler Moved #if (__clang_major__ > 8) || (__clang_major__ == 8 && __clang_minor__ >= 1) check inside of the presentDrawable method. Change 3345460 on 2017/03/14 by Will.Fissler ifdef changes for presentDrawable. The last submission duped the changes, instead of merging. #rb none Change 3346046 on 2017/03/14 by Will.Fissler Fixed MetalCommandBuffer.cpp [again] after last submission duped changes instead of merging. Change 3346367 on 2017/03/14 by Chris.Babcock Fix issue with GoogleVR ARMv7 libraries included for other architectures in link #ue4 #android Change 3347682 on 2017/03/15 by Allan.Bentham Enable HW sRGB correction with retainer widget's render target. Use slate's gamma correction for mobile (where no such support exists) Render retainer box RT content with gamma correction. #jira UE-40967 Change 3348712 on 2017/03/15 by Nick.Shin HTML5 - upload to S3 updated to AWS "signature version 4" authentication #jira UE-42525 HTML5 Upload to Amazon S3 fails with Incorrect Configuration error Change 3349254 on 2017/03/16 by Jack.Porter Fix for crash using the mobile previewer when the LQ lightmap shader permutation is disabled. #jira UE-42971 Change 3349739 on 2017/03/16 by Nick.Shin HTML5 - upload to S3 better error message feedback on upload failures #jira UE-42525 HTML5 Upload to Amazon S3 fails with Incorrect Configuration error Change 3349765 on 2017/03/16 by Alicia.Cano Disable mouseover events in Mobile Previewer #jira UE-19903 #mobile #rb: Jack.Porter Change 3350049 on 2017/03/16 by Nick.Shin HTML5 - upload to S3 folder in bucket is optional #jira UE-42525 HTML5 Upload to Amazon S3 fails with Incorrect Configuration error Change 3350153 on 2017/03/16 by Nick.Shin HTML5 - upload to S3 updated S3 public link generator #jira UE-42525 HTML5 Upload to Amazon S3 fails with Incorrect Configuration error Change 3351582 on 2017/03/17 by Will.Fissler Reverting the attempted fix for Xcode 8.3: Result += " -mcpu=cortex-a9"; Currently we cannot build arm64 for iOS with this change. Change 3352085 on 2017/03/17 by Alicia.Cano iOS doesn't honor request to close the virtual keyboard leading to a crash #jira UE-36447 #ios #rb:Peter.Sauerbrei Change 3353313 on 2017/03/19 by Ben.Marsh Always allow large *.js files in Github. Change 3354444 on 2017/03/20 by Nick.Shin HTML5 - upload to S3 to help make it obvious that "upload to S3" checkbox is set/or not -- disable S3 details if checkbox for "uploading to S3" is not set #jira UE-42525 HTML5 Upload to Amazon S3 fails with Incorrect Configuration error Change 3355618 on 2017/03/20 by Nick.Shin HTML5 Save Game System - ripped out HTML5 code [from Engine's SaveGameSystem.h] and placed it in HTML5Platform.cpp - cleaned up HTML5PlatformFile.cpp (make it match as clost to linux's version) - created HTML5's own PlatformFeature & SaveGameSystem files -- and updated HTML5PlatformMisc to make use of the the new HTML5 SaveGame code #jira UE-42081 Remove heinous HTML5 code from engine Change 3355621 on 2017/03/20 by Nick.Shin remove temp debugging code #jira UE-42081 Remove heinous HTML5 code from engine Change 3356937 on 2017/03/21 by Chris.Babcock Add "stat vulkanrhi" to new console dropdown #jira UE-43149 #ue4 #android Change 3357652 on 2017/03/21 by Nick.Shin HTML5 performance speed ups added "use fixed timestep" setting option for HTML5 builds (this has been separated from Engine - General Settings - Framerate) - this is slightly different to smooth framerate and fixed framerate - thus, the timestep option was put in the HTML5 specific panel this option is based on the suggestions by jukka's post: - https://answers.unrealengine.com/questions/409629/smooth-frame-rate-and-use-fixed-frame-rate-should.html however, using this option will make the player "run faster" on (for example) thirdperson blueprint template -- but, it has no effect on other (for example) zen garden... #jira UE-30214 - Implement a warning message for fps settings Change 3360415 on 2017/03/23 by Allan.Bentham Fix crash that occurs when ES3.1 preview is used with r.MobileHDR32bppMode modes. Change 3360418 on 2017/03/23 by Allan.Bentham Disable filmic tonemapper if r.MobileHDR32bppMode is in use. #jira UE-40913 Change 3360557 on 2017/03/23 by Allan.Bentham Better fix for mobile CSM shadow flickering (UE-42131), now works for PC OpenGL based mobile preview. #jira UE-42131 Change 3362258 on 2017/03/23 by Dmitriy.Dyomin Fixed: Canvas texture element gamma issues on iOS Metal Change 3362321 on 2017/03/24 by Dmitriy.Dyomin GitHub 3173 : MaterialAO support for mobile rendering path (contributed by kallehamalainen) #3173 Change 3363550 on 2017/03/24 by Alicia.Cano build fix for devices < Android 5.0 #jira UE-43299 #android #rb: chris.babcock Change 3363687 on 2017/03/24 by Chris.Babcock Fix Android password hiding in input dialog #jira WEX-5159 #ue4 #android Change 3365280 on 2017/03/27 by Dmitriy.Dyomin Fix for GL_EXT_shader_framebuffer_fetch on Zenfone5. Use UE_EXT_shader_framebuffer_fetch define on all devices to enable extension Change 3365291 on 2017/03/27 by Dmitriy.Dyomin Copied form WEX CL# 3308653 Fixed: Enabling shader cache causes crash on NVIDIA Shield #jira UE-41639 Change 3365293 on 2017/03/27 by Dmitriy.Dyomin GitHub 3411 : Fix crash in patching utils mount method (contributed by nverenik) #jira UE-43247 #3411 Change 3365340 on 2017/03/27 by Dmitriy.Dyomin Fixed: Moving sublevel in world composition browser does not appear in Undo History #jira UE-35535 Change 3365564 on 2017/03/27 by Allan.Bentham SkyLightComponent now serializes IrradianceMap SH values. clicking Recapture sky button in mobile preview switches back to SM4/5 to update captures. Skylights that are dirty from load will trigger reflection capture update once shaders are rebuilt. #jira UE-42436 Change 3366282 on 2017/03/27 by Nick.Shin remove dead links these files to not exist anywhere in the make-3.81 subfolders #UDN-354501 #jira none Change 3366306 on 2017/03/27 by Nick.Shin HTML5 - disable multi-threading for wasm #jira UE-43219 - HTML5 disable multi-threading for wasm Change 3366307 on 2017/03/27 by Nick.Shin HTML5 packaging Shipping builds big cleanup / additions to *gz file support for amazon s3 * both, uploading to s3 * and allowing s3 to host the games there #jira UE-43002 HTML5 in Shipping fails downloading symbols files #jria UE-43001 HTML5 Shipping Projects fail looking for compressed files when "Compress files during shipping packaging" is not selected. Change 3367385 on 2017/03/28 by Allan.Bentham Display skylight serialization warning only when cooking for mobile platforms. #jira UE-42436 Change 3368583 on 2017/03/28 by Chris.Babcock Expose JAVA_HOME setting in Android SDK project settings on Mac #jira UE-43418 #ue4 #android Change 3368803 on 2017/03/28 by Chris.Babcock Fix features requested in manifest for "Daydream and Cardboard" mode #jira UE-43314 #ue4 #android Change 3369087 on 2017/03/28 by Jack.Porter Changed tooltip and added supported devices in paretheses for Android Mobile Deferred / ES31+AEP #jira UE-42438 Change 3369372 on 2017/03/29 by Allan.Bentham Fix disappearing meshes when r.mobile.allowdistancefieldshadows is disabled. #jira UE-43366 Change 3369381 on 2017/03/29 by Jack.Porter Show warnings when mobile shader permutations required for rendering are disbaled Made FReadOnlyCVARCache a singleton and added mobile CVars, used for MobileBasePassRendering. #jira UE-43050 Change 3369430 on 2017/03/29 by Allan.Bentham fix CIS build Change 3369740 on 2017/03/29 by Allan.Bentham Added Android option to enable builds with hidden symbol visbility by default. (bBuildWithHiddenSymbolVisibility) Android links with -gc-sections to remove unused code/data Add JNI_METHOD for java accessible native functions, fixed up existing JNI functions to use macro. Add support for map file generation with android. Add 'bBuildWithHiddenSymbolVisibility' to AndroidPlatform.HasDefaultBuildConfig() bBuildWithHiddenSymbolVisibility defaults to false in BaseEngine.ini #jira UEMOB-168 Change 3369975 on 2017/03/29 by Nick.Shin HTML5 - AWS S3 shareable link for shipping builds corrected #jira UE-43379 Amazon S3 Shareable link does not generate correct filepath. Change 3369998 on 2017/03/29 by Nick.Shin HTML5 python build scripts PR:1cb836d43c#jira none Change 3370214 on 2017/03/29 by Nick.Shin HTML5 - default bUseFixedTimeStep to false... #jira UE-43380 - Default HTML5 gamespeed is faster than equivalent platforms Change 3370762 on 2017/03/29 by Chris.Babcock Fixes to new keyboard for Android - Ensure the local scope ScreenRect passed into OnVirtualKeyboardShown in AndroidJNI is captured by value instead of by reference. - Moved ShowVirtualKeyboardInput's bKeyboardShowing early-out checks into the UI thread task. This allows the keyboard to continue showing when changing focus between multiple EditableTextBox widgets. #ue4 #android Change 3371344 on 2017/03/30 by Jack.Porter Fixed issue where Vulkan screenshot R/B channels were reversed on Android #jira UE-43479 Change 3372926 on 2017/03/30 by Peter.Sauerbrei start the process of sunsetting 32-bit and GLES2 on iOS #jira UE-42266 Change 3372970 on 2017/03/30 by Nick.Shin HTML5 - 1.37.9 emscripten: wasm & webgl2 support - windows toolchain #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 #rn Change 3372989 on 2017/03/30 by Peter.Sauerbrei fix for Xcode 8.3 build with 32-bit Change 3373007 on 2017/03/30 by Peter.Sauerbrei fix for crash when online subsystem is disabled on IOS Change 3373108 on 2017/03/30 by Nick.Shin HTML5 - 1.37.9 emscripten: wasm & webgl2 support - emscripten toolchain WARNING: emscripten/incoming/source/include/libc/bit (the file) might need to be deleted first #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 #rn Change 3373163 on 2017/03/30 by Nick.Shin HTML5 - 1.37.9 emscripten: wasm & webgl2 support - OSX toolchain #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 #rn Change 3373169 on 2017/03/30 by Nick.Shin HTML5 - 1.37.9 emscripten: wasm & webgl2 support license file updated #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 #rnx Change 3373287 on 2017/03/30 by Nick.Shin HTML5 - 1.36.11 emscripten - remove old SDK #jira none #rnx Change 3373289 on 2017/03/30 by Nick.Shin HTML5 - 1.37.9 emscripten: wasm & webgl2 support - Linux toolchain #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 #rn Change 3373595 on 2017/03/30 by Chris.Babcock Reenable GooglePlay for ARM64 now that it doesn't crash #jira UE-36198 #ue4 #android Change 3373606 on 2017/03/30 by Chris.Babcock Submitting Allan's shelved EXT_shader_framebuffer_fetch fix #ue4 #android Change 3375456 on 2017/03/31 by Chris.Babcock Add missing keycodes for Android keyboard (@ and #) #jira WEX-5777 #ue4 #android Change 3376309 on 2017/04/03 by Allan.Bentham Fix overflow issues with mobile DoF. Change 3377041 on 2017/04/03 by Will.Fissler Adding Testbed content for PlatformShowcase. Change 3377582 on 2017/04/03 by Alicia.Cano adding back in GET_ACCOUNTS permission as it is required for Reset Achievements #jira: UE-43265 #android #rb: Chris.Babcock Change 3377643 on 2017/04/03 by Peter.Sauerbrei fix for memory leak in MallocBinned #jira UE-43008 Change 3378033 on 2017/04/04 by Nick.Shin HTML5 - 1.37.9 emscripten: wasm & webgl2 support - ThirdParty libs compiled with new toolchain with wasm and webgl2 support #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 #rn Change 3378034 on 2017/04/04 by Nick.Shin HTML5 - 1.37.9 emscripten: wasm & webgl2 support - ThirdParty build scripts #jira UEMOB-263 Switch [to] web assembly #jira UEMOB-201 Support ES3 / WebGL2 in HTML5 Change 3378035 on 2017/04/04 by Nick.Shin HTML5 - Update GameX template to make it work with trunk Emscripten PRdc2b26f452 (commitcomment-21454978)#jira none #rn Change 3378044 on 2017/04/04 by Nick.Shin HTML5 harfbuzz - double checking recompiled with NO multithreading wasm currently does not support pthreads *** THIS IS STILL WIP *** checking in to match 3rd party libs compiled configuration #jira UE-28588 - Build HarfBuzz for HTML5 #rnx Change 3378264 on 2017/04/04 by Allan.Bentham Fix crash when using consolas font on android sdk 24 #jira UE-43464 Change 3379097 on 2017/04/04 by Nick.Shin CIS HTML5 build warning fix #jria none #rnx Change 3379333 on 2017/04/04 by Chris.Babcock Prevent inserting extra permissions into manifest multiple times #jira UE-43583 #ue4 #android Change 3380870 on 2017/04/05 by Chris.Babcock Fix merge issue Change 3380898 on 2017/04/05 by Chris.Babcock Fixed again Change 3381443 on 2017/04/05 by Chris.Babcock Fix for GearVR non-unity build #ue4 #android Change 3381941 on 2017/04/05 by Chris.Babcock Fix HTTPChunkInstaller texture format checks and missing #define warning #jira UE-43706 #ue4 #android Change 3382056 on 2017/04/05 by Chris.Babcock Updates to Android AARs needed for Facebook plugin Change 3382097 on 2017/04/05 by Chris.Babcock Disable java console cmd receiver only in shipping builds #jira UE-43710 #ue4 #android Change 3382497 on 2017/04/06 by Allan.Bentham Fix Fortnite Cooked Server crashes when joining game from lobby. #jira UE-43695 Change 3383227 on 2017/04/06 by Will.Fissler Reverted case sensitive change, from yesterday, and implemented a pragma instead. #jira UE-41313 [CL 3383473 by Jack Porter in Main branch]
2742 lines
106 KiB
C#
2742 lines
106 KiB
C#
// Copyright 1998-2017 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
|
|
{
|
|
class UEDeployAndroid : UEBuildDeploy, IAndroidDeploy
|
|
{
|
|
/// <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 ConfigHierarchy GetConfigCacheIni(ConfigHierarchyType Type)
|
|
{
|
|
return ConfigCache.ReadHierarchy(Type, DirectoryReference.FromFile(ProjectFile), UnrealTargetPlatform.Android);
|
|
}
|
|
|
|
private string CachedSDKLevel = null;
|
|
private string GetSdkApiLevel(AndroidToolChain ToolChain)
|
|
{
|
|
if (CachedSDKLevel == null)
|
|
{
|
|
// ask the .ini system for what version to use
|
|
ConfigHierarchy Ini = GetConfigCacheIni(ConfigHierarchyType.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)
|
|
{
|
|
return PackageDataInsideApk(bDisallowPackagingDataInApk, null);
|
|
}
|
|
|
|
public bool PackageDataInsideApk(bool bDisallowPackagingDataInApk, ConfigHierarchy Ini)
|
|
{
|
|
if (bDisallowPackagingDataInApk)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// make a new one if one wasn't passed in
|
|
if (Ini == null)
|
|
{
|
|
Ini = GetConfigCacheIni(ConfigHierarchyType.Engine);
|
|
}
|
|
|
|
// we check this a lot, so make it easy
|
|
bool bPackageDataInsideApk;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bPackageDataInsideApk", out bPackageDataInsideApk);
|
|
|
|
return bPackageDataInsideApk;
|
|
}
|
|
|
|
public bool UseExternalFilesDir(bool bDisallowExternalFilesDir, ConfigHierarchy Ini = null)
|
|
{
|
|
if (bDisallowExternalFilesDir)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// make a new one if one wasn't passed in
|
|
if (Ini == null)
|
|
{
|
|
Ini = GetConfigCacheIni(ConfigHierarchyType.Engine);
|
|
}
|
|
|
|
// we check this a lot, so make it easy
|
|
bool bUseExternalFilesDir;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bUseExternalFilesDir", out bUseExternalFilesDir);
|
|
|
|
return bUseExternalFilesDir;
|
|
}
|
|
|
|
public bool IsPackagingForDaydream(ConfigHierarchy Ini = null)
|
|
{
|
|
// make a new one if one wasn't passed in
|
|
if (Ini == null)
|
|
{
|
|
Ini = GetConfigCacheIni(ConfigHierarchyType.Engine);
|
|
}
|
|
|
|
string GoogleVRMode = "";
|
|
if(Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "GoogleVRMode", out GoogleVRMode))
|
|
{
|
|
return GoogleVRMode == "Daydream" || GoogleVRMode == "DaydreamAndCardboard";
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool DisableVerifyOBBOnStartUp(ConfigHierarchy Ini = null)
|
|
{
|
|
// make a new one if one wasn't passed in
|
|
if (Ini == null)
|
|
{
|
|
Ini = GetConfigCacheIni(ConfigHierarchyType.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 variables
|
|
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 int GetStoreVersion()
|
|
{
|
|
var Ini = GetConfigCacheIni(ConfigHierarchyType.Engine);
|
|
int StoreVersion;
|
|
Ini.GetInt32("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "StoreVersion", out StoreVersion);
|
|
return StoreVersion;
|
|
}
|
|
|
|
public void WriteJavaOBBDataFile(string FileName, string PackageName, List<string> ObbSources)
|
|
{
|
|
|
|
Log.TraceInformation("\n==== Writing to OBB data file {0} ====", FileName);
|
|
|
|
int StoreVersion = GetStoreVersion();
|
|
|
|
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$$"]);
|
|
|
|
// Workaround to do OBB file checking without using DownloadActivity to avoid transit to another activity in Daydream
|
|
bool bPackageForDaydream = IsPackagingForDaydream();
|
|
if (bPackageForDaydream)
|
|
{
|
|
ShimFileContent.Append("import android.app.Activity;\n");
|
|
ShimFileContent.Append("import com.google.android.vending.expansion.downloader.Helpers;\n");
|
|
ShimFileContent.AppendFormat("import {0}.OBBData;\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");
|
|
|
|
// Workaround to do OBB file checking without using DownloadActivity to avoid a SPM bug
|
|
if (bPackageForDaydream)
|
|
{
|
|
ShimFileContent.Append("\tpublic static boolean expansionFilesDelivered(Activity activity) {\n");
|
|
ShimFileContent.Append("\t\tfor (OBBData.XAPKFile xf : OBBData.xAPKS) {\n");
|
|
ShimFileContent.Append("\t\t\tString fileName = Helpers.getExpansionAPKFileName(activity, xf.mIsMain, xf.mFileVersion);\n");
|
|
ShimFileContent.Append("\t\t\tGameActivity.Log.debug(\"Checking for file : \" + fileName);\n");
|
|
ShimFileContent.Append("\t\t\tString fileForNewFile = Helpers.generateSaveFileName(activity, fileName);\n");
|
|
ShimFileContent.Append("\t\t\tString fileForDevFile = Helpers.generateSaveFileNameDevelopment(activity, fileName);\n");
|
|
ShimFileContent.Append("\t\t\tGameActivity.Log.debug(\"which is really being resolved to : \" + fileForNewFile + \"\\n Or : \" + fileForDevFile);\n");
|
|
ShimFileContent.Append("\t\t\tif (!Helpers.doesFileExist(activity, fileName, xf.mFileSize, false) &&\n");
|
|
ShimFileContent.Append("\t\t\t\t!Helpers.doesFileExistDev(activity, fileName, xf.mFileSize, false))\n");
|
|
ShimFileContent.Append("\t\t\t\treturn false;\n");
|
|
ShimFileContent.Append("\t\t\t}\n");
|
|
ShimFileContent.Append("\t\treturn true;\n");
|
|
ShimFileContent.Append("\t}\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);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void CopyGfxDebugger(string UE4BuildPath, string UE4Arch, string NDKArch)
|
|
{
|
|
string AndroidGraphicsDebugger;
|
|
ConfigHierarchy Ini = GetConfigCacheIni(ConfigHierarchyType.Engine);
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "AndroidGraphicsDebugger", out AndroidGraphicsDebugger);
|
|
|
|
switch (AndroidGraphicsDebugger.ToLower())
|
|
{
|
|
case "mali":
|
|
{
|
|
string MaliGraphicsDebuggerPath;
|
|
AndroidPlatformSDK.GetPath(Ini, "/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "MaliGraphicsDebuggerPath", out MaliGraphicsDebuggerPath);
|
|
if (Directory.Exists(MaliGraphicsDebuggerPath))
|
|
{
|
|
Directory.CreateDirectory(Path.Combine(UE4BuildPath, "libs", NDKArch));
|
|
string MaliLibSrcPath = Path.Combine(MaliGraphicsDebuggerPath, @"target\android-non-root\arm", NDKArch, "libMGD.so");
|
|
if (!File.Exists(MaliLibSrcPath))
|
|
{
|
|
// in v4.3.0 library location was changed
|
|
MaliLibSrcPath = Path.Combine(MaliGraphicsDebuggerPath, @"target\android\arm\unrooted", NDKArch, "libMGD.so");
|
|
}
|
|
string MaliLibDstPath = Path.Combine(UE4BuildPath, "libs", NDKArch, "libMGD.so");
|
|
|
|
Console.WriteLine("Copying {0} to {1}", MaliLibSrcPath, MaliLibDstPath);
|
|
File.Copy(MaliLibSrcPath, MaliLibDstPath, true);
|
|
}
|
|
}
|
|
break;
|
|
// @TODO: Add NVIDIA Gfx Debugger
|
|
/*
|
|
case "nvidia":
|
|
{
|
|
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);
|
|
}
|
|
*/
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
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;
|
|
ConfigHierarchy Ini = GetConfigCacheIni(ConfigHierarchyType.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, bool bUseExternalFilesDir)
|
|
{
|
|
// 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));
|
|
CurrentSettings.AppendLine(string.Format("bUseExternalFilesDir={0}", bUseExternalFilesDir));
|
|
|
|
// all AndroidRuntimeSettings ini settings in here
|
|
ConfigHierarchy Ini = GetConfigCacheIni(ConfigHierarchyType.Engine);
|
|
ConfigHierarchySection Section = Ini.FindSection("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings");
|
|
if (Section != null)
|
|
{
|
|
foreach (string Key in Section.KeyNames)
|
|
{
|
|
IEnumerable<string> Values;
|
|
Section.TryGetValues(Key, out Values);
|
|
|
|
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.KeyNames)
|
|
{
|
|
IEnumerable<string> Values;
|
|
Section.TryGetValues(Key, out Values);
|
|
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)
|
|
{
|
|
ConfigHierarchy Ini = GetConfigCacheIni(ConfigHierarchyType.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 PackageForDaydream(string UE4BuildPath)
|
|
{
|
|
bool bPackageForDaydream = IsPackagingForDaydream();
|
|
|
|
if (!bPackageForDaydream)
|
|
{
|
|
// If this isn't a Daydream App, we need to make sure to remove
|
|
// Daydream specific assets.
|
|
|
|
// Remove the Daydream app tile background.
|
|
string AppTileBackgroundPath = UE4BuildPath + "/res/drawable-nodpi/vr_icon_background.png";
|
|
if (File.Exists(AppTileBackgroundPath))
|
|
{
|
|
File.Delete(AppTileBackgroundPath);
|
|
}
|
|
|
|
// Remove the Daydream app tile icon.
|
|
string AppTileIconPath = UE4BuildPath + "/res/drawable-nodpi/vr_icon.png";
|
|
if (File.Exists(AppTileIconPath))
|
|
{
|
|
File.Delete(AppTileIconPath);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void PickSplashScreenOrientation(string UE4BuildPath, bool bNeedPortrait, bool bNeedLandscape)
|
|
{
|
|
ConfigHierarchy Ini = GetConfigCacheIni(ConfigHierarchyType.Engine);
|
|
bool bShowLaunchImage = false;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bShowLaunchImage", out bShowLaunchImage);
|
|
bool bPackageForGearVR;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bPackageForGearVR", out bPackageForGearVR);
|
|
bool bPackageForDaydream = IsPackagingForDaydream();
|
|
|
|
//override the parameters if we are not showing a launch image or are packaging for GearVR and Daydream
|
|
if (bPackageForGearVR || bPackageForDaydream || !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)
|
|
{
|
|
ConfigHierarchy Ini = GetConfigCacheIni(ConfigHierarchyType.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()
|
|
{
|
|
ConfigHierarchy Ini = GetConfigCacheIni(ConfigHierarchyType.Engine);
|
|
string PlayLicenseKey = "";
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "GooglePlayLicenseKey", out PlayLicenseKey);
|
|
return PlayLicenseKey;
|
|
}
|
|
|
|
|
|
|
|
private string GenerateManifest(AndroidToolChain ToolChain, string ProjectName, string EngineDirectory, bool bIsForDistribution, bool bPackageDataInsideApk, string GameBuildFilesPath, bool bHasOBBFiles, bool bDisableVerifyOBBOnStartUp, string UE4Arch, string GPUArch, string CookFlavor, bool bUseExternalFilesDir, string Configuration)
|
|
{
|
|
// Read the engine version
|
|
string EngineMajorVersion = "4";
|
|
string EngineMinorVersion = "0";
|
|
string EnginePatchVersion = "0";
|
|
string EngineVersionFile = Path.Combine(EngineDirectory, "Source", "Runtime", "Launch", "Resources", "Version.h");
|
|
string[] EngineVersionLines = File.ReadAllLines(EngineVersionFile);
|
|
for (int i = 0; i < EngineVersionLines.Length; ++i)
|
|
{
|
|
if (EngineVersionLines[i].StartsWith("#define ENGINE_MAJOR_VERSION"))
|
|
{
|
|
EngineMajorVersion = EngineVersionLines[i].Split('\t')[1].Trim(' ');
|
|
}
|
|
else if (EngineVersionLines[i].StartsWith("#define ENGINE_MINOR_VERSION"))
|
|
{
|
|
EngineMinorVersion = EngineVersionLines[i].Split('\t')[1].Trim(' ');
|
|
}
|
|
else if (EngineVersionLines[i].StartsWith("#define ENGINE_PATCH_VERSION"))
|
|
{
|
|
EnginePatchVersion = EngineVersionLines[i].Split('\t')[1].Trim(' ');
|
|
}
|
|
}
|
|
string EngineVersion = EngineMajorVersion + "." + EngineMinorVersion + "." + EnginePatchVersion;
|
|
|
|
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
|
|
ConfigHierarchy Ini = GetConfigCacheIni(ConfigHierarchyType.Engine);
|
|
string PackageName = GetPackageName(ProjectName);
|
|
bool bEnableGooglePlaySupport;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bEnableGooglePlaySupport", out bEnableGooglePlaySupport);
|
|
bool bUseGetAccounts;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bUseGetAccounts", out bUseGetAccounts);
|
|
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 bEnableIAP = false;
|
|
Ini.GetBool("OnlineSubsystemGooglePlay.Store", "bSupportsInAppPurchasing", out bEnableIAP);
|
|
bool bShowLaunchImage = false;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bShowLaunchImage", out bShowLaunchImage);
|
|
string AndroidGraphicsDebugger;
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "AndroidGraphicsDebugger", out AndroidGraphicsDebugger);
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
bool bPackageForDaydream = IsPackagingForDaydream();
|
|
// disable splash screen for daydream
|
|
if (bPackageForDaydream)
|
|
{
|
|
if (bShowLaunchImage)
|
|
{
|
|
Log.TraceInformation("Disabling Show Launch Image for Daydream 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;
|
|
}
|
|
}
|
|
bool bSupportingAllTextureFormats = bETC1Enabled && bETC2Enabled && bDXTEnabled && bATCEnabled && bPVRTCEnabled && bASTCEnabled;
|
|
|
|
// If it is only ETC2 we need to skip adding the texture format filtering and instead use ES 3.0 as minimum version (it requires ETC2)
|
|
bool bOnlyETC2Enabled = (bETC2Enabled && !(bETC1Enabled || bDXTEnabled || bATCEnabled || bPVRTCEnabled || bASTCEnabled));
|
|
|
|
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:hardwareAccelerated=\"true\">");
|
|
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.EngineVersion\" android:value=\"{0}\"/>", EngineVersion));
|
|
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.BuildConfiguration\" android:value=\"{0}\"/>", Configuration));
|
|
Text.AppendLine(string.Format("\t\t<meta-data android:name=\"com.epicgames.ue4.GameActivity.bUseExternalFilesDir\" android:value=\"{0}\"/>", bUseExternalFilesDir ? "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, bOnlyETC2Enabled) + "\" 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\"/>");
|
|
|
|
if (bEnableGooglePlaySupport && bUseGetAccounts)
|
|
{
|
|
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)
|
|
{
|
|
string TrimmedPermission = Permission.Trim(' ');
|
|
if (TrimmedPermission != "")
|
|
{
|
|
string PermissionString = string.Format("\t<uses-permission android:name=\"{0}\"/>", TrimmedPermission);
|
|
if (!Text.ToString().Contains(PermissionString))
|
|
{
|
|
Text.AppendLine(PermissionString);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
string RequirementsAdditionsFile = Path.Combine(GameBuildFilesPath, "ManifestRequirementsAdditions.txt");
|
|
if (File.Exists(RequirementsAdditionsFile))
|
|
{
|
|
foreach (string Line in File.ReadAllLines(RequirementsAdditionsFile))
|
|
{
|
|
Text.AppendLine("\t" + Line);
|
|
}
|
|
}
|
|
if (AndroidGraphicsDebugger.ToLower() == "adreno")
|
|
{
|
|
string PermissionString = "\t<uses-permission android:name=\"com.qti.permission.PROFILER\"/>";
|
|
if (!Text.ToString().Contains(PermissionString))
|
|
{
|
|
Text.AppendLine(PermissionString);
|
|
}
|
|
}
|
|
|
|
if (!bSupportingAllTextureFormats)
|
|
{
|
|
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 && !bOnlyETC2Enabled)
|
|
{
|
|
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)
|
|
{
|
|
ConfigHierarchy Ini = GetConfigCacheIni(ConfigHierarchyType.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, bool bDisallowExternalFilesDir)
|
|
{
|
|
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();
|
|
bool bUseExternalFilesDir = UseExternalFilesDir(bDisallowExternalFilesDir);
|
|
|
|
// check to see if any "meta information" is newer than last time we build
|
|
string CurrentBuildSettings = GetAllBuildSettings(ToolChain, UE4BuildPath, bForDistribution, bMakeSeparateApks, bPackageDataInsideApk, bDisableVerifyOBBOnStartUp, bUseExternalFilesDir);
|
|
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();
|
|
|
|
// figure out the configuration from output filename
|
|
string Configuration = "Development";
|
|
string OutputConfig = Path.GetFileNameWithoutExtension(OutputPath);
|
|
if (OutputConfig.EndsWith("-Debug"))
|
|
{
|
|
Configuration = "Debug";
|
|
}
|
|
else if (OutputConfig.EndsWith("-Test"))
|
|
{
|
|
Configuration = "Test";
|
|
}
|
|
else if (OutputConfig.EndsWith("-DebugGame"))
|
|
{
|
|
Configuration = "Debug";
|
|
}
|
|
else if (OutputConfig.EndsWith("-Shipping"))
|
|
{
|
|
Configuration = "Shipping";
|
|
}
|
|
|
|
// Initialize UPL 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, ProjectDirectory, Configuration);
|
|
|
|
IEnumerable<Tuple<string, string, string>> BuildList = null;
|
|
|
|
if (!bBuildSettingsMatch)
|
|
{
|
|
BuildList = from Arch in Arches
|
|
from GPUArch in GPUArchitectures
|
|
let manifest = GenerateManifest(ToolChain, ProjectName, EngineDirectory, bForDistribution, bPackageDataInsideApk, GameBuildFilesPath, RequiresOBB(bDisallowPackagingDataInApk, ObbFileLocation), bDisableVerifyOBBOnStartUp, Arch, GPUArch, CookFlavor, bUseExternalFilesDir, Configuration)
|
|
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, EngineDirectory, bForDistribution, bPackageDataInsideApk, GameBuildFilesPath, RequiresOBB(bDisallowPackagingDataInApk, ObbFileLocation), bDisableVerifyOBBOnStartUp, Arch, GPUArch, CookFlavor, bUseExternalFilesDir, Configuration)
|
|
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, PackageName);
|
|
|
|
//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);
|
|
|
|
//Now package the app based on Daydream packaging settings
|
|
PackageForDaydream(UE4BuildPath);
|
|
|
|
//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
|
|
ConfigHierarchy Ini = GetConfigCacheIni(ConfigHierarchyType.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);
|
|
|
|
// modify the generated build.xml before the final include
|
|
UpdateBuildXML(Arch, NDKArch, EngineDirectory, UE4BuildPath);
|
|
|
|
// 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 AntOptions = AntBuildType + " -Djava.source=1.7 -Djava.target=1.7";
|
|
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 " + AntOptions + ShellParametersEnd, "Making .apk with Ant... (note: it's safe to ignore javac obsolete warnings)") != 0)
|
|
{
|
|
RunCommandLineProgramAndReturnResult(UE4BuildPath, ShellExecutable, ShellParametersBegin + "\"" + GetAntPath() + "\" " + AntOptions + ShellParametersEnd, "Making .apk with Ant again to show errors");
|
|
}
|
|
break;
|
|
|
|
case "normal":
|
|
RunCommandLineProgramAndReturnResult(UE4BuildPath, ShellExecutable, ShellParametersBegin + "\"" + GetAntPath() + "\" " + AntOptions + ShellParametersEnd, "Making .apk with Ant again to show errors");
|
|
break;
|
|
|
|
case "verbose":
|
|
RunCommandLineProgramAndReturnResult(UE4BuildPath, ShellExecutable, ShellParametersBegin + "\"" + GetAntPath() + "\" -verbose " + AntOptions + 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);
|
|
|
|
bool bBuildWithHiddenSymbolVisibility = false;
|
|
Ini.GetBool("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "bBuildWithHiddenSymbolVisibility", out bBuildWithHiddenSymbolVisibility);
|
|
if ( Configuration == "Shipping" && bBuildWithHiddenSymbolVisibility)
|
|
{
|
|
// Copy .so with symbols to
|
|
int StoreVersion = GetStoreVersion();
|
|
string SymbolSODirectory = Path.Combine(Path.GetDirectoryName(DestApkName), ProjectName + "_Symbols_v" + StoreVersion + "/" + ProjectName + Arch + GPUArchitecture);
|
|
string SymbolifiedSOPath = Path.Combine(SymbolSODirectory, Path.GetFileName(FinalSOName));
|
|
MakeDirectoryIfRequired(SymbolifiedSOPath);
|
|
|
|
File.Copy(FinalSOName, SymbolifiedSOPath, true);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
private void PrepareToSignApk(string BuildPath)
|
|
{
|
|
// ini file to get settings from
|
|
ConfigHierarchy Ini = GetConfigCacheIni(ConfigHierarchyType.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(UEBuildDeployTarget InTarget)
|
|
{
|
|
//Log.TraceInformation("$$$$$$$$$$$$$$ PrepTargetForDeployment $$$$$$$$$$$$$$$$$ {0}", InTarget.TargetName);
|
|
AndroidToolChain ToolChain = new AndroidToolChain(InTarget.ProjectFile, false, InTarget.AndroidArchitectures, InTarget.AndroidGPUArchitectures);
|
|
|
|
// 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)
|
|
string RelativeEnginePath = UnrealBuildTool.EngineDirectory.MakeRelativeTo(DirectoryReference.GetCurrentDirectory());
|
|
MakeApk(ToolChain, InTarget.TargetName, InTarget.ProjectDirectory.FullName, BaseSoName, RelativeEnginePath, bForDistribution: false, CookFlavor: "",
|
|
bMakeSeparateApks: ShouldMakeSeparateApks(), bIncrementalPackage: true, bDisallowPackagingDataInApk: false, bDisallowExternalFilesDir: true);
|
|
|
|
// 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 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, false, null, null);
|
|
MakeApk(ToolChain, ProjectName, ProjectDirectory, ExecutablePath, EngineDirectory, bForDistribution: bForDistribution, CookFlavor: CookFlavor,
|
|
bMakeSeparateApks: ShouldMakeSeparateApks(), bIncrementalPackage: false, bDisallowPackagingDataInApk: bIsDataDeploy, bDisallowExternalFilesDir: !bForDistribution || bIsDataDeploy );
|
|
return true;
|
|
}
|
|
|
|
public static void OutputReceivedDataEventHandler(Object Sender, DataReceivedEventArgs Line)
|
|
{
|
|
if ((Line != null) && (Line.Data != null))
|
|
{
|
|
Log.TraceInformation(Line.Data);
|
|
}
|
|
}
|
|
|
|
private void UpdateBuildXML(string UE4Arch, string NDKArch, string EngineDir, string UE4BuildPath)
|
|
{
|
|
string SourceFilename = Path.Combine(UE4BuildPath, "build.xml");
|
|
string DestFilename = SourceFilename;
|
|
|
|
Dictionary<string, string> Replacements = new Dictionary<string, string>{
|
|
{ "<import file=\"${sdk.dir}/tools/ant/build.xml\" />", UPL.ProcessPluginNode(NDKArch, "buildXmlPropertyAdditions", "")}
|
|
};
|
|
|
|
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))
|
|
{
|
|
// insert replacement before the <import>
|
|
SrcLine = SrcLine.Replace(KVP.Key, KVP.Value);
|
|
// then add the <import>
|
|
SrcLine += KVP.Key;
|
|
Changed = true;
|
|
}
|
|
}
|
|
if (Changed)
|
|
{
|
|
TemplateSrc[LineIndex] = SrcLine;
|
|
}
|
|
}
|
|
|
|
if (TemplateDest == null || TemplateSrc.Length != TemplateDest.Length || !TemplateSrc.SequenceEqual(TemplateDest))
|
|
{
|
|
Log.TraceInformation("\n==== Writing new build.xml file to {0} ====", DestFilename);
|
|
File.WriteAllLines(DestFilename, TemplateSrc);
|
|
}
|
|
}
|
|
|
|
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");
|
|
|
|
string LoadLibraryDefaults = "";
|
|
|
|
string AndroidGraphicsDebugger;
|
|
ConfigHierarchy Ini = GetConfigCacheIni(ConfigHierarchyType.Engine);
|
|
Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "AndroidGraphicsDebugger", out AndroidGraphicsDebugger);
|
|
|
|
switch (AndroidGraphicsDebugger.ToLower())
|
|
{
|
|
case "mali":
|
|
LoadLibraryDefaults += "\t\ttry\n" +
|
|
"\t\t{\n" +
|
|
"\t\t\tSystem.loadLibrary(\"MGD\");\n" +
|
|
"\t\t}\n" +
|
|
"\t\tcatch (java.lang.UnsatisfiedLinkError e)\n" +
|
|
"\t\t{\n" +
|
|
"\t\t\tLog.debug(\"libMGD.so not loaded.\");\n" +
|
|
"\t\t}\n";
|
|
break;
|
|
}
|
|
|
|
Dictionary<string, string> Replacements = new Dictionary<string, string>{
|
|
{ "//$${gameActivityImportAdditions}$$", UPL.ProcessPluginNode(NDKArch, "gameActivityImportAdditions", "")},
|
|
{ "//$${gameActivityPostImportAdditions}$$", UPL.ProcessPluginNode(NDKArch, "gameActivityPostImportAdditions", "")},
|
|
{ "//$${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", "")},
|
|
{ "//$${gameActivityOnNewIntentAdditions}$$", UPL.ProcessPluginNode(NDKArch, "gameActivityOnNewIntentAdditions", "")},
|
|
{ "//$${gameActivityOnActivityResultAdditions}$$", UPL.ProcessPluginNode(NDKArch, "gameActivityOnActivityResultAdditions", "")},
|
|
{ "//$${soLoadLibrary}$$", UPL.ProcessPluginNode(NDKArch, "soLoadLibrary", LoadLibraryDefaults)}
|
|
};
|
|
|
|
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, string AppPackageName)
|
|
{
|
|
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, AppPackageName);
|
|
AARHandler.CopyJARs(UE4BuildPath);
|
|
}
|
|
}
|
|
}
|