@@ -403,13 +403,22 @@ def ProcessSourceFile(info):
403
403
writeFile (filePath , lines )
404
404
return True
405
405
406
+ def HasUObjectMacros (rawLines ):
407
+ # Check if any line contains UCLASS(, USTRUCT(, or UENUM(
408
+ pattern = r'(UCLASS|USTRUCT|UENUM)\s*\('
409
+ for line in rawLines :
410
+ if re .search (pattern , StripComment (line )):
411
+ return True
412
+ return False
413
+
406
414
407
415
# returns success, includes[], custom_includes[], genheader, code[]
408
416
def ProcessHeaderRawLines (rawLines , cname ):
409
417
code = []
410
418
includes = []
411
419
custom_includes = []
412
420
genheader = None
421
+ needs_generated = HasUObjectMacros (rawLines )
413
422
414
423
# Make sure we have a line ending
415
424
if len (rawLines ) > 0 and len (rawLines [- 1 ]) > 0 :
@@ -439,10 +448,11 @@ def ProcessHeaderRawLines(rawLines, cname):
439
448
elif IsLineInclude (rawLine ):
440
449
if rawLine .strip ().endswith (".generated.h\" " ):
441
450
genheader = rawLine
451
+ needs_generated = False
442
452
else :
443
453
includes .append (rawLine )
444
454
else :
445
- bProcessingHeader = False ;
455
+ bProcessingHeader = False
446
456
447
457
if not bProcessingHeader :
448
458
code .append (rawLine )
@@ -454,6 +464,10 @@ def ProcessHeaderRawLines(rawLines, cname):
454
464
print ("WARN: Malformed custom include block. %s.cpp" % cname )
455
465
Success = False
456
466
467
+ # If we need a generated header but don't have one, create it
468
+ if needs_generated and not genheader :
469
+ genheader = f'#include "{ cname } .generated.h"'
470
+
457
471
return Success , includes , custom_includes , genheader , code
458
472
459
473
@@ -466,7 +480,7 @@ def StripComment(line):
466
480
467
481
def ValidateHeaderRawLines (rawLines , filename ):
468
482
# Check if blueprint properties have category defined
469
- pattern = '(UPROPERTY|UFUNCTION)\((.*Blueprint.*)\)'
483
+ pattern = r '(UPROPERTY|UFUNCTION)\((.*Blueprint.*)\)'
470
484
for i , rawLine in enumerate (rawLines ):
471
485
line = StripComment (rawLine )
472
486
m = re .search (pattern , line )
0 commit comments