OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Set of operations/utilities related to checking out the depot, and | 5 """Set of operations/utilities related to checking out the depot, and |
6 outputting annotations on the buildbot waterfall. These are intended to be | 6 outputting annotations on the buildbot waterfall. These are intended to be |
7 used by the bisection scripts.""" | 7 used by the bisection scripts.""" |
8 | 8 |
9 import errno | 9 import errno |
10 import os | 10 import os |
11 import shutil | 11 import shutil |
12 import subprocess | 12 import subprocess |
13 import sys | 13 import sys |
14 | 14 |
15 | 15 GCLIENT_SPEC_DATA = [ |
16 GCLIENT_SPEC = """ | |
17 solutions = [ | |
18 { "name" : "src", | 16 { "name" : "src", |
19 "url" : "https://chromium.googlesource.com/chromium/src.git", | 17 "url" : "https://chromium.googlesource.com/chromium/src.git", |
20 "deps_file" : ".DEPS.git", | 18 "deps_file" : ".DEPS.git", |
21 "managed" : True, | 19 "managed" : True, |
22 "custom_deps" : { | 20 "custom_deps" : { |
23 "src/data/page_cycler": "https://chrome-internal.googlesource.com/" + | 21 "src/data/page_cycler": "https://chrome-internal.googlesource.com/" |
24 "chrome/data/page_cycler/.git", | 22 "chrome/data/page_cycler/.git", |
25 "src/data/dom_perf": "https://chrome-internal.googlesource.com/" + | 23 "src/data/dom_perf": "https://chrome-internal.googlesource.com/" |
26 "chrome/data/dom_perf/.git", | 24 "chrome/data/dom_perf/.git", |
27 "src/tools/perf/data": "https://chrome-internal.googlesource.com/" + | 25 "src/tools/perf/data": "https://chrome-internal.googlesource.com/" |
28 "chrome/tools/perf/data/.git", | 26 "chrome/tools/perf/data/.git", |
29 "src/v8_bleeding_edge": "git://github.com/v8/v8.git", | |
30 }, | 27 }, |
31 "safesync_url": "", | 28 "safesync_url": "", |
32 }, | 29 }, |
33 ] | 30 ] |
34 """ | 31 GCLIENT_ANDROID = "\ntarget_os = ['android']" |
35 GCLIENT_SPEC = ''.join([l for l in GCLIENT_SPEC.splitlines()]) | 32 GCLIENT_CUSTOM_DEPS_V8 = {"src/v8_bleeding_edge": "git://github.com/v8/v8.git"} |
36 GCLIENT_SPEC_ANDROID = GCLIENT_SPEC + "\ntarget_os = ['android']" | |
37 FILE_DEPS_GIT = '.DEPS.git' | 33 FILE_DEPS_GIT = '.DEPS.git' |
38 | 34 |
39 REPO_PARAMS = [ | 35 REPO_PARAMS = [ |
40 'https://chrome-internal.googlesource.com/chromeos/manifest-internal/', | 36 'https://chrome-internal.googlesource.com/chromeos/manifest-internal/', |
41 '--repo-url', | 37 '--repo-url', |
42 'https://git.chromium.org/external/repo.git' | 38 'https://git.chromium.org/external/repo.git' |
43 ] | 39 ] |
44 | 40 |
45 REPO_SYNC_COMMAND = 'git checkout -f $(git rev-list --max-count=1 '\ | 41 REPO_SYNC_COMMAND = 'git checkout -f $(git rev-list --max-count=1 '\ |
46 '--before=%d remotes/m/master)' | 42 '--before=%d remotes/m/master)' |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 os.chdir(working_directory) | 75 os.chdir(working_directory) |
80 try: | 76 try: |
81 os.mkdir('bisect') | 77 os.mkdir('bisect') |
82 except OSError, e: | 78 except OSError, e: |
83 if e.errno != errno.EEXIST: | 79 if e.errno != errno.EEXIST: |
84 return False | 80 return False |
85 os.chdir('bisect') | 81 os.chdir('bisect') |
86 return True | 82 return True |
87 | 83 |
88 | 84 |
89 def SubprocessCall(cmd): | 85 def SubprocessCall(cmd, cwd=None): |
90 """Runs a subprocess with specified parameters. | 86 """Runs a subprocess with specified parameters. |
91 | 87 |
92 Args: | 88 Args: |
93 params: A list of parameters to pass to gclient. | 89 params: A list of parameters to pass to gclient. |
| 90 cwd: Working directory to run from. |
94 | 91 |
95 Returns: | 92 Returns: |
96 The return code of the call. | 93 The return code of the call. |
97 """ | 94 """ |
98 if os.name == 'nt': | 95 if os.name == 'nt': |
99 # "HOME" isn't normally defined on windows, but is needed | 96 # "HOME" isn't normally defined on windows, but is needed |
100 # for git to find the user's .netrc file. | 97 # for git to find the user's .netrc file. |
101 if not os.getenv('HOME'): | 98 if not os.getenv('HOME'): |
102 os.environ['HOME'] = os.environ['USERPROFILE'] | 99 os.environ['HOME'] = os.environ['USERPROFILE'] |
103 shell = os.name == 'nt' | 100 shell = os.name == 'nt' |
104 return subprocess.call(cmd, shell=shell) | 101 return subprocess.call(cmd, shell=shell, cwd=cwd) |
105 | 102 |
106 | 103 |
107 def RunGClient(params): | 104 def RunGClient(params, cwd=None): |
108 """Runs gclient with the specified parameters. | 105 """Runs gclient with the specified parameters. |
109 | 106 |
110 Args: | 107 Args: |
111 params: A list of parameters to pass to gclient. | 108 params: A list of parameters to pass to gclient. |
| 109 cwd: Working directory to run from. |
112 | 110 |
113 Returns: | 111 Returns: |
114 The return code of the call. | 112 The return code of the call. |
115 """ | 113 """ |
116 cmd = ['gclient'] + params | 114 cmd = ['gclient'] + params |
117 | 115 |
118 return SubprocessCall(cmd) | 116 return SubprocessCall(cmd, cwd=cwd) |
119 | 117 |
120 | 118 |
121 def RunRepo(params): | 119 def RunRepo(params): |
122 """Runs cros repo command with specified parameters. | 120 """Runs cros repo command with specified parameters. |
123 | 121 |
124 Args: | 122 Args: |
125 params: A list of parameters to pass to gclient. | 123 params: A list of parameters to pass to gclient. |
126 | 124 |
127 Returns: | 125 Returns: |
128 The return code of the call. | 126 The return code of the call. |
(...skipping 10 matching lines...) Expand all Loading... |
139 params: Unix timestamp to sync to. | 137 params: Unix timestamp to sync to. |
140 | 138 |
141 Returns: | 139 Returns: |
142 The return code of the call. | 140 The return code of the call. |
143 """ | 141 """ |
144 repo_sync = REPO_SYNC_COMMAND % timestamp | 142 repo_sync = REPO_SYNC_COMMAND % timestamp |
145 cmd = ['forall', '-c', REPO_SYNC_COMMAND % timestamp] | 143 cmd = ['forall', '-c', REPO_SYNC_COMMAND % timestamp] |
146 return RunRepo(cmd) | 144 return RunRepo(cmd) |
147 | 145 |
148 | 146 |
149 def RunGClientAndCreateConfig(opts): | 147 def RunGClientAndCreateConfig(opts, custom_deps=None, cwd=None): |
150 """Runs gclient and creates a config containing both src and src-internal. | 148 """Runs gclient and creates a config containing both src and src-internal. |
151 | 149 |
152 Args: | 150 Args: |
153 opts: The options parsed from the command line through parse_args(). | 151 opts: The options parsed from the command line through parse_args(). |
| 152 custom_deps: A dictionary of additional dependencies to add to .gclient. |
| 153 cwd: Working directory to run from. |
154 | 154 |
155 Returns: | 155 Returns: |
156 The return code of the call. | 156 The return code of the call. |
157 """ | 157 """ |
158 spec = GCLIENT_SPEC | 158 spec = GCLIENT_SPEC_DATA |
| 159 |
| 160 if custom_deps: |
| 161 for k, v in custom_deps.iteritems(): |
| 162 spec[0]['custom_deps'][k] = v |
| 163 |
| 164 # Cannot have newlines in string on windows |
| 165 spec = 'solutions =' + str(spec) |
| 166 spec = ''.join([l for l in spec.splitlines()]) |
| 167 |
159 if opts.target_platform == 'android': | 168 if opts.target_platform == 'android': |
160 spec = GCLIENT_SPEC_ANDROID | 169 spec += GCLIENT_SPEC_ANDROID |
161 | 170 |
162 return_code = RunGClient( | 171 return_code = RunGClient( |
163 ['config', '--spec=%s' % spec, '--git-deps']) | 172 ['config', '--spec=%s' % spec, '--git-deps'], cwd=cwd) |
164 return return_code | 173 return return_code |
165 | 174 |
166 | 175 |
167 def IsDepsFileBlink(): | 176 def IsDepsFileBlink(): |
168 """Reads .DEPS.git and returns whether or not we're using blink. | 177 """Reads .DEPS.git and returns whether or not we're using blink. |
169 | 178 |
170 Returns: | 179 Returns: |
171 True if blink, false if webkit. | 180 True if blink, false if webkit. |
172 """ | 181 """ |
173 locals = {'Var': lambda _: locals["vars"][_], | 182 locals = {'Var': lambda _: locals["vars"][_], |
(...skipping 11 matching lines...) Expand all Loading... |
185 try: | 194 try: |
186 path_to_dir = os.path.join(os.getcwd(), 'third_party', 'WebKit') | 195 path_to_dir = os.path.join(os.getcwd(), 'third_party', 'WebKit') |
187 if os.path.exists(path_to_dir): | 196 if os.path.exists(path_to_dir): |
188 shutil.rmtree(path_to_dir) | 197 shutil.rmtree(path_to_dir) |
189 except OSError, e: | 198 except OSError, e: |
190 if e.errno != errno.ENOENT: | 199 if e.errno != errno.ENOENT: |
191 return False | 200 return False |
192 return True | 201 return True |
193 | 202 |
194 | 203 |
195 def RunGClientAndSync(reset): | 204 def RunGClientAndSync(reset, cwd=None): |
196 """Runs gclient and does a normal sync. | 205 """Runs gclient and does a normal sync. |
197 | 206 |
198 Args: | 207 Args: |
199 reset: Whether to reset any changes to the depot. | 208 reset: Whether to reset any changes to the depot. |
| 209 cwd: Working directory to run from. |
200 | 210 |
201 Returns: | 211 Returns: |
202 The return code of the call. | 212 The return code of the call. |
203 """ | 213 """ |
204 params = ['sync', '--verbose', '--nohooks'] | 214 params = ['sync', '--verbose', '--nohooks'] |
205 if reset: | 215 if reset: |
206 params.extend(['--reset', '--force', '--delete_unversioned_trees']) | 216 params.extend(['--reset', '--force', '--delete_unversioned_trees']) |
207 return RunGClient(params) | 217 return RunGClient(params, cwd=cwd) |
208 | 218 |
209 | 219 |
210 def SetupGitDepot(opts, reset): | 220 def SetupGitDepot(opts, reset): |
211 """Sets up the depot for the bisection. The depot will be located in a | 221 """Sets up the depot for the bisection. The depot will be located in a |
212 subdirectory called 'bisect'. | 222 subdirectory called 'bisect'. |
213 | 223 |
214 Args: | 224 Args: |
215 opts: The options parsed from the command line through parse_args(). | 225 opts: The options parsed from the command line through parse_args(). |
216 reset: Whether to reset any changes to the depot. | 226 reset: Whether to reset any changes to the depot. |
217 | 227 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 print 'Error: Could not create bisect directory.' | 339 print 'Error: Could not create bisect directory.' |
330 print | 340 print |
331 return 1 | 341 return 1 |
332 | 342 |
333 if not SetupGitDepot(opts, reset): | 343 if not SetupGitDepot(opts, reset): |
334 print 'Error: Failed to grab source.' | 344 print 'Error: Failed to grab source.' |
335 print | 345 print |
336 return 1 | 346 return 1 |
337 | 347 |
338 return 0 | 348 return 0 |
OLD | NEW |