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 linux hosts."""
10
11
12import argparse
13import common
14import os
15import subprocess
16import utils
17
18URL = "https://github.com/ccache/ccache/releases/download/v3.7.7/ccache-3.7.7.tar.gz"
19VERSION = "ccache-3.7.7"
20
21def create_asset(target_dir):
22  # configure --prefix requires an absolute path.
23  target_dir = os.path.abspath(target_dir)
24
25  # Download and extract the source.
26  with utils.tmp_dir():
27    subprocess.check_call(["wget", "-O", VERSION + ".tar.gz",
28                           "https://github.com/ccache/ccache/releases/download/v3.7.7/ccache-3.7.7.tar.gz"])
29    subprocess.check_call(["tar", "-xzf", VERSION + ".tar.gz"])
30    os.chdir(VERSION)
31
32    subprocess.check_call(["./configure", "--disable-man", "--prefix=" + target_dir])
33    subprocess.check_call(["make"])
34    subprocess.check_call(["make" ,"install"])
35
36def main():
37  parser = argparse.ArgumentParser()
38  parser.add_argument('--target_dir', '-t', required=True)
39  args = parser.parse_args()
40  create_asset(args.target_dir)
41
42
43if __name__ == '__main__':
44  main()
45