Slim down engine source build?

I’m currently compiling the engine from source that I forked on GitHub. I would like to slim down the engine compile time and size by removing platforms I’m not interested in. So far I’ve done the following:

  • When using Setup.bat: added -exclude=“…” for all the platforms I don’t want.
  • In TargetPlatform.Build.cs: commented out all ‘DynamicallyLoadedModuleNames.Add(“…”);’ that deal with platforms I don’t want, like “AndroidTargetPlatform”.
  • In UnrealBuildTool.cs: changed the ‘static public UnrealTargetPlatform] AllPlatforms’ array to contain only the platforms I want.
  • In the AllDesktop.Automation.cs: commented out the Mac and Linux enum’s from the “GetStagePlatforms()” ovveride function.
  • In the UE4.sln, unloaded the unwanted projects under Programs/Automation like “Android.Autiomation”.

Beyond that I’m abit clueless, or not even sure if what I just described will have the correct effect. Does anyone have experience with this?
(FYI, the only platforms I’m interested in are Win32/Win64)

Huh? How did you do all that? I need it! Now! Gimme, quick! Come on, hurry up now, don’t got all day. Stop keeping it as a secret. TELL ME NOW!

Please?

Lol fam, I just described what I did in each list point. But as I said, I’m not sure this works as intended, need some confirmation from someone who knows the engine, this is my first time touching it. I’m currently compiling (1h+ so far…) and don’t have any errors so far, but it’s still takeing a long time.

As for the Setup.bat command line I passed:


Setup.bat -exclude=WinRT -exclude=winrt -exclude=Mac -exclude=mac -exclude=osx -exclude=osx64 -exclude=osx32 -exclude=Android -exclude=android -exclude=IOS -exclude=ios -exclude=TVOS -exclude=tvos -exclude=Linux -exclude=linux -exclude=Linux32 -exclude=linux32 -exclude=Linux64 -exclude=linux64 -exclude=linux_x64 -exclude=HTML5 -exclude=html5 -exclude=PS4 -exclude=XboxOne -exclude=Switch -exclude=Dingo

I noticed that alot of the folders are both upper and lowercase, so I added them to the exclude list. But it only lists the uppercase versions in the “(Excluding: …)” log message, so I’m not sure it makes a difference to add the lowercase version.

Also when cloning the fork, I used “–depth 1” as an addition parameter so it doesn’t download all the history, only the ‘recent version’, reducing the .git folder down to just a couple hundered megabytes on a fresh fork clone. So this was the git command:


git clone --branch 4.18.0-preview-3 --depth 1 https://github.com/<MyUserName>/UnrealEngine.git

Allright, so my build just finished with 3 failed projects.
Errors are:



- Error    C2039    'MergeShaderCacheFiles': is not a member of 'FShaderCache'    ShaderCacheTool    C:\Users\\Documents\Git\UnrealEngine\Engine\Source\Programs\Mac\ShaderCacheTool\Private\ShaderCacheTool.cpp    66
- Error    CS0006    Metadata file 'C:\Users\\Documents\Git\UnrealEngine\Engine\Binaries\DotNET\AutomationScripts\Android\Android.Automation.dll' could not be found    AutomationTool    C:\Users\\Documents\Git\UnrealEngine\Engine\Source\Programs\AutomationTool\CSC ... (For each unloaded project)
- Error    C1083    Cannot open include file: 'Interfaces/IAutomationWorkerModule.h': No such file or directory    BuildPatchTool    C:\Users\\Documents\Git\UnrealEngine\Engine\Source\Programs\BuildPatchTool\Private\ToolModes\AutomationMode.cpp    12


So now I’m going to do some reasearch… will edit this post for each error solved:

  • As for the error “‘MergeShaderCacheFiles’: is not a member of ‘FShaderCache’” - it seems that the project/program this code belongs to, ‘ShaderCacheTools’, is Mac only (considering all the code for this is under a /Mac/ directory), so I’ve now unloaded it. In addition, I checked all other Programs/<Project>'s, and found the following to be Mac/IOS only (due to the folder-name subfolder’ing) and unloaded them: ‘DsymExporter’ (Mac), ‘UE4EditorServies’ (Mac), ‘UnrealAtoS’ (Mac) and ‘UnrealLaunchDaemon’ (IOS).

