4"""Utility functions for Windows builds.
6This file is copied to the build directory as part of toolchain setup and
7is used to set up calls to tools used by the build that need wrappers.
18BASE_DIR = os.path.dirname(os.path.abspath(__file__))
22_LINK_EXE_OUT_ARG = re.compile(
'/OUT:(?P<out>.+)$', re.IGNORECASE)
27 exit_code = executor.Dispatch(args)
28 if exit_code
is not None:
33 """This class performs all the Windows tooling steps. The methods can either
34 be executed directly, or dispatched
from an argument list.
"""
36 def _UseSeparateMspdbsrv(self, env, args):
37 """Allows to use a unique instance of mspdbsrv.exe per linker instead of a
40 raise Exception(
"Not enough arguments")
42 if args[0] !=
'link.exe':
49 m = _LINK_EXE_OUT_ARG.match(arg)
51 endpoint_name = re.sub(
r'\W+',
'',
52 '%s_%d' % (m.group(
'out'), os.getpid()))
55 if endpoint_name
is None:
61 env[
'_MSPDBSRV_ENDPOINT_'] = endpoint_name
64 """Dispatches a string command to a method."""
66 raise Exception(
"Not enough arguments")
69 return getattr(self, method)(*args[1:])
71 def _CommandifyName(self, name_string):
72 """Transforms a tool name like recursive-mirror to RecursiveMirror."""
73 return name_string.title().replace(
'-',
'')
75 def _GetEnv(self, arch):
76 """Gets the saved environment from a file for a given architecture."""
80 pairs = open(arch).
read()[:-2].split(
'\0')
81 kvs = [item.split(
'=', 1)
for item
in pairs]
85 """Simple stamp command."""
86 open(path,
'w').close()
89 """Simple file delete command."""
90 if os.path.exists(path):
94 """Emulation of rm -rf out && cp -af in out."""
95 if os.path.exists(dest):
96 if os.path.isdir(dest):
98 def _on_error(fn, path, dummy_excinfo):
101 if not os.access(path, os.W_OK):
102 os.chmod(path, stat.S_IWRITE)
105 shutil.rmtree(dest, onerror=_on_error)
107 if not os.access(dest, os.W_OK):
109 os.chmod(dest, stat.S_IWRITE)
112 if os.path.isdir(source):
113 shutil.copytree(source, dest)
115 shutil.copy2(source, dest)
117 if not os.path.exists(dest):
118 raise Exception(
"Copying of %s to %s failed" % (source, dest))
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.
126 if use_separate_mspdbsrv ==
'True':
128 if sys.platform ==
'win32':
131 args[0] = args[0].replace(
'/',
'\\')
140 link = subprocess.Popen(args,
141 shell=sys.platform ==
'win32',
143 stdout=subprocess.PIPE,
144 stderr=subprocess.STDOUT,
145 universal_newlines=
True)
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')):
153 link_result = link.wait()
164 m = _LINK_EXE_OUT_ARG.match(arg)
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):
178 """Filter noisy filenames output from MIDL compile step that isn't
179 quietable via command line flags.
181 args = ['midl',
'/nologo'] + list(flags) + [
182 '/out', outdir,
'/tlb', tlb,
'/h', h,
'/dlldata', dlldata,
'/iid',
183 iid,
'/proxy', proxy, idl
186 popen = subprocess.Popen(args,
189 stdout=subprocess.PIPE,
190 stderr=subprocess.STDOUT,
191 universal_newlines=
True)
192 out, _ = popen.communicate()
197 lines = out.splitlines()
198 prefixes = (
'Processing ',
'64 bit Processing ')
200 os.path.basename(x)
for x
in lines
if x.startswith(prefixes))
202 if not line.startswith(prefixes)
and line
not in processing:
204 return popen.returncode
207 """Filter logo banner from invocations of asm.exe."""
209 popen = subprocess.Popen(args,
212 stdout=subprocess.PIPE,
213 stderr=subprocess.STDOUT,
214 universal_newlines=
True)
215 out, _ = popen.communicate()
216 for line
in out.splitlines():
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):
223 return popen.returncode
226 """Filter logo banner from invocations of rc.exe. Older versions of RC
227 don't support the /nologo flag."""
229 popen = subprocess.Popen(args,
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):
242 return popen.returncode
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.
"""
250 for k, v
in os.environ.items():
253 args = open(rspfile).
read()
254 dirname = dirname[0]
if dirname
else None
255 return subprocess.call(args, shell=
True, env=env, cwd=dirname)
258if __name__ ==
'__main__':
259 sys.exit(
main(sys.argv[1:]))
static bool read(SkStream *stream, void *buffer, size_t amount)
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
def print(*args, **kwargs)