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 """ Subclass for all slave-side Android build steps. """ | 5 """ Subclass for all slave-side Android build steps. """ |
6 | 6 |
7 from build_step import BuildStep, DeviceDirs | 7 from build_step import BuildStep, DeviceDirs |
8 from utils import android_utils | 8 from utils import android_utils |
9 from utils import gs_utils | 9 from utils import gs_utils |
10 from utils import shell_utils | 10 from utils import shell_utils |
(...skipping 21 matching lines...) Expand all Loading... |
32 """ Read the contents of a file on the device. """ | 32 """ Read the contents of a file on the device. """ |
33 return android_utils.ADBShell(self._serial, ['cat', filepath, ';', 'echo'], | 33 return android_utils.ADBShell(self._serial, ['cat', filepath, ';', 'echo'], |
34 echo=False) | 34 echo=False) |
35 | 35 |
36 def _RemoveDirectoryOnDevice(self, directory): | 36 def _RemoveDirectoryOnDevice(self, directory): |
37 """ Delete a directory on the device. """ | 37 """ Delete a directory on the device. """ |
38 try: | 38 try: |
39 android_utils.RunADB(self._serial, ['shell', 'rm', '-r', directory]) | 39 android_utils.RunADB(self._serial, ['shell', 'rm', '-r', directory]) |
40 except Exception: | 40 except Exception: |
41 pass | 41 pass |
42 if 'DIRECTORY_EXISTS' in android_utils.ADBShell(self._serial, | 42 if self.DevicePathExists(directory): |
43 ['if', '[', '-d', directory, '];', 'then', 'echo', 'DIRECTORY_EXISTS;', | |
44 'fi']): | |
45 raise Exception('Failed to remove %s' % directory) | 43 raise Exception('Failed to remove %s' % directory) |
46 | 44 |
47 def _CreateDirectoryOnDevice(self, directory): | 45 def _CreateDirectoryOnDevice(self, directory): |
48 """ Create a directory on the device. """ | 46 """ Create a directory on the device. """ |
49 android_utils.RunADB(self._serial, ['shell', 'mkdir', '-p', directory]) | 47 android_utils.RunADB(self._serial, ['shell', 'mkdir', '-p', directory]) |
50 | 48 |
51 def PushFileToDevice(self, src, dst): | 49 def PushFileToDevice(self, src, dst): |
52 """ Overrides build_step.PushFileToDevice() """ | 50 """ Overrides build_step.PushFileToDevice() """ |
53 android_utils.RunADB(self._serial, ['push', src, dst]) | 51 android_utils.RunADB(self._serial, ['push', src, dst]) |
54 | 52 |
| 53 def DeviceListDir(self, directory): |
| 54 """ Overrides build_step.DeviceListDir() """ |
| 55 return android_utils.ADBShell(self._serial, ['ls', directory], |
| 56 echo=False).split('\n') |
| 57 |
| 58 def DevicePathExists(self, path): |
| 59 """ Overrides build_step.DevicePathExists() """ |
| 60 return 'FILE_EXISTS' in android_utils.ADBShell( |
| 61 self._serial, |
| 62 ['if', '[', '-e', path, '];', 'then', 'echo', 'FILE_EXISTS;', 'fi']) |
| 63 |
55 def DevicePathJoin(self, *args): | 64 def DevicePathJoin(self, *args): |
56 """ Overrides build_step.DevicePathJoin() """ | 65 """ Overrides build_step.DevicePathJoin() """ |
57 return posixpath.sep.join(args) | 66 return posixpath.sep.join(args) |
58 | 67 |
59 def CreateCleanDirectory(self, directory): | 68 def CreateCleanDirectory(self, directory): |
60 self._RemoveDirectoryOnDevice(directory) | 69 self._RemoveDirectoryOnDevice(directory) |
61 self._CreateDirectoryOnDevice(directory) | 70 self._CreateDirectoryOnDevice(directory) |
62 | 71 |
63 def CopyDirectoryContentsToDevice(self, host_dir, device_dir): | 72 def CopyDirectoryContentsToDevice(self, host_dir, device_dir): |
64 """ Copy the contents of a host-side directory to a clean directory on the | 73 """ Copy the contents of a host-side directory to a clean directory on the |
(...skipping 19 matching lines...) Expand all Loading... |
84 device_scratch_dir = shell_utils.Bash( | 93 device_scratch_dir = shell_utils.Bash( |
85 '%s -s %s shell echo \$EXTERNAL_STORAGE' % ( | 94 '%s -s %s shell echo \$EXTERNAL_STORAGE' % ( |
86 android_utils.PATH_TO_ADB, self._serial), | 95 android_utils.PATH_TO_ADB, self._serial), |
87 echo=True, shell=True).rstrip().split('\n')[-1] | 96 echo=True, shell=True).rstrip().split('\n')[-1] |
88 super(AndroidBuildStep, self).__init__(args=args, **kwargs) | 97 super(AndroidBuildStep, self).__init__(args=args, **kwargs) |
89 prefix = posixpath.join(device_scratch_dir, 'skiabot', 'skia_') | 98 prefix = posixpath.join(device_scratch_dir, 'skiabot', 'skia_') |
90 self._device_dirs = DeviceDirs(perf_data_dir=prefix + 'perf', | 99 self._device_dirs = DeviceDirs(perf_data_dir=prefix + 'perf', |
91 gm_actual_dir=prefix + 'gm_actual', | 100 gm_actual_dir=prefix + 'gm_actual', |
92 gm_expected_dir=prefix + 'gm_expected', | 101 gm_expected_dir=prefix + 'gm_expected', |
93 resource_dir=prefix + 'resources', | 102 resource_dir=prefix + 'resources', |
| 103 skimage_in_dir=prefix + 'skimage_in', |
| 104 skimage_expected_dir=(prefix |
| 105 + 'skimage_expected'), |
| 106 skimage_out_dir=prefix + 'skimage_out', |
94 skp_dir=prefix + 'skp', | 107 skp_dir=prefix + 'skp', |
95 skp_perf_dir=prefix + 'skp_perf', | 108 skp_perf_dir=prefix + 'skp_perf', |
96 skp_out_dir=prefix + 'skp_out', | 109 skp_out_dir=prefix + 'skp_out', |
97 tmp_dir=prefix + 'tmp_dir') | 110 tmp_dir=prefix + 'tmp_dir') |
OLD | NEW |