Add relative path support for malioc_diff. (flutter/engine#41703)

Relative paths are required for integrating this tool as a test in engine v2.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
godofredoc
2023-05-03 16:45:30 -07:00
committed by GitHub
parent 8b0230dcc5
commit 7a1eeaffae

View File

@@ -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