Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1846)

Unified Diff: tools/binary_size/map2size.py

Issue 2802893002: Add gn args to metadata and metadata diffing (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/binary_size/integration_test.py ('k') | tools/binary_size/models.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/binary_size/map2size.py
diff --git a/tools/binary_size/map2size.py b/tools/binary_size/map2size.py
index bdb7cb577f223c625bcb7c88aca0e04d11c8c100..89737ce19aa35a4a3285519b05188e94f7437776 100755
--- a/tools/binary_size/map2size.py
+++ b/tools/binary_size/map2size.py
@@ -289,6 +289,19 @@ def _SectionSizesFromElf(elf_path, tool_prefix):
return section_sizes
+def _ParseGnArgs(args_path):
+ """Returns a list of normalized "key=value" strings."""
+ args = {}
+ with open(args_path) as f:
+ for l in f:
+ # Strips #s even if within string literal. Not a problem in practice.
+ parts = l.split('#')[0].split('=')
+ if len(parts) != 2:
+ continue
+ args[parts[0].strip()] = parts[1].strip()
+ return ["%s=%s" % x for x in sorted(args.iteritems())]
+
+
def main(argv):
parser = argparse.ArgumentParser(argv)
parser.add_argument('elf_file', help='Path to input ELF file.')
@@ -323,6 +336,7 @@ def main(argv):
timestamp_obj = datetime.datetime.utcfromtimestamp(os.path.getmtime(
args.elf_file))
timestamp = calendar.timegm(timestamp_obj.timetuple())
+ gn_args = _ParseGnArgs(os.path.join(lazy_paths.output_directory, 'args.gn'))
def relative_to_out(path):
return os.path.relpath(path, lazy_paths.VerifyOutputDirectory())
@@ -333,6 +347,7 @@ def main(argv):
models.METADATA_ELF_FILENAME: relative_to_out(args.elf_file),
models.METADATA_ELF_MTIME: timestamp,
models.METADATA_ELF_BUILD_ID: build_id,
+ models.METADATA_GN_ARGS: gn_args,
}
size_info = Analyze(map_file_path, lazy_paths)
@@ -347,8 +362,8 @@ def main(argv):
size_info.metadata = metadata
- logging.info('Recording metadata: %s',
- describe.DescribeSizeInfoMetadata(size_info))
+ logging.info('Recording metadata: \n %s',
+ '\n '.join(describe.DescribeMetadata(size_info.metadata)))
logging.info('Saving result to %s', args.output_file)
file_format.SaveSizeInfo(size_info, args.output_file)
logging.info('Done')
« no previous file with comments | « tools/binary_size/integration_test.py ('k') | tools/binary_size/models.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698