OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # | |
3 # Copyright 2016 Google Inc. | |
4 # | |
5 # Use of this source code is governed by a BSD-style license that can be | |
6 # found in the LICENSE file. | |
7 | |
8 | |
9 import copy | |
rmistry
2016/02/18 15:29:21
unused
borenet
2016/02/18 15:40:56
Done.
| |
10 import default_flavor | |
11 import os | |
12 import subprocess | |
13 | |
14 | |
15 """iOS flavor utils, used for building for and running tests on iOS.""" | |
16 | |
17 | |
18 class iOSFlavorUtils(default_flavor.DefaultFlavorUtils): | |
19 def __init__(self, bot_info): | |
20 super(iOSFlavorUtils, self).__init__(bot_info) | |
21 self.ios_bin = os.path.join(self._bot_info.skia_dir, 'platform_tools', | |
22 'ios', 'bin') | |
23 | |
24 def step(self, cmd, **kwargs): | |
25 args = [os.path.join(self.ios_bin, 'ios_run_skia')] | |
26 | |
27 # Convert 'dm' and 'nanobench' from positional arguments | |
28 # to flags, which is what iOSShell expects to select which | |
29 # one is being run. | |
30 cmd = ["--" + c if c in ['dm', 'nanobench'] else c | |
31 for c in cmd] | |
32 return self._bot_info.run(args + cmd, **kwargs) | |
33 | |
34 def compile(self, target): | |
35 """Build the given target.""" | |
36 cmd = [os.path.join(self.ios_bin, 'ios_ninja')] | |
37 self._bot_info.run(cmd) | |
38 | |
39 def device_path_join(self, *args): | |
40 """Like os.path.join(), but for paths on a connected iOS device.""" | |
41 return '/'.join(args) | |
42 | |
43 def device_path_exists(self, path): | |
44 """Like os.path.exists(), but for paths on a connected device.""" | |
45 return self._bot_info.run( | |
46 [os.path.join(self.ios_bin, 'ios_path_exists'), path], | |
47 ) # pragma: no cover | |
48 | |
49 def _remove_device_dir(self, path): | |
50 """Remove the directory on the device.""" | |
51 return self._bot_info.run( | |
52 [os.path.join(self.ios_bin, 'ios_rm'), path], | |
53 ) | |
54 | |
55 def _create_device_dir(self, path): | |
56 """Create the directory on the device.""" | |
57 return self._bot_info.run( | |
58 [os.path.join(self.ios_bin, 'ios_mkdir'), path], | |
59 ) | |
60 | |
61 def copy_directory_contents_to_device(self, host_dir, device_dir): | |
62 """Like shutil.copytree(), but for copying to a connected device.""" | |
63 return self._bot_info.run([ | |
64 os.path.join(self.ios_bin, 'ios_push_if_needed'), | |
65 host_dir, device_dir | |
66 ]) | |
67 | |
68 def copy_directory_contents_to_host(self, device_dir, host_dir): | |
69 """Like shutil.copytree(), but for copying from a connected device.""" | |
70 return self._bot_info.run( | |
71 [os.path.join(self.ios_bin, 'ios_pull_if_needed'), | |
72 device_dir, host_dir], | |
73 ) | |
74 | |
75 def copy_file_to_device(self, host_path, device_path): | |
76 """Like shutil.copyfile, but for copying to a connected device.""" | |
77 self._bot_info.run( | |
78 [os.path.join(self.ios_bin, 'ios_push_file'), host_path, device_path], | |
79 ) # pragma: no cover | |
80 | |
81 def create_clean_device_dir(self, path): | |
82 """Like shutil.rmtree() + os.makedirs(), but on a connected device.""" | |
83 self._remove_device_dir(path) | |
84 self._create_device_dir(path) | |
85 | |
86 def install(self): | |
87 """Run device-specific installation steps.""" | |
88 self._bot_info.run([os.path.join(self.ios_bin, 'ios_install')]) | |
89 | |
90 def cleanup_steps(self): | |
91 """Run any device-specific cleanup steps.""" | |
92 self._bot_info.run([os.path.join(self.ios_bin, 'ios_restart')]) | |
93 self._bot_info.run(['sleep', '20']) | |
94 | |
95 def read_file_on_device(self, path): | |
96 """Read the given file.""" | |
97 return subprocess.check_output( | |
98 [os.path.join(self.ios_bin, 'ios_cat_file'), path]).rstrip() | |
99 | |
100 def remove_file_on_device(self, path): | |
101 """Remove the file on the device.""" | |
102 return self._bot_info.run( | |
103 [os.path.join(self.ios_bin, 'ios_rm'), path], | |
104 ) | |
105 | |
106 def get_device_dirs(self): | |
107 """ Set the directories which will be used by the build steps.""" | |
108 prefix = self.device_path_join('skiabot', 'skia_') | |
109 return default_flavor.DeviceDirs( | |
110 dm_dir=prefix + 'dm', | |
111 perf_data_dir=prefix + 'perf', | |
112 resource_dir=prefix + 'resources', | |
113 images_dir=prefix + 'images', | |
114 skp_dir=prefix + 'skp/skps', | |
115 tmp_dir=prefix + 'tmp_dir') | |
OLD | NEW |