Definition at line 291 of file format_code.py.
◆ __init__()
def __init__ |
( |
|
self, |
|
|
|
folder |
|
) |
| |
Definition at line 292 of file format_code.py.
292 def __init__(self, folder):
294 self.bp_output_file =
"Generated_Android.bp"
◆ run()
Definition at line 296 of file format_code.py.
299 self.shell.save_cwd()
300 this_dir = os.path.dirname(__file__)
302 logger.debug(
"Running Android.bp check")
304 self.shell.cd(self.folder)
305 cmd =
"%s/generate_android_bp.py --folder %s --output_file %s" % (this_dir, self.folder, self.bp_output_file)
306 output = self.shell.run_single_to_str(cmd)
309 except subprocess.CalledProcessError
as e:
312 logger.error(
"OUTPUT= %s" % e.output)
315 if not filecmp.cmp(self.bp_output_file, self.folder +
"/Android.bp"):
318 with open(self.bp_output_file,
'r')
as generated_file:
319 with open(self.folder +
"/Android.bp",
'r')
as review_file:
320 diff = list(difflib.unified_diff(generated_file.readlines(), review_file.readlines(),
321 fromfile=
'Generated_Android.bp', tofile=
'Android.bp'))
327 num_removed_lines = 0
329 last_removed_line =
""
330 expect_add_line =
False
333 if line.startswith(
"-")
and not line.startswith(
"---"):
334 num_removed_lines += 1
335 if num_removed_lines > 1:
337 last_removed_line = line
338 expect_add_line =
True
339 elif line.startswith(
"+")
and not line.startswith(
"+++"):
341 if num_added_lines > 1:
344 last_added_line = line
346 expect_add_line =
False
348 if num_added_lines == 1
and num_removed_lines == 1:
349 re_copyright = re.compile(
"^(?:\+|\-)// Copyright © ([0-9]+)\-([0-9]+) Arm Ltd. All rights reserved.\n$")
350 generated_matches = re_copyright.search(last_removed_line)
351 review_matches = re_copyright.search(last_added_line)
353 if generated_matches
is not None and review_matches
is not None:
354 if generated_matches.group(1) == review_matches.group(1)
and \
355 int(generated_matches.group(2)) > int(review_matches.group(2)):
356 is_mismatched =
False
359 logger.error(
"Lines with '-' need to be added to Android.bp")
360 logger.error(
"Lines with '+' need to be removed from Android.bp")
363 logger.error(line.rstrip())
365 raise Exception(
"Android bp file is not updated")
368 raise Exception(
"generate Android bp file failed with error code %d" % retval)
◆ bp_output_file
◆ folder
◆ shell
The documentation for this class was generated from the following file: