aboutsummaryrefslogtreecommitdiffhomepage
path: root/infra/bots/recipe_modules/flavor
diff options
context:
space:
mode:
Diffstat (limited to 'infra/bots/recipe_modules/flavor')
-rw-r--r--infra/bots/recipe_modules/flavor/__init__.py1
-rw-r--r--infra/bots/recipe_modules/flavor/android.py (renamed from infra/bots/recipe_modules/flavor/gn_android_flavor.py)16
-rw-r--r--infra/bots/recipe_modules/flavor/api.py37
-rw-r--r--infra/bots/recipe_modules/flavor/chromebook.py (renamed from infra/bots/recipe_modules/flavor/gn_chromebook_flavor.py)19
-rw-r--r--infra/bots/recipe_modules/flavor/chromecast.py (renamed from infra/bots/recipe_modules/flavor/gn_chromecast_flavor.py)17
-rw-r--r--infra/bots/recipe_modules/flavor/default.py (renamed from infra/bots/recipe_modules/flavor/gn_flavor.py)145
-rw-r--r--infra/bots/recipe_modules/flavor/default_flavor.py157
-rw-r--r--infra/bots/recipe_modules/flavor/ios.py (renamed from infra/bots/recipe_modules/flavor/ios_flavor.py)15
-rw-r--r--infra/bots/recipe_modules/flavor/valgrind.py (renamed from infra/bots/recipe_modules/flavor/valgrind_flavor.py)8
9 files changed, 204 insertions, 211 deletions
diff --git a/infra/bots/recipe_modules/flavor/__init__.py b/infra/bots/recipe_modules/flavor/__init__.py
index 37321e559a..28b3d9bacb 100644
--- a/infra/bots/recipe_modules/flavor/__init__.py
+++ b/infra/bots/recipe_modules/flavor/__init__.py
@@ -12,6 +12,7 @@ DEPS = [
'infra',
'recipe_engine/context',
'recipe_engine/file',
+ 'recipe_engine/json',
'recipe_engine/path',
'recipe_engine/platform',
'recipe_engine/python',
diff --git a/infra/bots/recipe_modules/flavor/gn_android_flavor.py b/infra/bots/recipe_modules/flavor/android.py
index 1c352afc28..ed8d9af2d4 100644
--- a/infra/bots/recipe_modules/flavor/gn_android_flavor.py
+++ b/infra/bots/recipe_modules/flavor/android.py
@@ -2,17 +2,19 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+
from recipe_engine import recipe_api
-import default_flavor
-import re
-import subprocess
+from . import default
+import subprocess # TODO(borenet): No! Remove this.
+
+
+"""Android flavor, used for running code on Android."""
-"""GN Android flavor utils, used for building Skia for Android with GN."""
-class GNAndroidFlavorUtils(default_flavor.DefaultFlavorUtils):
+class AndroidFlavor(default.DefaultFlavor):
def __init__(self, m):
- super(GNAndroidFlavorUtils, self).__init__(m)
+ super(AndroidFlavor, self).__init__(m)
self._ever_ran_adb = False
self.ADB_BINARY = '/usr/bin/adb.1.0.35'
self.ADB_PUB_KEY = '/home/chrome-bot/.android/adbkey'
@@ -24,7 +26,7 @@ class GNAndroidFlavorUtils(default_flavor.DefaultFlavorUtils):
# Data should go in android_data_dir, which may be preserved across runs.
android_data_dir = '/sdcard/revenge_of_the_skiabot/'
- self.device_dirs = default_flavor.DeviceDirs(
+ self.device_dirs = default.DeviceDirs(
bin_dir = '/data/local/tmp/',
dm_dir = android_data_dir + 'dm_out',
perf_data_dir = android_data_dir + 'perf',
diff --git a/infra/bots/recipe_modules/flavor/api.py b/infra/bots/recipe_modules/flavor/api.py
index c5a1be8030..9dee6f77ee 100644
--- a/infra/bots/recipe_modules/flavor/api.py
+++ b/infra/bots/recipe_modules/flavor/api.py
@@ -8,13 +8,24 @@
from recipe_engine import recipe_api
-from . import default_flavor
-from . import gn_android_flavor
-from . import gn_chromebook_flavor
-from . import gn_chromecast_flavor
-from . import gn_flavor
-from . import ios_flavor
-from . import valgrind_flavor
+from . import android
+from . import chromebook
+from . import chromecast
+from . import default
+from . import ios
+from . import valgrind
+
+
+"""Abstractions for running code on various platforms.
+
+The methods in this module define how certain high-level functions should work.
+Each flavor should correspond to a subclass of DefaultFlavor which may override
+any of these functions as appropriate for that flavor.
+
+For example, the AndroidFlavor will override the functions for copying files
+between the host and Android device, as well as the 'step' function, so that
+commands may be run through ADB.
+"""
VERSION_FILE_SK_IMAGE = 'SK_IMAGE_VERSION'
@@ -50,17 +61,17 @@ class SkiaFlavorApi(recipe_api.RecipeApi):
def get_flavor(self, vars_api):
"""Return a flavor utils object specific to the given builder."""
if is_chromecast(vars_api):
- return gn_chromecast_flavor.GNChromecastFlavorUtils(self)
+ return chromecast.ChromecastFlavor(self)
if is_chromebook(vars_api):
- return gn_chromebook_flavor.GNChromebookFlavorUtils(self)
+ return chromebook.ChromebookFlavor(self)
if is_android(vars_api) and not is_test_skqp(vars_api):
- return gn_android_flavor.GNAndroidFlavorUtils(self)
+ return android.AndroidFlavor(self)
elif is_ios(vars_api):
- return ios_flavor.iOSFlavorUtils(self)
+ return ios.iOSFlavor(self)
elif is_valgrind(vars_api):
- return valgrind_flavor.ValgrindFlavorUtils(self)
+ return valgrind.ValgrindFlavor(self)
else:
- return gn_flavor.GNFlavorUtils(self)
+ return default.DefaultFlavor(self)
def setup(self):
self._f = self.get_flavor(self.m.vars)
diff --git a/infra/bots/recipe_modules/flavor/gn_chromebook_flavor.py b/infra/bots/recipe_modules/flavor/chromebook.py
index a133f2bb90..eb745d3972 100644
--- a/infra/bots/recipe_modules/flavor/gn_chromebook_flavor.py
+++ b/infra/bots/recipe_modules/flavor/chromebook.py
@@ -5,24 +5,21 @@
from recipe_engine import recipe_api
-import default_flavor
-import gn_flavor
-import json
-import subprocess
+import default
+import json # TODO(borenet): No! Remove this.
-"""
- GN Chromebook flavor utils, used for building and testing Skia for ARM
- Chromebooks with GN
-"""
-class GNChromebookFlavorUtils(gn_flavor.GNFlavorUtils):
+"""Chromebook flavor, used for running code on Chromebooks."""
+
+
+class ChromebookFlavor(default.DefaultFlavor):
def __init__(self, m):
- super(GNChromebookFlavorUtils, self).__init__(m)
+ super(ChromebookFlavor, self).__init__(m)
self._user_ip = ''
self.chromeos_homedir = '/home/chronos/user/'
- self.device_dirs = default_flavor.DeviceDirs(
+ self.device_dirs = default.DeviceDirs(
bin_dir = self.chromeos_homedir + 'bin',
dm_dir = self.chromeos_homedir + 'dm_out',
perf_data_dir = self.chromeos_homedir + 'perf',
diff --git a/infra/bots/recipe_modules/flavor/gn_chromecast_flavor.py b/infra/bots/recipe_modules/flavor/chromecast.py
index bd65e01516..c897aa93ab 100644
--- a/infra/bots/recipe_modules/flavor/gn_chromecast_flavor.py
+++ b/infra/bots/recipe_modules/flavor/chromecast.py
@@ -4,15 +4,16 @@
from recipe_engine import recipe_api
-import default_flavor
-import gn_android_flavor
-import subprocess
+from . import android
+from . import default
-"""GN Chromecast flavor utils, used for building Skia for Chromecast with GN"""
-class GNChromecastFlavorUtils(gn_android_flavor.GNAndroidFlavorUtils):
+"""Chromecast flavor, used for running code on Chromecast"""
+
+
+class ChromecastFlavor(android.AndroidFlavor):
def __init__(self, m):
- super(GNChromecastFlavorUtils, self).__init__(m)
+ super(ChromecastFlavor, self).__init__(m)
self._ever_ran_adb = False
self._user_ip = ''
@@ -21,7 +22,7 @@ class GNChromecastFlavorUtils(gn_android_flavor.GNAndroidFlavorUtils):
# resources, executable and output the dm images. So, we have dm_out be
# on the tempfs (i.e. RAM) /dev/shm. (which is about 140M)
data_dir = '/cache/skia/'
- self.device_dirs = default_flavor.DeviceDirs(
+ self.device_dirs = default.DeviceDirs(
bin_dir = '/cache/skia/bin',
dm_dir = '/dev/shm/skia/dm_out',
perf_data_dir = data_dir + 'perf',
@@ -51,7 +52,7 @@ class GNChromecastFlavorUtils(gn_android_flavor.GNAndroidFlavorUtils):
return self.user_ip_host.split(':')[0]
def install(self):
- super(GNChromecastFlavorUtils, self).install()
+ super(ChromecastFlavor, self).install()
self._adb('mkdir ' + self.device_dirs.bin_dir,
'shell', 'mkdir', '-p', self.device_dirs.bin_dir)
diff --git a/infra/bots/recipe_modules/flavor/gn_flavor.py b/infra/bots/recipe_modules/flavor/default.py
index 284f20b365..501c6bead5 100644
--- a/infra/bots/recipe_modules/flavor/gn_flavor.py
+++ b/infra/bots/recipe_modules/flavor/default.py
@@ -1,12 +1,147 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
+# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import default_flavor
-"""GN flavor utils, used for building Skia with GN."""
-class GNFlavorUtils(default_flavor.DefaultFlavorUtils):
- # TODO(borenet): Delete this file.
+# pylint: disable=W0201
+
+
+"""Default flavor, used for running code on desktop machines."""
+
+
+WIN_TOOLCHAIN_DIR = 't'
+
+
+class DeviceDirs(object):
+ def __init__(self,
+ bin_dir,
+ dm_dir,
+ perf_data_dir,
+ resource_dir,
+ images_dir,
+ skp_dir,
+ svg_dir,
+ tmp_dir):
+ self._bin_dir = bin_dir
+ self._dm_dir = dm_dir
+ self._perf_data_dir = perf_data_dir
+ self._resource_dir = resource_dir
+ self._images_dir = images_dir
+ self._skp_dir = skp_dir
+ self._svg_dir = svg_dir
+ self._tmp_dir = tmp_dir
+
+ @property
+ def bin_dir(self):
+ return self._bin_dir
+
+ @property
+ def dm_dir(self):
+ """Where DM writes."""
+ return self._dm_dir
+
+ @property
+ def perf_data_dir(self):
+ return self._perf_data_dir
+
+ @property
+ def resource_dir(self):
+ return self._resource_dir
+
+ @property
+ def images_dir(self):
+ return self._images_dir
+
+ @property
+ def skp_dir(self):
+ """Holds SKP files that are consumed by RenderSKPs and BenchPictures."""
+ return self._skp_dir
+
+ @property
+ def svg_dir(self):
+ return self._svg_dir
+
+ @property
+ def tmp_dir(self):
+ return self._tmp_dir
+
+
+class DefaultFlavor(object):
+ def __init__(self, module):
+ # Store a pointer to the parent recipe module (SkiaFlavorApi) so that
+ # FlavorUtils objects can do recipe module-like things, like run steps or
+ # access module-level resources.
+ self.module = module
+
+ # self.m is just a shortcut so that Flavor objects can use the same
+ # syntax as regular recipe modules to run steps, eg: self.m.step(...)
+ self.m = module.m
+ self._chrome_path = None
+ self.device_dirs = DeviceDirs(
+ bin_dir=self.m.vars.build_dir.join('out', self.m.vars.configuration),
+ dm_dir=self.m.path.join(self.m.vars.swarming_out_dir, 'dm'),
+ perf_data_dir=self.m.path.join(
+ self.m.vars.swarming_out_dir,
+ 'perfdata', self.m.vars.builder_name, 'data'),
+ resource_dir=self.m.path['start_dir'].join('skia', 'resources'),
+ images_dir=self.m.path['start_dir'].join('skimage'),
+ skp_dir=self.m.path['start_dir'].join('skp'),
+ svg_dir=self.m.path['start_dir'].join('svg'),
+ tmp_dir=self.m.vars.tmp_dir)
+ self.host_dirs = self.device_dirs
+
+ def device_path_join(self, *args):
+ """Like os.path.join(), but for paths on a connected device."""
+ return self.m.path.join(*args)
+
+ def copy_directory_contents_to_device(self, host_dir, device_dir):
+ """Like shutil.copytree(), but for copying to a connected device."""
+ # For "normal" builders who don't have an attached device, we expect
+ # host_dir and device_dir to be the same.
+ if str(host_dir) != str(device_dir):
+ raise ValueError('For builders who do not have attached devices, copying '
+ 'from host to device is undefined and only allowed if '
+ 'host_path and device_path are the same (%s vs %s).' % (
+ str(host_dir), str(device_dir)))
+
+ def copy_directory_contents_to_host(self, device_dir, host_dir):
+ """Like shutil.copytree(), but for copying from a connected device."""
+ # For "normal" builders who don't have an attached device, we expect
+ # host_dir and device_dir to be the same.
+ if str(host_dir) != str(device_dir):
+ raise ValueError('For builders who do not have attached devices, copying '
+ 'from device to host is undefined and only allowed if '
+ 'host_path and device_path are the same (%s vs %s).' % (
+ str(host_dir), str(device_dir)))
+
+ def copy_file_to_device(self, host_path, device_path):
+ """Like shutil.copyfile, but for copying to a connected device."""
+ # For "normal" builders who don't have an attached device, we expect
+ # host_dir and device_dir to be the same.
+ if str(host_path) != str(device_path):
+ raise ValueError('For builders who do not have attached devices, copying '
+ 'from host to device is undefined and only allowed if '
+ 'host_path and device_path are the same (%s vs %s).' % (
+ str(host_path), str(device_path)))
+
+ def create_clean_device_dir(self, path):
+ """Like shutil.rmtree() + os.makedirs(), but on a connected device."""
+ self.create_clean_host_dir(path)
+
+ def create_clean_host_dir(self, path):
+ """Convenience function for creating a clean directory."""
+ self.m.run.rmtree(path)
+ self.m.file.ensure_directory(
+ 'makedirs %s' % self.m.path.basename(path), path)
+
+ def install(self):
+ """Run device-specific installation steps."""
+ pass
+
+ def cleanup_steps(self):
+ """Run any device-specific cleanup steps."""
+ pass
+
def _run(self, title, cmd, infra_step=False, **kwargs):
return self.m.run(self.m.step, title, cmd=cmd,
infra_step=infra_step, **kwargs)
diff --git a/infra/bots/recipe_modules/flavor/default_flavor.py b/infra/bots/recipe_modules/flavor/default_flavor.py
deleted file mode 100644
index ec684efd1f..0000000000
--- a/infra/bots/recipe_modules/flavor/default_flavor.py
+++ /dev/null
@@ -1,157 +0,0 @@
-# Copyright 2014 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-
-# pylint: disable=W0201
-
-
-"""Default flavor utils class, used for desktop builders."""
-
-
-import json
-
-
-WIN_TOOLCHAIN_DIR = 't'
-
-
-class DeviceDirs(object):
- def __init__(self,
- bin_dir,
- dm_dir,
- perf_data_dir,
- resource_dir,
- images_dir,
- skp_dir,
- svg_dir,
- tmp_dir):
- self._bin_dir = bin_dir
- self._dm_dir = dm_dir
- self._perf_data_dir = perf_data_dir
- self._resource_dir = resource_dir
- self._images_dir = images_dir
- self._skp_dir = skp_dir
- self._svg_dir = svg_dir
- self._tmp_dir = tmp_dir
-
- @property
- def bin_dir(self):
- return self._bin_dir
-
- @property
- def dm_dir(self):
- """Where DM writes."""
- return self._dm_dir
-
- @property
- def perf_data_dir(self):
- return self._perf_data_dir
-
- @property
- def resource_dir(self):
- return self._resource_dir
-
- @property
- def images_dir(self):
- return self._images_dir
-
- @property
- def skp_dir(self):
- """Holds SKP files that are consumed by RenderSKPs and BenchPictures."""
- return self._skp_dir
-
- @property
- def svg_dir(self):
- return self._svg_dir
-
- @property
- def tmp_dir(self):
- return self._tmp_dir
-
-
-class DefaultFlavorUtils(object):
- """Utilities to be used by build steps.
-
- The methods in this class define how certain high-level functions should
- work. Each build step flavor should correspond to a subclass of
- DefaultFlavorUtils which may override any of these functions as appropriate
- for that flavor.
-
- For example, the AndroidFlavorUtils will override the functions for
- copying files between the host and Android device, as well as the
- 'step' function, so that commands may be run through ADB.
- """
- def __init__(self, module):
- # Store a pointer to the parent recipe module (SkiaFlavorApi) so that
- # FlavorUtils objects can do recipe module-like things, like run steps or
- # access module-level resources.
- self.module = module
-
- # self.m is just a shortcut so that FlavorUtils objects can use the same
- # syntax as regular recipe modules to run steps, eg: self.m.step(...)
- self.m = module.m
- self._chrome_path = None
- self.device_dirs = DeviceDirs(
- bin_dir=self.m.vars.build_dir.join('out', self.m.vars.configuration),
- dm_dir=self.m.path.join(self.m.vars.swarming_out_dir, 'dm'),
- perf_data_dir=self.m.path.join(
- self.m.vars.swarming_out_dir,
- 'perfdata', self.m.vars.builder_name, 'data'),
- resource_dir=self.m.path['start_dir'].join('skia', 'resources'),
- images_dir=self.m.path['start_dir'].join('skimage'),
- skp_dir=self.m.path['start_dir'].join('skp'),
- svg_dir=self.m.path['start_dir'].join('svg'),
- tmp_dir=self.m.vars.tmp_dir)
- self.host_dirs = self.device_dirs
-
- def device_path_join(self, *args):
- """Like os.path.join(), but for paths on a connected device."""
- return self.m.path.join(*args)
-
- def copy_directory_contents_to_device(self, host_dir, device_dir):
- """Like shutil.copytree(), but for copying to a connected device."""
- # For "normal" builders who don't have an attached device, we expect
- # host_dir and device_dir to be the same.
- if str(host_dir) != str(device_dir):
- raise ValueError('For builders who do not have attached devices, copying '
- 'from host to device is undefined and only allowed if '
- 'host_path and device_path are the same (%s vs %s).' % (
- str(host_dir), str(device_dir)))
-
- def copy_directory_contents_to_host(self, device_dir, host_dir):
- """Like shutil.copytree(), but for copying from a connected device."""
- # For "normal" builders who don't have an attached device, we expect
- # host_dir and device_dir to be the same.
- if str(host_dir) != str(device_dir):
- raise ValueError('For builders who do not have attached devices, copying '
- 'from device to host is undefined and only allowed if '
- 'host_path and device_path are the same (%s vs %s).' % (
- str(host_dir), str(device_dir)))
-
- def copy_file_to_device(self, host_path, device_path):
- """Like shutil.copyfile, but for copying to a connected device."""
- # For "normal" builders who don't have an attached device, we expect
- # host_dir and device_dir to be the same.
- if str(host_path) != str(device_path):
- raise ValueError('For builders who do not have attached devices, copying '
- 'from host to device is undefined and only allowed if '
- 'host_path and device_path are the same (%s vs %s).' % (
- str(host_path), str(device_path)))
-
- def create_clean_device_dir(self, path):
- """Like shutil.rmtree() + os.makedirs(), but on a connected device."""
- self.create_clean_host_dir(path)
-
- def create_clean_host_dir(self, path):
- """Convenience function for creating a clean directory."""
- self.m.run.rmtree(path)
- self.m.file.ensure_directory(
- 'makedirs %s' % self.m.path.basename(path), path)
-
- def install(self):
- """Run device-specific installation steps."""
- pass
-
- def cleanup_steps(self):
- """Run any device-specific cleanup steps."""
- pass
diff --git a/infra/bots/recipe_modules/flavor/ios_flavor.py b/infra/bots/recipe_modules/flavor/ios.py
index 3df07451e9..d78cd4ca39 100644
--- a/infra/bots/recipe_modules/flavor/ios_flavor.py
+++ b/infra/bots/recipe_modules/flavor/ios.py
@@ -5,14 +5,17 @@
# Disable warning about setting self.device_dirs in install(); we need to.
# pylint: disable=W0201
-import default_flavor
-import gn_flavor
-import os
-class iOSFlavorUtils(gn_flavor.GNFlavorUtils):
+from . import default
+
+
+"""iOS flavor, used for running code on iOS."""
+
+
+class iOSFlavor(default.DefaultFlavor):
def __init__(self, m):
- super(iOSFlavorUtils, self).__init__(m)
- self.device_dirs = default_flavor.DeviceDirs(
+ super(iOSFlavor, self).__init__(m)
+ self.device_dirs = default.DeviceDirs(
bin_dir='[unused]',
dm_dir='dm',
perf_data_dir='perf',
diff --git a/infra/bots/recipe_modules/flavor/valgrind_flavor.py b/infra/bots/recipe_modules/flavor/valgrind.py
index b54fcc36dd..774dbd461a 100644
--- a/infra/bots/recipe_modules/flavor/valgrind_flavor.py
+++ b/infra/bots/recipe_modules/flavor/valgrind.py
@@ -3,15 +3,15 @@
# found in the LICENSE file.
-import gn_flavor
+from . import default
-"""Utils for running under Valgrind."""
+"""Valgrind flavor, used for running code through Valgrind."""
-class ValgrindFlavorUtils(gn_flavor.GNFlavorUtils):
+class ValgrindFlavor(default.DefaultFlavor):
def __init__(self, m):
- super(ValgrindFlavorUtils, self).__init__(m)
+ super(ValgrindFlavor, self).__init__(m)
self._suppressions_file = self.m.path['start_dir'].join(
'skia', 'tools', 'valgrind.supp')
self._valgrind_cipd_dir = self.m.vars.slave_dir.join('valgrind')