Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
tool_wrapper.WinTool Class Reference
Inheritance diagram for tool_wrapper.WinTool:

Public Member Functions

def Dispatch (self, args)
 
def ExecStamp (self, path)
 
def ExecDeleteFile (self, path)
 
def ExecRecursiveMirror (self, source, dest)
 
def ExecLinkWrapper (self, arch, use_separate_mspdbsrv, *args)
 
def ExecMidlWrapper (self, arch, outdir, tlb, h, dlldata, iid, proxy, idl, *flags)
 
def ExecAsmWrapper (self, arch, *args)
 
def ExecRcWrapper (self, arch, *args)
 
def ExecActionWrapper (self, arch, rspfile, *dirname)
 

Detailed Description

This class performs all the Windows tooling steps. The methods can either
be executed directly, or dispatched from an argument list.

Definition at line 32 of file tool_wrapper.py.

Member Function Documentation

◆ Dispatch()

def tool_wrapper.WinTool.Dispatch (   self,
  args 
)
Dispatches a string command to a method.

Definition at line 63 of file tool_wrapper.py.

63 def Dispatch(self, args):
64 """Dispatches a string command to a method."""
65 if len(args) < 1:
66 raise Exception("Not enough arguments")
67
68 method = "Exec%s" % self._CommandifyName(args[0])
69 return getattr(self, method)(*args[1:])
70

◆ ExecActionWrapper()

def tool_wrapper.WinTool.ExecActionWrapper (   self,
  arch,
  rspfile,
dirname 
)
Runs an action command line from a response file using the environment
for |arch|. If |dirname| is supplied, use that as the working directory.

Definition at line 244 of file tool_wrapper.py.

244 def ExecActionWrapper(self, arch, rspfile, *dirname):
245 """Runs an action command line from a response file using the environment
246 for |arch|. If |dirname| is supplied, use that as the working directory."""
247 env = self._GetEnv(arch)
248 # TODO(scottmg): This is a temporary hack to get some specific variables
249 # through to actions that are set after GN-time. http://crbug.com/333738.
250 for k, v in os.environ.items():
251 if k not in env:
252 env[k] = v
253 args = open(rspfile).read()
254 dirname = dirname[0] if dirname else None
255 return subprocess.call(args, shell=True, env=env, cwd=dirname)
256
257
static bool read(SkStream *stream, void *buffer, size_t amount)

◆ ExecAsmWrapper()

def tool_wrapper.WinTool.ExecAsmWrapper (   self,
  arch,
args 
)
Filter logo banner from invocations of asm.exe.

Definition at line 206 of file tool_wrapper.py.

206 def ExecAsmWrapper(self, arch, *args):
207 """Filter logo banner from invocations of asm.exe."""
208 env = self._GetEnv(arch)
209 popen = subprocess.Popen(args,
210 shell=True,
211 env=env,
212 stdout=subprocess.PIPE,
213 stderr=subprocess.STDOUT,
214 universal_newlines=True)
215 out, _ = popen.communicate()
216 for line in out.splitlines():
217 # Split to avoid triggering license checks:
218 if (not line.startswith('Copy' + 'right (C' +
219 ') Microsoft Corporation') and
220 not line.startswith('Microsoft (R) Macro Assembler') and
221 not line.startswith(' Assembling: ') and line):
222 print(line)
223 return popen.returncode
224
def print(*args, **kwargs)
Definition: run_tests.py:49

◆ ExecDeleteFile()

def tool_wrapper.WinTool.ExecDeleteFile (   self,
  path 
)
Simple file delete command.

Definition at line 88 of file tool_wrapper.py.

88 def ExecDeleteFile(self, path):
89 """Simple file delete command."""
90 if os.path.exists(path):
91 os.unlink(path)
92

◆ ExecLinkWrapper()

def tool_wrapper.WinTool.ExecLinkWrapper (   self,
  arch,
  use_separate_mspdbsrv,
args 
)
Filter diagnostic output from link that looks like:
'   Creating library ui.dll.lib and object ui.dll.exp'
This happens when there are exports from the dll or exe.

Definition at line 120 of file tool_wrapper.py.

120 def ExecLinkWrapper(self, arch, use_separate_mspdbsrv, *args):
121 """Filter diagnostic output from link that looks like:
122 ' Creating library ui.dll.lib and object ui.dll.exp'
123 This happens when there are exports from the dll or exe.
124 """
125 env = self._GetEnv(arch)
126 if use_separate_mspdbsrv == 'True':
127 self._UseSeparateMspdbsrv(env, args)
128 if sys.platform == 'win32':
129 args = list(
130 args) # *args is a tuple by default, which is read-only.
131 args[0] = args[0].replace('/', '\\')
132 # https://docs.python.org/2/library/subprocess.html:
133 # "On Unix with shell=True [...] if args is a sequence, the first item
134 # specifies the command string, and any additional items will be treated as
135 # additional arguments to the shell itself. That is to say, Popen does the
136 # equivalent of:
137 # Popen(['/bin/sh', '-c', args[0], args[1], ...])"
138 # For that reason, since going through the shell doesn't seem necessary on
139 # non-Windows don't do that there.
140 link = subprocess.Popen(args,
141 shell=sys.platform == 'win32',
142 env=env,
143 stdout=subprocess.PIPE,
144 stderr=subprocess.STDOUT,
145 universal_newlines=True)
146 # Read output one line at a time as it shows up to avoid OOM failures when
147 # GBs of output is produced.
148 for line in link.stdout:
149 if (not line.startswith(' Creating library ') and
150 not line.startswith('Generating code') and
151 not line.startswith('Finished generating code')):
152 print(line)
153 link_result = link.wait()
154
155 if link_result != 0:
156 return link_result
157
158 # The toolchain configuration in gn always expects a .lib file to be
159 # included in the output of the link step. However, this only happens
160 # when the output has exports, and that is not always the case. In
161 # order to satisfy the expected outputs, we create a dummy .lib file
162 # in cases where the link step didn't actually create one.
163 for arg in args:
164 m = _LINK_EXE_OUT_ARG.match(arg)
165 if m:
166 output_filename = m.group('out')
167 (basename, extension) = os.path.splitext(output_filename)
168 if extension == '.exe':
169 lib_path = pathlib.Path(basename + ".lib")
170 if not os.path.exists(lib_path):
171 lib_path.touch()
172 break
173
174 return link_result
175

