Home | History | Annotate | Download | only in bloaty
      1 #!/usr/bin/env python
      2 #
      3 # Copyright 2017 Google Inc.
      4 #
      5 # Use of this source code is governed by a BSD-style license that can be
      6 # found in the LICENSE file.
      7 
      8 
      9 """Create Bloaty as a Linux executable."""
     10 
     11 
     12 import argparse
     13 import os
     14 import subprocess
     15 import shutil
     16 import utils
     17 
     18 REPO = 'https://github.com/google/bloaty'
     19 TAG = 'v1.0'
     20 
     21 def create_asset(target_dir):
     22   with utils.tmp_dir():
     23     # Check out bloaty
     24     subprocess.check_call(['git', 'clone', '--depth', '1', '-b', TAG,
     25                            '--single-branch', REPO])
     26     os.chdir('bloaty')
     27     # Build bloaty
     28     subprocess.check_call(['cmake', '.'])
     29     subprocess.check_call(['make', '-j'])
     30 
     31     shutil.move('./bloaty', target_dir)
     32 
     33 
     34 def main():
     35   parser = argparse.ArgumentParser()
     36   parser.add_argument('--target_dir', '-t', required=True)
     37   args = parser.parse_args()
     38   create_asset(args.target_dir)
     39 
     40 
     41 if __name__ == '__main__':
     42   main()
     43