Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
flavor.ios.iOSFlavor Class Reference
Inheritance diagram for flavor.ios.iOSFlavor:
flavor.default.DefaultFlavor

Public Member Functions

 __init__ (self, m, app_name)
 
 env (self)
 
 context (self)
 
 install (self)
 
 step (self, name, cmd, **kwargs)
 
 copy_file_to_device (self, host, device)
 
 copy_directory_contents_to_device (self, host, device)
 
 copy_directory_contents_to_host (self, device, host)
 
 remove_file_on_device (self, path)
 
 create_clean_device_dir (self, path)
 
 read_file_on_device (self, path, **kwargs)
 
- Public Member Functions inherited from flavor.default.DefaultFlavor
 device_path_join (self, *args)
 
 create_clean_host_dir (self, path)
 
 cleanup_steps (self)
 

Public Attributes

 device_dirs
 
 app_name
 
- Public Attributes inherited from flavor.default.DefaultFlavor
 app_name
 
 module
 
 m
 
 device_dirs
 
 host_dirs
 

Protected Member Functions

 _run (self, title, *cmd, **kwargs)
 
 _install (self)
 
 _run_ios_script (self, script, first, *rest)
 
- Protected Member Functions inherited from flavor.default.DefaultFlavor
 _py (self, title, script, infra_step=True, args=())
 

Additional Inherited Members

- Protected Attributes inherited from flavor.default.DefaultFlavor
 _chrome_path
 

Detailed Description

Definition at line 12 of file ios.py.

Constructor & Destructor Documentation

◆ __init__()

flavor.ios.iOSFlavor.__init__ (   self,
  m,
  app_name 
)

Reimplemented from flavor.default.DefaultFlavor.

Definition at line 13 of file ios.py.

13 def __init__(self, m, app_name):
14 super(iOSFlavor, self).__init__(m, app_name)
15 self.device_dirs = default.DeviceDirs(
16 bin_dir='[unused]',
17 dm_dir='dm',
18 perf_data_dir='perf',
19 resource_dir='resources',
20 fonts_dir = 'NOT_SUPPORTED',
21 images_dir='images',
22 lotties_dir='lotties',
23 skp_dir='skps',
24 svg_dir='svgs',
25 mskp_dir='mskp',
26 tmp_dir='tmp',
27 texttraces_dir='')
28

Member Function Documentation

◆ _install()

flavor.ios.iOSFlavor._install (   self)
protected

Definition at line 52 of file ios.py.

52 def _install(self):
53 # We assume a single device is connected.
54
55 # Pair the device.
56 try:
57 self.m.run(self.m.step, 'check if device is paired',
58 cmd=['idevicepair', 'validate'],
59 infra_step=True, abort_on_failure=True,
60 fail_build_on_failure=False)
61 except self.m.step.StepFailure: # pragma: nocover
62 self._run('pair device', 'idevicepair', 'pair') # pragma: nocover
63
64 # Mount developer image.
65 image_info = self._run('list mounted image',
66 'ideviceimagemounter', '--list',
67 stdout=self.m.raw_io.output())
68 image_info_out = (
69 image_info.stdout.decode('utf-8').strip() if image_info.stdout else '')
70
71 if 'ImageSignature' not in image_info_out:
72 image_pkgs = self.m.file.glob_paths('locate ios-dev-image package',
73 self.m.path['start_dir'],
74 'ios-dev-image*',
75 test_data=['ios-dev-image-13.2'])
76 if len(image_pkgs) != 1:
77 raise Exception('glob for ios-dev-image* returned %s'
78 % image_pkgs) # pragma: nocover
79
80 image_pkg = image_pkgs[0]
81 contents = self.m.file.listdir(
82 'locate image and signature', image_pkg,
83 test_data=['DeveloperDiskImage.dmg',
84 'DeveloperDiskImage.dmg.signature'])
85 image = None
86 sig = None
87 for f in contents:
88 if str(f).endswith('.dmg'):
89 image = f
90 if str(f).endswith('.dmg.signature'):
91 sig = f
92 if not image or not sig:
93 raise Exception('%s does not contain *.dmg and *.dmg.signature' %
94 image_pkg) # pragma: nocover
95
96 self._run('mount developer image', 'ideviceimagemounter', image, sig)
97
98 # Install app (necessary before copying any resources to the device).
99 if self.app_name:
100 app_package = self.host_dirs.bin_dir.join('%s.app' % self.app_name)
101
102 def uninstall_app(attempt):
103 # If app ID changes, upgrade will fail, so try uninstalling.
104 self.m.run(self.m.step,
105 'uninstall %s' % self.app_name,
106 cmd=['ideviceinstaller', '-U',
107 'com.google.%s' % self.app_name],
108 infra_step=True,
109 # App may not be installed.
110 abort_on_failure=False, fail_build_on_failure=False)
111
112 num_attempts = 2
113 self.m.run.with_retry(self.m.step, 'install %s' % self.app_name,
114 num_attempts,
115 cmd=['ideviceinstaller', '-i', app_package],
116 between_attempts_fn=uninstall_app,
117 infra_step=True)
118
Definition run.py:1

◆ _run()

flavor.ios.iOSFlavor._run (   self,
  title,
cmd,
**  kwargs 
)
protected

Reimplemented from flavor.default.DefaultFlavor.

Definition at line 39 of file ios.py.

