in src/advisor/scanners/makefile_scanner.py [0:0]
def scan_file_object(self, filename, file, report):
continuation_parser = ContinuationParser()
old_crt_lib_name = None
seen_ucrt = False
other_arch_cpu_condition = None
seen_aarch64_cpu_condition = False
d_other_arch = None
seen_d_aarch64 = False
targets = set()
commands = set()
assignments = dict()
continuation_line = None
for lineno, line in enumerate(file, 1):
line = continuation_parser.parse_line(line)
if not line:
continue
match = MakefileScanner.ARCH_SPECIFIC_LIBS_RE_PROG.search(line)
if match:
lib_name = match.group(1)
report.add_issue(ArchSpecificLibraryIssue(
filename, lineno + 1, lib_name))
match = MakefileScanner.OLD_CRT_RE_PROG.search(line)
if match:
old_crt_lib_name = match.group(1)
match = MakefileScanner.UCRT_RE_PROG.search(line)
if match:
seen_ucrt = True
match = MakefileScanner.OTHER_ARCH_CPU_LINE_RE_PROG.search(line)
if match:
other_arch_cpu_condition = line
match = MakefileScanner.AARCH64_CPU_LINE_RE_PROG.search(line)
if match:
seen_aarch64_cpu_condition = True
match = MakefileScanner.TARGET_RE_PROG.search(line)
if match:
target = match.group(1)
if target.startswith('./') or target.startswith('.\\'):
target = target[2:]
targets.add(target)
match = MakefileScanner.COMMAND_RE_PROG.search(line)
if match:
command = match.group(1)
if not command:
command = match.group(2)
if command.startswith('./') or command.startswith('.\\'):
command = command[2:]
commands.add(command)
match = MakefileScanner.ASSIGNMENT_RE_PROG.search(line)
if match:
assignments['$(%s)' % match.group(1)] = match.group(2)
match = MakefileScanner.D_OTHER_ARCH_RE_PROG.search(line)
if match:
if not d_other_arch:
d_other_arch = match.group(1)
match = MakefileScanner.D_AARCH64_RE_PROG.search(line)
if match:
seen_d_aarch64 = True
if old_crt_lib_name and not seen_ucrt:
report.add_issue(OldCrtIssue(
filename, lineno + 1, old_crt_lib_name))
if other_arch_cpu_condition and not seen_aarch64_cpu_condition:
report.add_issue(HostCpuDetectionIssue(filename, lineno + 1, other_arch_cpu_condition))
build_commands = targets.intersection(commands)
for command in build_commands:
if command in assignments:
command = assignments[command]
report.add_issue(BuildCommandIssue(filename, lineno + 1, command))
if d_other_arch and not seen_d_aarch64:
report.add_issue(DefineOtherArchIssue(filename, lineno + 1, d_other_arch))