Commit 9afaad55 authored by Samuel Huang's avatar Samuel Huang Committed by Commit Bot

[Binary Size] Remove deprecated arguments from binary size scripts.

Now that size config JSON files have become the default way for android
binary size bots to pass data to binary size scripts, deprecated
arguments can be removed:
* generate_commit_size_analysis.py: Remove {--apk-name, --mapping-file}
  (replaced by --size-config-json).
* trybot_commit_size_checker.py: Remove --apk-name (replaced by
  --size-config-json-name).
  * Remove functions to guess .mapping file names (no longer needed).

Bug: 1040645
Change-Id: I62aab4982edb523ea66a9c14ef5fc541260e922a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2546445Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Commit-Queue: Samuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828947}
parent c347e103
...@@ -92,23 +92,10 @@ def main(): ...@@ -92,23 +92,10 @@ def main():
# .minimal.apks, .ssargs}. If .ssargs, then the file is copied to the # .minimal.apks, .ssargs}. If .ssargs, then the file is copied to the
# staging dir. # staging dir.
# --size-config-json will replace {--apk-name, --mapping-name}.
parser.add_argument('--size-config-json', parser.add_argument('--size-config-json',
required=True,
help='Path to JSON file with configs for binary size ' help='Path to JSON file with configs for binary size '
'measurement.') 'measurement.')
# Deprecated.
parser.add_argument(
'--apk-name',
help='Name of the apk (ex. Name.apk)',
)
# Deprecated.
parser.add_argument(
'--mapping-name',
action='append',
help='Filename of the proguard mapping file.',
)
parser.add_argument( parser.add_argument(
'--chromium-output-directory', '--chromium-output-directory',
required=True, required=True,
...@@ -122,23 +109,11 @@ def main(): ...@@ -122,23 +109,11 @@ def main():
args = parser.parse_args() args = parser.parse_args()
assert bool(args.size_config_json) != bool( with open(args.size_config_json, 'rt') as fh:
args.apk_name), ('Require exactly one of --size-config-json or the' config = json.load(fh)
' {--apk-name, --mapping-name} group.') to_resource_sizes_py = config['to_resource_sizes_py']
assert bool(args.apk_name) == bool(args.mapping_name), ( mapping_files = config['mapping_files']
'Require {--apk-name, --mapping-name} to be specified together.') supersize_input_file = config['supersize_input_file']
if args.size_config_json:
with open(args.size_config_json, 'rt') as fh:
config = json.load(fh)
to_resource_sizes_py = config['to_resource_sizes_py']
mapping_files = config['mapping_files']
supersize_input_file = config['supersize_input_file']
else:
# Deprecated flow. Add 'apks/' prefix for compatibility.
to_resource_sizes_py = {'apk_name': os.path.join('apks', args.apk_name)}
mapping_files = [os.path.join('apks', name) for name in args.mapping_name]
supersize_input_file = os.path.join('apks', args.apk_name)
def make_chromium_output_path(path_rel_to_output=None): def make_chromium_output_path(path_rel_to_output=None):
if path_rel_to_output is None: if path_rel_to_output is None:
......
...@@ -202,18 +202,6 @@ def _CreateTestingSymbolsDeltas(before_mapping_paths, after_mapping_paths): ...@@ -202,18 +202,6 @@ def _CreateTestingSymbolsDeltas(before_mapping_paths, after_mapping_paths):
len(added_symbols) - len(removed_symbols)) len(added_symbols) - len(removed_symbols))
def _GuessMappingFilename(to_result_path, container_filename):
guess = to_result_path(container_filename + '.mapping')
if os.path.exists(guess):
return guess
guess = to_result_path(
container_filename.replace('.minimal.apks', '.aab').replace(
'.apks', '.aab') + '.mapping')
if os.path.exists(guess):
return guess
return None
def _GenerateBinarySizePluginDetails(metrics): def _GenerateBinarySizePluginDetails(metrics):
binary_size_listings = [] binary_size_listings = []
for delta, log_name in metrics: for delta, log_name in metrics:
...@@ -255,16 +243,10 @@ def _FormatNumber(number): ...@@ -255,16 +243,10 @@ def _FormatNumber(number):
def main(): def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--author', required=True, help='CL author') parser.add_argument('--author', required=True, help='CL author')
parser.add_argument('--size-config-json-name',
name_parser = parser.add_mutually_exclusive_group(required=True) required=True,
help='Filename of JSON with configs for '
# --size-config-json-name will replace --apk-name. 'binary size measurement.')
name_parser.add_argument('--size-config-json-name',
help='Filename of JSON with configs for '
'binary size measurement.')
# Deprecated.
name_parser.add_argument('--apk-name', help='Name of the apk (ex. Name.apk).')
parser.add_argument( parser.add_argument(
'--before-dir', '--before-dir',
required=True, required=True,
...@@ -289,25 +271,12 @@ def main(): ...@@ -289,25 +271,12 @@ def main():
to_before_path = lambda p: os.path.join(args.before_dir, os.path.basename(p)) to_before_path = lambda p: os.path.join(args.before_dir, os.path.basename(p))
to_after_path = lambda p: os.path.join(args.after_dir, os.path.basename(p)) to_after_path = lambda p: os.path.join(args.after_dir, os.path.basename(p))
if args.size_config_json_name:
with open(to_after_path(args.size_config_json_name), 'rt') as fh: with open(to_after_path(args.size_config_json_name), 'rt') as fh:
config = json.load(fh) config = json.load(fh)
supersize_input_name = os.path.basename(config['supersize_input_file']) supersize_input_name = os.path.basename(config['supersize_input_file'])
before_mapping_paths = [to_before_path(f) for f in config['mapping_files']] before_mapping_paths = [to_before_path(f) for f in config['mapping_files']]
after_mapping_paths = [to_after_path(f) for f in config['mapping_files']] after_mapping_paths = [to_after_path(f) for f in config['mapping_files']]
else:
supersize_input_name = args.apk_name
# Guess separately for "before" and "after" to be robust against naming
# glitches as generate_commit_size_analysis.py's renaming scheme change.
before_mapping_path = _GuessMappingFilename(to_before_path, args.apk_name)
if not before_mapping_path:
raise Exception('Cannot find "before" proguard mapping file.')
before_mapping_paths = [before_mapping_path]
after_mapping_path = _GuessMappingFilename(to_after_path, args.apk_name)
if not after_mapping_path:
raise Exception('Cannot find "after" proguard mapping file.')
after_mapping_paths = [after_mapping_path]
logging.info('Creating Supersize diff') logging.info('Creating Supersize diff')
supersize_diff_lines, delta_size_info = _CreateSupersizeDiff( supersize_diff_lines, delta_size_info = _CreateSupersizeDiff(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment