Skip to content

Commit ac33e13

Browse files
committed
Fixed a warning
1 parent 62ad254 commit ac33e13

File tree

4 files changed

+21
-486
lines changed

4 files changed

+21
-486
lines changed

.idea/misc.xml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/ue4-code-headers-lint.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fix_header.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,22 @@ def ProcessSourceFile(info):
403403
writeFile(filePath, lines)
404404
return True
405405

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+
406414

407415
# returns success, includes[], custom_includes[], genheader, code[]
408416
def ProcessHeaderRawLines(rawLines, cname):
409417
code = []
410418
includes = []
411419
custom_includes = []
412420
genheader = None
421+
needs_generated = HasUObjectMacros(rawLines)
413422

414423
# Make sure we have a line ending
415424
if len(rawLines) > 0 and len(rawLines[-1]) > 0:
@@ -439,10 +448,11 @@ def ProcessHeaderRawLines(rawLines, cname):
439448
elif IsLineInclude(rawLine):
440449
if rawLine.strip().endswith(".generated.h\""):
441450
genheader = rawLine
451+
needs_generated = False
442452
else:
443453
includes.append(rawLine)
444454
else:
445-
bProcessingHeader = False;
455+
bProcessingHeader = False
446456

447457
if not bProcessingHeader:
448458
code.append(rawLine)
@@ -454,6 +464,10 @@ def ProcessHeaderRawLines(rawLines, cname):
454464
print("WARN: Malformed custom include block. %s.cpp" % cname)
455465
Success = False
456466

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+
457471
return Success, includes, custom_includes, genheader, code
458472

459473

@@ -466,7 +480,7 @@ def StripComment(line):
466480

467481
def ValidateHeaderRawLines(rawLines, filename):
468482
# Check if blueprint properties have category defined
469-
pattern = '(UPROPERTY|UFUNCTION)\((.*Blueprint.*)\)'
483+
pattern = r'(UPROPERTY|UFUNCTION)\((.*Blueprint.*)\)'
470484
for i, rawLine in enumerate(rawLines):
471485
line = StripComment(rawLine)
472486
m = re.search(pattern, line)

0 commit comments

Comments
 (0)