ModuleDescriptor-Unreal4源码拆解-UnrealBuildTool功能流程解析

Unreal4源码拆解-UnrealBuildTool功能流程解析-ModuleDescriptor

知乎专栏:UBT源码解析

  • 引擎版本4.27
  • 4.2x功能不会差太多

主要功能

概括

  • ModuleDescriptor类,如其命名,模块描述信息
  • 功能上大致是以JSON的方式读取和更新 .uplugin文件
  • 具体设计上类内变量名和JSON中项名相同。
    注意:可读可写
.uplugin文件

首先.uplugin文件文件是JSON文件,在每个插件的主文件夹中描述插件信息的文件。举例:
Engine\Plugins\Animation\LiveLinkCurveDebugUI\ LiveLinkCurveDebugUI.uplugin

{
	//PluginDescriptor描述区域
	"FileVersion": 3,
	"Version": 1,
	"VersionName": "0.1",
	"FriendlyName": "Live Link Curve Debug UI",
	"Description": "Allows Viewing LiveLink Curve Debug Information",
	"Category": "Animation",
	"CreatedBy": "Epic Games, Inc.",
	"CreatedByURL": "http://epicgames.com",
	"DocsURL": "",
	"MarketplaceURL": "",
	"SupportURL": "",
	"EnabledByDefault": false,
	"CanContainContent": false,
	"IsBetaVersion": true,
	
	//ModuleDescriptor描述区域
	"Modules": [
		{
			"Name": "LiveLinkCurveDebugUI",
			"Type": "Runtime",
			"LoadingPhase": "PreDefault"
		}
	],
	//ModuleDescriptor描述区域
	//PluginReferenceDescriptor描述区域
	"Plugins": [
		{
			"Name": "LiveLink",
			"Enabled": true
		}
	]
	//PluginReferenceDescriptor描述区域
	
	//PluginDescriptor描述区域
}

枚举

enum ModuleHostType
  • 主要功能:表示模块运行的主机类型
	public enum ModuleHostType
	{
		/// <summary>
		/// 
		/// </summary>
		Default,

		/// <summary>
		/// Any target using the UE4 runtime
		/// </summary>
		Runtime,

		/// <summary>
		/// Any target except for commandlet
		/// </summary>
		RuntimeNoCommandlet,

        /// <summary>
        /// Any target or program
        /// </summary>
        RuntimeAndProgram,

		/// <summary>
		/// Loaded only in cooked builds
		/// </summary>
		CookedOnly,

		/// <summary>
		/// Loaded only in uncooked builds
		/// </summary>
		UncookedOnly,

		/// <summary>
		/// Loaded only when the engine has support for developer tools enabled
		/// </summary>
		Developer,

		/// <summary>
		/// Loads on any targets where bBuildDeveloperTools is enabled
		/// </summary>
		DeveloperTool,

		/// <summary>
		/// Loaded only by the editor
		/// </summary>
		Editor,

		/// <summary>
		/// Loaded only by the editor, except when running commandlets
		/// </summary>
		EditorNoCommandlet,

		/// <summary>
		/// Loaded by the editor or program targets
		/// </summary>
		EditorAndProgram,

		/// <summary>
		/// Loaded only by programs
		/// </summary>
		Program,

		/// <summary>
		/// Loaded only by servers
		/// </summary>
        	ServerOnly,

		/// <summary>
		/// Loaded only by clients, and commandlets, and editor....
		/// </summary>
        	ClientOnly,

		/// <summary>
		/// Loaded only by clients and editor (editor can run PIE which is kinda a commandlet)
		/// </summary>
		ClientOnlyNoCommandlet,
	}
