21
21
import stat
22
22
import subprocess
23
23
import sys
24
+
24
25
from gn_helpers import ToGNString
25
26
26
27
@@ -63,9 +64,14 @@ def SetEnvironmentAndGetRuntimeDllDirs():
63
64
win_sdk = toolchain_data ['win8sdk' ]
64
65
wdk = toolchain_data ['wdk' ]
65
66
# TODO(scottmg): The order unfortunately matters in these. They should be
66
- # split into separate keys for x86 and x64. (See CopyDlls call below).
67
+ # split into separate keys for x64/x86/arm64 . (See CopyDlls call below).
67
68
# http://crbug.com/345992
68
69
vs_runtime_dll_dirs = toolchain_data ['runtime_dirs' ]
70
+ # The number of runtime_dirs in the toolchain_data was two (x64/x86) but
71
+ # changed to three (x64/x86/arm64) and this code needs to handle both
72
+ # possibilities, which can change independently from this code.
73
+ if len (vs_runtime_dll_dirs ) == 2 :
74
+ vs_runtime_dll_dirs .append ('Arm64Unused' )
69
75
70
76
os .environ ['GYP_MSVS_OVERRIDE_PATH' ] = toolchain
71
77
os .environ ['GYP_MSVS_VERSION' ] = version
@@ -87,9 +93,12 @@ def SetEnvironmentAndGetRuntimeDllDirs():
87
93
# directory ensures that they are available when needed.
88
94
bitness = platform .architecture ()[0 ]
89
95
# When running 64-bit python the x64 DLLs will be in System32
96
+ # ARM64 binaries will not be available in the system directories because we
97
+ # don't build on ARM64 machines.
90
98
x64_path = 'System32' if bitness == '64bit' else 'Sysnative'
91
99
x64_path = os .path .join (os .path .expandvars ('%windir%' ), x64_path )
92
- vs_runtime_dll_dirs = [x64_path , os .path .expandvars ('%windir%/SysWOW64' )]
100
+ vs_runtime_dll_dirs = [x64_path , os .path .expandvars ('%windir%/SysWOW64' ),
101
+ 'Arm64Unused' ]
93
102
94
103
return vs_runtime_dll_dirs
95
104
@@ -141,7 +150,6 @@ def DetectVisualStudioPath():
141
150
raise Exception (('Visual Studio version %s (from GYP_MSVS_VERSION)'
142
151
' not supported. Supported versions are: %s' ) % (
143
152
version_as_year , ', ' .join (year_to_version .keys ())))
144
- version = year_to_version [version_as_year ]
145
153
if version_as_year == '2017' :
146
154
# The VC++ 2017 install location needs to be located using COM instead of
147
155
# the registry. For details see:
@@ -201,16 +209,21 @@ def _CopyUCRTRuntime(target_dir, source_dir, target_cpu, dll_pattern, suffix):
201
209
os .environ .get ('WINDOWSSDKDIR' ,
202
210
os .path .expandvars ('%ProgramFiles(x86)%'
203
211
'\\ Windows Kits\\ 10' )))
204
- ucrt_dll_dirs = os .path .join (win_sdk_dir , 'Redist' , 'ucrt' , 'DLLs' ,
205
- target_cpu )
206
- ucrt_files = glob .glob (os .path .join (ucrt_dll_dirs , 'api-ms-win-*.dll' ))
207
- assert len (ucrt_files ) > 0
208
- for ucrt_src_file in ucrt_files :
209
- file_part = os .path .basename (ucrt_src_file )
210
- ucrt_dst_file = os .path .join (target_dir , file_part )
211
- _CopyRuntimeImpl (ucrt_dst_file , ucrt_src_file , False )
212
- _CopyRuntimeImpl (os .path .join (target_dir , 'ucrtbase' + suffix ),
213
- os .path .join (source_dir , 'ucrtbase' + suffix ))
212
+ # ARM64 doesn't have a redist for the ucrt DLLs because they are always
213
+ # present in the OS.
214
+ if target_cpu != 'arm64' :
215
+ ucrt_dll_dirs = os .path .join (win_sdk_dir , 'Redist' , 'ucrt' , 'DLLs' ,
216
+ target_cpu )
217
+ ucrt_files = glob .glob (os .path .join (ucrt_dll_dirs , 'api-ms-win-*.dll' ))
218
+ assert len (ucrt_files ) > 0
219
+ for ucrt_src_file in ucrt_files :
220
+ file_part = os .path .basename (ucrt_src_file )
221
+ ucrt_dst_file = os .path .join (target_dir , file_part )
222
+ _CopyRuntimeImpl (ucrt_dst_file , ucrt_src_file , False )
223
+ # We must copy ucrtbase.dll for x64/x86, and ucrtbased.dll for all CPU types.
224
+ if target_cpu != 'arm64' or not suffix .startswith ('.' ):
225
+ _CopyRuntimeImpl (os .path .join (target_dir , 'ucrtbase' + suffix ),
226
+ os .path .join (source_dir , 'ucrtbase' + suffix ))
214
227
215
228
216
229
def FindVCToolsRoot ():
@@ -249,6 +262,7 @@ def _CopyPGORuntime(target_dir, target_cpu):
249
262
# from HostX86/x86.
250
263
pgo_x86_runtime_dir = os .path .join (pgo_runtime_root , 'HostX86' , 'x86' )
251
264
pgo_x64_runtime_dir = os .path .join (pgo_runtime_root , 'HostX64' , 'x64' )
265
+ pgo_arm64_runtime_dir = os .path .join (pgo_runtime_root , 'arm64' )
252
266
else :
253
267
raise Exception ('Unexpected toolchain version: %s.' % env_version )
254
268
@@ -261,8 +275,10 @@ def _CopyPGORuntime(target_dir, target_cpu):
261
275
source = os .path .join (pgo_x86_runtime_dir , runtime )
262
276
elif target_cpu == 'x64' :
263
277
source = os .path .join (pgo_x64_runtime_dir , runtime )
278
+ elif target_cpu == 'arm64' :
279
+ source = os .path .join (pgo_arm64_runtime_dir , runtime )
264
280
else :
265
- raise NotImplementedError (" Unexpected target_cpu value: " + target_cpu )
281
+ raise NotImplementedError (' Unexpected target_cpu value: ' + target_cpu )
266
282
if not os .path .exists (source ):
267
283
raise Exception ('Unable to find %s.' % source )
268
284
_CopyRuntimeImpl (os .path .join (target_dir , runtime ), source )
@@ -271,7 +287,7 @@ def _CopyPGORuntime(target_dir, target_cpu):
271
287
def _CopyRuntime (target_dir , source_dir , target_cpu , debug ):
272
288
"""Copy the VS runtime DLLs, only if the target doesn't exist, but the target
273
289
directory does exist. Handles VS 2015 and VS 2017."""
274
- suffix = " d.dll" if debug else " .dll"
290
+ suffix = ' d.dll' if debug else ' .dll'
275
291
# VS 2017 uses the same CRT DLLs as VS 2015.
276
292
_CopyUCRTRuntime (target_dir , source_dir , target_cpu , '%s140' + suffix ,
277
293
suffix )
@@ -290,8 +306,15 @@ def CopyDlls(target_dir, configuration, target_cpu):
290
306
if not vs_runtime_dll_dirs :
291
307
return
292
308
293
- x64_runtime , x86_runtime = vs_runtime_dll_dirs
294
- runtime_dir = x64_runtime if target_cpu == 'x64' else x86_runtime
309
+ x64_runtime , x86_runtime , arm64_runtime = vs_runtime_dll_dirs
310
+ if target_cpu == 'x64' :
311
+ runtime_dir = x64_runtime
312
+ elif target_cpu == 'x86' :
313
+ runtime_dir = x86_runtime
314
+ elif target_cpu == 'arm64' :
315
+ runtime_dir = arm64_runtime
316
+ else :
317
+ raise Exception ('Unknown target_cpu: ' + target_cpu )
295
318
_CopyRuntime (target_dir , runtime_dir , target_cpu , debug = False )
296
319
if configuration == 'Debug' :
297
320
_CopyRuntime (target_dir , runtime_dir , target_cpu , debug = True )
@@ -424,7 +447,7 @@ def Update(force=False):
424
447
425
448
426
449
def NormalizePath (path ):
427
- while path .endswith (" \\ " ):
450
+ while path .endswith (' \\ ' ):
428
451
path = path [:- 1 ]
429
452
return path
430
453
@@ -476,4 +499,4 @@ def main():
476
499
477
500
478
501
if __name__ == '__main__' :
479
- sys .exit (main ())
502
+ sys .exit (main ())
0 commit comments