9from recipe_engine
import recipe_api
12from .
import chromebook
18"""Abstractions for running code on various platforms.
20The methods in this module define how certain high-level functions should work.
21Each flavor should correspond to a subclass of DefaultFlavor which may override
22any of these functions as appropriate for that flavor.
24For example, the AndroidFlavor will override the functions for copying files
25between the host and Android device, as well as the 'step' function, so that
26commands may be run through ADB.
30VERSION_FILE_LOTTIE =
'LOTTIE_VERSION'
31VERSION_FILE_SK_IMAGE =
'SK_IMAGE_VERSION'
32VERSION_FILE_SKP =
'SKP_VERSION'
33VERSION_FILE_SVG =
'SVG_VERSION'
34VERSION_FILE_TEXTTRACES =
'TEXTTRACES_VERSION'
39 return (
'Android' in vars_api.extra_tokens
or
40 'Android' in vars_api.builder_cfg.get(
'os',
''))
43 return (
'Chromebook' in vars_api.extra_tokens
or
44 'ChromeOS' in vars_api.builder_cfg.get(
'os',
''))
47 return (
'iOS' in vars_api.extra_tokens
or
48 'iOS' == vars_api.builder_cfg.get(
'os',
''))
51 return 'Valgrind' in vars_api.extra_tokens
56 """Return a flavor utils object specific to the given builder."""
72 self.
_skia_dir = self.m.path.start_dir.join(
'skia')
74 def step(self, name, cmd, **kwargs):
75 return self.
_f.
step(name, cmd, **kwargs)
101 def install(self, skps=False, images=False, lotties=False, svgs=False,
102 resources=False, texttraces=False):
110 self.m.path.start_dir.join(
'skia',
'resources'),
125 def _copy_dir(self, host_version, version_file, tmp_dir,
126 host_path, device_path):
127 actual_version_file = self.m.path.join(tmp_dir, version_file)
131 if str(actual_version_file) != str(device_version_file):
133 abort_on_failure=
False,
134 fail_build_on_failure=
False)
135 if not device_version:
136 device_version = VERSION_NONE
137 if device_version != host_version:
141 host_path, device_path)
146 def _copy_images(self):
147 """Copy test images if needed."""
148 version = self.m.run.asset_version(
'skimage', self.
_skia_dir)
149 self.m.run.writefile(
150 self.m.path.join(self.m.vars.tmp_dir, VERSION_FILE_SK_IMAGE),
154 VERSION_FILE_SK_IMAGE,
160 def _copy_lotties(self):
161 """Copy test lotties if needed."""
162 version = self.m.run.asset_version(
'lottie-samples', self.
_skia_dir)
163 self.m.run.writefile(
164 self.m.path.join(self.m.vars.tmp_dir, VERSION_FILE_LOTTIE),
174 def _copy_skps(self):
175 """Copy the SKPs if needed."""
176 version = self.m.run.asset_version(
'skp', self.
_skia_dir)
177 self.m.run.writefile(
178 self.m.path.join(self.m.vars.tmp_dir, VERSION_FILE_SKP),
188 def _copy_svgs(self):
189 """Copy the SVGs if needed."""
190 version = self.m.run.asset_version(
'svg', self.
_skia_dir)
191 self.m.run.writefile(
192 self.m.path.join(self.m.vars.tmp_dir, VERSION_FILE_SVG),
202 def _copy_texttraces(self):
203 """Copy the text traces if needed."""
204 version = self.m.run.asset_version(
'text_blob_traces', self.
_skia_dir)
205 self.m.run.writefile(
206 self.m.path.join(self.m.vars.tmp_dir, VERSION_FILE_TEXTTRACES),
210 VERSION_FILE_TEXTTRACES,
def create_clean_device_dir(self, path)
def device_path_join(self, *args)
def read_file_on_device(self, path, **kwargs)
def copy_directory_contents_to_host(self, device_dir, host_dir)
def create_clean_host_dir(self, path)
def copy_file_to_device(self, host_path, device_path)
def _copy_texttraces(self)
def remove_file_on_device(self, path)
def get_flavor(self, vars_api, app_name)
def _copy_dir(self, host_version, version_file, tmp_dir, host_path, device_path)
def step(self, name, cmd, **kwargs)
def setup(self, app_name)
def install(self, skps=False, images=False, lotties=False, svgs=False, resources=False, texttraces=False)
def copy_directory_contents_to_device(self, host_dir, device_dir)
def is_valgrind(vars_api)
def is_chromebook(vars_api)