Debian Codegraph @

infra/bots/assets/cmake_win/create.py

raw
1 #!/usr/bin/env python3
2 #
3 # Copyright 2019 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 VERSION = '3.31.8'
24 URL = ('https://github.com/Kitware/CMake/releases/download/v%s/'
25 'cmake-%s-windows-x86_64.zip') % (VERSION, VERSION)
26
27
28 def create_asset(target_dir):
29 """Create the asset."""
30 with utils.tmp_dir():
31 subprocess.check_call(['wget', URL, '--output-document=cmake.zip'])
32 subprocess.check_call(['unzip', 'cmake.zip'])
33 cmake_dir = 'cmake-%s-windows-x86_64' % VERSION
34 # Move the bin and share directories into the target directory.
35 # The directory structure inside cmake_dir is bin/ and share/.
36 # After this, target_dir will contain bin/ and share/.
37 for d in ['bin', 'share']:
38 subprocess.check_call(
39 ['mv', os.path.join(cmake_dir, d), target_dir])
40
41
42 def main():
43 parser = argparse.ArgumentParser()
44 parser.add_argument('--target_dir', '-t', required=True)
45 args = parser.parse_args()
46 create_asset(args.target_dir)
47
48
49 if __name__ == '__main__':
50 main()