Kevin Lubick | 402bf74 | 2019-02-12 08:28:12 -0500 | [diff] [blame] | 1 | # Copyright 2019 The Chromium Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | |
| 6 | """Creates a .tar.gz file containing an HTML treemap displaying the codesize. |
| 7 | |
| 8 | Requires docker to be installed. |
| 9 | |
| 10 | Example usage: |
| 11 | python make_treemap.py $SKIA_ROOT/out/Release/skottie_tool /tmp/size |
| 12 | |
| 13 | """ |
| 14 | |
| 15 | |
| 16 | import os |
| 17 | import subprocess |
| 18 | import sys |
| 19 | import tempfile |
| 20 | |
| 21 | DOCKER_IMAGE = 'gcr.io/skia-public/binary-size:v1' |
| 22 | DOCKER_SCRIPT = '/opt/binary_size/src/run_binary_size_analysis.py' |
| 23 | |
| 24 | def main(): |
| 25 | input_file = sys.argv[1] |
| 26 | out_dir = sys.argv[2] |
| 27 | |
| 28 | input_base = os.path.basename(input_file) |
| 29 | input_dir = os.path.dirname(input_file) |
| 30 | temp_out = tempfile.mkdtemp('treemap') |
| 31 | |
| 32 | subprocess.check_call(['docker', 'run', '--volume', '%s:/IN' % input_dir, |
| 33 | '--volume', '%s:/OUT' % temp_out, |
| 34 | DOCKER_IMAGE, DOCKER_SCRIPT, |
| 35 | '--library', '/IN/%s' % input_base, |
| 36 | '--destdir', '/OUT']) |
| 37 | |
| 38 | subprocess.check_call(['tar', '--directory=%s' % temp_out, '-zcf', |
| 39 | '%s/%s_tree.tar.gz' % (out_dir, input_base), |
| 40 | '.']) |
| 41 | |
| 42 | |
| 43 | if __name__ == '__main__': |
| 44 | main() |