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]
3006 lines
92 KiB
C#
3006 lines
92 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.Xml.Linq;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
|
|
namespace UnrealBuildTool
|
|
{
|
|
/* UnrealPluginLanguage (UPL) is a simple XML-based language for manipulating XML and returning
|
|
* strings. It contains an <init> section which is evaluated once per architecture before any
|
|
* other sections. The state is maintained and carried forward to the next section evaluated
|
|
* so the order the sections are executed matters.
|
|
*
|
|
* While UPL is a general system for modifying and quering XML it is specifically used to allow
|
|
* plug-ins to effect the global configuration of the package that they are a part of. For
|
|
* example, this allows a plug-in to modify an Android's APK AndroidManfiest.xml file or an
|
|
* IOS IPA's plist file. UBT will also query a plug-in's UPL xml file for strings to be included
|
|
* in files that must be common to the package such as some .java files on Android.
|
|
*
|
|
* If you need to see the instructions executed in your plugin context add the following to
|
|
* enable tracing:
|
|
*
|
|
* <trace enable="true"/>
|
|
*
|
|
* After this instuction all the nodes actually executed in your context will be written to the
|
|
* log until you do a <trace enable="false"/>. You can also get a dump of all the variables in
|
|
* your context with this command:
|
|
*
|
|
* <dumpvars/>
|
|
*
|
|
* Bool, Int, and String variable types are supported. Any attribute may reference a variable
|
|
* and will be replaced with the string equivalent before evaluation using this syntax:
|
|
*
|
|
* $B(name) = boolean variable "name"'s value
|
|
* $I(name) = integer variable "name"'s value
|
|
* $S(name) = string variable "name"'s value
|
|
* $E(name) = element variable "name"'s value
|
|
*
|
|
* The following variables are initialized automatically:
|
|
*
|
|
* $S(Output) = the output returned for evaluating the section (initialized to Input)
|
|
* $S(Architecture) = target architecture (armeabi-armv7a, arm64-v8a, x86, x86_64)
|
|
* $S(PluginDir) = directory the XML file was loaded from
|
|
* $S(EngineDir) = engine directory
|
|
* $S(BuildDir) = project's platform appropriate build directory (within the Intermediate folder)
|
|
* $S(Configuration) = configuration type (Debug, DebugGame, Development, Test, Shipping)
|
|
* $B(Distribution) = true if distribution build
|
|
*
|
|
* Note: with the exception of the above variables, all are in the context of the plugin to
|
|
* prevent namespace collision; trying to set a new value to any of the above, with the
|
|
* exception of Output, will only affect the current context.
|
|
*
|
|
* The following nodes allow manipulation of variables:
|
|
*
|
|
* <setBool result="" value=""/>
|
|
* <setInt result="" value=""/>
|
|
* <setString result="" value=""/>
|
|
* <setElement result="" value=""/>
|
|
* <setElement result="" value="" text=""/>
|
|
* <setElement result="" xml=""/>
|
|
*
|
|
* <setElement> with value creates an empty XML element with the tag set to value.
|
|
* <setElement> with value and text creates an XML element with tag set to value of unparsed text.
|
|
* <setElement> with xml will parse the XML provided. Remember to escape any special characters!
|
|
*
|
|
* Variables may also be set from a property in an ini file:
|
|
*
|
|
* <setBoolFromProperty result="" ini="" section="" property="" default=""/>
|
|
* <setIntFromProperty result="" ini="" section="" property="" default=""/>
|
|
* <setStringFromProperty result="" ini="" section="" property="" default=""/>
|
|
*
|
|
* Boolean variables may also be set to the result of applying operators:
|
|
*
|
|
* <setBoolNot result="" source=""/>
|
|
* <setBoolAnd result="" arg1="" arg2=""/>
|
|
* <setBoolOr result="" arg1="" arg2=""/>
|
|
* <setBoolIsEqual result="" arg1="" arg2=""/>
|
|
* <setBoolIsLess result="" arg1="" arg2=""/>
|
|
* <setBoolIsLessEqual result="" arg1="" arg2=""/>
|
|
* <setBoolIsGreater result="" arg1="" arg2=""/>
|
|
* <setBoolIsGreaterEqual result="" arg1="" arg2=""/>
|
|
*
|
|
* Integer variables may use these arithmetic operations:
|
|
*
|
|
* <setIntAdd result="" arg1="" arg2=""/>
|
|
* <setIntSubtract result="" arg1="" arg2=""/>
|
|
* <setIntMultiply result="" arg1="" arg2=""/>
|
|
* <setIntDivide result="" arg1="" arg2=""/>
|
|
*
|
|
* Strings are manipulated with the following:
|
|
*
|
|
* <setStringAdd result="" arg1="" arg2=""/>
|
|
* <setStringSubstring result="" source="" start="" length=""/>
|
|
* <setStringReplace result="" source="" find="" with=""/>
|
|
*
|
|
* String length may be retrieved with:
|
|
*
|
|
* <setIntLength result="" source=""/>
|
|
*
|
|
* The index of a search string may be found in source with:
|
|
*
|
|
* <setIntFindString result="" source="" find=""/>
|
|
*
|
|
* The following shortcut string comparisons may also be used instead of using <setIntFindString>
|
|
* and checking the result:
|
|
*
|
|
* <setBoolStartsWith result="" source="" find=""/>
|
|
* <setBoolEndsWith result="" source="" find=""/>
|
|
* <setBoolContains result="" source="" find=""/>
|
|
*
|
|
* Messages are written to the log with this node:
|
|
*
|
|
* <log text=""/>
|
|
*
|
|
* Conditional execution uses the following form:
|
|
*
|
|
* <if condition="">
|
|
* <true>
|
|
* <!-- executes if boolean variable in condition is true -->
|
|
* </true>
|
|
* <false>
|
|
* <!-- executes if boolean variable in condition is false -->
|
|
* </false>
|
|
* </if>
|
|
*
|
|
* The <true> and <false> blocks are optional. The condition must be in a boolean variable.
|
|
* The boolean operator nodes may be combined to create a final state for more complex
|
|
* conditions:
|
|
*
|
|
* <setBoolNot result="notDistribution" source="$B(Distribution)/>
|
|
* <setBoolIsEqual result="isX86" arg1="$S(Architecture)" arg2="x86"/>
|
|
* <setBoolIsEqual result="isX86_64" arg2="$S(Architecture)" arg2="x86_64/">
|
|
* <setBoolOr result="isIntel" arg1="$B(isX86)" arg2="$B(isX86_64)"/>
|
|
* <setBoolAnd result="intelAndNotDistribution" arg1="$B(isIntel)" arg2="$B(notDistribution)"/>
|
|
* <if condition="intelAndNotDistribution">
|
|
* <true>
|
|
* <!-- do something for Intel if not a distribution build -->
|
|
* </true>
|
|
* </if>
|
|
*
|
|
* Note the "isIntel" could also be done like this:
|
|
*
|
|
* <setStringSubstring result="subarch" source="$S(Architecture)" start="0" length="3"/>
|
|
* <setBoolEquals result="isIntel" arg1="$S(subarch)" arg2="x86"/>
|
|
*
|
|
* Two shortcut nodes are available for conditional execution:
|
|
*
|
|
* <isArch arch="armeabi-armv7">
|
|
* <!-- do stuff -->
|
|
* </isArch>
|
|
*
|
|
* is the equivalent of:
|
|
*
|
|
* <setBoolEquals result="temp" arg1="$S(Architecture)" arg2="armeabi-armv7">
|
|
* <if condition="temp">
|
|
* <true>
|
|
* <!-- do stuff -->
|
|
* </true>
|
|
* </if>
|
|
*
|
|
* and
|
|
*
|
|
* <isDistribution>
|
|
* <!-- do stuff -->
|
|
* </isDistribution>
|
|
*
|
|
* is the equivalent of:
|
|
*
|
|
* <if condition="$B(Distribution)">
|
|
* <!-- do stuff -->
|
|
* </if>
|
|
*
|
|
* Execution may be stopped with:
|
|
*
|
|
* <return/>
|
|
*
|
|
* Loops may be created using these nodes:
|
|
*
|
|
* <while condition="">
|
|
* <!-- do stuff -->
|
|
* </while>
|
|
*
|
|
* <break/>
|
|
* <continue/>
|
|
*
|
|
* The <while> body will execute until the condition is false or a <break/> is hit. The
|
|
* <continue/> will restart execution of the loop if the condition is still true or exit.
|
|
*
|
|
* Note: <break/> outside a <while> body will act the same as <return/>
|
|
*
|
|
* Here is an example loop which writes 1 to 5 to the log, skipping 3. Note the update of the
|
|
* while condition should be done before the continue otherwise it may not exit.
|
|
*
|
|
* <setInt result="index" value="0"/>
|
|
* <setBool result="loopRun" value="true"/>
|
|
* <while condition="loopRun">
|
|
* <setIntAdd result="index" arg1="$I(index)" arg2="1"/>
|
|
* <setBoolIsLess result="loopRun" arg1="$I(index)" arg2="5"/>
|
|
* <setBoolIsEqual result="indexIs3" arg1="$I(index)" arg2="3"/>
|
|
* <if condition="indexIs3">
|
|
* <true>
|
|
* <continue/>
|
|
* </true>
|
|
* </if>
|
|
* <log text="$I(index)"/>
|
|
* </while>
|
|
*
|
|
* It is possible to use variable replacement in generating the result variable
|
|
* name as well. This makes the creation of arrays in loops possible:
|
|
*
|
|
* <setString result="array_$I(index)" value="element $I(index) in array"/>
|
|
*
|
|
* This may be retrieved using the following (value is treated as the variable
|
|
* name):
|
|
*
|
|
* <setStringFrom result="out" value="array_$I(index)"/>
|
|
*
|
|
* For boolean and integer types, you may use <setBoolFrom/> and <setIntFrom/>.
|
|
*
|
|
* Nodes for inserting text into the section are as follows:
|
|
*
|
|
* <insert> body </insert>
|
|
* <insertNewline/>
|
|
* <insertValue value=""/>
|
|
* <loadLibrary name="" failmsg=""/>
|
|
*
|
|
* The first one will insert either text or nodes into the returned section
|
|
* string. Please note you must use escaped characters for:
|
|
*
|
|
* < = <
|
|
* > = >
|
|
* & = &
|
|
*
|
|
* <insertValue value=""/> evaluates variables in value before insertion. If value contains
|
|
* double quote ("), you must escape it with ".
|
|
*
|
|
* <loadLibrary name="" failmsg=""/> is a shortcut to insert a system.LoadLibrary try/catch
|
|
* block with an optional logged message for failure to load case.
|
|
*
|
|
* You can do a search and replace in the Output with:
|
|
*
|
|
* <replace find="" with=""/>
|
|
*
|
|
* Note you can also manipulate the actual $S(Output) directly, the above are more efficient:
|
|
*
|
|
* <setStringAdd result="Input" arg1="$S(Output)" arg2="sample\n"/>
|
|
* <setStringReplace result="Input" source="$S(Output)" find=".LAUNCH" with=".INFO"/>
|
|
*
|
|
* XML manipulation uses the following nodes:
|
|
*
|
|
* <addElement tag="" name=""/>
|
|
* <addElements tag=""> body </addElements>
|
|
* <removeElement tag=""/>
|
|
* <setStringFromTag result="" tag="" name=""/>
|
|
* <setStringFromAttribute result="" tag="" name=""/>
|
|
* <addAttribute tag="" name="" value=""/>
|
|
* <removeAttribute tag="" name=""/>
|
|
* <loopElements tag=""> instructions </loopElements>
|
|
*
|
|
* The current element is referenced with tag="$". Element variables are referenced with $varname
|
|
* since using $E(varname) will be expanded to the string equivalent of the XML.
|
|
*
|
|
* <uses-permission>, <uses-feature>, and <uses-library> are updated with:
|
|
*
|
|
* <addPermission android:name="" .. />
|
|
* <addFeature android:name="" .. />
|
|
* <addLibrary android:name="" .. />
|
|
*
|
|
* Any attributes in the above commands are copied to the element added to the manifest so you
|
|
* can do the following, for example:
|
|
*
|
|
* <addFeature android:name="android.hardware.usb.host" android:required="true"/>
|
|
*
|
|
* Finally, these nodes allow copying of files useful for staging jar and so files:
|
|
*
|
|
* <copyFile src="" dst=""/>
|
|
* <copyDir src="" dst=""/>
|
|
*
|
|
* The following should be used as the base for the src and dst paths:
|
|
*
|
|
* $S(PluginDir) = directory the XML file was loaded from
|
|
* $S(EngineDir) = engine directory
|
|
* $S(BuildDir) = project's platform appropriate build directory
|
|
*
|
|
* While it is possible to write outside the APK directory, it is not recommended.
|
|
*
|
|
* If you must remove files (like development-only files from distribution builds) you can
|
|
* use this node:
|
|
*
|
|
* <deleteFiles filespec=""/>
|
|
*
|
|
* It is restricted to only removing files from the BuildDir. Here is example usage to remove
|
|
* the Oculus Signature Files (osig) from the assets directory:
|
|
*
|
|
* <deleteFiles filespec="assets/oculussig_*"/>
|
|
*
|
|
* The following sections are evaluated during the packaging or deploy stages:
|
|
*
|
|
* ** For all platforms **
|
|
* <!-- init section is always evaluated once per architecture -->
|
|
* <init> </init>
|
|
*
|
|
* ** Android Specific sections **
|
|
* <!-- optional updates applied to AndroidManifest.xml -->
|
|
* <androidManifestUpdates> </androidManifestUpdates>
|
|
*
|
|
* <!-- optional additions to proguard -->
|
|
* <proguardAdditions> </proguardAdditions>
|
|
*
|
|
* <!-- optional additions to generated build.xml before ${sdk.dir}/tools/ant/build.xml import -->
|
|
* <buildXmlPropertyAdditions> </buildXmlPropertyAdditions>
|
|
*
|
|
* <!-- optional files or directories to copy or delete from Intermediate/Android/APK before ndk-build -->
|
|
* <prebuildCopies> </prebuildCopies>
|
|
*
|
|
* <!-- optional files or directories to copy or delete from Intermediate/Android/APK after ndk-build -->
|
|
* <resourceCopies> </resourceCopies>
|
|
*
|
|
* <!-- optional additions to the GameActivity imports in GameActivity.java -->
|
|
* <gameActivityImportAdditions> </gameActivityImportAdditions>
|
|
*
|
|
* <!-- optional additions to the GameActivity after imports in GameActivity.java -->
|
|
* <gameActivityPostImportAdditions> </gameActivityPostImportAdditions>
|
|
*
|
|
* <!-- optional additions to the GameActivity class in GameActivity.java -->
|
|
* <gameActivityClassAdditions> </gameActivityOnClassAdditions>
|
|
*
|
|
* <!-- optional additions to GameActivity onCreate metadata reading in GameActivity.java -->
|
|
* <gameActivityReadMetadata> </gameActivityReadMetadata>
|
|
*
|
|
* <!-- optional additions to GameActivity onCreate in GameActivity.java -->
|
|
* <gameActivityOnCreateAdditions> </gameActivityOnCreateAdditions>
|
|
*
|
|
* <!-- optional additions to GameActivity onDestroy in GameActivity.java -->
|
|
* <gameActivityOnDestroyAdditions> </gameActivityOnDestroyAdditions>
|
|
*
|
|
* <!-- optional additions to GameActivity onStart in GameActivity.java -->
|
|
* <gameActivityOnStartAdditions> </gameActivityOnStartAdditions>
|
|
*
|
|
* <!-- optional additions to GameActivity onStop in GameActivity.java -->
|
|
* <gameActivityOnStopAdditions> </gameActivityOnStopAdditions>
|
|
*
|
|
* <!-- optional additions to GameActivity onPause in GameActivity.java -->
|
|
* <gameActivityOnPauseAdditions> </gameActivityOnPauseAdditions>
|
|
*
|
|
* <!-- optional additions to GameActivity onResume in GameActivity.java -->
|
|
* <gameActivityOnResumeAdditions> </gameActivityOnResumeAdditions>
|
|
*
|
|
* <!-- optional additions to GameActivity onNewIntent in GameActivity.java -->
|
|
* <gameActivityOnNewIntentAdditions> </gameActivityOnNewIntentAdditions>
|
|
*
|
|
* <!-- optional additions to GameActivity onActivityResult in GameActivity.java -->
|
|
* <gameActivityOnActivityResultAdditions> </gameActivityOnActivityResultAdditions>
|
|
*
|
|
* <!-- optional libraries to load in GameActivity.java before libUE4.so -->
|
|
* <soLoadLibrary> </soLoadLibrary>
|
|
*
|
|
*
|
|
* Here is the complete list of supported nodes:
|
|
*
|
|
* <isArch arch="">
|
|
* <isDistribution>
|
|
* <if> => <true> / <false>
|
|
* <while condition="">
|
|
* <return/>
|
|
* <break/>
|
|
* <continue/>
|
|
* <log text=""/>
|
|
* <insert> </insert>
|
|
* <insertValue value=""/>
|
|
* <replace find="" with""/>
|
|
* <copyFile src="" dst=""/>
|
|
* <copyDir src="" dst=""/>
|
|
* <loadLibrary name="" failmsg=""/>
|
|
* <setBool result="" value=""/>
|
|
* <setBoolFrom result="" value=""/>
|
|
* <setBoolFromProperty result="" ini="" section="" property="" default=""/>
|
|
* <setBoolNot result="" source=""/>
|
|
* <setBoolAnd result="" arg1="" arg2=""/>
|
|
* <setBoolOr result="" arg1="" arg2=""/>
|
|
* <setBoolIsEqual result="" arg1="" arg2=""/>
|
|
* <setBoolIsLess result="" arg1="" arg2=""/>
|
|
* <setBoolIsLessEqual result="" arg1="" arg2=""/>
|
|
* <setBoolIsGreater result="" arg1="" arg2=""/>
|
|
* <setBoolIsGreaterEqual result="" arg1="" arg2=""/>
|
|
* <setInt result="" value=""/>
|
|
* <setIntFrom result="" value=""/>
|
|
* <setIntFromProperty result="" ini="" section="" property="" default=""/>
|
|
* <setIntAdd result="" arg1="" arg2=""/>
|
|
* <setIntSubtract result="" arg1="" arg2=""/>
|
|
* <setIntMultiply result="" arg1="" arg2=""/>
|
|
* <setIntDivide result="" arg1="" arg2=""/>
|
|
* <setIntLength result="" source=""/>
|
|
* <setIntFindString result="" source="" find=""/>
|
|
* <setString result="" value=""/>
|
|
* <setStringFrom result="" value=""/>
|
|
* <setStringFromProperty result="" ini="" section="" property="" default=""/>
|
|
* <setStringAdd result="" arg1="" arg2=""/>
|
|
* <setStringSubstring result="" source="" index="" length=""/>
|
|
* <setStringReplace result="" source="" find="" with=""/>
|
|
*
|
|
*/
|
|
|
|
class UnrealPluginLanguage
|
|
{
|
|
/** The merged XML program to run */
|
|
private XDocument XDoc;
|
|
|
|
/** XML namespace */
|
|
private XNamespace XMLNameSpace;
|
|
private string XMLRootDefinition;
|
|
|
|
private UnrealTargetPlatform TargetPlatform;
|
|
|
|
/** Trace flag to enable debugging */
|
|
static private bool bGlobalTrace = false;
|
|
|
|
/** Project file reference */
|
|
private FileReference ProjectFile;
|
|
|
|
static private XDocument XMLDummy = XDocument.Parse("<manifest></manifest>");
|
|
|
|
private class UPLContext
|
|
{
|
|
/** Variable state */
|
|
public Dictionary<string, bool> BoolVariables;
|
|
public Dictionary<string, int> IntVariables;
|
|
public Dictionary<string, string> StringVariables;
|
|
public Dictionary<string, XElement> ElementVariables;
|
|
|
|
/** Local context trace */
|
|
public bool bTrace;
|
|
|
|
public UPLContext(string Architecture, string PluginDir)
|
|
{
|
|
BoolVariables = new Dictionary<string, bool>();
|
|
IntVariables = new Dictionary<string, int>();
|
|
StringVariables = new Dictionary<string, string>();
|
|
ElementVariables = new Dictionary<string, XElement>();
|
|
|
|
StringVariables["Architecture"] = Architecture;
|
|
StringVariables["PluginDir"] = PluginDir;
|
|
|
|
bTrace = false;
|
|
}
|
|
}
|
|
|
|
private UPLContext GlobalContext;
|
|
private Dictionary<string, UPLContext> Contexts;
|
|
private int ContextIndex;
|
|
|
|
public UnrealPluginLanguage(FileReference InProjectFile, List<string> InXMLFiles, List<string> InArchitectures, string InXMLNameSpace, string InRootDefinition, UnrealTargetPlatform InTargetPlatform)
|
|
{
|
|
ProjectFile = InProjectFile;
|
|
|
|
Contexts = new Dictionary<string, UPLContext>();
|
|
GlobalContext = new UPLContext("", "");
|
|
ContextIndex = 0;
|
|
|
|
XMLNameSpace = InXMLNameSpace;
|
|
XMLRootDefinition = InRootDefinition;
|
|
TargetPlatform = InTargetPlatform;
|
|
|
|
string PathPrefix = Path.GetFileName(Directory.GetCurrentDirectory()).Equals("Source") ? ".." : "Engine";
|
|
|
|
XDoc = XDocument.Parse("<root " + InRootDefinition + "></root>");
|
|
foreach (string Basename in InXMLFiles)
|
|
{
|
|
string Filename = Path.Combine(PathPrefix, Basename.Replace("\\", "/"));
|
|
Log.TraceInformation("\nUPL: {0}", Filename);
|
|
if (File.Exists(Filename))
|
|
{
|
|
string PluginDir = Path.GetDirectoryName(Filename);
|
|
try
|
|
{
|
|
XDocument MergeDoc = XDocument.Load(Filename);
|
|
MergeXML(MergeDoc, PluginDir, InArchitectures);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.TraceError("\nUnreal Plugin file {0} parsing failed! {1}", Filename, e);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Log.TraceError("\nUnreal Plugin file {0} missing!", Filename);
|
|
Log.TraceInformation("\nCWD: {0}", Directory.GetCurrentDirectory());
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool GetTrace() { return bGlobalTrace; }
|
|
public void SetTrace() { bGlobalTrace = true; }
|
|
public void ClearTrace() { bGlobalTrace = false; }
|
|
|
|
public bool MergeXML(XDocument MergeDoc, string PluginDir, List<string> Architectures)
|
|
{
|
|
if (MergeDoc == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// create a context for each architecture
|
|
ContextIndex++;
|
|
foreach (string Architecture in Architectures)
|
|
{
|
|
UPLContext Context = new UPLContext(Architecture, PluginDir);
|
|
Contexts[Architecture + "_" + ContextIndex] = Context;
|
|
}
|
|
|
|
// merge in the nodes
|
|
foreach (var Element in MergeDoc.Root.Elements())
|
|
{
|
|
var Parent = XDoc.Root.Element(Element.Name);
|
|
if (Parent != null)
|
|
{
|
|
var Entry = new XElement("Context", new XAttribute("index", ContextIndex.ToString()));
|
|
Entry.Add(Element.Elements());
|
|
Parent.Add(Entry);
|
|
}
|
|
else
|
|
{
|
|
var Entry = new XElement("Context", new XAttribute("index", ContextIndex.ToString()));
|
|
Entry.Add(Element.Elements());
|
|
var Base = new XElement(Element.Name);
|
|
Base.Add(Entry);
|
|
XDoc.Root.Add(Base);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public void SaveXML(string Filename)
|
|
{
|
|
if (XDoc != null)
|
|
{
|
|
XDoc.Save(Filename);
|
|
}
|
|
}
|
|
|
|
private string DumpContext(UPLContext Context)
|
|
{
|
|
StringBuilder Text = new StringBuilder();
|
|
foreach (var Variable in Context.BoolVariables)
|
|
{
|
|
Text.AppendLine(string.Format("\tbool {0} = {1}", Variable.Key, Variable.Value.ToString().ToLower()));
|
|
}
|
|
foreach (var Variable in Context.IntVariables)
|
|
{
|
|
Text.AppendLine(string.Format("\tint {0} = {1}", Variable.Key, Variable.Value));
|
|
}
|
|
foreach (var Variable in Context.StringVariables)
|
|
{
|
|
Text.AppendLine(string.Format("\tstring {0} = {1}", Variable.Key, Variable.Value));
|
|
}
|
|
foreach (var Variable in Context.ElementVariables)
|
|
{
|
|
Text.AppendLine(string.Format("\telement {0} = {1}", Variable.Key, Variable.Value));
|
|
}
|
|
return Text.ToString();
|
|
}
|
|
|
|
public string DumpVariables()
|
|
{
|
|
string Result = "Global Context:\n" + DumpContext(GlobalContext);
|
|
foreach (var Context in Contexts)
|
|
{
|
|
Result += "Context " + Context.Key + ": " + Context.Value.StringVariables["PluginDir"] + "\n" + DumpContext(Context.Value);
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
private bool GetCondition(UPLContext Context, XElement Node, string Condition, out bool Result)
|
|
{
|
|
Result = false;
|
|
if (!Context.BoolVariables.TryGetValue(Condition, out Result))
|
|
{
|
|
if (!GlobalContext.BoolVariables.TryGetValue(Condition, out Result))
|
|
{
|
|
Log.TraceWarning("\nMissing condition '{0}' in '{1}' (skipping instruction)", Condition, TraceNodeString(Node));
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private string ExpandVariables(UPLContext Context, string InputString)
|
|
{
|
|
string Result = InputString;
|
|
for (int Idx = Result.IndexOf("$B("); Idx != -1; Idx = Result.IndexOf("$B(", Idx))
|
|
{
|
|
// Find the end of the variable name
|
|
int EndIdx = Result.IndexOf(')', Idx + 3);
|
|
if (EndIdx == -1)
|
|
{
|
|
break;
|
|
}
|
|
|
|
// Extract the variable name from the string
|
|
string Name = Result.Substring(Idx + 3, EndIdx - (Idx + 3));
|
|
|
|
// Find the value for it, either from the dictionary or the environment block
|
|
bool Value;
|
|
if (!Context.BoolVariables.TryGetValue(Name, out Value))
|
|
{
|
|
if (!GlobalContext.BoolVariables.TryGetValue(Name, out Value))
|
|
{
|
|
Idx = EndIdx + 1;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
// Replace the variable, or skip past it
|
|
Result = Result.Substring(0, Idx) + Value.ToString().ToLower() + Result.Substring(EndIdx + 1);
|
|
}
|
|
for (int Idx = Result.IndexOf("$I("); Idx != -1; Idx = Result.IndexOf("$I(", Idx))
|
|
{
|
|
// Find the end of the variable name
|
|
int EndIdx = Result.IndexOf(')', Idx + 3);
|
|
if (EndIdx == -1)
|
|
{
|
|
break;
|
|
}
|
|
|
|
// Extract the variable name from the string
|
|
string Name = Result.Substring(Idx + 3, EndIdx - (Idx + 3));
|
|
|
|
// Find the value for it, either from the dictionary or the environment block
|
|
int Value;
|
|
if (!Context.IntVariables.TryGetValue(Name, out Value))
|
|
{
|
|
if (!GlobalContext.IntVariables.TryGetValue(Name, out Value))
|
|
{
|
|
Idx = EndIdx + 1;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
// Replace the variable, or skip past it
|
|
Result = Result.Substring(0, Idx) + Value.ToString() + Result.Substring(EndIdx + 1);
|
|
}
|
|
for (int Idx = Result.IndexOf("$S("); Idx != -1; Idx = Result.IndexOf("$S(", Idx))
|
|
{
|
|
// Find the end of the variable name
|
|
int EndIdx = Result.IndexOf(')', Idx + 3);
|
|
if (EndIdx == -1)
|
|
{
|
|
break;
|
|
}
|
|
|
|
// Extract the variable name from the string
|
|
string Name = Result.Substring(Idx + 3, EndIdx - (Idx + 3));
|
|
|
|
// Find the value for it, either from the dictionary or the environment block
|
|
string Value;
|
|
if (!Context.StringVariables.TryGetValue(Name, out Value))
|
|
{
|
|
if (!GlobalContext.StringVariables.TryGetValue(Name, out Value))
|
|
{
|
|
Idx = EndIdx + 1;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
// Replace the variable, or skip past it
|
|
Result = Result.Substring(0, Idx) + Value + Result.Substring(EndIdx + 1);
|
|
}
|
|
for (int Idx = Result.IndexOf("$E("); Idx != -1; Idx = Result.IndexOf("$E(", Idx))
|
|
{
|
|
// Find the end of the variable name
|
|
int EndIdx = Result.IndexOf(')', Idx + 3);
|
|
if (EndIdx == -1)
|
|
{
|
|
break;
|
|
}
|
|
|
|
// Extract the variable name from the string
|
|
string Name = Result.Substring(Idx + 3, EndIdx - (Idx + 3));
|
|
|
|
// Find the value for it, either from the dictionary or the environment block
|
|
XElement Value;
|
|
if (!Context.ElementVariables.TryGetValue(Name, out Value))
|
|
{
|
|
if (!GlobalContext.ElementVariables.TryGetValue(Name, out Value))
|
|
{
|
|
Idx = EndIdx + 1;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
// Replace the variable, or skip past it
|
|
Result = Result.Substring(0, Idx) + Value + Result.Substring(EndIdx + 1);
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
private string TraceNodeString(XElement Node)
|
|
{
|
|
string Result = Node.Name.ToString();
|
|
foreach (var Attrib in Node.Attributes())
|
|
{
|
|
Result += " " + Attrib.ToString();
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
private bool StringToBool(string Input)
|
|
{
|
|
if (Input == null)
|
|
{
|
|
return false;
|
|
}
|
|
Input = Input.ToLower();
|
|
return !(Input.Equals("0") || Input.Equals("false") || Input.Equals("off") || Input.Equals("no"));
|
|
}
|
|
|
|
private int StringToInt(string Input, XElement Node)
|
|
{
|
|
int Result = 0;
|
|
if (!int.TryParse(Input, out Result))
|
|
{
|
|
Log.TraceWarning("\nInvalid integer '{0}' in '{1}' (defaulting to 0)", Input, TraceNodeString(Node));
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
private string GetAttribute(UPLContext Context, XElement Node, string AttributeName, bool bExpand = true, bool bRequired = true, string Fallback = null)
|
|
{
|
|
XAttribute Attribute = Node.Attribute(AttributeName);
|
|
if (Attribute == null)
|
|
{
|
|
if (bRequired)
|
|
{
|
|
Log.TraceWarning("\nMissing attribute '{0}' in '{1}' (skipping instruction)", AttributeName, TraceNodeString(Node));
|
|
}
|
|
return Fallback;
|
|
}
|
|
string Result = Attribute.Value;
|
|
return bExpand ? ExpandVariables(Context, Result) : Result;
|
|
}
|
|
|
|
private string GetAttributeWithNamespace(UPLContext Context, XElement Node, XNamespace Namespace, string AttributeName, bool bExpand = true, bool bRequired = true, string Fallback = null)
|
|
{
|
|
XAttribute Attribute = Node.Attribute(Namespace + AttributeName);
|
|
if (Attribute == null)
|
|
{
|
|
if (bRequired)
|
|
{
|
|
Log.TraceWarning("\nMissing attribute '{0}' in '{1}' (skipping instruction)", AttributeName, TraceNodeString(Node));
|
|
}
|
|
return Fallback;
|
|
}
|
|
string Result = Attribute.Value;
|
|
return bExpand ? ExpandVariables(Context, Result) : Result;
|
|
}
|
|
|
|
static private Dictionary<string, ConfigCacheIni_UPL> ConfigCache = null;
|
|
|
|
private ConfigCacheIni_UPL GetConfigCacheIni_UPL(string baseIniName)
|
|
{
|
|
if (ConfigCache == null)
|
|
{
|
|
ConfigCache = new Dictionary<string, ConfigCacheIni_UPL>();
|
|
}
|
|
ConfigCacheIni_UPL config = null;
|
|
if (!ConfigCache.TryGetValue(baseIniName, out config))
|
|
{
|
|
// note: use our own ConfigCacheIni since EngineConfiguration.cs only parses RequiredSections!
|
|
config = ConfigCacheIni_UPL.CreateConfigCacheIni_UPL(TargetPlatform, baseIniName, DirectoryReference.FromFile(ProjectFile));
|
|
ConfigCache.Add(baseIniName, config);
|
|
}
|
|
return config;
|
|
}
|
|
|
|
private static void CopyFileDirectory(string SourceDir, string DestDir)
|
|
{
|
|
if (!Directory.Exists(SourceDir))
|
|
{
|
|
return;
|
|
}
|
|
|
|
string[] Files = Directory.GetFiles(SourceDir, "*.*", SearchOption.AllDirectories);
|
|
foreach (string Filename in Files)
|
|
{
|
|
// 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);
|
|
}
|
|
|
|
File.Copy(Filename, DestFilename);
|
|
|
|
// remove any read only flags
|
|
FileInfo DestFileInfo = new FileInfo(DestFilename);
|
|
DestFileInfo.Attributes = DestFileInfo.Attributes & ~FileAttributes.ReadOnly;
|
|
}
|
|
}
|
|
|
|
private static void DeleteFiles(string Filespec)
|
|
{
|
|
string BaseDir = Path.GetDirectoryName(Filespec);
|
|
string Mask = Path.GetFileName(Filespec);
|
|
|
|
if (!Directory.Exists(BaseDir))
|
|
{
|
|
return;
|
|
}
|
|
|
|
string[] Files = Directory.GetFiles(BaseDir, Mask, SearchOption.TopDirectoryOnly);
|
|
foreach (string Filename in Files)
|
|
{
|
|
File.Delete(Filename);
|
|
Log.TraceInformation("\nDeleted file {0}", Filename);
|
|
}
|
|
}
|
|
|
|
private void AddAttribute(XElement Element, string Name, string Value)
|
|
{
|
|
XAttribute Attribute;
|
|
int Index = Name.IndexOf(":");
|
|
if (Index >= 0)
|
|
{
|
|
Name = Name.Substring(Index + 1);
|
|
Attribute = Element.Attribute(XMLNameSpace + Name);
|
|
}
|
|
else
|
|
{
|
|
Attribute = Element.Attribute(Name);
|
|
}
|
|
|
|
if (Attribute != null)
|
|
{
|
|
Attribute.SetValue(Value);
|
|
}
|
|
else
|
|
{
|
|
if (Index >= 0)
|
|
{
|
|
Element.Add(new XAttribute(XMLNameSpace + Name, Value));
|
|
}
|
|
else
|
|
{
|
|
Element.Add(new XAttribute(Name, Value));
|
|
}
|
|
}
|
|
}
|
|
|
|
private void RemoveAttribute(XElement Element, string Name)
|
|
{
|
|
XAttribute Attribute;
|
|
int Index = Name.IndexOf(":");
|
|
if (Index >= 0)
|
|
{
|
|
Name = Name.Substring(Index + 1);
|
|
Attribute = Element.Attribute(XMLNameSpace + Name);
|
|
}
|
|
else
|
|
{
|
|
Attribute = Element.Attribute(Name);
|
|
}
|
|
|
|
if (Attribute != null)
|
|
{
|
|
Attribute.Remove();
|
|
}
|
|
}
|
|
|
|
private void AddElements(XElement Target, XElement Source)
|
|
{
|
|
if (Source.HasElements)
|
|
{
|
|
foreach (var Index in Source.Elements())
|
|
{
|
|
// if (Target.Element(Index.Name) == null)
|
|
{
|
|
Target.Add(Index);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public string ProcessPluginNode(string Architecture, string NodeName, string Input)
|
|
{
|
|
return ProcessPluginNode(Architecture, NodeName, Input, ref XMLDummy);
|
|
}
|
|
|
|
public string ProcessPluginNode(string Architecture, string NodeName, string Input, ref XDocument XMLWork)
|
|
{
|
|
// add all instructions to execution list
|
|
var ExecutionStack = new Stack<XElement>();
|
|
var StartNode = XDoc.Root.Element(NodeName);
|
|
if (StartNode != null)
|
|
{
|
|
foreach (var Instruction in StartNode.Elements().Reverse())
|
|
{
|
|
ExecutionStack.Push(Instruction);
|
|
}
|
|
}
|
|
|
|
if (ExecutionStack.Count == 0)
|
|
{
|
|
return Input;
|
|
}
|
|
|
|
var ContextStack = new Stack<UPLContext>();
|
|
UPLContext CurrentContext = GlobalContext;
|
|
|
|
// update Output in global context
|
|
GlobalContext.StringVariables["Output"] = Input;
|
|
|
|
var ElementStack = new Stack<XElement>();
|
|
XElement CurrentElement = XMLWork.Elements().First();
|
|
|
|
// run the instructions
|
|
while (ExecutionStack.Count > 0)
|
|
{
|
|
var Node = ExecutionStack.Pop();
|
|
if (bGlobalTrace || CurrentContext.bTrace)
|
|
{
|
|
Log.TraceInformation("Execute: '{0}'", TraceNodeString(Node));
|
|
}
|
|
switch (Node.Name.ToString())
|
|
{
|
|
case "trace":
|
|
{
|
|
string Enable = GetAttribute(CurrentContext, Node, "enable");
|
|
if (Enable != null)
|
|
{
|
|
CurrentContext.bTrace = StringToBool(Enable);
|
|
if (!bGlobalTrace && CurrentContext.bTrace)
|
|
{
|
|
Log.TraceInformation("Context: '{0}' using Architecture='{1}', NodeName='{2}', Input='{3}'", CurrentContext.StringVariables["PluginDir"], Architecture, NodeName, Input);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "dumpvars":
|
|
{
|
|
if (!bGlobalTrace && !CurrentContext.bTrace)
|
|
{
|
|
Log.TraceInformation("Context: '{0}' using Architecture='{1}', NodeName='{2}', Input='{3}'", CurrentContext.StringVariables["PluginDir"], Architecture, NodeName, Input);
|
|
}
|
|
Log.TraceInformation("Variables:\n{0}", DumpContext(CurrentContext));
|
|
}
|
|
break;
|
|
|
|
case "Context":
|
|
{
|
|
ContextStack.Push(CurrentContext);
|
|
string index = GetAttribute(CurrentContext, Node, "index");
|
|
CurrentContext = Contexts[Architecture + "_" + index];
|
|
ExecutionStack.Push(new XElement("PopContext"));
|
|
foreach (var instruction in Node.Elements().Reverse())
|
|
{
|
|
ExecutionStack.Push(instruction);
|
|
}
|
|
|
|
if (bGlobalTrace || CurrentContext.bTrace)
|
|
{
|
|
Log.TraceInformation("Context: '{0}' using Architecture='{1}', NodeName='{2}', Input='{3}'", CurrentContext.StringVariables["PluginDir"], Architecture, NodeName, Input);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "PopContext":
|
|
{
|
|
CurrentContext = ContextStack.Pop();
|
|
}
|
|
break;
|
|
|
|
case "PopElement":
|
|
{
|
|
CurrentElement = ElementStack.Pop();
|
|
}
|
|
break;
|
|
|
|
case "isArch":
|
|
{
|
|
string arch = GetAttribute(CurrentContext, Node, "arch");
|
|
if (arch != null && arch.Equals(Architecture))
|
|
{
|
|
foreach (var instruction in Node.Elements().Reverse())
|
|
{
|
|
ExecutionStack.Push(instruction);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "isDistribution":
|
|
{
|
|
bool Result = false;
|
|
if (GetCondition(CurrentContext, Node, "Distribution", out Result))
|
|
{
|
|
if (Result)
|
|
{
|
|
foreach (var Instruction in Node.Elements().Reverse())
|
|
{
|
|
ExecutionStack.Push(Instruction);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "if":
|
|
{
|
|
bool Result;
|
|
if (GetCondition(CurrentContext, Node, GetAttribute(CurrentContext, Node, "condition"), out Result))
|
|
{
|
|
var ResultNode = Node.Element(Result ? "true" : "false");
|
|
if (ResultNode != null)
|
|
{
|
|
foreach (var Instruction in ResultNode.Elements().Reverse())
|
|
{
|
|
ExecutionStack.Push(Instruction);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "while":
|
|
{
|
|
bool Result;
|
|
if (GetCondition(CurrentContext, Node, GetAttribute(CurrentContext, Node, "condition"), out Result))
|
|
{
|
|
if (Result)
|
|
{
|
|
var ResultNode = Node.Elements();
|
|
if (ResultNode != null)
|
|
{
|
|
ExecutionStack.Push(Node);
|
|
foreach (var Instruction in ResultNode.Reverse())
|
|
{
|
|
ExecutionStack.Push(Instruction);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "return":
|
|
{
|
|
while (ExecutionStack.Count > 0)
|
|
{
|
|
ExecutionStack.Pop();
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "break":
|
|
{
|
|
// remove up to while (or acts like a return if outside by removing everything)
|
|
while (ExecutionStack.Count > 0)
|
|
{
|
|
Node = ExecutionStack.Pop();
|
|
if (Node.Name.ToString().Equals("while"))
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "continue":
|
|
{
|
|
// remove up to while (or acts like a return if outside by removing everything)
|
|
while (ExecutionStack.Count > 0)
|
|
{
|
|
Node = ExecutionStack.Pop();
|
|
if (Node.Name.ToString().Equals("while"))
|
|
{
|
|
ExecutionStack.Push(Node);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "log":
|
|
{
|
|
string Text = GetAttribute(CurrentContext, Node, "text");
|
|
if (Text != null)
|
|
{
|
|
Log.TraceInformation("{0}", Text);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "loopElements":
|
|
{
|
|
string Tag = GetAttribute(CurrentContext, Node, "tag");
|
|
ElementStack.Push(CurrentElement);
|
|
ExecutionStack.Push(new XElement("PopElement"));
|
|
var WorkList = (Tag == "$") ? CurrentElement.Elements().Reverse() : CurrentElement.Descendants(Tag).Reverse();
|
|
foreach (var WorkNode in WorkList)
|
|
{
|
|
foreach (var Instruction in Node.Elements().Reverse())
|
|
{
|
|
ExecutionStack.Push(Instruction);
|
|
}
|
|
ElementStack.Push(WorkNode);
|
|
ExecutionStack.Push(new XElement("PopElement"));
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "addAttribute":
|
|
{
|
|
string Tag = GetAttribute(CurrentContext, Node, "tag");
|
|
string Name = GetAttribute(CurrentContext, Node, "name");
|
|
string Value = GetAttribute(CurrentContext, Node, "value");
|
|
if (Tag != null && Name != null && Value != null)
|
|
{
|
|
if (Tag.StartsWith("$"))
|
|
{
|
|
XElement Target = CurrentElement;
|
|
if (Tag.Length > 1)
|
|
{
|
|
if (!CurrentContext.ElementVariables.TryGetValue(Tag.Substring(1), out Target))
|
|
{
|
|
if (!GlobalContext.ElementVariables.TryGetValue(Tag.Substring(1), out Target))
|
|
{
|
|
Log.TraceWarning("\nMissing element variable '{0}' in '{1}' (skipping instruction)", Tag, TraceNodeString(Node));
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
AddAttribute(Target, Name, Value);
|
|
}
|
|
else
|
|
{
|
|
if (CurrentElement.Name.ToString().Equals(Tag))
|
|
{
|
|
AddAttribute(CurrentElement, Name, Value);
|
|
}
|
|
foreach (var WorkNode in CurrentElement.Descendants(Tag))
|
|
{
|
|
AddAttribute(WorkNode, Name, Value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "removeAttribute":
|
|
{
|
|
string Tag = GetAttribute(CurrentContext, Node, "tag");
|
|
string Name = GetAttribute(CurrentContext, Node, "name");
|
|
if (Tag != null && Name != null)
|
|
{
|
|
if (Tag.StartsWith("$"))
|
|
{
|
|
XElement Target = CurrentElement;
|
|
if (Tag.Length > 1)
|
|
{
|
|
if (!CurrentContext.ElementVariables.TryGetValue(Tag.Substring(1), out Target))
|
|
{
|
|
if (!GlobalContext.ElementVariables.TryGetValue(Tag.Substring(1), out Target))
|
|
{
|
|
Log.TraceWarning("\nMissing element variable '{0}' in '{1}' (skipping instruction)", Tag, TraceNodeString(Node));
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
RemoveAttribute(Target, Name);
|
|
}
|
|
else
|
|
{
|
|
if (CurrentElement.Name.ToString().Equals(Tag))
|
|
{
|
|
RemoveAttribute(CurrentElement, Name);
|
|
}
|
|
foreach (var WorkNode in CurrentElement.Descendants(Tag))
|
|
{
|
|
RemoveAttribute(WorkNode, Name);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "addPermission":
|
|
{
|
|
string Name = GetAttributeWithNamespace(CurrentContext, Node, XMLNameSpace, "name");
|
|
if (Name != null)
|
|
{
|
|
// make sure it isn't already added
|
|
bool bFound = false;
|
|
foreach (var Element in XMLWork.Descendants("uses-permission"))
|
|
{
|
|
XAttribute Attribute = Element.Attribute(XMLNameSpace + "name");
|
|
if (Attribute != null)
|
|
{
|
|
if (Attribute.Value == Name)
|
|
{
|
|
bFound = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// add it if not found
|
|
if (!bFound)
|
|
{
|
|
XMLWork.Element("manifest").Add(new XElement("uses-permission", Node.Attributes()));
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "removePermission":
|
|
{
|
|
string Name = GetAttributeWithNamespace(CurrentContext, Node, XMLNameSpace, "name");
|
|
if (Name != null)
|
|
{
|
|
foreach (var Element in XMLWork.Descendants("uses-permission"))
|
|
{
|
|
XAttribute Attribute = Element.Attribute(XMLNameSpace + "name");
|
|
if (Attribute != null)
|
|
{
|
|
if (Attribute.Value == Name)
|
|
{
|
|
Element.Remove();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "addFeature":
|
|
{
|
|
string Name = GetAttributeWithNamespace(CurrentContext, Node, XMLNameSpace, "name");
|
|
if (Name != null)
|
|
{
|
|
// make sure it isn't already added
|
|
bool bFound = false;
|
|
foreach (var Element in XMLWork.Descendants("uses-feature"))
|
|
{
|
|
XAttribute Attribute = Element.Attribute(XMLNameSpace + "name");
|
|
if (Attribute != null)
|
|
{
|
|
if (Attribute.Value == Name)
|
|
{
|
|
bFound = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// add it if not found
|
|
if (!bFound)
|
|
{
|
|
XMLWork.Element("manifest").Add(new XElement("uses-feature", Node.Attributes()));
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "removeFeature":
|
|
{
|
|
string Name = GetAttributeWithNamespace(CurrentContext, Node, XMLNameSpace, "name");
|
|
if (Name != null)
|
|
{
|
|
foreach (var Element in XMLWork.Descendants("uses-feature"))
|
|
{
|
|
XAttribute Attribute = Element.Attribute(XMLNameSpace + "name");
|
|
if (Attribute != null)
|
|
{
|
|
if (Attribute.Value == Name)
|
|
{
|
|
Element.Remove();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "addLibrary":
|
|
{
|
|
string Name = GetAttributeWithNamespace(CurrentContext, Node, XMLNameSpace, "name");
|
|
if (Name != null)
|
|
{
|
|
// make sure it isn't already added
|
|
bool bFound = false;
|
|
foreach (var Element in XMLWork.Descendants("uses-library"))
|
|
{
|
|
XAttribute Attribute = Element.Attribute(XMLNameSpace + "name");
|
|
if (Attribute != null)
|
|
{
|
|
if (Attribute.Value == Name)
|
|
{
|
|
bFound = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// add it if not found
|
|
if (!bFound)
|
|
{
|
|
XMLWork.Element("manifest").Element("application").Add(new XElement("uses-library", Node.Attributes()));
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "removeLibrary":
|
|
{
|
|
string Name = GetAttributeWithNamespace(CurrentContext, Node, XMLNameSpace, "name");
|
|
if (Name != null)
|
|
{
|
|
foreach (var Element in XMLWork.Descendants("uses-library"))
|
|
{
|
|
XAttribute Attribute = Element.Attribute(XMLNameSpace + "name");
|
|
if (Attribute != null)
|
|
{
|
|
if (Attribute.Value == Name)
|
|
{
|
|
Element.Remove();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "removeElement":
|
|
{
|
|
string Tag = GetAttribute(CurrentContext, Node, "tag");
|
|
if (Tag != null)
|
|
{
|
|
if (Tag == "$")
|
|
{
|
|
XElement Parent = CurrentElement.Parent;
|
|
CurrentElement.Remove();
|
|
CurrentElement = Parent;
|
|
}
|
|
else
|
|
{
|
|
// use a list since Remove() may modify it
|
|
foreach (var Element in XMLWork.Descendants(Tag).ToList())
|
|
{
|
|
Element.Remove();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "addElement":
|
|
{
|
|
string Tag = GetAttribute(CurrentContext, Node, "tag");
|
|
string Name = GetAttribute(CurrentContext, Node, "name");
|
|
if (Tag != null && Name != null)
|
|
{
|
|
XElement Element;
|
|
if (!CurrentContext.ElementVariables.TryGetValue(Name, out Element))
|
|
{
|
|
if (!GlobalContext.ElementVariables.TryGetValue(Name, out Element))
|
|
{
|
|
Log.TraceWarning("\nMissing element variable '{0}' in '{1}' (skipping instruction)", Name, TraceNodeString(Node));
|
|
continue;
|
|
}
|
|
}
|
|
if (Tag.StartsWith("$"))
|
|
{
|
|
XElement Target = CurrentElement;
|
|
if (Tag.Length > 1)
|
|
{
|
|
if (!CurrentContext.ElementVariables.TryGetValue(Tag.Substring(1), out Target))
|
|
{
|
|
if (!GlobalContext.ElementVariables.TryGetValue(Tag.Substring(1), out Target))
|
|
{
|
|
Log.TraceWarning("\nMissing element variable '{0}' in '{1}' (skipping instruction)", Tag, TraceNodeString(Node));
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
Target.Add(new XElement(Element));
|
|
}
|
|
else
|
|
{
|
|
if (CurrentElement.Name.ToString().Equals(Tag))
|
|
{
|
|
CurrentElement.Add(new XElement(Element));
|
|
}
|
|
foreach (var WorkNode in CurrentElement.Descendants(Tag))
|
|
{
|
|
WorkNode.Add(new XElement(Element));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "addElements":
|
|
{
|
|
string Tag = GetAttribute(CurrentContext, Node, "tag");
|
|
if (Tag != null)
|
|
{
|
|
if (Tag.StartsWith("$"))
|
|
{
|
|
XElement Target = CurrentElement;
|
|
if (Tag.Length > 1)
|
|
{
|
|
if (!CurrentContext.ElementVariables.TryGetValue(Tag.Substring(1), out Target))
|
|
{
|
|
if (!GlobalContext.ElementVariables.TryGetValue(Tag.Substring(1), out Target))
|
|
{
|
|
Log.TraceWarning("\nMissing element variable '{0}' in '{1}' (skipping instruction)", Tag, TraceNodeString(Node));
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
AddElements(Target, Node);
|
|
}
|
|
else
|
|
{
|
|
if (CurrentElement.Name.ToString().Equals(Tag))
|
|
{
|
|
AddElements(CurrentElement, Node);
|
|
}
|
|
foreach (var WorkNode in CurrentElement.Descendants(Tag))
|
|
{
|
|
AddElements(WorkNode, Node);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "insert":
|
|
{
|
|
if (Node.HasElements)
|
|
{
|
|
foreach (var Element in Node.Elements())
|
|
{
|
|
string Value = Element.ToString().Replace(" " + XMLRootDefinition + " ", "");
|
|
GlobalContext.StringVariables["Output"] += Value + "\n";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string Value = Node.Value.ToString();
|
|
|
|
// trim trailing tabs
|
|
int Index = Value.Length;
|
|
while (Index > 0 && Value[Index - 1] == '\t')
|
|
{
|
|
Index--;
|
|
}
|
|
if (Index < Value.Length)
|
|
{
|
|
Value = Value.Substring(0, Index);
|
|
}
|
|
|
|
// trim leading newlines
|
|
Index = 0;
|
|
while (Index < Value.Length && Value[Index] == '\n')
|
|
{
|
|
Index++;
|
|
}
|
|
|
|
if (Index < Value.Length)
|
|
{
|
|
GlobalContext.StringVariables["Output"] += Value.Substring(Index);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "insertNewline":
|
|
GlobalContext.StringVariables["Output"] += "\n";
|
|
break;
|
|
|
|
case "insertValue":
|
|
{
|
|
string Value = GetAttribute(CurrentContext, Node, "value");
|
|
if (Value != null)
|
|
{
|
|
GlobalContext.StringVariables["Output"] += Value;
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "replace":
|
|
{
|
|
string Find = GetAttribute(CurrentContext, Node, "find");
|
|
string With = GetAttribute(CurrentContext, Node, "with");
|
|
if (Find != null && With != null)
|
|
{
|
|
GlobalContext.StringVariables["Output"] = GlobalContext.StringVariables["Output"].Replace(Find, With);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "copyFile":
|
|
{
|
|
string Src = GetAttribute(CurrentContext, Node, "src");
|
|
string Dst = GetAttribute(CurrentContext, Node, "dst");
|
|
if (Src != null && Dst != null)
|
|
{
|
|
if (File.Exists(Src))
|
|
{
|
|
// check to see if newer than last time we copied
|
|
bool bFileExists = File.Exists(Dst);
|
|
TimeSpan Diff = File.GetLastWriteTimeUtc(Dst) - File.GetLastWriteTimeUtc(Src);
|
|
if (!bFileExists || Diff.TotalSeconds < -1 || Diff.TotalSeconds > 1)
|
|
{
|
|
if (bFileExists)
|
|
{
|
|
File.Delete(Dst);
|
|
}
|
|
Directory.CreateDirectory(Path.GetDirectoryName(Dst));
|
|
File.Copy(Src, Dst, true);
|
|
Log.TraceInformation("\nFile {0} copied to {1}", Src, Dst);
|
|
|
|
// remove any read only flags
|
|
FileInfo DestFileInfo = new FileInfo(Dst);
|
|
DestFileInfo.Attributes = DestFileInfo.Attributes & ~FileAttributes.ReadOnly;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "copyDir":
|
|
{
|
|
string Src = GetAttribute(CurrentContext, Node, "src");
|
|
string Dst = GetAttribute(CurrentContext, Node, "dst");
|
|
if (Src != null && Dst != null)
|
|
{
|
|
CopyFileDirectory(Src, Dst);
|
|
Log.TraceInformation("\nDirectory {0} copied to {1}", Src, Dst);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "deleteFiles":
|
|
{
|
|
string Filespec = GetAttribute(CurrentContext, Node, "filespec");
|
|
if (Filespec != null)
|
|
{
|
|
if (Filespec.Contains(":") || Filespec.Contains(".."))
|
|
{
|
|
Log.TraceInformation("\nFilespec {0} not allowed; ignored.", Filespec);
|
|
}
|
|
else
|
|
{
|
|
// force relative to BuildDir (and only from global context so someone doesn't try to be clever)
|
|
DeleteFiles(Path.Combine(GlobalContext.StringVariables["BuildDir"], Filespec));
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "loadLibrary":
|
|
{
|
|
string Name = GetAttribute(CurrentContext, Node, "name");
|
|
string FailMsg = GetAttribute(CurrentContext, Node, "failmsg", true, false);
|
|
if (Name != null)
|
|
{
|
|
string Work = "\t\ttry\n" +
|
|
"\t\t{\n" +
|
|
"\t\t\tSystem.loadLibrary(\"" + Name + "\");\n" +
|
|
"\t\t}\n" +
|
|
"\t\tcatch (java.lang.UnsatisfiedLinkError e)\n" +
|
|
"\t\t{\n";
|
|
if (FailMsg != null)
|
|
{
|
|
Work += "\t\t\tLog.debug(\"" + FailMsg + "\");\n";
|
|
}
|
|
GlobalContext.StringVariables["Output"] += Work + "\t\t}\n";
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setBool":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Value = GetAttribute(CurrentContext, Node, "value", true, false, "false");
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.BoolVariables[Result] = StringToBool(Value);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setBoolFrom":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Value = GetAttribute(CurrentContext, Node, "value", true, false, "false");
|
|
if (Result != null)
|
|
{
|
|
Value = ExpandVariables(CurrentContext, "$B(" + Value + ")");
|
|
CurrentContext.BoolVariables[Result] = StringToBool(Value);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setBoolFromProperty":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Ini = GetAttribute(CurrentContext, Node, "ini");
|
|
string Section = GetAttribute(CurrentContext, Node, "section");
|
|
string Property = GetAttribute(CurrentContext, Node, "property");
|
|
string DefaultVal = GetAttribute(CurrentContext, Node, "default", true, false, "false");
|
|
if (Result != null && Ini != null && Section != null && Property != null)
|
|
{
|
|
bool Value = StringToBool(DefaultVal);
|
|
|
|
ConfigCacheIni_UPL ConfigIni = GetConfigCacheIni_UPL(Ini);
|
|
if (ConfigIni != null)
|
|
{
|
|
if (!ConfigIni.GetBool(Section, Property, out Value))
|
|
{
|
|
Value = StringToBool(DefaultVal);
|
|
}
|
|
}
|
|
CurrentContext.BoolVariables[Result] = Value;
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setBoolContains":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Source = GetAttribute(CurrentContext, Node, "source", true, false, "");
|
|
string Find = GetAttribute(CurrentContext, Node, "find", true, false, "");
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.BoolVariables[Result] = Source.Contains(Find);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setBoolStartsWith":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Source = GetAttribute(CurrentContext, Node, "source", true, false, "");
|
|
string Find = GetAttribute(CurrentContext, Node, "find", true, false, "");
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.BoolVariables[Result] = Source.StartsWith(Find);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setBoolEndsWith":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Source = GetAttribute(CurrentContext, Node, "source", true, false, "");
|
|
string Find = GetAttribute(CurrentContext, Node, "find", true, false, "");
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.BoolVariables[Result] = Source.EndsWith(Find);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setBoolNot":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Source = GetAttribute(CurrentContext, Node, "source", true, false, "false");
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.BoolVariables[Result] = !StringToBool(Source);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setBoolAnd":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Arg1 = GetAttribute(CurrentContext, Node, "arg1", true, false, "false");
|
|
string Arg2 = GetAttribute(CurrentContext, Node, "arg2", true, false, "false");
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.BoolVariables[Result] = StringToBool(Arg1) && StringToBool(Arg2);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setBoolOr":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Arg1 = GetAttribute(CurrentContext, Node, "arg1", true, false, "false");
|
|
string Arg2 = GetAttribute(CurrentContext, Node, "arg2", true, false, "false");
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.BoolVariables[Result] = StringToBool(Arg1) || StringToBool(Arg2);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setBoolIsEqual":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Arg1 = GetAttribute(CurrentContext, Node, "arg1", true, false, "");
|
|
string Arg2 = GetAttribute(CurrentContext, Node, "arg2", true, false, "");
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.BoolVariables[Result] = Arg1.Equals(Arg2);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setBoolIsLess":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Arg1 = GetAttribute(CurrentContext, Node, "arg1", true, false);
|
|
string Arg2 = GetAttribute(CurrentContext, Node, "arg2", true, false);
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.BoolVariables[Result] = (StringToInt(Arg1, Node) < StringToInt(Arg2, Node));
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setBoolIsLessEqual":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Arg1 = GetAttribute(CurrentContext, Node, "arg1", true, false);
|
|
string Arg2 = GetAttribute(CurrentContext, Node, "arg2", true, false);
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.BoolVariables[Result] = (StringToInt(Arg1, Node) <= StringToInt(Arg2, Node));
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setBoolIsGreater":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Arg1 = GetAttribute(CurrentContext, Node, "arg1", true, false);
|
|
string Arg2 = GetAttribute(CurrentContext, Node, "arg2", true, false);
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.BoolVariables[Result] = (StringToInt(Arg1, Node) > StringToInt(Arg2, Node));
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setBoolIsGreaterEqual":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Arg1 = GetAttribute(CurrentContext, Node, "arg1", true, false);
|
|
string Arg2 = GetAttribute(CurrentContext, Node, "arg2", true, false);
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.BoolVariables[Result] = (StringToInt(Arg1, Node) >= StringToInt(Arg2, Node));
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setInt":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Value = GetAttribute(CurrentContext, Node, "value", true, false, "0");
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.IntVariables[Result] = StringToInt(Value, Node);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setIntFrom":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Value = GetAttribute(CurrentContext, Node, "value", true, false, "0");
|
|
if (Result != null)
|
|
{
|
|
Value = ExpandVariables(CurrentContext, "$I(" + Value + ")");
|
|
CurrentContext.IntVariables[Result] = StringToInt(Value, Node);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setIntFromProperty":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Ini = GetAttribute(CurrentContext, Node, "ini");
|
|
string Section = GetAttribute(CurrentContext, Node, "section");
|
|
string Property = GetAttribute(CurrentContext, Node, "property");
|
|
string DefaultVal = GetAttribute(CurrentContext, Node, "default", true, false, "0");
|
|
if (Result != null && Ini != null && Section != null && Property != null)
|
|
{
|
|
int Value = StringToInt(DefaultVal, Node);
|
|
|
|
ConfigCacheIni_UPL ConfigIni = GetConfigCacheIni_UPL(Ini);
|
|
if (ConfigIni != null)
|
|
{
|
|
ConfigIni.GetInt32(Section, Property, out Value);
|
|
}
|
|
CurrentContext.IntVariables[Result] = Value;
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setIntAdd":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Arg1 = GetAttribute(CurrentContext, Node, "arg1", true, false, "0");
|
|
string Arg2 = GetAttribute(CurrentContext, Node, "arg2", true, false, "0");
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.IntVariables[Result] = StringToInt(Arg1, Node) + StringToInt(Arg2, Node);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setIntSubtract":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Arg1 = GetAttribute(CurrentContext, Node, "arg1", true, false, "0");
|
|
string Arg2 = GetAttribute(CurrentContext, Node, "arg2", true, false, "0");
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.IntVariables[Result] = StringToInt(Arg1, Node) - StringToInt(Arg2, Node);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setIntMultiply":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Arg1 = GetAttribute(CurrentContext, Node, "arg1", true, false, "1");
|
|
string Arg2 = GetAttribute(CurrentContext, Node, "arg2", true, false, "1");
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.IntVariables[Result] = StringToInt(Arg1, Node) * StringToInt(Arg2, Node);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setIntDivide":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Arg1 = GetAttribute(CurrentContext, Node, "arg1", true, false, "1");
|
|
string Arg2 = GetAttribute(CurrentContext, Node, "arg2", true, false, "1");
|
|
if (Result != null)
|
|
{
|
|
int Denominator = StringToInt(Arg2, Node);
|
|
if (Denominator == 0)
|
|
{
|
|
CurrentContext.IntVariables[Result] = StringToInt(Arg1, Node);
|
|
}
|
|
else
|
|
{
|
|
CurrentContext.IntVariables[Result] = StringToInt(Arg1, Node) / Denominator;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setIntLength":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Source = GetAttribute(CurrentContext, Node, "source", true, false, "");
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.IntVariables[Result] = Source.Length;
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setIntFindString":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Source = GetAttribute(CurrentContext, Node, "source", true, false, "");
|
|
string Find = GetAttribute(CurrentContext, Node, "find", true, false, "");
|
|
if (Result != null)
|
|
{
|
|
CurrentContext.IntVariables[Result] = Source.IndexOf(Find);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setString":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Value = GetAttribute(CurrentContext, Node, "value", true, false, "");
|
|
if (Result != null)
|
|
{
|
|
if (Result == "Output")
|
|
{
|
|
GlobalContext.StringVariables["Output"] = Value;
|
|
}
|
|
else
|
|
{
|
|
CurrentContext.StringVariables[Result] = Value;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setStringFrom":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Value = GetAttribute(CurrentContext, Node, "value", true, false, "0");
|
|
if (Result != null)
|
|
{
|
|
Value = ExpandVariables(CurrentContext, "$S(" + Value + ")");
|
|
CurrentContext.StringVariables[Result] = Value;
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setStringFromTag":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Tag = GetAttribute(CurrentContext, Node, "tag", true, false, "$");
|
|
if (Result != null)
|
|
{
|
|
XElement Element = CurrentElement;
|
|
if (Tag.StartsWith("$"))
|
|
{
|
|
if (Tag.Length > 1)
|
|
{
|
|
if (!CurrentContext.ElementVariables.TryGetValue(Tag.Substring(1), out Element))
|
|
{
|
|
if (!GlobalContext.ElementVariables.TryGetValue(Tag.Substring(1), out Element))
|
|
{
|
|
Log.TraceWarning("\nMissing element variable '{0}' in '{1}' (skipping instruction)", Tag, TraceNodeString(Node));
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
CurrentContext.StringVariables[Result] = Element.Name.ToString();
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setStringFromAttribute":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Tag = GetAttribute(CurrentContext, Node, "tag");
|
|
string Name = GetAttribute(CurrentContext, Node, "name");
|
|
if (Result != null && Tag != null && Name != null)
|
|
{
|
|
XElement Element = CurrentElement;
|
|
if (Tag.StartsWith("$"))
|
|
{
|
|
if (Tag.Length > 1)
|
|
{
|
|
if (!CurrentContext.ElementVariables.TryGetValue(Tag.Substring(1), out Element))
|
|
{
|
|
if (!GlobalContext.ElementVariables.TryGetValue(Tag.Substring(1), out Element))
|
|
{
|
|
Log.TraceWarning("\nMissing element variable '{0}' in '{1}' (skipping instruction)", Tag, TraceNodeString(Node));
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
XAttribute Attribute;
|
|
int Index = Name.IndexOf(":");
|
|
if (Index >= 0)
|
|
{
|
|
Name = Name.Substring(Index + 1);
|
|
Attribute = Element.Attribute(XMLNameSpace + Name);
|
|
}
|
|
else
|
|
{
|
|
Attribute = Element.Attribute(Name);
|
|
}
|
|
|
|
CurrentContext.StringVariables[Result] = (Attribute != null) ? Attribute.Value : "";
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setStringFromProperty":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Ini = GetAttribute(CurrentContext, Node, "ini");
|
|
string Section = GetAttribute(CurrentContext, Node, "section");
|
|
string Property = GetAttribute(CurrentContext, Node, "property");
|
|
string DefaultVal = GetAttribute(CurrentContext, Node, "default", true, false, "");
|
|
if (Result != null && Ini != null && Section != null && Property != null)
|
|
{
|
|
string Value = DefaultVal;
|
|
|
|
ConfigCacheIni_UPL ConfigIni = GetConfigCacheIni_UPL(Ini);
|
|
if (ConfigIni != null)
|
|
{
|
|
if (!ConfigIni.GetString(Section, Property, out Value))
|
|
{
|
|
// If the string was not found in the config, Value will have been set to an empty string
|
|
// Set it back to the DefaultVal
|
|
Value = DefaultVal;
|
|
}
|
|
}
|
|
if (Result == "Output")
|
|
{
|
|
GlobalContext.StringVariables["Output"] = Value;
|
|
}
|
|
else
|
|
{
|
|
CurrentContext.StringVariables[Result] = Value;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setStringAdd":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Arg1 = GetAttribute(CurrentContext, Node, "arg1", true, false, "");
|
|
string Arg2 = GetAttribute(CurrentContext, Node, "arg2", true, false, "");
|
|
if (Result != null)
|
|
{
|
|
string Value = Arg1 + Arg2;
|
|
if (Result == "Output")
|
|
{
|
|
GlobalContext.StringVariables["Output"] = Value;
|
|
}
|
|
else
|
|
{
|
|
CurrentContext.StringVariables[Result] = Value;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setStringSubstring":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Source = GetAttribute(CurrentContext, Node, "source", true, false, "");
|
|
string Start = GetAttribute(CurrentContext, Node, "start", true, false, "0");
|
|
string Length = GetAttribute(CurrentContext, Node, "length", true, false, "0");
|
|
if (Result != null && Source != null)
|
|
{
|
|
int Index = StringToInt(Start, Node);
|
|
int Count = StringToInt(Length, Node);
|
|
Index = (Index < 0) ? 0 : (Index > Source.Length) ? Source.Length : Index;
|
|
Count = (Index + Count > Source.Length) ? Source.Length - Index : Count;
|
|
string Value = Source.Substring(Index, Count);
|
|
if (Result == "Output")
|
|
{
|
|
GlobalContext.StringVariables["Output"] = Value;
|
|
}
|
|
else
|
|
{
|
|
CurrentContext.StringVariables[Result] = Value;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setStringReplace":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Source = GetAttribute(CurrentContext, Node, "source", true, false, "");
|
|
string Find = GetAttribute(CurrentContext, Node, "find");
|
|
string With = GetAttribute(CurrentContext, Node, "with", true, false, "");
|
|
if (Result != null && Find != null)
|
|
{
|
|
string Value = Source.Replace(Find, With);
|
|
if (Result == "Output")
|
|
{
|
|
GlobalContext.StringVariables["Output"] = Value;
|
|
}
|
|
else
|
|
{
|
|
CurrentContext.StringVariables[Result] = Value;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case "setElement":
|
|
{
|
|
string Result = GetAttribute(CurrentContext, Node, "result");
|
|
string Value = GetAttribute(CurrentContext, Node, "value", true, false);
|
|
string Text = GetAttribute(CurrentContext, Node, "text", true, false);
|
|
string Parse = GetAttribute(CurrentContext, Node, "xml", true, false);
|
|
if (Result != null)
|
|
{
|
|
if (Value != null)
|
|
{
|
|
XElement NewElement = new XElement(Value);
|
|
if (Text != null)
|
|
{
|
|
NewElement.Value = Text;
|
|
}
|
|
CurrentContext.ElementVariables[Result] = NewElement;
|
|
}
|
|
else if (Parse != null)
|
|
{
|
|
try
|
|
{
|
|
CurrentContext.ElementVariables[Result] = XElement.Parse(Parse);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.TraceError("\nXML parsing {0} failed! {1} (skipping instruction)", Parse, e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
default:
|
|
Log.TraceWarning("\nUnknown command: {0}", Node.Name);
|
|
break;
|
|
}
|
|
}
|
|
|
|
return GlobalContext.StringVariables["Output"];
|
|
}
|
|
|
|
public void Init(List<string> Architectures, bool bDistribution, string EngineDirectory, string BuildDirectory, string ProjectDirectory, string Configuration)
|
|
{
|
|
GlobalContext.BoolVariables["Distribution"] = bDistribution;
|
|
GlobalContext.StringVariables["EngineDir"] = EngineDirectory;
|
|
GlobalContext.StringVariables["BuildDir"] = BuildDirectory;
|
|
GlobalContext.StringVariables["ProjectDir"] = ProjectDirectory;
|
|
GlobalContext.StringVariables["Configuration"] = Configuration;
|
|
|
|
foreach (string Arch in Architectures)
|
|
{
|
|
Log.TraceInformation("UPL Init: {0}", Arch);
|
|
ProcessPluginNode(Arch, "init", "");
|
|
}
|
|
|
|
if (bGlobalTrace)
|
|
{
|
|
Log.TraceInformation("\nVariables:\n{0}", DumpVariables());
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Equivalent of FConfigCacheIni_UPL. Parses ini files. This version reads ALL sections since ConfigCacheIni_UPL does NOT
|
|
/// </summary>
|
|
class ConfigCacheIni_UPL
|
|
{
|
|
/// <summary>
|
|
/// Exception when parsing ini files
|
|
/// </summary>
|
|
public class IniParsingException : Exception
|
|
{
|
|
public IniParsingException(string Message)
|
|
: base(Message)
|
|
{ }
|
|
public IniParsingException(string Format, params object[] Args)
|
|
: base(String.Format(Format, Args))
|
|
{ }
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// command class for being able to create config caches over and over without needing to read the ini files
|
|
/// </summary>
|
|
public class Command
|
|
{
|
|
public string TrimmedLine;
|
|
}
|
|
|
|
class SectionCommand : Command
|
|
{
|
|
public FileReference Filename;
|
|
public int LineIndex;
|
|
}
|
|
|
|
class KeyValueCommand : Command
|
|
{
|
|
public string Key;
|
|
public string Value;
|
|
public ParseAction LastAction;
|
|
}
|
|
|
|
// cached ini files
|
|
static Dictionary<string, List<Command>> FileCache = new Dictionary<string, List<Command>>();
|
|
static Dictionary<string, ConfigCacheIni_UPL> IniCache = new Dictionary<string, ConfigCacheIni_UPL>();
|
|
static Dictionary<string, ConfigCacheIni_UPL> BaseIniCache = new Dictionary<string, ConfigCacheIni_UPL>();
|
|
|
|
// static creation functions for ini files
|
|
public static ConfigCacheIni_UPL CreateConfigCacheIni_UPL(UnrealTargetPlatform Platform, string BaseIniName, DirectoryReference ProjectDirectory, DirectoryReference EngineDirectory = null)
|
|
{
|
|
if (EngineDirectory == null)
|
|
{
|
|
EngineDirectory = UnrealBuildTool.EngineDirectory;
|
|
}
|
|
|
|
// cache base ini for use as the seed for the rest
|
|
if (!BaseIniCache.ContainsKey(BaseIniName))
|
|
{
|
|
BaseIniCache.Add(BaseIniName, new ConfigCacheIni_UPL(UnrealTargetPlatform.Unknown, BaseIniName, null, EngineDirectory, EngineOnly: true));
|
|
}
|
|
|
|
// build the new ini and cache it for later re-use
|
|
ConfigCacheIni_UPL BaseCache = BaseIniCache[BaseIniName];
|
|
string Key = GetIniPlatformName(Platform) + BaseIniName + EngineDirectory.FullName + (ProjectDirectory != null ? ProjectDirectory.FullName : "");
|
|
if (!IniCache.ContainsKey(Key))
|
|
{
|
|
IniCache.Add(Key, new ConfigCacheIni_UPL(Platform, BaseIniName, ProjectDirectory, EngineDirectory, BaseCache: BaseCache));
|
|
}
|
|
return IniCache[Key];
|
|
}
|
|
|
|
/// <summary>
|
|
/// List of values (or a single value)
|
|
/// </summary>
|
|
public class IniValues : List<string>
|
|
{
|
|
public IniValues()
|
|
{
|
|
}
|
|
public IniValues(IniValues Other)
|
|
: base(Other)
|
|
{
|
|
}
|
|
public override string ToString()
|
|
{
|
|
return String.Join(",", ToArray());
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ini section (map of keys and values)
|
|
/// </summary>
|
|
public class IniSection : Dictionary<string, IniValues>
|
|
{
|
|
public IniSection()
|
|
: base(StringComparer.InvariantCultureIgnoreCase)
|
|
{ }
|
|
public IniSection(IniSection Other)
|
|
: this()
|
|
{
|
|
foreach (var Pair in Other)
|
|
{
|
|
Add(Pair.Key, new IniValues(Pair.Value));
|
|
}
|
|
}
|
|
public override string ToString()
|
|
{
|
|
return "IniSection";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// True if we are loading a hierarchy of config files that should be merged together
|
|
/// </summary>
|
|
bool bIsMergingConfigs;
|
|
|
|
/// <summary>
|
|
/// All sections parsed from ini file
|
|
/// </summary>
|
|
Dictionary<string, IniSection> Sections;
|
|
|
|
/// <summary>
|
|
/// Constructor. Parses a single ini file. No Platform settings, no engine hierarchy. Do not use this with ini files that have hierarchy!
|
|
/// </summary>
|
|
/// <param name="Filename">The ini file to load</param>
|
|
public ConfigCacheIni_UPL(FileReference Filename)
|
|
{
|
|
Init(Filename);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor. Parses ini hierarchy for the specified project. No Platform settings.
|
|
/// </summary>
|
|
/// <param name="BaseIniName">Ini name (Engine, Editor, etc)</param>
|
|
/// <param name="ProjectDirectory">Project path</param>
|
|
/// <param name="EngineDirectory"></param>
|
|
public ConfigCacheIni_UPL(string BaseIniName, string ProjectDirectory, string EngineDirectory = null)
|
|
{
|
|
Init(UnrealTargetPlatform.Unknown, BaseIniName, (ProjectDirectory == null) ? null : new DirectoryReference(ProjectDirectory), (EngineDirectory == null) ? null : new DirectoryReference(EngineDirectory));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor. Parses ini hierarchy for the specified project. No Platform settings.
|
|
/// </summary>
|
|
/// <param name="BaseIniName">Ini name (Engine, Editor, etc)</param>
|
|
/// <param name="ProjectDirectory">Project path</param>
|
|
/// <param name="EngineDirectory"></param>
|
|
public ConfigCacheIni_UPL(string BaseIniName, DirectoryReference ProjectDirectory, DirectoryReference EngineDirectory = null)
|
|
{
|
|
Init(UnrealTargetPlatform.Unknown, BaseIniName, ProjectDirectory, EngineDirectory);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor. Parses ini hierarchy for the specified platform and project.
|
|
/// </summary>
|
|
/// <param name="ProjectDirectory">Project path</param>
|
|
/// <param name="Platform">Target platform</param>
|
|
/// <param name="BaseIniName">Ini name (Engine, Editor, etc)</param>
|
|
/// <param name="EngineDirectory"></param>
|
|
public ConfigCacheIni_UPL(UnrealTargetPlatform Platform, string BaseIniName, string ProjectDirectory, string EngineDirectory = null)
|
|
{
|
|
Init(Platform, BaseIniName, (ProjectDirectory == null) ? null : new DirectoryReference(ProjectDirectory), (EngineDirectory == null) ? null : new DirectoryReference(EngineDirectory));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor. Parses ini hierarchy for the specified platform and project.
|
|
/// </summary>
|
|
/// <param name="ProjectDirectory">Project path</param>
|
|
/// <param name="Platform">Target platform</param>
|
|
/// <param name="BaseIniName">Ini name (Engine, Editor, etc)</param>
|
|
/// <param name="EngineDirectory"></param>
|
|
/// <param name="EngineOnly"></param>
|
|
/// <param name="BaseCache"></param>
|
|
public ConfigCacheIni_UPL(UnrealTargetPlatform Platform, string BaseIniName, DirectoryReference ProjectDirectory, DirectoryReference EngineDirectory = null, bool EngineOnly = false, ConfigCacheIni_UPL BaseCache = null)
|
|
{
|
|
Init(Platform, BaseIniName, ProjectDirectory, EngineDirectory, EngineOnly, BaseCache);
|
|
}
|
|
|
|
private void InitCommon()
|
|
{
|
|
Sections = new Dictionary<string, IniSection>(StringComparer.InvariantCultureIgnoreCase);
|
|
}
|
|
|
|
private void Init(FileReference IniFileName)
|
|
{
|
|
InitCommon();
|
|
bIsMergingConfigs = false;
|
|
ParseIniFile(IniFileName);
|
|
}
|
|
|
|
private void Init(UnrealTargetPlatform Platform, string BaseIniName, DirectoryReference ProjectDirectory, DirectoryReference EngineDirectory, bool EngineOnly = false, ConfigCacheIni_UPL BaseCache = null)
|
|
{
|
|
InitCommon();
|
|
bIsMergingConfigs = true;
|
|
if (EngineDirectory == null)
|
|
{
|
|
EngineDirectory = UnrealBuildTool.EngineDirectory;
|
|
}
|
|
|
|
if (BaseCache != null)
|
|
{
|
|
foreach (var Pair in BaseCache.Sections)
|
|
{
|
|
Sections.Add(Pair.Key, new IniSection(Pair.Value));
|
|
}
|
|
}
|
|
if (EngineOnly)
|
|
{
|
|
foreach (var IniFileName in EnumerateEngineIniFileNames(EngineDirectory, BaseIniName))
|
|
{
|
|
if (FileReference.Exists(IniFileName))
|
|
{
|
|
ParseIniFile(IniFileName);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (var IniFileName in EnumerateCrossPlatformIniFileNames(ProjectDirectory, EngineDirectory, Platform, BaseIniName, BaseCache != null))
|
|
{
|
|
if (FileReference.Exists(IniFileName))
|
|
{
|
|
ParseIniFile(IniFileName);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Finds a section in INI
|
|
/// </summary>
|
|
/// <param name="SectionName"></param>
|
|
/// <returns>Found section or null</returns>
|
|
public IniSection FindSection(string SectionName)
|
|
{
|
|
IniSection Section;
|
|
Sections.TryGetValue(SectionName, out Section);
|
|
return Section;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Finds values associated with the specified key (does not copy the list)
|
|
/// </summary>
|
|
private bool GetList(string SectionName, string Key, out IniValues Value)
|
|
{
|
|
bool Result = false;
|
|
var Section = FindSection(SectionName);
|
|
Value = null;
|
|
if (Section != null)
|
|
{
|
|
if (Section.TryGetValue(Key, out Value))
|
|
{
|
|
Result = true;
|
|
}
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets all values associated with the specified key
|
|
/// </summary>
|
|
/// <param name="SectionName">Section where the key is located</param>
|
|
/// <param name="Key">Key name</param>
|
|
/// <param name="Value">Copy of the list containing all values associated with the specified key</param>
|
|
/// <returns>True if the key exists</returns>
|
|
public bool GetArray(string SectionName, string Key, out List<string> Value)
|
|
{
|
|
Value = null;
|
|
IniValues ValueList;
|
|
bool Result = GetList(SectionName, Key, out ValueList);
|
|
if (Result)
|
|
{
|
|
Value = new List<string>(ValueList);
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a single string value associated with the specified key.
|
|
/// </summary>
|
|
/// <param name="SectionName">Section name</param>
|
|
/// <param name="Key">Key name</param>
|
|
/// <param name="Value">Value associated with the specified key. If the key has more than one value, only the first one is returned</param>
|
|
/// <returns>True if the key exists</returns>
|
|
public bool GetString(string SectionName, string Key, out string Value)
|
|
{
|
|
Value = String.Empty;
|
|
IniValues ValueList;
|
|
bool Result = GetList(SectionName, Key, out ValueList);
|
|
if (Result && ValueList != null && ValueList.Count > 0)
|
|
{
|
|
Value = ValueList[0];
|
|
Result = true;
|
|
}
|
|
else
|
|
{
|
|
Result = false;
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a single bool value associated with the specified key.
|
|
/// </summary>
|
|
/// <param name="SectionName">Section name</param>
|
|
/// <param name="Key">Key name</param>
|
|
/// <param name="Value">Value associated with the specified key. If the key has more than one value, only the first one is returned</param>
|
|
/// <returns>True if the key exists</returns>
|
|
public bool GetBool(string SectionName, string Key, out bool Value)
|
|
{
|
|
Value = false;
|
|
string TextValue;
|
|
bool Result = GetString(SectionName, Key, out TextValue);
|
|
if (Result)
|
|
{
|
|
// C# Boolean type expects "False" or "True" but since we're not case sensitive, we need to suppor that manually
|
|
if (String.Compare(TextValue, "true", true) == 0 || String.Compare(TextValue, "1") == 0)
|
|
{
|
|
Value = true;
|
|
}
|
|
else if (String.Compare(TextValue, "false", true) == 0 || String.Compare(TextValue, "0") == 0)
|
|
{
|
|
Value = false;
|
|
}
|
|
else
|
|
{
|
|
// Failed to parse
|
|
Result = false;
|
|
}
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a single Int32 value associated with the specified key.
|
|
/// </summary>
|
|
/// <param name="SectionName">Section name</param>
|
|
/// <param name="Key">Key name</param>
|
|
/// <param name="Value">Value associated with the specified key. If the key has more than one value, only the first one is returned</param>
|
|
/// <returns>True if the key exists</returns>
|
|
public bool GetInt32(string SectionName, string Key, out int Value)
|
|
{
|
|
Value = 0;
|
|
string TextValue;
|
|
bool Result = GetString(SectionName, Key, out TextValue);
|
|
if (Result)
|
|
{
|
|
Result = Int32.TryParse(TextValue, out Value);
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a single GUID value associated with the specified key.
|
|
/// </summary>
|
|
/// <param name="SectionName">Section name</param>
|
|
/// <param name="Key">Key name</param>
|
|
/// <param name="Value">Value associated with the specified key. If the key has more than one value, only the first one is returned</param>
|
|
/// <returns>True if the key exists</returns>
|
|
public bool GetGUID(string SectionName, string Key, out Guid Value)
|
|
{
|
|
Value = Guid.Empty;
|
|
string TextValue;
|
|
bool Result = GetString(SectionName, Key, out TextValue);
|
|
if (Result)
|
|
{
|
|
string HexString = "";
|
|
if (TextValue.Contains("A=") && TextValue.Contains("B=") && TextValue.Contains("C=") && TextValue.Contains("D="))
|
|
{
|
|
char[] Separators = new char[] { '(', ')', '=', ',', ' ', 'A', 'B', 'C', 'D' };
|
|
string[] ComponentValues = TextValue.Split(Separators, StringSplitOptions.RemoveEmptyEntries);
|
|
if (ComponentValues.Length == 4)
|
|
{
|
|
for (int ComponentIndex = 0; ComponentIndex < 4; ComponentIndex++)
|
|
{
|
|
int IntegerValue;
|
|
Result &= Int32.TryParse(ComponentValues[ComponentIndex], out IntegerValue);
|
|
HexString += IntegerValue.ToString("X8");
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
HexString = TextValue;
|
|
}
|
|
|
|
try
|
|
{
|
|
Value = Guid.ParseExact(HexString, "N");
|
|
Result = true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
Result = false;
|
|
}
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a single float value associated with the specified key.
|
|
/// </summary>
|
|
/// <param name="SectionName">Section name</param>
|
|
/// <param name="Key">Key name</param>
|
|
/// <param name="Value">Value associated with the specified key. If the key has more than one value, only the first one is returned</param>
|
|
/// <returns>True if the key exists</returns>
|
|
public bool GetSingle(string SectionName, string Key, out float Value)
|
|
{
|
|
Value = 0.0f;
|
|
string TextValue;
|
|
bool Result = GetString(SectionName, Key, out TextValue);
|
|
if (Result)
|
|
{
|
|
Result = Single.TryParse(TextValue, out Value);
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a single double value associated with the specified key.
|
|
/// </summary>
|
|
/// <param name="SectionName">Section name</param>
|
|
/// <param name="Key">Key name</param>
|
|
/// <param name="Value">Value associated with the specified key. If the key has more than one value, only the first one is returned</param>
|
|
/// <returns>True if the key exists</returns>
|
|
public bool GetDouble(string SectionName, string Key, out double Value)
|
|
{
|
|
Value = 0.0;
|
|
string TextValue;
|
|
bool Result = GetString(SectionName, Key, out TextValue);
|
|
if (Result)
|
|
{
|
|
Result = Double.TryParse(TextValue, out Value);
|
|
}
|
|
return Result;
|
|
}
|
|
|
|
private static bool ExtractPath(string Source, out string Path)
|
|
{
|
|
int start = Source.IndexOf('"');
|
|
int end = Source.LastIndexOf('"');
|
|
if (start != 1 && end != -1 && start < end)
|
|
{
|
|
++start;
|
|
Path = Source.Substring(start, end - start);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
Path = "";
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public bool GetPath(string SectionName, string Key, out string Value)
|
|
{
|
|
string temp;
|
|
if (GetString(SectionName, Key, out temp))
|
|
{
|
|
return ExtractPath(temp, out Value);
|
|
}
|
|
else
|
|
{
|
|
Value = "";
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// List of actions that can be performed on a single line from ini file
|
|
/// </summary>
|
|
enum ParseAction
|
|
{
|
|
None,
|
|
New,
|
|
Add,
|
|
Remove
|
|
}
|
|
|
|
/// <summary>
|
|
/// Checks what action should be performed on a single line from ini file
|
|
/// </summary>
|
|
private ParseAction GetActionForLine(ref string Line)
|
|
{
|
|
if (String.IsNullOrEmpty(Line) || Line.StartsWith(";") || Line.StartsWith("//"))
|
|
{
|
|
return ParseAction.None;
|
|
}
|
|
else if (Line.StartsWith("-"))
|
|
{
|
|
Line = Line.Substring(1).TrimStart();
|
|
return ParseAction.Remove;
|
|
}
|
|
else if (Line.StartsWith("+"))
|
|
{
|
|
Line = Line.Substring(1).TrimStart();
|
|
return ParseAction.Add;
|
|
}
|
|
else
|
|
{
|
|
// We use Add rather than New when we're not merging config files together in order
|
|
// to mimic the behavior of the C++ config cache when loading a single file
|
|
return (bIsMergingConfigs) ? ParseAction.New : ParseAction.Add;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Loads and parses ini file.
|
|
/// </summary>
|
|
public void ParseIniFile(FileReference Filename)
|
|
{
|
|
String[] IniLines = null;
|
|
List<Command> Commands = null;
|
|
if (!FileCache.ContainsKey(Filename.FullName))
|
|
{
|
|
try
|
|
{
|
|
IniLines = File.ReadAllLines(Filename.FullName);
|
|
Commands = new List<Command>();
|
|
FileCache.Add(Filename.FullName, Commands);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine("Error reading ini file: " + Filename + " Exception: " + ex.Message);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Commands = FileCache[Filename.FullName];
|
|
}
|
|
if (IniLines != null && Commands != null)
|
|
{
|
|
IniSection CurrentSection = null;
|
|
|
|
// Line Index for exceptions
|
|
var LineIndex = 1;
|
|
var bMultiLine = false;
|
|
var SingleValue = "";
|
|
var Key = "";
|
|
var LastAction = ParseAction.None;
|
|
|
|
// Parse each line
|
|
foreach (var Line in IniLines)
|
|
{
|
|
var TrimmedLine = Line.Trim();
|
|
// Multiline value support
|
|
bool bWasMultiLine = bMultiLine;
|
|
bMultiLine = TrimmedLine.EndsWith("\\");
|
|
if (bMultiLine)
|
|
{
|
|
TrimmedLine = TrimmedLine.Substring(0, TrimmedLine.Length - 1).TrimEnd();
|
|
}
|
|
if (!bWasMultiLine)
|
|
{
|
|
if (TrimmedLine.StartsWith("["))
|
|
{
|
|
CurrentSection = FindOrAddSection(TrimmedLine, Filename, LineIndex);
|
|
LastAction = ParseAction.None;
|
|
if (CurrentSection != null)
|
|
{
|
|
SectionCommand Command = new SectionCommand();
|
|
Command.Filename = Filename;
|
|
Command.LineIndex = LineIndex;
|
|
Command.TrimmedLine = TrimmedLine;
|
|
Commands.Add(Command);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (LastAction != ParseAction.None)
|
|
{
|
|
throw new IniParsingException("Parsing new key/value pair when the previous one has not yet been processed ({0}, {1}) in {2}, line {3}: {4}", Key, SingleValue, Filename, LineIndex, TrimmedLine);
|
|
}
|
|
// Check if the line is empty or a comment, also remove any +/- markers
|
|
LastAction = GetActionForLine(ref TrimmedLine);
|
|
if (LastAction != ParseAction.None)
|
|
{
|
|
/* if (CurrentSection == null)
|
|
{
|
|
throw new IniParsingException("Trying to parse key/value pair that doesn't belong to any section in {0}, line {1}: {2}", Filename, LineIndex, TrimmedLine);
|
|
}*/
|
|
ParseKeyValuePair(TrimmedLine, Filename, LineIndex, out Key, out SingleValue);
|
|
}
|
|
}
|
|
}
|
|
if (bWasMultiLine)
|
|
{
|
|
SingleValue += TrimmedLine;
|
|
}
|
|
if (!bMultiLine && LastAction != ParseAction.None && CurrentSection != null)
|
|
{
|
|
ProcessKeyValuePair(CurrentSection, Key, SingleValue, LastAction);
|
|
KeyValueCommand Command = new KeyValueCommand();
|
|
Command.Key = Key;
|
|
Command.Value = SingleValue;
|
|
Command.LastAction = LastAction;
|
|
Commands.Add(Command);
|
|
LastAction = ParseAction.None;
|
|
SingleValue = "";
|
|
Key = "";
|
|
}
|
|
else if (CurrentSection == null)
|
|
{
|
|
LastAction = ParseAction.None;
|
|
}
|
|
LineIndex++;
|
|
}
|
|
}
|
|
else if (Commands != null)
|
|
{
|
|
IniSection CurrentSection = null;
|
|
|
|
// run each command
|
|
for (int Idx = 0; Idx < Commands.Count; ++Idx)
|
|
{
|
|
var Command = Commands[Idx];
|
|
if (Command is SectionCommand)
|
|
{
|
|
CurrentSection = FindOrAddSection((Command as SectionCommand).TrimmedLine, (Command as SectionCommand).Filename, (Command as SectionCommand).LineIndex);
|
|
}
|
|
else if (Command is KeyValueCommand)
|
|
{
|
|
ProcessKeyValuePair(CurrentSection, (Command as KeyValueCommand).Key, (Command as KeyValueCommand).Value, (Command as KeyValueCommand).LastAction);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Splits a line into key and value
|
|
/// </summary>
|
|
private static void ParseKeyValuePair(string TrimmedLine, FileReference Filename, int LineIndex, out string Key, out string Value)
|
|
{
|
|
var AssignIndex = TrimmedLine.IndexOf('=');
|
|
if (AssignIndex < 0)
|
|
{
|
|
throw new IniParsingException("Failed to find value when parsing {0}, line {1}: {2}", Filename, LineIndex, TrimmedLine);
|
|
}
|
|
Key = TrimmedLine.Substring(0, AssignIndex).Trim();
|
|
if (String.IsNullOrEmpty(Key))
|
|
{
|
|
throw new IniParsingException("Empty key when parsing {0}, line {1}: {2}", Filename, LineIndex, TrimmedLine);
|
|
}
|
|
Value = TrimmedLine.Substring(AssignIndex + 1).Trim();
|
|
if (Value.StartsWith("\""))
|
|
{
|
|
// Remove quotes
|
|
var QuoteEnd = Value.LastIndexOf('\"');
|
|
if (QuoteEnd == 0)
|
|
{
|
|
throw new IniParsingException("Mismatched quotes when parsing {0}, line {1}: {2}", Filename, LineIndex, TrimmedLine);
|
|
}
|
|
Value = Value.Substring(1, Value.Length - 2);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Processes parsed key/value pair
|
|
/// </summary>
|
|
private static void ProcessKeyValuePair(IniSection CurrentSection, string Key, string SingleValue, ParseAction Action)
|
|
{
|
|
switch (Action)
|
|
{
|
|
case ParseAction.New:
|
|
{
|
|
// New/replace
|
|
IniValues Value;
|
|
if (CurrentSection.TryGetValue(Key, out Value) == false)
|
|
{
|
|
Value = new IniValues();
|
|
CurrentSection.Add(Key, Value);
|
|
}
|
|
Value.Clear();
|
|
Value.Add(SingleValue);
|
|
}
|
|
break;
|
|
case ParseAction.Add:
|
|
{
|
|
IniValues Value;
|
|
if (CurrentSection.TryGetValue(Key, out Value) == false)
|
|
{
|
|
Value = new IniValues();
|
|
CurrentSection.Add(Key, Value);
|
|
}
|
|
Value.Add(SingleValue);
|
|
}
|
|
break;
|
|
case ParseAction.Remove:
|
|
{
|
|
IniValues Value;
|
|
if (CurrentSection.TryGetValue(Key, out Value))
|
|
{
|
|
var ExistingIndex = Value.FindIndex(X => (String.Compare(SingleValue, X, true) == 0));
|
|
if (ExistingIndex >= 0)
|
|
{
|
|
Value.RemoveAt(ExistingIndex);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Finds an existing section or adds a new one
|
|
/// </summary>
|
|
private IniSection FindOrAddSection(string TrimmedLine, FileReference Filename, int LineIndex)
|
|
{
|
|
var SectionEndIndex = TrimmedLine.IndexOf(']');
|
|
if (SectionEndIndex != (TrimmedLine.Length - 1))
|
|
{
|
|
throw new IniParsingException("Mismatched brackets when parsing section name in {0}, line {1}: {2}", Filename, LineIndex, TrimmedLine);
|
|
}
|
|
var SectionName = TrimmedLine.Substring(1, TrimmedLine.Length - 2);
|
|
if (String.IsNullOrEmpty(SectionName))
|
|
{
|
|
throw new IniParsingException("Empty section name when parsing {0}, line {1}: {2}", Filename, LineIndex, TrimmedLine);
|
|
}
|
|
{
|
|
IniSection CurrentSection;
|
|
if (Sections.TryGetValue(SectionName, out CurrentSection) == false)
|
|
{
|
|
CurrentSection = new IniSection();
|
|
Sections.Add(SectionName, CurrentSection);
|
|
}
|
|
return CurrentSection;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns a list of INI filenames for the engine
|
|
/// </summary>
|
|
private static IEnumerable<FileReference> EnumerateEngineIniFileNames(DirectoryReference EngineDirectory, string BaseIniName)
|
|
{
|
|
// Engine/Config/Base.ini (included in every ini type, required)
|
|
yield return FileReference.Combine(EngineDirectory, "Config", "Base.ini");
|
|
|
|
// Engine/Config/Base* ini
|
|
yield return FileReference.Combine(EngineDirectory, "Config", "Base" + BaseIniName + ".ini");
|
|
|
|
// Engine/Config/NotForLicensees/Base* ini
|
|
yield return FileReference.Combine(EngineDirectory, "Config", "NotForLicensees", "Base" + BaseIniName + ".ini");
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Returns a list of INI filenames for the given project
|
|
/// </summary>
|
|
private static IEnumerable<FileReference> EnumerateCrossPlatformIniFileNames(DirectoryReference ProjectDirectory, DirectoryReference EngineDirectory, UnrealTargetPlatform Platform, string BaseIniName, bool SkipEngine)
|
|
{
|
|
if (!SkipEngine)
|
|
{
|
|
// Engine/Config/Base.ini (included in every ini type, required)
|
|
yield return FileReference.Combine(EngineDirectory, "Config", "Base.ini");
|
|
|
|
// Engine/Config/Base* ini
|
|
yield return FileReference.Combine(EngineDirectory, "Config", "Base" + BaseIniName + ".ini");
|
|
|
|
// Engine/Config/NotForLicensees/Base* ini
|
|
yield return FileReference.Combine(EngineDirectory, "Config", "NotForLicensees", "Base" + BaseIniName + ".ini");
|
|
|
|
// NOTE: 4.7: See comment in GetSourceIniHierarchyFilenames()
|
|
// Engine/Config/NoRedist/Base* ini
|
|
// yield return Path.Combine(EngineDirectory, "Config", "NoRedist", "Base" + BaseIniName + ".ini");
|
|
}
|
|
|
|
if (ProjectDirectory != null)
|
|
{
|
|
// Game/Config/Default* ini
|
|
yield return FileReference.Combine(ProjectDirectory, "Config", "Default" + BaseIniName + ".ini");
|
|
|
|
// Game/Config/NotForLicensees/Default* ini
|
|
yield return FileReference.Combine(ProjectDirectory, "Config", "NotForLicensees", "Default" + BaseIniName + ".ini");
|
|
|
|
// Game/Config/NoRedist/Default* ini
|
|
yield return FileReference.Combine(ProjectDirectory, "Config", "NoRedist", "Default" + BaseIniName + ".ini");
|
|
}
|
|
|
|
string PlatformName = GetIniPlatformName(Platform);
|
|
if (Platform != UnrealTargetPlatform.Unknown)
|
|
{
|
|
// Engine/Config/Platform/Platform* ini
|
|
yield return FileReference.Combine(EngineDirectory, "Config", PlatformName, PlatformName + BaseIniName + ".ini");
|
|
|
|
if (ProjectDirectory != null)
|
|
{
|
|
// Game/Config/Platform/Platform* ini
|
|
yield return FileReference.Combine(ProjectDirectory, "Config", PlatformName, PlatformName + BaseIniName + ".ini");
|
|
}
|
|
}
|
|
|
|
DirectoryReference UserSettingsFolder = Utils.GetUserSettingDirectory(); // Match FPlatformProcess::UserSettingsDir()
|
|
DirectoryReference PersonalFolder = null; // Match FPlatformProcess::UserDir()
|
|
if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Mac)
|
|
{
|
|
PersonalFolder = new DirectoryReference(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Documents"));
|
|
}
|
|
else if (Environment.OSVersion.Platform == PlatformID.Unix)
|
|
{
|
|
PersonalFolder = new DirectoryReference(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Documents"));
|
|
}
|
|
else
|
|
{
|
|
// Not all user accounts have a local application data directory (eg. SYSTEM, used by Jenkins for builds).
|
|
string PersonalFolderSetting = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
|
if(!String.IsNullOrEmpty(PersonalFolderSetting))
|
|
{
|
|
PersonalFolder = new DirectoryReference(PersonalFolderSetting);
|
|
}
|
|
}
|
|
|
|
if(UserSettingsFolder != null)
|
|
{
|
|
// <AppData>/UE4/EngineConfig/User* ini
|
|
yield return FileReference.Combine(UserSettingsFolder, "Unreal Engine", "Engine", "Config", "User" + BaseIniName + ".ini");
|
|
}
|
|
|
|
if(PersonalFolder != null)
|
|
{
|
|
// <Documents>/UE4/EngineConfig/User* ini
|
|
yield return FileReference.Combine(PersonalFolder, "Unreal Engine", "Engine", "Config", "User" + BaseIniName + ".ini");
|
|
}
|
|
|
|
// Game/Config/User* ini
|
|
if (ProjectDirectory != null)
|
|
{
|
|
yield return FileReference.Combine(ProjectDirectory, "Config", "User" + BaseIniName + ".ini");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the platform name to use as part of platform-specific config files
|
|
/// </summary>
|
|
private static string GetIniPlatformName(UnrealTargetPlatform TargetPlatform)
|
|
{
|
|
if (TargetPlatform == UnrealTargetPlatform.Win32 || TargetPlatform == UnrealTargetPlatform.Win64)
|
|
{
|
|
return "Windows";
|
|
}
|
|
else
|
|
{
|
|
return Enum.GetName(typeof(UnrealTargetPlatform), TargetPlatform);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|