Debian Codegraph @

infra/bots/assets/ccache_mac/create.py

raw
1 #!/usr/bin/env python
2 #
3 # Copyright 2016 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 a ccache binary for mac hosts."""
10
11
12 import argparse
13 import os
14 import subprocess
15 import sys
16
17 FILE_DIR = os.path.dirname(os.path.abspath(__file__))
18 INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir))
19 sys.path.insert(0, INFRA_BOTS_DIR)
20 import utils
21
22
23 URL = "https://github.com/ccache/ccache/releases/download/v3.7.7/ccache-3.7.7.tar.gz"
24 VERSION = "ccache-3.7.7"
25
26
27 def create_asset(target_dir):
28 # configure --prefix requires an absolute path.
29 target_dir = os.path.abspath(target_dir)
30
31 # Download and extract the source.
32 with utils.tmp_dir():
33 subprocess.check_call(["curl", "-L", "-o", VERSION + ".tar.gz",
34 "https://github.com/ccache/ccache/releases/download/v3.7.7/ccache-3.7.7.tar.gz"])
35 subprocess.check_call(["tar", "-xzf", VERSION + ".tar.gz"])
36 os.chdir(VERSION)
37
38 subprocess.check_call(["./configure", "--disable-man", "--prefix=" + target_dir])
39 subprocess.check_call(["make"])
40 subprocess.check_call(["make" ,"install"])
41
42
43 def main():
44 parser = argparse.ArgumentParser()
45 parser.add_argument('--target_dir', '-t', required=True)
46 args = parser.parse_args()
47 create_asset(args.target_dir)
48
49
50 if __name__ == '__main__':
51 main()