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 """ Utilities for generic build steps. """ | 5 """ Utilities for generic build steps. """ |
6 | 6 |
7 import errno | 7 import errno |
8 import os | 8 import os |
9 import shutil | 9 import shutil |
10 import sys | 10 import sys |
11 | 11 |
12 from utils import file_utils | 12 from utils import file_utils |
13 from utils import shell_utils | 13 from utils import shell_utils |
14 | 14 |
15 | 15 |
16 class DeviceDirs(object): | 16 class DeviceDirs(object): |
17 def __init__(self, perf_data_dir, gm_actual_dir, gm_expected_dir, | 17 def __init__(self, perf_data_dir, gm_actual_dir, gm_expected_dir, |
18 resource_dir, skimage_in_dir, skimage_expected_dir, | 18 resource_dir, skimage_in_dir, skimage_expected_dir, |
19 skimage_out_dir, skp_dir, skp_perf_dir, skp_out_dir, tmp_dir): | 19 skimage_out_dir, skp_dir, skp_perf_dir, |
| 20 playback_actual_images_dir, playback_actual_summaries_dir, |
| 21 playback_expected_summaries_dir, tmp_dir): |
20 self._perf_data_dir = perf_data_dir | 22 self._perf_data_dir = perf_data_dir |
21 self._gm_actual_dir = gm_actual_dir | 23 self._gm_actual_dir = gm_actual_dir |
22 self._gm_expected_dir = gm_expected_dir | 24 self._gm_expected_dir = gm_expected_dir |
23 self._resource_dir = resource_dir | 25 self._resource_dir = resource_dir |
24 self._skimage_in_dir = skimage_in_dir | 26 self._skimage_in_dir = skimage_in_dir |
25 self._skimage_expected_dir = skimage_expected_dir | 27 self._skimage_expected_dir = skimage_expected_dir |
26 self._skimage_out_dir = skimage_out_dir | 28 self._skimage_out_dir = skimage_out_dir |
27 self._skp_dir = skp_dir | 29 self._skp_dir = skp_dir |
28 self._skp_perf_dir = skp_perf_dir | 30 self._skp_perf_dir = skp_perf_dir |
29 self._skp_out_dir = skp_out_dir | 31 self._playback_actual_images_dir = playback_actual_images_dir |
| 32 self._playback_actual_summaries_dir = playback_actual_summaries_dir |
| 33 self._playback_expected_summaries_dir = playback_expected_summaries_dir |
30 self._tmp_dir = tmp_dir | 34 self._tmp_dir = tmp_dir |
31 | 35 |
32 def GMActualDir(self): | 36 def GMActualDir(self): |
33 return self._gm_actual_dir | 37 """Holds images and JSON summary written out by the 'gm' tool.""" |
| 38 return self._gm_actual_dir |
34 | 39 |
35 def GMExpectedDir(self): | 40 def GMExpectedDir(self): |
| 41 """Holds expectations JSON summary read by the 'gm' tool.""" |
36 return self._gm_expected_dir | 42 return self._gm_expected_dir |
37 | 43 |
38 def PerfDir(self): | 44 def PerfDir(self): |
39 return self._perf_data_dir | 45 return self._perf_data_dir |
40 | 46 |
| 47 def PlaybackActualImagesDir(self): |
| 48 """Holds image files written out by the 'render_pictures' tool.""" |
| 49 return self._playback_actual_images_dir |
| 50 |
| 51 def PlaybackActualSummariesDir(self): |
| 52 """Holds actual-result JSON summaries written by 'render_pictures' tool.""" |
| 53 return self._playback_actual_summaries_dir |
| 54 |
| 55 def PlaybackExpectedSummariesDir(self): |
| 56 """Holds expected-result JSON summaries read by 'render_pictures' tool.""" |
| 57 return self._playback_expected_summaries_dir |
| 58 |
41 def ResourceDir(self): | 59 def ResourceDir(self): |
42 return self._resource_dir | 60 return self._resource_dir |
43 | 61 |
44 def SKImageInDir(self): | 62 def SKImageInDir(self): |
45 return self._skimage_in_dir | 63 return self._skimage_in_dir |
46 | 64 |
47 def SKImageExpectedDir(self): | 65 def SKImageExpectedDir(self): |
48 return self._skimage_expected_dir | 66 return self._skimage_expected_dir |
49 | 67 |
50 def SKImageOutDir(self): | 68 def SKImageOutDir(self): |
51 return self._skimage_out_dir | 69 return self._skimage_out_dir |
52 | 70 |
53 def SKPDir(self): | 71 def SKPDir(self): |
| 72 """Holds SKP files that are consumed by RenderSKPs and BenchPictures.""" |
54 return self._skp_dir | 73 return self._skp_dir |
55 | 74 |
56 def SKPPerfDir(self): | 75 def SKPPerfDir(self): |
57 return self._skp_perf_dir | 76 return self._skp_perf_dir |
58 | 77 |
59 def SKPOutDir(self): | |
60 return self._skp_out_dir | |
61 | |
62 def TmpDir(self): | 78 def TmpDir(self): |
63 return self._tmp_dir | 79 return self._tmp_dir |
64 | 80 |
65 | 81 |
66 class DefaultBuildStepUtils: | 82 class DefaultBuildStepUtils: |
67 """ Utilities to be used by subclasses of BuildStep. | 83 """ Utilities to be used by subclasses of BuildStep. |
68 | 84 |
69 The methods in this class define how certain high-level functions should work. | 85 The methods in this class define how certain high-level functions should work. |
70 Each build step flavor should correspond to a subclass of BuildStepUtils which | 86 Each build step flavor should correspond to a subclass of BuildStepUtils which |
71 may override any of these functions as appropriate for that flavor. | 87 may override any of these functions as appropriate for that flavor. |
(...skipping 27 matching lines...) Expand all Loading... |
99 """ Read the contents of a file on the associated device. Subclasses should | 115 """ Read the contents of a file on the associated device. Subclasses should |
100 override this method with one appropriate for reading the contents of a file | 116 override this method with one appropriate for reading the contents of a file |
101 on the device side. """ | 117 on the device side. """ |
102 with open(filepath) as f: | 118 with open(filepath) as f: |
103 return f.read() | 119 return f.read() |
104 | 120 |
105 def CopyDirectoryContentsToDevice(self, host_dir, device_dir): | 121 def CopyDirectoryContentsToDevice(self, host_dir, device_dir): |
106 """ Copy the contents of a host-side directory to a clean directory on the | 122 """ Copy the contents of a host-side directory to a clean directory on the |
107 device side. Subclasses should override this method with one appropriate for | 123 device side. Subclasses should override this method with one appropriate for |
108 copying the contents of a host-side directory to a clean device-side | 124 copying the contents of a host-side directory to a clean device-side |
109 directory.""" | 125 directory. |
| 126 |
| 127 TODO(epoger): Clarify the description a bit: this method does not expect |
| 128 device_dir to be an empty directory before it is called. Implementations |
| 129 of this method for other device types create an empty directory at |
| 130 device_dir as the first step. |
| 131 """ |
110 # For "normal" builders who don't have an attached device, we expect | 132 # For "normal" builders who don't have an attached device, we expect |
111 # host_dir and device_dir to be the same. | 133 # host_dir and device_dir to be the same. |
112 if host_dir != device_dir: | 134 if host_dir != device_dir: |
113 raise ValueError('For builders who do not have attached devices, copying ' | 135 raise ValueError('For builders who do not have attached devices, copying ' |
114 'from host to device is undefined and only allowed if ' | 136 'from host to device is undefined and only allowed if ' |
115 'host_dir and device_dir are the same.') | 137 'host_dir and device_dir are the same.') |
116 | 138 |
117 def CopyDirectoryContentsToHost(self, device_dir, host_dir): | 139 def CopyDirectoryContentsToHost(self, device_dir, host_dir): |
118 """ Copy the contents of a device-side directory to a clean directory on the | 140 """ Copy the contents of a device-side directory to a clean directory on the |
119 host side. Subclasses should override this method with one appropriate for | 141 host side. Subclasses should override this method with one appropriate for |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 make_cmd = 'make' | 225 make_cmd = 'make' |
204 if os.name == 'nt': | 226 if os.name == 'nt': |
205 make_cmd = 'make.bat' | 227 make_cmd = 'make.bat' |
206 shell_utils.run([make_cmd, 'clean']) | 228 shell_utils.run([make_cmd, 'clean']) |
207 | 229 |
208 def PreRun(self): | 230 def PreRun(self): |
209 """ Preprocessing step to run before the BuildStep itself. """ | 231 """ Preprocessing step to run before the BuildStep itself. """ |
210 pass | 232 pass |
211 | 233 |
212 def GetDeviceDirs(self): | 234 def GetDeviceDirs(self): |
213 """ Set the directories which will be used by the BuildStep. """ | 235 """ Set the directories which will be used by the BuildStep. |
| 236 |
| 237 In the case of DefaultBuildStepUtils, host_dirs and device_dirs are the |
| 238 same, which is why CopyDirectoryContentsToDevice() is a no-op. |
| 239 """ |
214 return DeviceDirs( | 240 return DeviceDirs( |
215 perf_data_dir=self._step.perf_data_dir, | 241 perf_data_dir=self._step.perf_data_dir, |
216 # TODO(epoger): Instead, set gm_actual_dir to self._step._gm_actual_dir | 242 # TODO(epoger): Instead, set gm_actual_dir to self._step._gm_actual_dir |
217 # and remove os.path.join() with self._builder_name in postrender.py ? | 243 # and remove os.path.join() with self._builder_name in postrender.py ? |
218 # (CopyDirectoryContentsToHost fails if the paths are different when | 244 # (CopyDirectoryContentsToHost fails if the paths are different when |
219 # host==device, so why not just make them inherently equal?) | 245 # host==device, so why not just make them inherently equal?) |
220 gm_actual_dir=os.path.join(os.pardir, os.pardir, 'gm', 'actual'), | 246 gm_actual_dir=os.path.join(os.pardir, os.pardir, 'gm', 'actual'), |
221 gm_expected_dir=os.path.join(os.pardir, os.pardir, 'gm', 'expected'), | 247 gm_expected_dir=os.path.join(os.pardir, os.pardir, 'gm', 'expected'), |
222 resource_dir=self._step.resource_dir, | 248 resource_dir=self._step.resource_dir, |
223 skimage_in_dir=self._step.skimage_in_dir, | 249 skimage_in_dir=self._step.skimage_in_dir, |
224 skimage_expected_dir=self._step.skimage_expected_dir, | 250 skimage_expected_dir=self._step.skimage_expected_dir, |
225 skimage_out_dir=self._step.skimage_out_dir, | 251 skimage_out_dir=self._step.skimage_out_dir, |
226 skp_dir=self._step.skp_dir, | 252 skp_dir=self._step.skp_dir, |
227 skp_perf_dir=self._step.perf_data_dir, | 253 skp_perf_dir=self._step.perf_data_dir, |
228 skp_out_dir=self._step.skp_out_dir, | 254 playback_actual_images_dir=self._step.playback_actual_images_dir, |
| 255 playback_actual_summaries_dir=self._step.playback_actual_summaries_dir, |
| 256 playback_expected_summaries_dir=( |
| 257 self._step.playback_expected_summaries_dir), |
229 tmp_dir=os.path.join(os.pardir, 'tmp')) | 258 tmp_dir=os.path.join(os.pardir, 'tmp')) |
OLD | NEW |