OLD | NEW |
---|---|
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 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 from slave import recipe_api | 5 from slave import recipe_api |
6 | 6 |
7 GIT_DEFAULT_WHITELIST = frozenset(( | 7 GIT_DEFAULT_WHITELIST = frozenset(( |
8 'tools_build', | 8 'tools_build', |
9 )) | 9 )) |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 """Return a step generator function for gclient checkouts.""" | 57 """Return a step generator function for gclient checkouts.""" |
58 cfg = gclient_config or self.c | 58 cfg = gclient_config or self.c |
59 assert cfg.complete() | 59 assert cfg.complete() |
60 | 60 |
61 if not spec_name: | 61 if not spec_name: |
62 step_name = lambda n: 'gclient ' + n | 62 step_name = lambda n: 'gclient ' + n |
63 else: | 63 else: |
64 step_name = lambda n: '[spec: %s] gclient %s' % (spec_name, n) | 64 step_name = lambda n: '[spec: %s] gclient %s' % (spec_name, n) |
65 | 65 |
66 spec_string = jsonish_to_python(cfg.as_jsonish(), True) | 66 spec_string = jsonish_to_python(cfg.as_jsonish(), True) |
67 gclient = self.m.path.depot_tools('gclient', wrapper=True) | 67 gclient = lambda name, *args: self.m.python( |
68 name, self.m.path.depot_tools('gclient.py'), args) | |
68 | 69 |
69 gclient_sync_extra_args = [] | 70 revisions = [] |
70 for s in cfg.solutions: | 71 for s in cfg.solutions: |
71 if s.revision is not None: | 72 if s.revision is not None: |
72 gclient_sync_extra_args += [ | 73 revisions.extend(['--revision', '%s@%s' % (s.name, s.revision)]) |
73 '--revision', '%s@%s' % (s.name, s.revision)] | |
74 | 74 |
75 if not cfg.GIT_MODE: | 75 if not cfg.GIT_MODE: |
76 clean_step = self.revert(step_name) | 76 clean_step = self.revert(step_name) |
77 sync_step = self.m.step(step_name('sync'), [ | 77 sync_step = gclient( |
78 gclient, 'sync', '--nohooks'] + gclient_sync_extra_args) | 78 step_name('sync'), 'sync', '--nohooks', *revisions) |
79 else: | 79 else: |
80 # clean() isn't used because the gclient sync flags passed in checkout() | 80 # clean() isn't used because the gclient sync flags passed in checkout() |
81 # do much the same thing, and they're more correct than doing a separate | 81 # do much the same thing, and they're more correct than doing a separate |
82 # 'gclient revert' because it makes sure the other args are correct when | 82 # 'gclient revert' because it makes sure the other args are correct when |
83 # a repo was deleted and needs to be re-cloned (notably | 83 # a repo was deleted and needs to be re-cloned (notably |
84 # --with_branch_heads), whereas 'revert' uses default args for clone | 84 # --with_branch_heads), whereas 'revert' uses default args for clone |
85 # operations. | 85 # operations. |
86 # | 86 # |
87 # TODO(mmoss): To be like current official builders, this step could just | 87 # TODO(mmoss): To be like current official builders, this step could just |
88 # delete the whole <slave_name>/build/ directory and start each build | 88 # delete the whole <slave_name>/build/ directory and start each build |
89 # from scratch. That might be the least bad solution, at least until we | 89 # from scratch. That might be the least bad solution, at least until we |
90 # have a reliable gclient method to produce a pristine working dir for | 90 # have a reliable gclient method to produce a pristine working dir for |
91 # git-based builds (e.g. maybe some combination of 'git reset/clean -fx' | 91 # git-based builds (e.g. maybe some combination of 'git reset/clean -fx' |
92 # and removing the 'out' directory). | 92 # and removing the 'out' directory). |
93 clean_step = None | 93 clean_step = None |
94 sync_step = self.m.step(step_name('sync'), [ | 94 sync_step = gclient(step_name('sync'), |
95 gclient, 'sync', '--verbose', '--with_branch_heads', '--nohooks', | 95 'sync', '--verbose', '--with_branch_heads', '--nohooks', |
96 '--reset', '--delete_unversioned_trees', '--force']) | 96 '--reset', '--delete_unversioned_trees', '--force', *revisions) |
97 | |
97 steps = [ | 98 steps = [ |
98 self.m.step( | 99 gclient(step_name('setup'), 'config', '--spec', spec_string) |
99 step_name('setup'), | |
100 [gclient, 'config', '--spec', spec_string], | |
101 ), | |
102 ] | 100 ] |
103 if clean_step: | 101 if clean_step: |
104 steps.append(clean_step) | 102 steps.append(clean_step) |
105 if sync_step: | 103 if sync_step: |
106 steps.append(sync_step) | 104 steps.append(sync_step) |
107 | 105 |
108 self.m.path.set_checkout(self.m.path.slave_build(cfg.solutions[0].name)) | 106 self.m.path.set_checkout(self.m.path.slave_build(cfg.solutions[0].name)) |
109 | 107 |
110 return steps | 108 return steps |
111 | 109 |
112 def revert(self, step_name_fn=lambda x: 'gclient '+x): | 110 def revert(self, step_name_fn=lambda x: 'gclient '+x): |
113 """Return a gclient_safe_revert step.""" | 111 """Return a gclient_safe_revert step.""" |
114 return self.m.step( | 112 return self.m.python( |
115 step_name_fn('revert'), [ | 113 step_name_fn('revert'), |
116 'python', | 114 self.m.path.build('scripts', 'slave', 'gclient_safe_revert.py'), |
117 self.m.path.build('scripts', 'slave', 'gclient_safe_revert.py'), '.', | 115 ['.', self.m.path.depot_tools('gclient', wrapper=True)], |
Isaac (away)
2013/06/29 05:34:02
I think this should be gclient.py. Recipes should
| |
118 self.m.path.depot_tools('gclient', wrapper=True)], | |
119 ) | 116 ) |
OLD | NEW |