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 12import argparse 13import os 14import shutil 15import subprocess 16import sys 17 18FILE_DIR = os.path.dirname(os.path.abspath(__file__)) 19INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir)) 20sys.path.insert(0, INFRA_BOTS_DIR) 21import utils 22 23 24REPO = 'https://github.com/google/bloaty' 25TAG = 'v1.0' 26 27 28def create_asset(target_dir): 29 with utils.tmp_dir(): 30 # Check out bloaty 31 subprocess.check_call(['git', 'clone', '--depth', '1', '-b', TAG, 32 '--single-branch', REPO]) 33 os.chdir('bloaty') 34 # Build bloaty 35 subprocess.check_call(['cmake', '.']) 36 subprocess.check_call(['make', '-j']) 37 38 shutil.move('./bloaty', target_dir) 39 40 41def main(): 42 parser = argparse.ArgumentParser() 43 parser.add_argument('--target_dir', '-t', required=True) 44 args = parser.parse_args() 45 create_asset(args.target_dir) 46 47 48if __name__ == '__main__': 49 main() 50