Debian Codegraph @

infra/bots/assets/clang_win/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 the asset."""
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 # Copied from https://cs.chromium.org/chromium/src/tools/clang/scripts/update.py
24 CLANG_REVISION = 'llvmorg-18-init-17730-gf670112a'
25 CLANG_SUB_REVISION = 5
26
27 PACKAGE_VERSION = '%s-%s' % (CLANG_REVISION, CLANG_SUB_REVISION)
28
29 # (End copying)
30
31 GS_URL = ('https://commondatastorage.googleapis.com/chromium-browser-clang'
32 '/Win/clang-%s.tgz' % PACKAGE_VERSION)
33
34
35 def create_asset(target_dir):
36 """Create the asset."""
37 with utils.chdir(target_dir):
38 tarball = 'clang.tgz'
39 subprocess.check_call(['wget', '-O', tarball, GS_URL])
40 subprocess.check_call(['tar', 'zxvf', tarball])
41 os.remove(tarball)
42
43
44 def main():
45 parser = argparse.ArgumentParser()
46 parser.add_argument('--target_dir', '-t', required=True)
47 args = parser.parse_args()
48 create_asset(args.target_dir)
49
50
51 if __name__ == '__main__':
52 main()