[M73 Dev][EFL] Fix errors to generate ninja files
[platform/framework/web/chromium-efl.git] / build / run_swarming_xcode_install.py
1 #!/usr/bin/env python
2 # Copyright 2017 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """
7 This script runs swarming_xcode_install on the bots.  It should be run when we
8 need to upgrade all the swarming testers.  It:
9   1) Packages two python files into an isolate.
10   2) Runs the isolate on swarming machines that satisfy certain dimensions.
11
12 Example usage:
13   $  ./build/run_swarming_xcode_install.py  --luci_path ~/work/luci-py \
14        --swarming-server touch-swarming.appspot.com \
15        --isolate-server touch-isolate.appspot.com
16 """
17
18 import argparse
19 import os
20 import shutil
21 import subprocess
22 import sys
23 import tempfile
24
25
26 def main():
27   parser = argparse.ArgumentParser(
28       description='Run swarming_xcode_install on the bots.')
29   parser.add_argument('--luci_path', required=True, type=os.path.abspath)
30   parser.add_argument('--swarming-server', required=True, type=str)
31   parser.add_argument('--isolate-server', required=True, type=str)
32   parser.add_argument('--batches', type=int, default=25,
33                       help="Run xcode install in batches of size |batches|.")
34   parser.add_argument('--dimension', nargs=2, action='append')
35   args = parser.parse_args()
36
37   args.dimension = args.dimension or []
38
39   script_dir = os.path.dirname(os.path.abspath(__file__))
40   tmp_dir = tempfile.mkdtemp(prefix='swarming_xcode')
41   try:
42     print 'Making isolate.'
43     shutil.copyfile(os.path.join(script_dir, 'swarming_xcode_install.py'),
44                     os.path.join(tmp_dir, 'swarming_xcode_install.py'))
45     shutil.copyfile(os.path.join(script_dir, 'mac_toolchain.py'),
46                     os.path.join(tmp_dir, 'mac_toolchain.py'))
47
48     luci_client = os.path.join(args.luci_path, 'client')
49     cmd = [
50       sys.executable, os.path.join(luci_client, 'isolateserver.py'), 'archive',
51       '-I', args.isolate_server, tmp_dir,
52     ]
53     isolate_hash = subprocess.check_output(cmd).split()[0]
54
55     print 'Running swarming_xcode_install.'
56     # TODO(crbug.com/765361): The dimensions below should be updated once
57     # swarming for iOS is fleshed out, likely removing xcode_version 9 and
58     # adding different dimensions.
59     luci_tools = os.path.join(luci_client, 'tools')
60     dimensions = [['pool', 'Chrome'], ['xcode_version', '9.0']] + args.dimension
61     dim_args = []
62     for d in dimensions:
63       dim_args += ['--dimension'] + d
64     cmd = [
65       sys.executable, os.path.join(luci_tools, 'run_on_bots.py'),
66       '--swarming', args.swarming_server, '--isolate-server',
67       args.isolate_server, '--priority', '20', '--batches', str(args.batches),
68       '--tags', 'name:run_swarming_xcode_install',
69     ] + dim_args + ['--name', 'run_swarming_xcode_install', '--', isolate_hash,
70       'python', 'swarming_xcode_install.py',
71     ]
72     subprocess.check_call(cmd)
73     print 'All tasks completed.'
74
75   finally:
76     shutil.rmtree(tmp_dir)
77   return 0
78
79
80 if __name__ == '__main__':
81   sys.exit(main())