Unreal Build System refers to a collection of tools that automate the process of building Unreal Engine 4 (UE4). At a high level, UnrealBuildTool and UnrealHeaderTool support Unreal Build System.
This guide provides and overview of UnrealBuildTool and UnrealHeaderTool, including a brief discussion about UE4's modular architecture. If you want to use this collection of build tools, we've included some guides that will help you set up and configure Unreal Build System for your own projects. Finally, we've included some guides for advanced users, those wanting to learn more about the Include-What-You-Use (IWYU) dependency model and the BuildGraph scripting system
UnrealBuildTool
UnrealBuildTool (UBT) is a custom tool that manages the process of building the UE4 source code across a variety of build configurations. Check out BuildConfiguration.cs
to explore various user-configurable build options.
UnrealHeaderTool
UnrealHeaderTool (UHT) is a custom parsing and code-generation tool that supports the UObject system. Code compilation happens in two phases:
-
UHT is invoked, which parses the C++ headers for Unreal-related class metadata and generates custom code to implement the various UObject-related features.
-
The normal C++ compiler is invoked to compile the results.
When compiling, it is possible for either tool to emit errors, so be sure to look carefully.
Modular Architecture
UE4 is split into many modules. Each module has a .build.cs
file that controls how it is built, including options for defining module dependencies, additional libraries, include paths, etc. By default, these modules are compiled into DLLs and loaded by a single executable. You can choose to build a monolithic executable in the BuildConfiguration.cs
file.
Using Unreal Build System
Before using Unreal Build System, it is important to understand that the build process executes independently of any project files for the development environment, such as .sln
or .vcproj
files (for Visual Studio). These files are useful to have for editing purposes though, so there is a tool being provided to generate them dynamically (based on the contents of your project directory tree). You can run this tool with the GenerateProject.bat
file located in your [Root UE4]
directory.
Running GenerateProject.bat
from time-to-time will keep your code editor up-to-date with files that are being added to (or being removed) from disk.
Unreal build tool的编译target有多种,总有一款满足你:
UnrealBuildTool supports building several target types:
Game - A standalone game which requires cooked data to run.
Client - Same as Game, but does not include any server code. Useful for networked games.
Server - Same as Game, but does not include any client code. Useful for dedicated servers in networked games.
Editor - A target which extends the Unreal Editor.
Program - A standalone utility program built on top of the Unreal Engine.
Targets are declared through C# source files with a .target.cs extension, and are stored under your project's Source directory. Each .target.cs file declares a class deriving from the TargetRules base class, and sets properties controlling how it should be built from its constructor. When asked to build a target, UnrealBuildTool will compile your target.cs file and construct the class inside it to determine its settings.
GenerateProjectFiles.sh / GenerateProjectFiles.bat的使用
This script is a simple wrapper around Unreal Build Tool, which is launched in a special mode that builds project files instead of building program executables. It invokes Unreal Build Tool with the -ProjectFiles
command-line option.
例子:
GenerateProjectFiles.sh /path/to/.uproject -game -engine
Command-line Options (Advanced) :
The project generator has some optional command-line arguments that you can use if you want to customize your generated project files to suit your needs more closely. Typically these options are not required or recommended.
Option
Description
-CurrentPlatform
Generates buildable projects for only the current desktop platform (Windows or Mac), instead of all detected available target platforms.
-2015
Generates projects in a format native to VS 2015. The Visual C++ 2015 compiler will be used to compile when this option is set.
-2017
Generates projects in a format native to VS 2017. The Visual C++ 2017 compiler will be used to compile when this option is set.
-ThirdParty
Adds headers and other files from third-party libraries to the project. This could be useful if you like to see symbols and files in Visual Assist for PhysX, Steamworks or Bink for example. However, it will make the project files take longer to load!
-Game
GameNameTells the project generator to generate projects that only include code and content for the specified project name, excluding all other discovered projects. Make sure to specify a project name as well. For example
GenerateProjectFiles.bat ShooterGame.uproject -Game
would generate projects that only have source and targets for ShooterGame. If you want to include Engine source code and Programs alongside a single game project, you can also pass the-Engine
parameter.
-Engine
When used with
-Game
, causes Engine code, content, and programs to also be included in the generated solution. This is useful if you think you will need to work with engine source a lot while working on your game project.
-NoIntelliSense
Skips generation of IntelliSense data used for auto-completion and error squiggles in the IDE.
-AllLanguages
Includes engine documentation for all languages. By default, we only include files in the project for English.
-OnlyPublic
When specified, only public header files will be included in the generated projects for Engine modules. By default, all source files are included for Engine modules. This can give you faster project load times, but it might be more difficult to navigate engine code.
-NoShippingConfigs
Omits the
Shipping
andTest
build configurations from the generated projects. This will reduce the number of target configurations you need to deal with.
-Platforms
=PlatformNameOverrides the default set of platforms to generate buildable projects for, and instead generates projects for the platform(s) that you specify. You can specify multiple platforms by separating them with a '+' character. This also causes the generated solution file to be named with a suffix that includes the platform name(s).
UE4的 .uplugin和.uproject
Ref:
https://docs.unrealengine.com/4.27/en-US/ProductionPipelines/UnrealBuildSystem/