OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 | 5 |
6 # pylint: disable=W0201 | 6 # pylint: disable=W0201 |
7 | 7 |
8 | 8 |
9 from recipe_engine import recipe_api | 9 from recipe_engine import recipe_api |
10 | 10 |
11 from . import android_flavor | 11 from . import android_flavor |
12 from . import cmake_flavor | 12 from . import cmake_flavor |
13 from . import coverage_flavor | 13 from . import coverage_flavor |
14 from . import default_flavor | 14 from . import default_flavor |
15 from . import gn_flavor | 15 from . import gn_flavor |
16 from . import ios_flavor | 16 from . import ios_flavor |
17 from . import pdfium_flavor | 17 from . import pdfium_flavor |
18 from . import valgrind_flavor | 18 from . import valgrind_flavor |
19 from . import xsan_flavor | 19 from . import xsan_flavor |
20 | 20 |
21 | 21 |
| 22 TEST_EXPECTED_SKP_VERSION = '42' |
| 23 TEST_EXPECTED_SK_IMAGE_VERSION = '42' |
| 24 |
| 25 VERSION_FILE_SK_IMAGE = 'SK_IMAGE_VERSION' |
| 26 VERSION_FILE_SKP = 'SKP_VERSION' |
| 27 |
| 28 VERSION_NONE = -1 |
| 29 |
| 30 |
22 def is_android(builder_cfg): | 31 def is_android(builder_cfg): |
23 """Determine whether the given builder is an Android builder.""" | 32 """Determine whether the given builder is an Android builder.""" |
24 return ('Android' in builder_cfg.get('extra_config', '') or | 33 return ('Android' in builder_cfg.get('extra_config', '') or |
25 builder_cfg.get('os') == 'Android') | 34 builder_cfg.get('os') == 'Android') |
26 | 35 |
27 | 36 |
28 def is_cmake(builder_cfg): | 37 def is_cmake(builder_cfg): |
29 return 'CMake' in builder_cfg.get('extra_config', '') | 38 return 'CMake' in builder_cfg.get('extra_config', '') |
30 | 39 |
31 | 40 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 def create_clean_device_dir(self, path): | 120 def create_clean_device_dir(self, path): |
112 return self._f.create_clean_device_dir(path) | 121 return self._f.create_clean_device_dir(path) |
113 | 122 |
114 def read_file_on_device(self, path): | 123 def read_file_on_device(self, path): |
115 return self._f.read_file_on_device(path) | 124 return self._f.read_file_on_device(path) |
116 | 125 |
117 def remove_file_on_device(self, path): | 126 def remove_file_on_device(self, path): |
118 return self._f.remove_file_on_device(path) | 127 return self._f.remove_file_on_device(path) |
119 | 128 |
120 def install(self): | 129 def install(self): |
121 rv = self._f.install() | 130 self._f.install() |
122 self.device_dirs = self._f.device_dirs | 131 self.device_dirs = self._f.device_dirs |
123 return rv | 132 |
| 133 # TODO(borenet): Only copy files which have changed. |
| 134 # Resources |
| 135 self.copy_directory_contents_to_device( |
| 136 self.m.vars.resource_dir, |
| 137 self.device_dirs.resource_dir) |
| 138 |
| 139 self._copy_skps() |
| 140 self._copy_images() |
124 | 141 |
125 def cleanup_steps(self): | 142 def cleanup_steps(self): |
126 return self._f.cleanup_steps() | 143 return self._f.cleanup_steps() |
| 144 |
| 145 def _copy_dir(self, host_version, version_file, tmp_dir, |
| 146 host_path, device_path, test_expected_version, |
| 147 test_actual_version): |
| 148 actual_version_file = self.m.path.join(tmp_dir, version_file) |
| 149 # Copy to device. |
| 150 device_version_file = self.device_path_join( |
| 151 self.device_dirs.tmp_dir, version_file) |
| 152 if str(actual_version_file) != str(device_version_file): |
| 153 try: |
| 154 device_version = self.read_file_on_device(device_version_file) |
| 155 except self.m.step.StepFailure: |
| 156 device_version = VERSION_NONE |
| 157 if device_version != host_version: |
| 158 self.remove_file_on_device(device_version_file) |
| 159 self.create_clean_device_dir(device_path) |
| 160 self.copy_directory_contents_to_device( |
| 161 host_path, device_path) |
| 162 |
| 163 # Copy the new version file. |
| 164 self.copy_file_to_device(actual_version_file, device_version_file) |
| 165 |
| 166 def _copy_images(self): |
| 167 """Download and copy test images if needed.""" |
| 168 version_file = self.m.vars.infrabots_dir.join( |
| 169 'assets', 'skimage', 'VERSION') |
| 170 test_data = self.m.properties.get( |
| 171 'test_downloaded_sk_image_version', TEST_EXPECTED_SK_IMAGE_VERSION) |
| 172 version = self.m.run.readfile( |
| 173 version_file, |
| 174 name='Get downloaded skimage VERSION', |
| 175 test_data=test_data).rstrip() |
| 176 self.m.run.writefile( |
| 177 self.m.path.join(self.m.vars.tmp_dir, VERSION_FILE_SK_IMAGE), |
| 178 version) |
| 179 self._copy_dir( |
| 180 version, |
| 181 VERSION_FILE_SK_IMAGE, |
| 182 self.m.vars.tmp_dir, |
| 183 self.m.vars.images_dir, |
| 184 self.device_dirs.images_dir, |
| 185 test_expected_version=self.m.properties.get( |
| 186 'test_downloaded_sk_image_version', |
| 187 TEST_EXPECTED_SK_IMAGE_VERSION), |
| 188 test_actual_version=self.m.properties.get( |
| 189 'test_downloaded_sk_image_version', |
| 190 TEST_EXPECTED_SK_IMAGE_VERSION)) |
| 191 return version |
| 192 |
| 193 def _copy_skps(self): |
| 194 """Download and copy the SKPs if needed.""" |
| 195 version_file = self.m.vars.infrabots_dir.join( |
| 196 'assets', 'skp', 'VERSION') |
| 197 test_data = self.m.properties.get( |
| 198 'test_downloaded_skp_version', TEST_EXPECTED_SKP_VERSION) |
| 199 version = self.m.run.readfile( |
| 200 version_file, |
| 201 name='Get downloaded SKP VERSION', |
| 202 test_data=test_data).rstrip() |
| 203 self.m.run.writefile( |
| 204 self.m.path.join(self.m.vars.tmp_dir, VERSION_FILE_SKP), |
| 205 version) |
| 206 self._copy_dir( |
| 207 version, |
| 208 VERSION_FILE_SKP, |
| 209 self.m.vars.tmp_dir, |
| 210 self.m.vars.local_skp_dir, |
| 211 self.device_dirs.skp_dir, |
| 212 test_expected_version=self.m.properties.get( |
| 213 'test_downloaded_skp_version', TEST_EXPECTED_SKP_VERSION), |
| 214 test_actual_version=self.m.properties.get( |
| 215 'test_downloaded_skp_version', TEST_EXPECTED_SKP_VERSION)) |
| 216 return version |
OLD | NEW |