Index: infra/bots/recipe_modules/flavor/ios_flavor.py |
diff --git a/infra/bots/recipe_modules/skia/ios_flavor.py b/infra/bots/recipe_modules/flavor/ios_flavor.py |
similarity index 69% |
rename from infra/bots/recipe_modules/skia/ios_flavor.py |
rename to infra/bots/recipe_modules/flavor/ios_flavor.py |
index d83cf213de9013482a2b28d9346591eafa1639a6..d0d60f428442e0af91fc5887f871e1e65b278f5c 100644 |
--- a/infra/bots/recipe_modules/skia/ios_flavor.py |
+++ b/infra/bots/recipe_modules/flavor/ios_flavor.py |
@@ -3,6 +3,9 @@ |
# found in the LICENSE file. |
+# pylint: disable=W0201 |
+ |
+ |
import copy |
import default_flavor |
@@ -11,12 +14,12 @@ import default_flavor |
class iOSFlavorUtils(default_flavor.DefaultFlavorUtils): |
- def __init__(self, skia_api): |
- super(iOSFlavorUtils, self).__init__(skia_api) |
+ def __init__(self, m): |
+ super(iOSFlavorUtils, self).__init__(m) |
self.default_env = {} |
self.default_env['XCODEBUILD'] = ( |
- self._skia_api.slave_dir.join('xcodebuild')) |
- self.ios_bin = self._skia_api.skia_dir.join( |
+ self.m.vars.slave_dir.join('xcodebuild')) |
+ self.ios_bin = self.m.vars.skia_dir.join( |
'platform_tools', 'ios', 'bin') |
def step(self, name, cmd, **kwargs): |
@@ -29,15 +32,14 @@ class iOSFlavorUtils(default_flavor.DefaultFlavorUtils): |
# one is being run. |
cmd = ["--" + c if c in ['dm', 'nanobench'] else c |
for c in cmd] |
- return self._skia_api.run(self._skia_api.m.step, name=name, cmd=args + cmd, |
- env=env, |
- **kwargs) |
+ return self.m.run(self.m.step, name=name, cmd=args + cmd, |
+ env=env, **kwargs) |
def compile(self, target): |
"""Build the given target.""" |
cmd = [self.ios_bin.join('ios_ninja')] |
- self._skia_api.run(self._skia_api.m.step, 'build iOSShell', cmd=cmd, |
- cwd=self._skia_api.m.path['checkout']) |
+ self.m.run(self.m.step, 'build iOSShell', cmd=cmd, |
+ cwd=self.m.path['checkout']) |
def device_path_join(self, *args): |
"""Like os.path.join(), but for paths on a connected iOS device.""" |
@@ -45,8 +47,8 @@ class iOSFlavorUtils(default_flavor.DefaultFlavorUtils): |
def device_path_exists(self, path): |
"""Like os.path.exists(), but for paths on a connected device.""" |
- return self._skia_api.run( |
- self._skia_api.m.step, |
+ return self.m.run( |
+ self.m.step, |
'exists %s' % path, |
cmd=[self.ios_bin.join('ios_path_exists'), path], |
env=self.default_env, |
@@ -55,8 +57,8 @@ class iOSFlavorUtils(default_flavor.DefaultFlavorUtils): |
def _remove_device_dir(self, path): |
"""Remove the directory on the device.""" |
- return self._skia_api.run( |
- self._skia_api.m.step, |
+ return self.m.run( |
+ self.m.step, |
'rmdir %s' % path, |
cmd=[self.ios_bin.join('ios_rm'), path], |
env=self.default_env, |
@@ -65,8 +67,8 @@ class iOSFlavorUtils(default_flavor.DefaultFlavorUtils): |
def _create_device_dir(self, path): |
"""Create the directory on the device.""" |
- return self._skia_api.run( |
- self._skia_api.m.step, |
+ return self.m.run( |
+ self.m.step, |
'mkdir %s' % path, |
cmd=[self.ios_bin.join('ios_mkdir'), path], |
env=self.default_env, |
@@ -75,10 +77,10 @@ class iOSFlavorUtils(default_flavor.DefaultFlavorUtils): |
def copy_directory_contents_to_device(self, host_dir, device_dir): |
"""Like shutil.copytree(), but for copying to a connected device.""" |
- return self._skia_api.run( |
- self._skia_api.m.step, |
- name='push %s to %s' % (self._skia_api.m.path.basename(host_dir), |
- self._skia_api.m.path.basename(device_dir)), |
+ return self.m.run( |
+ self.m.step, |
+ name='push %s to %s' % (self.m.path.basename(host_dir), |
+ self.m.path.basename(device_dir)), |
cmd=[self.ios_bin.join('ios_push_if_needed'), |
host_dir, device_dir], |
env=self.default_env, |
@@ -87,9 +89,9 @@ class iOSFlavorUtils(default_flavor.DefaultFlavorUtils): |
def copy_directory_contents_to_host(self, device_dir, host_dir): |
"""Like shutil.copytree(), but for copying from a connected device.""" |
- self._skia_api.run( |
- self._skia_api.m.step, |
- name='pull %s' % self._skia_api.m.path.basename(device_dir), |
+ self.m.run( |
+ self.m.step, |
+ name='pull %s' % self.m.path.basename(device_dir), |
cmd=[self.ios_bin.join('ios_pull_if_needed'), |
device_dir, host_dir], |
env=self.default_env, |
@@ -98,8 +100,8 @@ class iOSFlavorUtils(default_flavor.DefaultFlavorUtils): |
def copy_file_to_device(self, host_path, device_path): |
"""Like shutil.copyfile, but for copying to a connected device.""" |
- self._skia_api.run( |
- self._skia_api.m.step, |
+ self.m.run( |
+ self.m.step, |
name='push %s' % host_path, |
cmd=[self.ios_bin.join('ios_push_file'), host_path, device_path], |
env=self.default_env, |
@@ -107,10 +109,10 @@ class iOSFlavorUtils(default_flavor.DefaultFlavorUtils): |
) # pragma: no cover |
def copy_extra_build_products(self, swarming_out_dir): |
- xcode_dir = self._skia_api.m.path.join( |
- 'xcodebuild', '%s-iphoneos' % self._skia_api.configuration) |
- self._skia_api.copy_build_products( |
- self._skia_api.skia_dir.join(xcode_dir), |
+ xcode_dir = self.m.path.join( |
+ 'xcodebuild', '%s-iphoneos' % self.m.vars.configuration) |
+ self.m.run.copy_build_products( |
+ self.m.vars.skia_dir.join(xcode_dir), |
swarming_out_dir.join(xcode_dir)) |
def create_clean_device_dir(self, path): |
@@ -120,8 +122,17 @@ class iOSFlavorUtils(default_flavor.DefaultFlavorUtils): |
def install(self): |
"""Run device-specific installation steps.""" |
- self._skia_api.run( |
- self._skia_api.m.step, |
+ prefix = self.device_path_join('skiabot', 'skia_') |
+ self.device_dirs = default_flavor.DeviceDirs( |
+ dm_dir=prefix + 'dm', |
+ perf_data_dir=prefix + 'perf', |
+ resource_dir=prefix + 'resources', |
+ images_dir=prefix + 'images', |
+ skp_dir=prefix + 'skp/skps', |
+ tmp_dir=prefix + 'tmp_dir') |
+ |
+ self.m.run( |
+ self.m.step, |
name='install iOSShell', |
cmd=[self.ios_bin.join('ios_install')], |
env=self.default_env, |
@@ -129,15 +140,15 @@ class iOSFlavorUtils(default_flavor.DefaultFlavorUtils): |
def cleanup_steps(self): |
"""Run any device-specific cleanup steps.""" |
- if self._skia_api.do_test_steps or self._skia_api.do_perf_steps: |
- self._skia_api.run( |
- self._skia_api.m.step, |
+ if self.m.vars.do_test_steps or self.m.vars.do_perf_steps: |
+ self.m.run( |
+ self.m.step, |
name='reboot', |
cmd=[self.ios_bin.join('ios_restart')], |
env=self.default_env, |
infra_step=True) |
- self._skia_api.run( |
- self._skia_api.m.step, |
+ self.m.run( |
+ self.m.step, |
name='wait for reboot', |
cmd=['sleep', '20'], |
env=self.default_env, |
@@ -145,32 +156,21 @@ class iOSFlavorUtils(default_flavor.DefaultFlavorUtils): |
def read_file_on_device(self, path): |
"""Read the given file.""" |
- ret = self._skia_api.run( |
- self._skia_api.m.step, |
- name='read %s' % self._skia_api.m.path.basename(path), |
+ ret = self.m.run( |
+ self.m.step, |
+ name='read %s' % self.m.path.basename(path), |
cmd=[self.ios_bin.join('ios_cat_file'), path], |
env=self.default_env, |
- stdout=self._skia_api.m.raw_io.output(), |
+ stdout=self.m.raw_io.output(), |
infra_step=True) |
return ret.stdout.rstrip() if ret.stdout else ret.stdout |
def remove_file_on_device(self, path): |
"""Remove the file on the device.""" |
- return self._skia_api.run( |
- self._skia_api.m.step, |
+ return self.m.run( |
+ self.m.step, |
'rm %s' % path, |
cmd=[self.ios_bin.join('ios_rm'), path], |
env=self.default_env, |
infra_step=True, |
) |
- |
- def get_device_dirs(self): |
- """ Set the directories which will be used by the build steps.""" |
- prefix = self.device_path_join('skiabot', 'skia_') |
- return default_flavor.DeviceDirs( |
- dm_dir=prefix + 'dm', |
- perf_data_dir=prefix + 'perf', |
- resource_dir=prefix + 'resources', |
- images_dir=prefix + 'images', |
- skp_dir=prefix + 'skp/skps', |
- tmp_dir=prefix + 'tmp_dir') |