meh…l. I give up, just gonna install the engine as is - I have better things to do than mess around with platform dependencies -_-. I wish they had some kind of git and source dependency settings for removing platforms that are not wanted in the engine source. Guess I’ll stick to the full engine size for now…

Incase anyone is interested, I’ve managed to slim down the engine size on disk a lot. I’ve optimised it for Win32/Win64, but you can theoretically remove the excludes and ignores for the platform you want to use.

Setup.bat command line


Setup.bat -exclude=WinRT -exclude=Mac -exclude=MacOS -exclude=MacOSX -exclude=osx -exclude=osx64 -exclude=osx32 -exclude=Android -exclude=IOS -exclude=TVOS -exclude=Linux -exclude=Linux32 -exclude=Linux64 -exclude=linux_x64 -exclude=HTML5 -exclude=PS4 -exclude=XboxOne -exclude=Switch -exclude=Dingo

.gitdepsignore file, sorted by: Documentations, Samples/Examples, TVOS, Mac, Linux, Android, IOS, HTML5


/Engine/Documentation/**
/Engine/Extras/ThirdPartyNotUE/GNU_Make/make-3.81/src/make/3.81/make-3.81-src/doc/**
/Engine/Extras/ThirdPartyNotUE/emsdk/emscripten/1.37.19/docs/**
/Engine/Extras/ThirdPartyNotUE/emsdk/emscripten/1.37.19/site/**
/Engine/Plugins/Experimental/AlembicImporter/Source/ThirdParty/Alembic/openexr/Contrib/Photoshop/doc/**
/Engine/Plugins/Experimental/AlembicImporter/Source/ThirdParty/Alembic/openexr/OpenEXR/doc/**
/Engine/Plugins/Experimental/AlembicImporter/Source/ThirdParty/Alembic/openexr/OpenEXR_Viewers/doc/**
/Engine/Source/ThirdParty/AMD/AMD_AGS/doc/**
/Engine/Source/ThirdParty/Expat/expat-2.2.0/doc/**
/Engine/Source/ThirdParty/HarfBuzz/harfbuzz-1.2.4/docs/**
/Engine/Source/ThirdParty/IntelTBB/IntelTBB-4.4u3/doc/**
/Engine/Source/ThirdParty/MCPP/mcpp-2.7.2/doc-jp/**
/Engine/Source/ThirdParty/MCPP/mcpp-2.7.2/doc/**
/Engine/Source/ThirdParty/PLCrashReporter/plcrashreporter-master-5ae3b0a/Documentation/**
/Engine/Source/ThirdParty/PhysX/NvCloth/docs/**
/Engine/Source/ThirdParty/PhysX/PhysX_3.4/Documentation/**
/Engine/Source/ThirdParty/PhysX/PxShared/src/foundation/doc/**
/Engine/Source/ThirdParty/SDL2/SDL-gui-backend/debian/docs/**
/Engine/Source/ThirdParty/SDL2/SDL-gui-backend/docs/**
/Engine/Source/ThirdParty/Vorbis/libvorbis-1.3.2/doc/**
/Engine/Source/ThirdParty/libOpus/opus-1.0.3/doc/**
/Engine/Source/ThirdParty/libOpus/opus-1.1/doc/**
/Samples/**
/Engine/Extras/Maya_AnimationRiggingTools/ARTv1/MayaTools/General/ART/Projects/Sample/**
/Engine/Extras/Maya_AnimationRiggingTools/ArtToolsOSX/MayaTools/General/ART/Projects/Sample/**
/Engine/Extras/Maya_AnimationRiggingTools/MayaTools/General/ART/Projects/Sample/**
/Engine/Plugins/Online/OnlineSubsystemGoogle/Source/ThirdParty/IOS/Sample/**
/Engine/Source/ThirdParty/Facebook/IOS/Samples/**
/Engine/Source/ThirdParty/FakeIt/2.0.2/samples/**
/Engine/Source/ThirdParty/ICU/icu4c-53_1/source/samples/**
/Engine/Source/ThirdParty/PhysX/PxShared/src/foundation/samples/**
/Engine/Plugins/Experimental/AlembicImporter/Source/ThirdParty/Alembic/hdf5/c++/examples/**
/Engine/Plugins/Experimental/AlembicImporter/Source/ThirdParty/Alembic/hdf5/examples/**
/Engine/Plugins/Experimental/AlembicImporter/Source/ThirdParty/Alembic/hdf5/fortran/examples/**
/Engine/Plugins/Experimental/AlembicImporter/Source/ThirdParty/Alembic/hdf5/hl/c++/examples/**
/Engine/Plugins/Experimental/AlembicImporter/Source/ThirdParty/Alembic/hdf5/hl/examples/**
/Engine/Plugins/Experimental/AlembicImporter/Source/ThirdParty/Alembic/hdf5/hl/fortran/examples/**
/Engine/Plugins/Experimental/AlembicImporter/Source/ThirdParty/Alembic/openexr/OpenEXR/IlmImfExamples/**
/Engine/Source/ThirdParty/DotNetZip/Help/**
/Engine/Source/ThirdParty/DotNetZip/Examples/**
/Engine/Source/ThirdParty/IntelTBB/IntelTBB-4.4u3/examples/**
/Engine/Source/ThirdParty/zlib/zlib-1.2.5/Src/examples/**
/Engine/Build/TVOS/**
/Engine/Source/Programs/AutomationTool/TVOS/**
/Engine/Source/ThirdParty/ICU/icu4c-53_1/TVOS/**
/Engine/Source/ThirdParty/zlib/zlib-1.2.5/Src/contrib/TVOS/**
/Engine/Binaries/Mac/**
/Engine/Binaries/ThirdParty/ARM/Mac/**
/Engine/Binaries/ThirdParty/CEF3/Mac/**
/Engine/Binaries/ThirdParty/GoogleInstantPreview/Mac/**
/Engine/Binaries/ThirdParty/Mono/Mac/**
/Engine/Binaries/ThirdParty/PhysX/Mac/**
/Engine/Binaries/ThirdParty/libsndfile/Mac/**
/Engine/Binaries/ThirdParty/svn/Mac/**
/Engine/Build/Mac/**
/Engine/Extras/AndroidWorks/Mac/**
/Engine/Extras/ThirdPartyNotUE/emsdk/Mac/**
/Engine/Source/Programs/AutomationTool/Mac/**
/Engine/Source/Programs/Mac/**
/Engine/Source/ThirdParty/FreeType2/FreeType2-2.4.12/Builds/mac/**
/Engine/Source/ThirdParty/FreeType2/FreeType2-2.6/Builds/mac/**
/Engine/Source/ThirdParty/GoogleInstantPreview/Mac/**
/Engine/Source/ThirdParty/GoogleVR/lib/mac/**
/Engine/Source/ThirdParty/HarfBuzz/harfbuzz-1.2.4/Mac/**
/Engine/Source/ThirdParty/ICU/icu4c-53_1/Mac/**
/Engine/Source/ThirdParty/IntelEmbree/Embree2140/MacOSX/**
/Engine/Source/ThirdParty/IntelEmbree/Embree2140/src/scripts/install_macosx/**
/Engine/Source/ThirdParty/IntelEmbree/Embree270/MacOSX/**
/Engine/Source/ThirdParty/IntelEmbree/Embree270/src/scripts/install_macosx/**
/Engine/Source/ThirdParty/IntelISPCTexComp/ISPC Texture Compressor/ispc_osx/**
/Engine/Source/ThirdParty/libOpus/opus-1.0.3/Mac/**
/Engine/Source/ThirdParty/libOpus/opus-1.1/Mac/**
/Engine/Source/ThirdParty/libcurl/7_48_0/lib/Mac/**
/Engine/Source/ThirdParty/nvTextureTools/nvTextureTools-2.0.8/lib/Mac/**
/Engine/Source/ThirdParty/PLCrashReporter/plcrashreporter-master-5ae3b0a/Mac/**
/Engine/Source/ThirdParty/PLCrashReporter/plcrashreporter-master-5ae3b0a/Tools/google-toolbox-for-mac-trunk-r582/**
/Engine/Source/ThirdParty/SpeedTree/SpeedTreeSDK-v7.0/Source/Core/MacOSX/**
/Engine/Source/ThirdParty/Vorbis/libvorbis-1.3.2/macos/**
/Engine/Source/ThirdParty/Vorbis/libvorbis-1.3.2/macosx/**
/Engine/Binaries/ThirdParty/IntelISPCTexComp/Mac64-Release/**
/Engine/Source/ThirdParty/CEF3/cef_binary_3.3071.1611.g4a19305_macosx64/**
/Engine/Binaries/ThirdParty/OpenVR/OpenVRv1_0_10/osx32/**
/Engine/Binaries/ThirdParty/OpenVR/OpenVRv1_0_9/osx32/**
/Engine/Binaries/ThirdParty/OpenVR/OpenVRv1_0_10/osx64/**
/Engine/Binaries/ThirdParty/OpenVR/OpenVRv1_0_9/osx64/**
/Engine/Binaries/Linux/**
/Engine/Source/Programs/AutomationTool/Linux/**
/Engine/Binaries/ThirdParty/CEF3/Linux/**
/Engine/Binaries/ThirdParty/OpenAL/Linux/**
/Engine/Binaries/ThirdParty/Qualcomm/Linux/**
/Engine/Extras/ThirdPartyNotUE/emsdk/Linux/**
/Engine/Source/ThirdParty/FreeType2/FreeType2-2.4.12/Builds/Linux/**
/Engine/Source/ThirdParty/ICU/icu4c-53_1/Linux/**
/Engine/Source/ThirdParty/IntelEmbree/Embree2140/src/scripts/install_linux/**
/Engine/Source/ThirdParty/IntelEmbree/Embree270/src/scripts/install_linux/**
/Engine/Source/ThirdParty/IntelISPCTexComp/ISPC Texture Compressor/ispc_linux/**
/Engine/Source/ThirdParty/Linux/**
/Engine/Source/ThirdParty/Vorbis/libvorbis-1.3.2/lib/Linux/**
/Engine/Source/ThirdParty/Vulkan/Linux/**
/Engine/Source/ThirdParty/WebRTC/sdk_trunk_linux/**
/Engine/Source/ThirdParty/elftoolchain/build/Linux/**
/Engine/Source/ThirdParty/libOpus/opus-1.0.3/Linux/**
/Engine/Source/ThirdParty/libOpus/opus-1.1/Linux/**
/Engine/Source/ThirdParty/libcurl/7_48_0/lib/Linux/**
/Engine/Source/ThirdParty/libcurl/build/Linux/**
/Engine/Source/ThirdParty/nvTextureTools/nvTextureTools-2.0.8/lib/Linux/**
/Engine/Binaries/ThirdParty/ARM/Linux32/**
/Engine/Binaries/ThirdParty/OpenVR/OpenVRv1_0_10/linux32/**
/Engine/Binaries/ThirdParty/OpenVR/OpenVRv1_0_9/linux32/**
/Engine/Binaries/ThirdParty/IntelISPCTexComp/Linux64-Release/**
/Engine/Binaries/ThirdParty/OpenVR/OpenVRv1_0_10/linux64/**
/Engine/Binaries/ThirdParty/OpenVR/OpenVRv1_0_9/linux64/**
/Engine/Source/ThirdParty/CEF3/cef_binary_3.2623.1395.g3034273_linux64/**
/Engine/Build/Android/**
/Engine/Extras/AndroidWorks/Linux/**
/Engine/Extras/AndroidWorks/Win64/**
/Engine/Source/Programs/AutomationTool/Android/**
/Engine/Source/ThirdParty/Android/**
/Engine/Source/ThirdParty/GooglePlay/gpg-cpp-sdk.v2.3/gpg-cpp-sdk/android/**
/Engine/Source/ThirdParty/GoogleVR/lib/android/**
/Engine/Source/ThirdParty/HarfBuzz/harfbuzz-1.2.4/Android/**
/Engine/Source/ThirdParty/ICU/icu4c-53_1/Android/**
/Engine/Source/ThirdParty/Vorbis/libvorbis-1.3.2/lib/Android/**
/Engine/Source/ThirdParty/libOpus/opus-1.1/Android/**
/Engine/Source/ThirdParty/libcurl/build/Android/**
/Engine/Binaries/DotNET/IOS/**
/Engine/Build/IOS/**
/Engine/Source/Programs/IOS/**
/Engine/Source/Programs/AutomationTool/IOS/**
/Engine/Source/ThirdParty/Facebook/IOS/**
/Engine/Source/ThirdParty/FreeType2/FreeType2-2.4.12/Builds/IOS/**
/Engine/Source/ThirdParty/GoogleVR/lib/ios/**
/Engine/Source/ThirdParty/HarfBuzz/harfbuzz-1.2.4/IOS/**
/Engine/Source/ThirdParty/ICU/icu4c-53_1/IOS/**
/Engine/Source/ThirdParty/PLCrashReporter/plcrashreporter-master-5ae3b0a/IOS/**
/Engine/Source/ThirdParty/libPNG/libPNG-1.5.2/projects/IOS/**
/Engine/Build/HTML5/**
/Engine/Source/Programs/HTML5/**
/Engine/Source/Programs/AutomationTool/HTML5/**
/Engine/Source/ThirdParty/HarfBuzz/harfbuzz-1.2.4/HTML5/**
/Engine/Source/ThirdParty/ICU/icu4c-53_1/HTML5/**
/Engine/Source/ThirdParty/SDL2/HTML5/**
/Engine/Source/ThirdParty/Vorbis/libvorbis-1.3.2/lib/HTML5/**
/Engine/Source/ThirdParty/Vorbis/libvorbis-1.3.2/lib/HTML5Win32/**

  • In TargetPlatform.Build.cs: commented out all ‘DynamicallyLoadedModuleNames.Add(“…”);’ that deal with platforms I don’t want, like “AndroidTargetPlatform”.
  • In UnrealBuildTool.cs: changed the ‘static public UnrealTargetPlatform] AllPlatforms’ array to contain only the platforms I want.
  • In the AllDesktop.Automation.cs: commented out the Mac and Linux enum’s from the “GetStagePlatforms()” ovveride function.
  • In each Automation project, added a “public override bool CanBeCompiled() { return false; }” to the platforms I don’t want.
  • Disabled UE4.sln projects: DsymExporter (Mac), ShaderCacheTool (Mac), UE4EditorServies (Mac), UnrealAtoS (Mac), UnrealLaunchDaemon (IOS)

Also when cloning/fetching the git repo, I only cloned the branch I wanted instead of all, and used --depth 1 to only get the latest history, this also saves alot of disk space.

Why do you even care about it? Seems like an awful lot of fiddling with it, high risk of breaking stuff, for no real gain.

I agree. You could always just load ue 4.10 or even udk if you want to roll back features. Im sure your compile time will be faster. the engine will also be a smaller size. You could go buy a 32gb flash drive and install the engine to it if the size struggle is that real. Thats like 10$.

I only have a 256GB SSD atm, and I’m sharing it with other engines and tools.
As for my last post, that compiles without an issue and the engine runs without a problem.

Hey , you aren’t the only one who has embarked on this endeavor. Can be a bit of work, but it’s something that I think should be more streamlined. Thankfully, those switches are available. I’m working on slimming things down as well. I don’t have the links handy, but a couple of other threads are floating around that cover this topic as well.

@ I am currently on linux Mint 19v2 trying to slim down the engine as well. I have a 120gb ssd (kinda hard for me to buy new hardware now) and trying to reduce the size cause UE4 now gets like 55.7GB with 141k files inside the installation. I’m need to slim down cause the disk is shared with the projects and currently i can’t build my main project as the build (procedure and existing stuff) also gets plenty of space. Just wanted to say ty for the post and effort you placed. Any tips for linux in reducing the size? Will try your way but for linux post back if i make any progress. P. S unrelated would love if any1 knows how to build for windows FROM linux.

I managed to reduce the size a bit but that was because of git clone --depth 1. i managed to change some setting in the build but i don’t think i completed the changes as i was unable to complete the last 3 steps. Overall the size went down by 5-6 GB. :confused: maybe when i grow up :stuck_out_tongue: in experience I’ll try again. I ended up deleting some stuff to make do.

Anyone can build UE5? because some config have been changed from UE4. Now, I can’t build UE5 only for Win64 (–exclude anything except Win64)