Debian Codegraph @

infra/bots/assets/bloaty/create.py

raw
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 shutil
15 import subprocess
16 import sys
17
18 FILE_DIR = os.path.dirname(os.path.abspath(__file__))
19 INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir))
20 sys.path.insert(0, INFRA_BOTS_DIR)
21 import utils
22
23
24 REPO = 'https://github.com/google/bloaty'
25 TAG = 'v1.0'
26
27
28 def 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
41 def 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
48 if __name__ == '__main__':
49 main()