enum ModuleLoadingPhase
  • 主要功能:表示模块加载时机
	public enum ModuleLoadingPhase
	{
		/// <summary>
		/// Loaded at the default loading point during startup (during engine init, after game modules are loaded.)
		/// </summary>
		Default,

		/// <summary>
		/// Right after the default phase
		/// </summary>
		PostDefault,

		/// <summary>
		/// Right before the default phase
		/// </summary>
		PreDefault,

		/// <summary>
		/// Loaded as soon as plugins can possibly be loaded (need GConfig)
		/// </summary>
		EarliestPossible,

		/// <summary>
		/// Loaded before the engine is fully initialized, immediately after the config system has been initialized.  Necessary only for very low-level hooks
		/// </summary>
		PostConfigInit,

		/// <summary>
		/// The first screen to be rendered after system splash screen
		/// </summary>
		PostSplashScreen,

		/// <summary>
		/// After PostConfigInit and before coreUobject initialized. used for early boot loading screens before the uobjects are initialized
		/// </summary>
		PreEarlyLoadingScreen,

		/// <summary>
		/// Loaded before the engine is fully initialized for modules that need to hook into the loading screen before it triggers
		/// </summary>
		PreLoadingScreen,

		/// <summary>
		/// After the engine has been initialized
		/// </summary>
		PostEngineInit,

		/// <summary>
		/// Do not automatically load this module
		/// </summary>
		None,
	}

主要成员变量

public readonly string Name;
  • 主要功能:表示模块名称
public ModuleHostType Type;
  • 主要功能:表示模块使用的主机类型
public ModuleLoadingPhase LoadingPhase = ModuleLoadingPhase.Default;
  • 主要功能:表示模块加载阶段
public List WhitelistPlatforms;
  • 主要功能:表示模块支持的白名单平台
public List BlacklistPlatforms;
  • 主要功能:表示模块支持的黑名单平台
public TargetType[] WhitelistTargets;
  • 主要功能:表示模块支持的白名单目标类型
public TargetType[] BlacklistTargets;
  • 主要功能:表示模块支持的黑名单目标类型
	public enum TargetType
	{
		/// <summary>
		/// Cooked monolithic game executable (GameName.exe).  Also used for a game-agnostic engine executable (UE4Game.exe or RocketGame.exe)
		/// </summary>
		Game,

		/// <summary>
		/// Uncooked modular editor executable and DLLs (UE4Editor.exe, UE4Editor*.dll, GameName*.dll)
		/// </summary>
		Editor,

		/// <summary>
		/// Cooked monolithic game client executable (GameNameClient.exe, but no server code)
		/// </summary>
		Client,

		/// <summary>
		/// Cooked monolithic game server executable (GameNameServer.exe, but no client code)
		/// </summary>
		Server,

		/// <summary>
		/// Program (standalone program, e.g. ShaderCompileWorker.exe, can be modular or monolithic depending on the program)
		/// </summary>
		Program,
	}
public UnrealTargetConfiguration[] WhitelistTargetConfigurations;
  • 主要功能:表示模块支持的白名单目标配置类型
public UnrealTargetConfiguration[] BlacklistTargetConfigurations;
  • 主要功能:表示模块支持的黑名单目标配置类型
public string[] WhitelistPrograms;
  • 主要功能:表示模块依赖的白名单程序
public string[] BlacklistPrograms;
  • 主要功能:表示模块依赖的黑名单程序
public string[] AdditionalDependencies;
  • 主要功能:传入JSON对象,解析每一个条目并设置到同名变量中

主要成员函数

public static ModuleDescriptor FromJsonObject(JsonObject InObject)
  • 主要功能:传入文件,新建并且返回一个PluginDescriptor对象
void Write(JsonWriter Writer)
  • 主要功能:更新信息到Json中。
public static void WriteArray(JsonWriter Writer, string Name, ModuleDescriptor[] Modules)
  • 主要功能:同时更新多个ModuleDescriptor信息到其对应的Json中。
public void Validate(FileReference File)
  • Tip: 传入参数没有用,只是报错信息
  • 主要功能:模块可以加载的目标程序类型是Developer则报错不支持,ModuleHostType.Developer4.24及以后被弃用了
public bool IsCompiledInConfiguration(UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, string TargetName, TargetType TargetType, bool bBuildDeveloperTools, bool bBuildRequiresCookedData)
  • 决定当前给定的插件模块是否在本次build中被编译

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值