Repository navigation
Expand file tree
/
Copy pathModuleRules_Fix.cs
More file actions
2042 lines (1774 loc) · 72.5 KB
/
Copy pathModuleRules_Fix.cs
File metadata and controls
2042 lines (1774 loc) · 72.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using EpicGames.Core;
using Microsoft.Extensions.Logging;
using UnrealBuildBase;
namespace UnrealBuildTool
{
/// <summary>
/// Controls how a particular warning is treated
/// </summary>
public enum WarningLevel
{
/// <summary>
/// Use the default behavior
/// </summary>
Default,
/// <summary>
/// Do not display diagnostics
/// </summary>
Off,
/// <summary>
/// Output warnings normally
/// </summary>
Warning,
/// <summary>
/// Output warnings as errors
/// </summary>
Error,
}
/// <summary>
/// Describes the origin and visibility of Verse code
/// </summary>
public enum VerseScope
{
/// <summary>
/// Created by Epic and only public definitions will be visible to public users
/// </summary>
PublicAPI,
/// <summary>
/// Created by Epic and is entirely hidden from public users
/// </summary>
InternalAPI,
/// <summary>
/// Created by a public user
/// </summary>
PublicUser,
/// <summary>
/// Created by an Epic internal user
/// </summary>
InternalUser
}
/// <summary>
/// To what extent a module supports include-what-you-use
/// </summary>
public enum IWYUSupport
{
/// <summary>
/// None means code does not even compile. IWYU needs to skip this module entirely
/// </summary>
None,
/// <summary>
/// Module could be modified with iwyu but we want it to stay the way it is and handle changes manually
/// </summary>
KeepAsIs,
/// <summary>
/// Module is parsed and processed. This means that from the outside it is stripped for includes
/// even though the files are not modified. This can be used to defer iwyu work on a module.
/// When it comes to transitive includes this module is seen as modified from the outside.
/// </summary>
KeepAsIsForNow,
/// <summary>
/// Same as KeepAsIsForNow but will allow iwyu to update private headers and cpp files.
/// </summary>
KeepPublicAsIsForNow,
/// <summary>
/// Full iwyu support. When running with -Mode=IWYU this module will be modified if needed
/// </summary>
Full,
}
/// <summary>
/// ModuleRules is a data structure that contains the rules for defining a module
/// </summary>
public class ModuleRules
{
/// <summary>
/// Type of module
/// </summary>
public enum ModuleType
{
/// <summary>
/// C++
/// </summary>
CPlusPlus,
/// <summary>
/// External (third-party)
/// </summary>
External,
}
/// <summary>
/// Override the settings of the UHTModuleType to have a different set of
/// PKG_ flags. Cannot set on a plugin because that value already set in
/// the '.uplugin' file
/// </summary>
public enum PackageOverrideType
{
/// <summary>
/// Do not override the package type on this module
/// </summary>
None,
/// <summary>
/// Set the PKG_EditorOnly flag on this module
/// </summary>
EditorOnly,
/// <summary>
/// Set the PKG_Developer on this module
/// </summary>
EngineDeveloper,
/// <summary>
/// Set the PKG_Developer on this module
/// </summary>
GameDeveloper,
/// <summary>
/// Set the PKG_UncookedOnly flag on this module
/// </summary>
EngineUncookedOnly,
/// <summary>
/// Set the PKG_UncookedOnly flag on this module as a game
/// </summary>
GameUncookedOnly
}
/// <summary>
/// Code optimization settings
/// </summary>
public enum CodeOptimization
{
/// <summary>
/// Code should never be optimized if possible.
/// </summary>
Never,
/// <summary>
/// Code should only be optimized in non-debug builds (not in Debug).
/// </summary>
InNonDebugBuilds,
/// <summary>
/// Code should only be optimized in shipping builds (not in Debug, DebugGame, Development)
/// </summary>
InShippingBuildsOnly,
/// <summary>
/// Code should always be optimized if possible.
/// </summary>
Always,
/// <summary>
/// Default: 'InNonDebugBuilds' for game modules, 'Always' otherwise.
/// </summary>
Default,
}
/// <summary>
/// What type of PCH to use for this module.
/// </summary>
public enum PCHUsageMode
{
/// <summary>
/// Default: Engine modules use shared PCHs, game modules do not
/// </summary>
Default,
/// <summary>
/// Never use any PCHs.
/// </summary>
NoPCHs,
/// <summary>
/// Never use shared PCHs. Always generate a unique PCH for this module if appropriate
/// </summary>
NoSharedPCHs,
/// <summary>
/// Shared PCHs are OK!
/// </summary>
UseSharedPCHs,
/// <summary>
/// Shared PCHs may be used if an explicit private PCH is not set through PrivatePCHHeaderFile. In either case, none of the source files manually include a module PCH, and should include a matching header instead.
/// </summary>
UseExplicitOrSharedPCHs,
}
/// <summary>
/// Which type of targets this module should be precompiled for
/// </summary>
public enum PrecompileTargetsType
{
/// <summary>
/// Never precompile this module.
/// </summary>
None,
/// <summary>
/// Inferred from the module's directory. Engine modules under Engine/Source/Runtime will be compiled for games, those under Engine/Source/Editor will be compiled for the editor, etc...
/// </summary>
Default,
/// <summary>
/// Any game targets.
/// </summary>
Game,
/// <summary>
/// Any editor targets.
/// </summary>
Editor,
/// <summary>
/// Any targets.
/// </summary>
Any,
}
/// <summary>
/// Control visibility of symbols in this module for special cases
/// </summary>
public enum SymbolVisibility
{
/// <summary>
/// Standard visibility rules
/// </summary>
Default,
/// <summary>
/// Make sure symbols in this module are visible in Dll builds
/// </summary>
VisibileForDll,
}
/// <summary>
/// Information about a file which is required by the target at runtime, and must be moved around with it.
/// </summary>
[Serializable]
public class RuntimeDependency
{
/// <summary>
/// The file that should be staged. Should use $(EngineDir) and $(ProjectDir) variables as a root, so that the target can be relocated to different machines.
/// </summary>
public string Path { get; init; }
/// <summary>
/// The initial location for this file. It will be copied to Path at build time, ready for staging.
/// </summary>
public string? SourcePath { get; init; }
/// <summary>
/// How to stage this file.
/// </summary>
public StagedFileType Type { get; init; }
/// <summary>
/// Constructor
/// </summary>
/// <param name="inPath">Path to the runtime dependency</param>
/// <param name="inType">How to stage the given path</param>
public RuntimeDependency(string inPath, StagedFileType inType = StagedFileType.NonUFS)
{
Path = inPath;
Type = inType;
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="inPath">Path to the runtime dependency</param>
/// <param name="inSourcePath">Source path for the file in the working tree</param>
/// <param name="inType">How to stage the given path</param>
public RuntimeDependency(string inPath, string inSourcePath, StagedFileType inType = StagedFileType.NonUFS)
{
Path = inPath;
SourcePath = inSourcePath;
Type = inType;
}
}
/// <summary>
/// List of runtime dependencies, with convenience methods for adding new items
/// </summary>
[Serializable]
public class RuntimeDependencyList
{
/// <summary>
/// Inner list of runtime dependencies
/// </summary>
readonly List<RuntimeDependency> _inner = new();
/// <summary>
/// Readonly access of inner list of runtime dependencies
/// </summary>
internal IReadOnlyList<RuntimeDependency> Inner => _inner.AsReadOnly();
/// <summary>
/// Default constructor
/// </summary>
public RuntimeDependencyList()
{
}
/// <summary>
/// Add a runtime dependency to the list
/// </summary>
/// <param name="inPath">Path to the runtime dependency. May include wildcards.</param>
public void Add(string inPath)
{
_inner.Add(new RuntimeDependency(inPath));
}
/// <summary>
/// Add a runtime dependency to the list
/// </summary>
/// <param name="inPath">Path to the runtime dependency. May include wildcards.</param>
/// <param name="inType">How to stage this file</param>
public void Add(string inPath, StagedFileType inType)
{
_inner.Add(new RuntimeDependency(inPath, inType));
}
/// <summary>
/// Add a runtime dependency to the list
/// </summary>
/// <param name="inPath">Path to the runtime dependency. May include wildcards.</param>
/// <param name="inSourcePath">Source path for the file to be added as a dependency. May include wildcards.</param>
/// <param name="inType">How to stage this file</param>
public void Add(string inPath, string inSourcePath, StagedFileType inType = StagedFileType.NonUFS)
{
_inner.Add(new RuntimeDependency(inPath, inSourcePath, inType));
}
}
/// <summary>
/// List of runtime dependencies, with convenience methods for adding new items
/// </summary>
[Serializable]
public class ReceiptPropertyList
{
/// <summary>
/// Inner list of runtime dependencies
/// </summary>
readonly List<ReceiptProperty> _inner = new();
/// <summary>
/// Readonly access of inner list of runtime dependencies
/// </summary>
internal IReadOnlyList<ReceiptProperty> Inner => _inner.AsReadOnly();
/// <summary>
/// Default constructor
/// </summary>
public ReceiptPropertyList()
{
}
/// <summary>
/// Add a receipt property to the list
/// </summary>
/// <param name="name">Name of the property</param>
/// <param name="value">Value for the property</param>
public void Add(string name, string value)
{
_inner.Add(new ReceiptProperty(name, value));
}
/// <summary>
/// Remove recepit properties from the list
/// </summary>
/// <param name="match">the maatcher predicate</param>
/// <returns>the number of items removed</returns>
public int RemoveAll(Predicate<ReceiptProperty> match)
{
return _inner.RemoveAll(match);
}
}
/// <summary>
/// Stores information about a framework on IOS or MacOS
/// </summary>
public class Framework
{
/// <summary>
/// Name of the framework
/// </summary>
internal string Name { get; init; }
/// <summary>
/// Specifies the path to a zip file that contains it or where the framework is located on disk
/// </summary>
internal string Path { get; init; }
/// <summary>
///
/// </summary>
internal string? CopyBundledAssets { get; init; } = null;
/// <summary>
/// How to handle linking and copying the framework
/// </summary>
public enum FrameworkMode
{
/// <summary>
/// Pass this framework to the linker
/// </summary>
Link,
/// <summary>
/// Copy this framework into the final .app
/// </summary>
Copy,
/// <summary>
/// Both link into executable and copy into .app
/// </summary>
LinkAndCopy,
}
/// <summary>
/// How to treat the framework during linking and creating the .app
/// </summary>
internal FrameworkMode Mode { get; init; }
/// <summary>
/// Constructor
/// </summary>
/// <param name="name">Name of the framework</param>
/// <param name="path">Path to a zip file containing the framework or a framework on disk</param>
/// <param name="copyBundledAssets"></param>
/// <param name="bCopyFramework">Copy the framework to the target's Framework directory</param>
public Framework(string name, string path, string? copyBundledAssets = null, bool bCopyFramework = false)
: this(name, path, bCopyFramework ? FrameworkMode.LinkAndCopy : FrameworkMode.Link, copyBundledAssets)
{
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="name">Name of the framework</param>
/// <param name="path">Path to a zip file containing the framework or a framework on disk</param>
/// <param name="mode">How to treat the framework during linking and creating the .app</param>
/// <param name="copyBundledAssets"></param>
public Framework(string name, string path, FrameworkMode mode, string? copyBundledAssets = null)
{
Name = name;
Path = path;
Mode = mode;
CopyBundledAssets = copyBundledAssets;
}
/// <summary>
/// Specifies if the file is a zip file
/// </summary>
public bool IsZipFile() => Path.EndsWith(".zip", StringComparison.OrdinalIgnoreCase);
}
/// <summary>
///
/// </summary>
public class BundleResource
{
/// <summary>
///
/// </summary>
public string? ResourcePath { get; init; } = null;
/// <summary>
///
/// </summary>
public string? BundleContentsSubdir { get; init; } = null;
/// <summary>
///
/// </summary>
public bool bShouldLog { get; init; } = true;
/// <summary>
/// Constructor
/// </summary>
/// <param name="resourcePath"></param>
/// <param name="bundleContentsSubdir"></param>
/// <param name="bShouldLog"></param>
public BundleResource(string resourcePath, string bundleContentsSubdir = "Resources", bool bShouldLog = true)
{
ResourcePath = resourcePath;
BundleContentsSubdir = bundleContentsSubdir;
this.bShouldLog = bShouldLog;
}
}
/// <summary>
/// Information about a Windows type library (TLB/OLB file) which requires a generated header.
/// </summary>
public class TypeLibrary
{
/// <summary>
/// Name of the type library
/// </summary>
public string FileName { get; init; }
/// <summary>
/// Additional attributes for the #import directive
/// </summary>
public string Attributes { get; init; }
/// <summary>
/// Name of the output header
/// </summary>
public string Header { get; init; }
/// <summary>
/// Name of the output include
/// </summary>
public string? Include { get; init; }
/// <summary>
/// Constructor
/// </summary>
/// <param name="fileName">Name of the type library. Follows the same conventions as the filename parameter in the MSVC #import directive.</param>
/// <param name="attributes">Additional attributes for the import directive</param>
/// <param name="header">Name of the output header</param>
/// <param name="include">Name of the output include</param>
public TypeLibrary(string fileName, string attributes, string header, string? include = null)
{
FileName = fileName;
Attributes = attributes;
Header = header;
Include = include;
}
}
/// <summary>
/// Name of this module
/// </summary>
public string Name { get; internal set; }
/// <summary>
/// File containing this module
/// </summary>
internal FileReference File { get; set; }
/// <summary>
/// Directory containing this module
/// </summary>
internal DirectoryReference Directory { get; set; }
/// <summary>
/// The Directory that contains either the Build.cs file, or the platform extension's SubClass directory
/// </summary>
protected DirectoryReference PlatformDirectory => DirectoriesForModuleSubClasses[GetType()]; // this is expected to always exist if we are able to be queried
/// <summary>
/// Returns true if the rules are a platform extension subclass
/// </summary>
protected bool bIsPlatformExtension => (Directory != PlatformDirectory);
/// <summary>
/// Additional directories that contribute to this module (likely in UnrealBuildTool.EnginePlatformExtensionsDirectory).
/// The dictionary tracks module subclasses
/// </summary>
internal Dictionary<Type, DirectoryReference> DirectoriesForModuleSubClasses;
/// <summary>
/// Additional directories that contribute to this module but are not based on a subclass (NotForLicensees, etc)
/// </summary>
private List<DirectoryReference> AdditionalModuleDirectories = new();
/// <summary>
/// The rules assembly to use when searching for modules
/// </summary>
internal RulesAssembly RulesAssembly;
/// <summary>
/// Plugin containing this module
/// </summary>
internal PluginInfo? Plugin;
/// <summary>
/// True if a Plugin contains this module
/// </summary>
public bool IsPlugin => Plugin != null;
/// <summary>
/// The rules context for this instance
/// </summary>
internal ModuleRulesContext Context { get; set; }
/// <summary>
/// Rules for the target that this module belongs to
/// </summary>
public ReadOnlyTargetRules Target { get; init; }
/// <summary>
/// Type of module
/// </summary>
public ModuleType Type { get; set; } = ModuleType.CPlusPlus;
/// <summary>
/// Accessor for the target logger
/// </summary>
public ILogger Logger => Target.Logger;
/// <summary>
/// Overridden type of module that will set different package flags.
/// Cannot be used for modules that are a part of a plugin because that is
/// set in the `.uplugin` file already.
/// </summary>
public PackageOverrideType OverridePackageType
{
get => overridePackageType ?? PackageOverrideType.None;
set => overridePackageType = !IsPlugin
? value
: throw new CompilationResultException(CompilationResult.RulesError, KnownLogEvents.RulesAssembly, "Module '{ModuleName}' cannot override package type because it is part of a plugin!", Name);
}
private PackageOverrideType? overridePackageType;
/// <summary>
/// Returns true if there has been an override type specified on this module
/// </summary>
public bool HasPackageOverride => OverridePackageType != PackageOverrideType.None;
/// <summary>
/// Subfolder of Binaries/PLATFORM folder to put this module in when building DLLs. This should only be used by modules that are found via searching like the
/// TargetPlatform or ShaderFormat modules. If FindModules is not used to track them down, the modules will not be found.
/// </summary>
public string BinariesSubFolder { get; set; } = String.Empty;
private CodeOptimization? OptimizeCodeOverride;
/// <summary>
/// When this module's code should be optimized.
/// </summary>
public CodeOptimization OptimizeCode
{
get
{
if (bCodeCoverage)
{
return CodeOptimization.Never;
}
if (OptimizeCodeOverride.HasValue)
{
return OptimizeCodeOverride.Value;
}
bool? shouldOptimizeCode = null;
if (Target.EnableOptimizeCodeForModules?.Contains(Name) ?? false)
{
shouldOptimizeCode = true;
}
if (Target.DisableOptimizeCodeForModules?.Contains(Name) ?? false)
{
shouldOptimizeCode = false;
}
if (!shouldOptimizeCode.HasValue)
{
return CodeOptimization.Default;
}
return shouldOptimizeCode.Value ? CodeOptimization.Always : CodeOptimization.Never;
}
set => OptimizeCodeOverride = value;
}
private OptimizationMode? OptimizationLevelOverride = null;
/// <summary>
/// Allows fine tuning optimization level for speed and\or code size. This requires a private PCH (or NoPCHs, which is not recommended)
/// </summary>
public OptimizationMode OptimizationLevel
{
get
{
if (Target.OptimizeForSizeModules?.Contains(Name) ?? false)
{
return OptimizationMode.Size;
}
if (Target.OptimizeForSizeAndSpeedModules?.Contains(Name) ?? false)
{
return OptimizationMode.SizeAndSpeed;
}
if (OptimizationLevelOverride.HasValue)
{
return OptimizationLevelOverride.Value;
}
else
{
return Target.OptimizationLevel;
}
}
set => OptimizationLevelOverride = value;
}
/// <summary>
/// Allows overriding the FP semantics for this module. This requires a private PCH (or NoPCHs, which is not recommended)
/// </summary>
public FPSemanticsMode FPSemantics
{
get => FPSemanticsPrivate ?? Target.FPSemantics;
set => FPSemanticsPrivate = value;
}
private FPSemanticsMode? FPSemanticsPrivate = null;
/// <summary>
/// Header files that should be force included for every source file in this module.
/// </summary>
public List<string> ForceIncludeFiles { get; } = new List<string>();
/// <summary>
/// Explicit private PCH for this module. Implies that this module will not use a shared PCH.
/// </summary>
public string? PrivatePCHHeaderFile { get; set; }
/// <summary>
/// Header file name for a shared PCH provided by this module. Must be a valid relative path to a public C++ header file.
/// This should only be set for header files that are included by a significant number of other C++ modules.
/// </summary>
public string? SharedPCHHeaderFile { get; set; }
/// <summary>
/// Specifies an alternate name for intermediate directories and files for intermediates of this module. Useful when hitting path length limitations.
/// </summary>
public string? ShortName { get; set; } = null;
/// <summary>
/// Precompiled header usage for this module
/// </summary>
public PCHUsageMode PCHUsage
{
get
{
if (PCHUsagePrivate.HasValue)
{
// Use the override
return PCHUsagePrivate.Value;
}
else if (Target.bEnableCppModules)
{
return PCHUsageMode.NoPCHs;
}
else if (Target.bIWYU || DefaultBuildSettings >= BuildSettingsVersion.V2)
{
// Use shared or explicit PCHs, and enable IWYU
return PCHUsageMode.UseExplicitOrSharedPCHs;
}
else if (Plugin != null)
{
// Older plugins use shared PCHs by default, since they aren't typically large enough to warrant their own PCH.
return PCHUsageMode.UseSharedPCHs;
}
else
{
// Older game modules do not enable shared PCHs by default, because games usually have a large precompiled header of their own.
return PCHUsageMode.NoSharedPCHs;
}
}
set => PCHUsagePrivate = value;
}
private PCHUsageMode? PCHUsagePrivate;
/// <summary>
/// Whether this module should be treated as an engine module (eg. using engine definitions, PCHs, compiled with optimizations enabled in DebugGame configurations, etc...).
/// Initialized to a default based on the rules assembly it was created from.
/// </summary>
public bool bTreatAsEngineModule { get; set; }
/// <summary>
/// If this contains a platform and the project has had it's SDK version overriden from default, this module will be compiled as a project module, instead of shared engine module
/// </summary>
public List<UnrealTargetPlatform> SDKVersionRelevantPlatforms { get; } = new();
/// <summary>
/// Emits compilation errors for incorrect UE_LOG format strings.
/// </summary>
public bool bValidateFormatStrings
{
get => bValidateFormatStringsPrivate ?? (bTreatAsEngineModule || Target.bValidateFormatStrings);
set => bValidateFormatStringsPrivate = value;
}
private bool? bValidateFormatStringsPrivate;
/// <summary>
/// Emits deprecated warnings\errors for internal API usage for non-engine modules
/// </summary>
public bool bValidateInternalApi
{
get => bValidateInternalApiPrivate ?? !bTreatAsEngineModule;
set => bValidateInternalApiPrivate = value;
}
private bool? bValidateInternalApiPrivate;
/// <summary>
/// Which engine version's build settings to use by default.
/// </summary>
public BuildSettingsVersion DefaultBuildSettings
{
get => DefaultBuildSettingsPrivate ?? Target.DefaultBuildSettings;
set => DefaultBuildSettingsPrivate = value;
}
private BuildSettingsVersion? DefaultBuildSettingsPrivate;
/// <summary>
/// What version of include order to use when compiling this module. Can be overridden via -ForceIncludeOrder on the command line or in a module's rules.
/// </summary>
public EngineIncludeOrderVersion IncludeOrderVersion
{
get
{
if (Target.ForcedIncludeOrder != null)
{
return Target.ForcedIncludeOrder.Value;
}
if (bTreatAsEngineModule)
{
return EngineIncludeOrderVersion.Latest;
}
return IncludeOrderVersionPrivate ?? Target.IncludeOrderVersion;
}
set => IncludeOrderVersionPrivate = value;
}
private EngineIncludeOrderVersion? IncludeOrderVersionPrivate;
/// <summary>
/// Use run time type information
/// </summary>
public bool bUseRTTI { get; set; }
/// <summary>
/// Whether to direct MSVC to remove unreferenced COMDAT functions and data.
/// </summary>
/// <seealso href="https://learn.microsoft.com/en-us/cpp/build/reference/zc-inline-remove-unreferenced-comdat">zc-inline-remove-unreferenced-comdat</seealso>
public bool bVcRemoveUnreferencedComdat { get; set; } = true;
/// <summary>
/// Enable code coverage compilation/linking support.
/// </summary>
public bool bCodeCoverage { get; set; }
/// <summary>
/// Obsolete: Direct the compiler to generate AVX instructions wherever SSE or AVX intrinsics are used, on the platforms that support it.
/// Note that by enabling this you are changing the minspec for the PC platform, and the resultant executable will crash on machines without AVX support.
/// </summary>
[Obsolete("bUseAVX is obsolete and will be removed in UE5.4, please replace with MinCpuArchX64")]
public bool bUseAVX
{
get => MinCpuArchX64 >= MinimumCpuArchitectureX64.AVX;
set => MinCpuArchX64 = value ? MinimumCpuArchitectureX64.AVX : MinimumCpuArchitectureX64.None;
}
/// <summary>
/// Direct the compiler to generate AVX instructions wherever SSE or AVX intrinsics are used, on the x64 platforms that support it.
/// Note that by enabling this you are changing the minspec for the PC platform, and the resultant executable will crash on machines without AVX support.
/// </summary>
public MinimumCpuArchitectureX64? MinCpuArchX64 { get; set; } = null;
/// <summary>
/// Enable buffer security checks. This should usually be enabled as it prevents severe security risks.
/// </summary>
public bool bEnableBufferSecurityChecks { get; set; } = true;
/// <summary>
/// Enable exception handling
/// </summary>
public bool bEnableExceptions { get; set; }
/// <summary>
/// Enable objective C exception handling
/// </summary>
public bool bEnableObjCExceptions { get; set; }
/// <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 { get; set; }
/// <summary>
/// How to treat deterministic warnings (experimental).
/// </summary>
public WarningLevel DeterministicWarningLevel
{
get => (DeterministicWarningLevelPrivate == WarningLevel.Default) ? (Target.bDeterministic ? WarningLevel.Warning : WarningLevel.Off) : DeterministicWarningLevelPrivate;
set => DeterministicWarningLevelPrivate = value;
}
/// <inheritdoc cref="DeterministicWarningLevelPrivate"/>
private WarningLevel DeterministicWarningLevelPrivate;
/// <summary>
/// How to treat shadow variable warnings
/// </summary>
public WarningLevel ShadowVariableWarningLevel
{
get => (ShadowVariableWarningLevelPrivate == WarningLevel.Default) ? ((DefaultBuildSettings >= BuildSettingsVersion.V2) ? WarningLevel.Error : Target.ShadowVariableWarningLevel) : ShadowVariableWarningLevelPrivate;
set => ShadowVariableWarningLevelPrivate = value;
}
/// <inheritdoc cref="ShadowVariableWarningLevelPrivate"/>
private WarningLevel ShadowVariableWarningLevelPrivate;
/// <summary>
/// Whether to enable all warnings as errors. UE enables most warnings as errors already, but disables a few (such as deprecation warnings).
/// </summary>`
public bool bWarningsAsErrors { get; set; }
/// <summary>
/// How to treat unsafe implicit type cast warnings (e.g., double->float or int64->int32)
/// </summary>
public WarningLevel UnsafeTypeCastWarningLevel
{
get => (UnsafeTypeCastWarningLevelPrivate == WarningLevel.Default) ? Target.UnsafeTypeCastWarningLevel : UnsafeTypeCastWarningLevelPrivate;
set => UnsafeTypeCastWarningLevelPrivate = value;
}
/// <inheritdoc cref="UnsafeTypeCastWarningLevel"/>
private WarningLevel UnsafeTypeCastWarningLevelPrivate;
/// <summary>
/// Indicates what warning/error level to treat undefined identifiers in conditional expressions.
/// </summary>
public WarningLevel UndefinedIdentifierWarningLevel
{
get => (_undefinedIdentifierWarningLevelPrivate == WarningLevel.Default) ? Target.UndefinedIdentifierWarningLevel : _undefinedIdentifierWarningLevelPrivate;
set => _undefinedIdentifierWarningLevelPrivate = value;
}
/// <inheritdoc cref="UndefinedIdentifierWarningLevel"/>
private WarningLevel _undefinedIdentifierWarningLevelPrivate;
/// <summary>
/// Enable warnings for using undefined identifiers in #if expressions
/// </summary>
[Obsolete("Deprecated in UE5.5 - Replace with ModuleRules.UndefinedIdentifierWarningLevel")]
public bool bEnableUndefinedIdentifierWarnings { get; set; } = true;
/// <summary>
/// How to treat general module include path validation messages
/// </summary>
public WarningLevel ModuleIncludePathWarningLevel
{
get => (ModuleIncludePathWarningLevelPrivate == WarningLevel.Default) ? Target.ModuleIncludePathWarningLevel : ModuleIncludePathWarningLevelPrivate;
set => ModuleIncludePathWarningLevelPrivate = value;
}
/// <inheritdoc cref="ModuleIncludePathWarningLevel"/>
private WarningLevel ModuleIncludePathWarningLevelPrivate;
/// <summary>
/// How to treat private module include path validation messages, where a module is adding an include path that exposes private headers
/// </summary>
public WarningLevel ModuleIncludePrivateWarningLevel
{
get => (ModuleIncludePrivateWarningLevelPrivate == WarningLevel.Default) ? Target.ModuleIncludePrivateWarningLevel : ModuleIncludePrivateWarningLevelPrivate;
set => ModuleIncludePrivateWarningLevelPrivate = value;
}
/// <inheritdoc cref="ModuleIncludePrivateWarningLevel"/>
private WarningLevel ModuleIncludePrivateWarningLevelPrivate;
/// <summary>