diff --git a/engine/src/flutter/impeller/tools/malioc_diff.py b/engine/src/flutter/impeller/tools/malioc_diff.py index 2c675656ee..72aa458b00 100755 --- a/engine/src/flutter/impeller/tools/malioc_diff.py +++ b/engine/src/flutter/impeller/tools/malioc_diff.py @@ -44,6 +44,12 @@ CORES = [ 'Mali-T880', # 2016 ] +# Path to the engine root checkout. This is used to calculate absolute +# paths if relative ones are passed to the script. +BUILD_ROOT_DIR = os.path.abspath( + os.path.join(os.path.realpath(__file__), '..', '..', '..', '..') +) + def parse_args(argv): parser = argparse.ArgumentParser( @@ -61,6 +67,22 @@ def parse_args(argv): type=str, help='The path to a json file containing existing malioc results.', ) + parser.add_argument( + '--after-relative-to-src', + type=str, + help=( + 'A relative path calculated from the engine src directory to ' + 'a directory tree containing new malioc results in json files' + ), + ) + parser.add_argument( + '--before-relative-to-src', + type=str, + help=( + 'A relative path calculated from the engine src directory to ' + 'a json file containing existing malioc results in json files' + ), + ) parser.add_argument( '--print-diff', '-p', @@ -86,6 +108,23 @@ def parse_args(argv): def validate_args(args): + if not args.after and not args.after_relative_to_src: + print('--after argument or --after-relative-to-src must be specified.') + return False + + if not args.before and not args.before_relative_to_src: + print('--before argument or --before-relative-to-src must be specified.') + return False + + # Generate full paths if relative ones are provided with before and + # after taking precedence. + args.before = ( + args.before or os.path.join(BUILD_ROOT_DIR, args.before_relative_to_src) + ) + args.after = ( + args.after or os.path.join(BUILD_ROOT_DIR, args.after_relative_to_src) + ) + if not args.after or not os.path.isdir(args.after): print('The --after argument must refer to a directory.') return False