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_MSKP =
'MSKP_VERSION'
35VERSION_FILE_TEXTTRACES =
'TEXTTRACES_VERSION'
40 return (
'Android' in vars_api.extra_tokens
or
41 'Android' in vars_api.builder_cfg.get(
'os',
''))
44 return (
'Chromebook' in vars_api.extra_tokens
or
45 'ChromeOS' in vars_api.builder_cfg.get(
'os',
''))
48 return (
'iOS' in vars_api.extra_tokens
or
49 'iOS' == vars_api.builder_cfg.get(
'os',
''))
52 return 'Valgrind' in vars_api.extra_tokens
57 """Return a flavor utils object specific to the given builder."""
73 self.
_skia_dir = self.m.path[
'start_dir'].join(
'skia')
75 def step(self, name, cmd, **kwargs):
76 return self.
_f.
step(name, cmd, **kwargs)
102 def install(self, skps=False, images=False, lotties=False, svgs=False,
103 resources=False, mskps=False, texttraces=False):
111 self.m.path[
'start_dir'].join(
'skia',
'resources'),
128 def _copy_dir(self, host_version, version_file, tmp_dir,
129 host_path, device_path):
130 actual_version_file = self.m.path.join(tmp_dir, version_file)
134 if str(actual_version_file) != str(device_version_file):
136 abort_on_failure=
False,
137 fail_build_on_failure=
False)
138 if not device_version:
139 device_version = VERSION_NONE
140 if device_version != host_version:
144 host_path, device_path)
150 """Copy test images if needed."""
151 version = self.m.run.asset_version(
'skimage', self.
_skia_dir)
152 self.m.run.writefile(
153 self.m.path.join(self.m.vars.tmp_dir, VERSION_FILE_SK_IMAGE),
157 VERSION_FILE_SK_IMAGE,
164 """Copy test lotties if needed."""
165 version = self.m.run.asset_version(
'lottie-samples', self.
_skia_dir)
166 self.m.run.writefile(
167 self.m.path.join(self.m.vars.tmp_dir, VERSION_FILE_LOTTIE),
178 """Copy the SKPs if needed."""
179 version = self.m.run.asset_version(
'skp', self.
_skia_dir)
180 self.m.run.writefile(
181 self.m.path.join(self.m.vars.tmp_dir, VERSION_FILE_SKP),
192 """Copy the SVGs if needed."""
193 version = self.m.run.asset_version(
'svg', self.
_skia_dir)
194 self.m.run.writefile(
195 self.m.path.join(self.m.vars.tmp_dir, VERSION_FILE_SVG),
206 """Copy the MSKPs if needed."""
207 version = self.m.run.asset_version(
'mskp', self.
_skia_dir)
208 self.m.run.writefile(
209 self.m.path.join(self.m.vars.tmp_dir, VERSION_FILE_MSKP),
220 """Copy the text traces if needed."""
221 version = self.m.run.asset_version(
'text_blob_traces', self.
_skia_dir)
222 self.m.run.writefile(
223 self.m.path.join(self.m.vars.tmp_dir, VERSION_FILE_TEXTTRACES),
227 VERSION_FILE_TEXTTRACES,
install(self, skps=False, images=False, lotties=False, svgs=False, resources=False, mskps=False, texttraces=False)
copy_directory_contents_to_host(self, device_dir, host_dir)
remove_file_on_device(self, path)
read_file_on_device(self, path, **kwargs)
create_clean_device_dir(self, path)
copy_directory_contents_to_device(self, host_dir, device_dir)
_copy_dir(self, host_version, version_file, tmp_dir, host_path, device_path)
step(self, name, cmd, **kwargs)
get_flavor(self, vars_api, app_name)
device_path_join(self, *args)
create_clean_host_dir(self, path)
copy_file_to_device(self, host_path, device_path)