39 def _run(self, title, *cmd, **kwargs):
40 def sleep(attempt):
41 self.m.step(
42 'sleep before attempt %d' % attempt,
43 cmd=['sleep', '2']) # pragma: nocover
44
45 return self.m.run.with_retry(self.m.step, title, 3, cmd=list(cmd),
46 between_attempts_fn=sleep, **kwargs)
47
static int step(int x, SkScalar min, SkScalar max)
Definition BlurTest.cpp:215

◆ _run_ios_script()

flavor.ios.iOSFlavor._run_ios_script (   self,
  script,
  first,
rest 
)
protected

Definition at line 134 of file ios.py.

134 def _run_ios_script(self, script, first, *rest):
135 with self.context():
136 full = self.m.path['start_dir'].join(
137 'skia', 'platform_tools', 'ios', 'bin', 'ios_' + script)
138 self.m.run(self.m.step,
139 name = '%s %s' % (script, first),
140 cmd = [full, first] + list(rest),
141 infra_step=True)
142

◆ context()

flavor.ios.iOSFlavor.context (   self)

Definition at line 36 of file ios.py.

36 def context(self):
37 return self.m.context(env=self.env)
38

◆ copy_directory_contents_to_device()

flavor.ios.iOSFlavor.copy_directory_contents_to_device (   self,
  host_dir,
  device_dir 
)
Like shutil.copytree(), but for copying to a connected device.

Reimplemented from flavor.default.DefaultFlavor.

Definition at line 146 of file ios.py.

146 def copy_directory_contents_to_device(self, host, device):
147 self._run_ios_script('push_if_needed', host, device)
148

◆ copy_directory_contents_to_host()

flavor.ios.iOSFlavor.copy_directory_contents_to_host (   self,
  device_dir,
  host_dir 
)
Like shutil.copytree(), but for copying from a connected device.

Reimplemented from flavor.default.DefaultFlavor.

Definition at line 149 of file ios.py.

149 def copy_directory_contents_to_host(self, device, host):
150 self._run_ios_script('pull_if_needed', device, host)
151

◆ copy_file_to_device()

flavor.ios.iOSFlavor.copy_file_to_device (   self,
  host_path,
  device_path 
)
Like shutil.copyfile, but for copying to a connected device.

Reimplemented from flavor.default.DefaultFlavor.

Definition at line 143 of file ios.py.

143 def copy_file_to_device(self, host, device):
144 self._run_ios_script('push_file', host, device)
145

◆ create_clean_device_dir()

flavor.ios.iOSFlavor.create_clean_device_dir (   self,
  path 
)
Like shutil.rmtree() + os.makedirs(), but on a connected device.

Reimplemented from flavor.default.DefaultFlavor.

Definition at line 155 of file ios.py.

155 def create_clean_device_dir(self, path):
156 self._run_ios_script('rm', path)
157 self._run_ios_script('mkdir', path)
158

◆ env()

flavor.ios.iOSFlavor.env (   self)

Definition at line 30 of file ios.py.

30 def env(self):
31 return {
32 'IOS_BUNDLE_ID': 'com.google.%s' % self.app_name,
33 'IOS_MOUNT_POINT': self.m.vars.workdir.join('mnt_iosdevice'),
34 }
35
Definition __init__.py:1

◆ install()

flavor.ios.iOSFlavor.install (   self)
Run device-specific installation steps.

Reimplemented from flavor.default.DefaultFlavor.

Definition at line 48 of file ios.py.

48 def install(self):
49 with self.context():
50 self._install()
51
static bool install(SkBitmap *bm, const SkImageInfo &info, const SkRasterHandleAllocator::Rec &rec)

◆ read_file_on_device()

flavor.ios.iOSFlavor.read_file_on_device (   self,
  path,
**  kwargs 
)
Reads the specified file.

Reimplemented from flavor.default.DefaultFlavor.

Definition at line 159 of file ios.py.

159 def read_file_on_device(self, path, **kwargs):
160 with self.context():
161 full = self.m.path['start_dir'].join(
162 'skia', 'platform_tools', 'ios', 'bin', 'ios_cat_file')
163 rv = self.m.run(self.m.step,
164 name = 'cat_file %s' % path,
165 cmd = [full, path],
166 stdout=self.m.raw_io.output(),
167 infra_step=True,
168 **kwargs)
169 return rv.stdout.decode('utf-8').rstrip() if rv and rv.stdout else None

◆ remove_file_on_device()

flavor.ios.iOSFlavor.remove_file_on_device (   self,
  path 
)
Removes the specified file.

Reimplemented from flavor.default.DefaultFlavor.

Definition at line 152 of file ios.py.

152 def remove_file_on_device(self, path):
153 self._run_ios_script('rm', path)
154

◆ step()

flavor.ios.iOSFlavor.step (   self,
  name,
  cmd,
**  kwargs 
)

Reimplemented from flavor.default.DefaultFlavor.

Definition at line 119 of file ios.py.

119 def step(self, name, cmd, **kwargs):
120 app_name = cmd[0]
121 bundle_id = 'com.google.%s' % app_name
122 args = [bundle_id] + [str(ele) for ele in cmd[1:]]
123 success = False
124 with self.context():
125 try:
126 self.m.run(self.m.step, name, cmd=['idevicedebug', 'run'] + args)
127 success = True
128 finally:
129 if not success:
130 self.m.run(
131 self.m.step, '%s with full debug output' % name,
132 cmd=['python3', self.module.resource('ios_debug_cmd.py')] + args)
133

Member Data Documentation

◆ app_name

flavor.ios.iOSFlavor.app_name

Definition at line 32 of file ios.py.

◆ device_dirs

flavor.ios.iOSFlavor.device_dirs

Definition at line 15 of file ios.py.


The documentation for this class was generated from the following file: