300 return 1
301
303 if not bool(after_json):
304 print(
'Did not find any malioc results under {}.'.
format(args.after))
305 return 1
306
307 if args.update:
308
309 with open(args.before, 'w') as file:
310 json.dump(after_json, file, sort_keys=True, indent=2)
311 return 0
312
313 with open(args.before, 'r') as file:
314 before_json = json.load(file)
315
316 changed = False
317 for filename, shaders in before_json.items():
318 if filename not in after_json.keys():
319 print(
'Shader "{}" has been removed.'.
format(filename))
320 changed = True
321 continue
322 for core, before_shader in shaders.items():
323 if core not in after_json[filename].keys():
324 continue
325 after_shader = after_json[filename][core]
327 changed = True
328
329 for filename, shaders in after_json.items():
330 if filename not in before_json:
332 changed = True
333
334 if changed:
336 'There are new shaders, shaders have been removed, or performance '
337 'changes to existing shaders. The golden file must be updated after a '
338 'build of android_debug_unopt using the --malioc-path flag to the '
339 'flutter/tools/gn script.\n\n'
340 '$ ./flutter/impeller/tools/malioc_diff.py --before {} --after {} --update'.
format(
341 args.before, args.after
342 )
343 )
344 if args.print_diff:
345 before_lines = json.dumps(before_json, sort_keys=True, indent=2).splitlines(keepends=True)
346 after_lines = json.dumps(after_json, sort_keys=True, indent=2).splitlines(keepends=True)
347 before_path = os.path.relpath(os.path.abspath(args.before), start=SRC_ROOT)
348 diff = difflib.unified_diff(before_lines, after_lines, fromfile=before_path)
349 print(
'\nYou can alternately apply the diff below:')
350 print(
'patch -p0 <<DONE')
353
354 return 1 if changed else 0
355
356
def read_malioc_tree(malioc_tree)
static void parse_args(int argc, char *argv[], Args *args)