Support enable ARC in modules

#jira UE-107891
#review @Sam.Zamani @Bertrand.Carre @Chris.Varnsverry @Roman.Dzieciol @Josh.Adams  @Jack.Porter
#preflight

[CL 23133821 by Rafa Lecina in ue5-main branch]
This commit is contained in:
Rafa Lecina
2022-11-15 06:02:36 -05:00
parent 758d8e4330
commit df001c1d21
7 changed files with 41 additions and 8 deletions
@@ -720,6 +720,13 @@ namespace UnrealBuildTool
/// </summary>
public bool bEnableObjCExceptions = false;
/// <summary>
/// Enable objective C automatic reference counting (ARC)
/// If you set this to true you should not use shared PCHs for this module. The engine won't be extensively using ARC in the short term
/// Not doing this will result in a compile errors because shared PCHs were compiled with different flags than consumer
/// </summary>
public bool bEnableObjCAutomaticReferenceCounting = false;
/// <summary>
/// How to treat shadow variable warnings
/// </summary>
@@ -1558,6 +1558,7 @@ namespace UnrealBuildTool
Result.bBuildLocallyWithSNDBS = Rules.bBuildLocallyWithSNDBS;
Result.bEnableExceptions |= Rules.bEnableExceptions;
Result.bEnableObjCExceptions |= Rules.bEnableObjCExceptions;
Result.bEnableObjCAutomaticReferenceCounting = Rules.bEnableObjCAutomaticReferenceCounting;
Result.ShadowVariableWarningLevel = Rules.ShadowVariableWarningLevel;
Result.UnsafeTypeCastWarningLevel = Rules.UnsafeTypeCastWarningLevel;
Result.bDisableStaticAnalysis = Rules.bDisableStaticAnalysis;
@@ -228,6 +228,13 @@ namespace UnrealBuildTool
/// </summary>
public bool bEnableObjCExceptions = false;
/// <summary>
/// Enable objective C automatic reference counting (ARC)
/// If you set this to true you should not use shared PCHs for this module. The engine won't be extensively using ARC in the short term
/// Not doing this will result in a compile errors because shared PCHs were compiled with different flags than consumer
/// </summary>
public bool bEnableObjCAutomaticReferenceCounting = false;
/// <summary>
/// How to treat any warnings in the code
/// </summary>
@@ -526,6 +533,7 @@ namespace UnrealBuildTool
bRetainFramePointers = Other.bRetainFramePointers;
bEnableExceptions = Other.bEnableExceptions;
bEnableObjCExceptions = Other.bEnableObjCExceptions;
bEnableObjCAutomaticReferenceCounting = Other.bEnableObjCAutomaticReferenceCounting;
DefaultWarningLevel = Other.DefaultWarningLevel;
DeprecationWarningLevel = Other.DeprecationWarningLevel;
ShadowVariableWarningLevel = Other.ShadowVariableWarningLevel;
@@ -254,6 +254,16 @@ namespace UnrealBuildTool
return Definition.Contains("\"") ? Definition.Replace("\"", "\\\"") : Definition;
}
protected override void GetCppStandardCompileArgument(CppCompileEnvironment CompileEnvironment, List<string> Arguments)
{
if (CompileEnvironment.bEnableObjCAutomaticReferenceCounting)
{
Arguments.Add("-fobjc-arc");
}
base.GetCppStandardCompileArgument(CompileEnvironment, Arguments);
}
protected override void GetCompileArguments_CPP(CppCompileEnvironment CompileEnvironment, List<string> Arguments)
{
Arguments.Add("-x objective-c++");