• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 the asset and upload it."""
10
11
12import argparse
13import common
14import os
15import subprocess
16import sys
17import utils
18
19
20def main():
21  parser = argparse.ArgumentParser()
22  parser.add_argument('--gsutil')
23  parser.add_argument('--src_dir', '-s', required=True)
24  args = parser.parse_args()
25
26  with utils.tmp_dir():
27    cwd = os.getcwd()
28    create_script = os.path.join(common.FILE_DIR, 'create.py')
29    upload_script = os.path.join(common.FILE_DIR, 'upload.py')
30    target_dir = os.path.join(cwd, 'win_toolchain')
31
32    try:
33      cmd = ['python', create_script,
34             '-t', target_dir,
35             '-s', args.src_dir]
36      subprocess.check_call(cmd)
37      cmd = ['python', upload_script, '-t', target_dir]
38      if args.gsutil:
39        cmd.extend(['--gsutil', args.gsutil])
40      subprocess.check_call(cmd)
41    except subprocess.CalledProcessError:
42      # Trap exceptions to avoid printing two stacktraces.
43      sys.exit(1)
44
45
46if __name__ == '__main__':
47  main()
48