◆ ExecMidlWrapper()

def tool_wrapper.WinTool.ExecMidlWrapper (   self,
  arch,
  outdir,
  tlb,
  h,
  dlldata,
  iid,
  proxy,
  idl,
flags 
)
Filter noisy filenames output from MIDL compile step that isn't
quietable via command line flags.

Definition at line 176 of file tool_wrapper.py.

177 *flags):
178 """Filter noisy filenames output from MIDL compile step that isn't
179 quietable via command line flags.
180 """
181 args = ['midl', '/nologo'] + list(flags) + [
182 '/out', outdir, '/tlb', tlb, '/h', h, '/dlldata', dlldata, '/iid',
183 iid, '/proxy', proxy, idl
184 ]
185 env = self._GetEnv(arch)
186 popen = subprocess.Popen(args,
187 shell=True,
188 env=env,
189 stdout=subprocess.PIPE,
190 stderr=subprocess.STDOUT,
191 universal_newlines=True)
192 out, _ = popen.communicate()
193 # Filter junk out of stdout, and write filtered versions. Output we want
194 # to filter is pairs of lines that look like this:
195 # Processing C:\Program Files (x86)\Microsoft SDKs\...\include\objidl.idl
196 # objidl.idl
197 lines = out.splitlines()
198 prefixes = ('Processing ', '64 bit Processing ')
199 processing = set(
200 os.path.basename(x) for x in lines if x.startswith(prefixes))
201 for line in lines:
202 if not line.startswith(prefixes) and line not in processing:
203 print(line)
204 return popen.returncode
205
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition: switches.h:76

◆ ExecRcWrapper()

def tool_wrapper.WinTool.ExecRcWrapper (   self,
  arch,
args 
)
Filter logo banner from invocations of rc.exe. Older versions of RC
don't support the /nologo flag.

Definition at line 225 of file tool_wrapper.py.

225 def ExecRcWrapper(self, arch, *args):
226 """Filter logo banner from invocations of rc.exe. Older versions of RC
227 don't support the /nologo flag."""
228 env = self._GetEnv(arch)
229 popen = subprocess.Popen(args,
230 shell=True,
231 env=env,
232 stdout=subprocess.PIPE,
233 stderr=subprocess.STDOUT,
234 universal_newlines=True)
235 out, _ = popen.communicate()
236 for line in out.splitlines():
237 if (not line.startswith(
238 'Microsoft (R) Windows (R) Resource Compiler') and
239 not line.startswith('Copy' + 'right (C' +
240 ') Microsoft Corporation') and line):
241 print(line)
242 return popen.returncode
243

◆ ExecRecursiveMirror()

def tool_wrapper.WinTool.ExecRecursiveMirror (   self,
  source,
  dest 
)
Emulation of rm -rf out && cp -af in out.

Definition at line 93 of file tool_wrapper.py.

93 def ExecRecursiveMirror(self, source, dest):
94 """Emulation of rm -rf out && cp -af in out."""
95 if os.path.exists(dest):
96 if os.path.isdir(dest):
97
98 def _on_error(fn, path, dummy_excinfo):
99 # The operation failed, possibly because the file is set to
100 # read-only. If that's why, make it writable and try the op again.
101 if not os.access(path, os.W_OK):
102 os.chmod(path, stat.S_IWRITE)
103 fn(path)
104
105 shutil.rmtree(dest, onerror=_on_error)
106 else:
107 if not os.access(dest, os.W_OK):
108 # Attempt to make the file writable before deleting it.
109 os.chmod(dest, stat.S_IWRITE)
110 os.unlink(dest)
111
112 if os.path.isdir(source):
113 shutil.copytree(source, dest)
114 else:
115 shutil.copy2(source, dest)
116 # Try to diagnose crbug.com/741603
117 if not os.path.exists(dest):
118 raise Exception("Copying of %s to %s failed" % (source, dest))
119

◆ ExecStamp()

def tool_wrapper.WinTool.ExecStamp (   self,
  path 
)
Simple stamp command.

Definition at line 84 of file tool_wrapper.py.

84 def ExecStamp(self, path):
85 """Simple stamp command."""
86 open(path, 'w').close()
87

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