@ -48,9 +48,9 @@ import zipfile
import get_toolchain_if_necessary
VS_VERSION = None
WIN_VERSION = None
VC_TOOLS = None
_vs_version = None
_win_version = None
_vc_tools = None
SUPPORTED_VS_VERSIONS = [ ' 2017 ' , ' 2019 ' ]
@ -65,7 +65,7 @@ def GetVSPath():
for line in output . splitlines ( ) :
if line . startswith ( marker ) :
return line [ len ( marker ) : ]
raise Exception ( ' VS %s path not found in vswhere output ' % ( VS_VERSION ) )
raise Exception ( ' VS %s path not found in vswhere output ' % ( _vs_version ) )
def ExpandWildcards ( root , sub_dir ) :
@ -106,22 +106,22 @@ def BuildFileList(override_dir, include_arm):
' DIA SDK/idl ' ,
' DIA SDK/include ' ,
' DIA SDK/lib ' ,
VC_TOOLS + ' /atlmfc ' ,
VC_TOOLS + ' /crt ' ,
_vc_tools + ' /atlmfc ' ,
_vc_tools + ' /crt ' ,
' VC/redist ' ,
]
if override_dir :
paths + = [
( os . path . join ( override_dir , ' bin ' ) , VC_TOOLS + ' /bin ' ) ,
( os . path . join ( override_dir , ' include ' ) , VC_TOOLS + ' /include ' ) ,
( os . path . join ( override_dir , ' lib ' ) , VC_TOOLS + ' /lib ' ) ,
( os . path . join ( override_dir , ' bin ' ) , _vc_tools + ' /bin ' ) ,
( os . path . join ( override_dir , ' include ' ) , _vc_tools + ' /include ' ) ,
( os . path . join ( override_dir , ' lib ' ) , _vc_tools + ' /lib ' ) ,
]
else :
paths + = [
VC_TOOLS + ' /bin ' ,
VC_TOOLS + ' /include ' ,
VC_TOOLS + ' /lib ' ,
_vc_tools + ' /bin ' ,
_vc_tools + ' /include ' ,
_vc_tools + ' /lib ' ,
]
paths + = [
@ -216,15 +216,15 @@ def BuildFileList(override_dir, include_arm):
# path with 10.0.15063.0.
if ( tail . startswith ( ' Include \\ ' ) or tail . startswith ( ' Lib \\ ' ) or
tail . startswith ( ' Source \\ ' ) or tail . startswith ( ' bin \\ ' ) ) :
if tail . count ( WIN_VERSION ) == 0 :
if tail . count ( _win_version ) == 0 :
continue
to = os . path . join ( ' Windows Kits ' , ' 10 ' , tail )
result . append ( ( combined , to ) )
# Copy the x86 ucrt DLLs to all directories with x86 binaries that are
# added to the path by SetEnv.cmd, and to sys32. Starting with the 17763
# SDK the ucrt files are in WIN_VERSION \ucrt instead of just ucrt.
ucrt_dir = os . path . join ( sdk_path , ' redist ' , WIN_VERSION , r ' ucrt \ dlls \ x86 ' )
# SDK the ucrt files are in _win_version \ucrt instead of just ucrt.
ucrt_dir = os . path . join ( sdk_path , ' redist ' , _win_version , r ' ucrt \ dlls \ x86 ' )
if not os . path . exists ( ucrt_dir ) :
ucrt_dir = os . path . join ( sdk_path , r ' redist \ ucrt \ dlls \ x86 ' )
ucrt_paths = glob . glob ( ucrt_dir + r ' \ * ' )
@ -236,7 +236,7 @@ def BuildFileList(override_dir, include_arm):
# Copy the x64 ucrt DLLs to all directories with x64 binaries that are
# added to the path by SetEnv.cmd, and to sys64.
ucrt_dir = os . path . join ( sdk_path , ' redist ' , WIN_VERSION , r ' ucrt \ dlls \ x64 ' )
ucrt_dir = os . path . join ( sdk_path , ' redist ' , _win_version , r ' ucrt \ dlls \ x64 ' )
if not os . path . exists ( ucrt_dir ) :
ucrt_dir = os . path . join ( sdk_path , r ' redist \ ucrt \ dlls \ x64 ' )
ucrt_paths = glob . glob ( ucrt_dir + r ' \ * ' )
@ -262,7 +262,7 @@ def BuildFileList(override_dir, include_arm):
for system_crt_file in system_crt_files :
for cpu_pair in cpu_pairs :
target_cpu , dest_dir = cpu_pair
src_path = os . path . join ( sdk_path , ' bin ' , WIN_VERSION , target_cpu , ' ucrt ' )
src_path = os . path . join ( sdk_path , ' bin ' , _win_version , target_cpu , ' ucrt ' )
result . append ( ( os . path . join ( src_path , system_crt_file ) ,
os . path . join ( dest_dir , system_crt_file ) ) )
@ -283,22 +283,22 @@ def GenerateSetEnvCmd(target_dir):
This is normally generated by a full install of the SDK , but we
do it here manually since we do not do a full install . """
vc_tools_parts = VC_TOOLS . split ( ' / ' )
vc_tools_parts = _vc_tools . split ( ' / ' )
# All these paths are relative to the root of the toolchain package.
include_dirs = [
[ ' Windows Kits ' , ' 10 ' , ' Include ' , WIN_VERSION , ' um ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' Include ' , WIN_VERSION , ' shared ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' Include ' , WIN_VERSION , ' winrt ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' Include ' , _win_version , ' um ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' Include ' , _win_version , ' shared ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' Include ' , _win_version , ' winrt ' ] ,
]
include_dirs . append ( [ ' Windows Kits ' , ' 10 ' , ' Include ' , WIN_VERSION , ' ucrt ' ] )
include_dirs . append ( [ ' Windows Kits ' , ' 10 ' , ' Include ' , _win_version , ' ucrt ' ] )
include_dirs . extend ( [
vc_tools_parts + [ ' include ' ] ,
vc_tools_parts + [ ' atlmfc ' , ' include ' ] ,
] )
libpath_dirs = [
vc_tools_parts + [ ' lib ' , ' x86 ' , ' store ' , ' references ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' UnionMetadata ' , WIN_VERSION ] ,
[ ' Windows Kits ' , ' 10 ' , ' UnionMetadata ' , _win_version ] ,
]
# Common to x86, x64, and arm64
env = collections . OrderedDict ( [
@ -317,15 +317,15 @@ def GenerateSetEnvCmd(target_dir):
(
' PATH ' ,
[
[ ' Windows Kits ' , ' 10 ' , ' bin ' , WIN_VERSION , ' x64 ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' bin ' , _win_version , ' x64 ' ] ,
vc_tools_parts + [ ' bin ' , ' HostX64 ' , ' x86 ' ] ,
vc_tools_parts + [ ' bin ' , ' HostX64 ' , ' x64 '
] , # Needed for mspdb1x0.dll.
] ) ,
( ' LIB ' , [
vc_tools_parts + [ ' lib ' , ' x86 ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' Lib ' , WIN_VERSION , ' um ' , ' x86 ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' Lib ' , WIN_VERSION , ' ucrt ' , ' x86 ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' Lib ' , _win_version , ' um ' , ' x86 ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' Lib ' , _win_version , ' ucrt ' , ' x86 ' ] ,
vc_tools_parts + [ ' atlmfc ' , ' lib ' , ' x86 ' ] ,
] ) ,
] )
@ -333,13 +333,13 @@ def GenerateSetEnvCmd(target_dir):
# x64.
env_x64 = collections . OrderedDict ( [
( ' PATH ' , [
[ ' Windows Kits ' , ' 10 ' , ' bin ' , WIN_VERSION , ' x64 ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' bin ' , _win_version , ' x64 ' ] ,
vc_tools_parts + [ ' bin ' , ' HostX64 ' , ' x64 ' ] ,
] ) ,
( ' LIB ' , [
vc_tools_parts + [ ' lib ' , ' x64 ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' Lib ' , WIN_VERSION , ' um ' , ' x64 ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' Lib ' , WIN_VERSION , ' ucrt ' , ' x64 ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' Lib ' , _win_version , ' um ' , ' x64 ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' Lib ' , _win_version , ' ucrt ' , ' x64 ' ] ,
vc_tools_parts + [ ' atlmfc ' , ' lib ' , ' x64 ' ] ,
] ) ,
] )
@ -347,14 +347,14 @@ def GenerateSetEnvCmd(target_dir):
# arm64.
env_arm64 = collections . OrderedDict ( [
( ' PATH ' , [
[ ' Windows Kits ' , ' 10 ' , ' bin ' , WIN_VERSION , ' x64 ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' bin ' , _win_version , ' x64 ' ] ,
vc_tools_parts + [ ' bin ' , ' HostX64 ' , ' arm64 ' ] ,
vc_tools_parts + [ ' bin ' , ' HostX64 ' , ' x64 ' ] ,
] ) ,
( ' LIB ' , [
vc_tools_parts + [ ' lib ' , ' arm64 ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' Lib ' , WIN_VERSION , ' um ' , ' arm64 ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' Lib ' , WIN_VERSION , ' ucrt ' , ' arm64 ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' Lib ' , _win_version , ' um ' , ' arm64 ' ] ,
[ ' Windows Kits ' , ' 10 ' , ' Lib ' , _win_version , ' ucrt ' , ' arm64 ' ] ,
vc_tools_parts + [ ' atlmfc ' , ' lib ' , ' arm64 ' ] ,
] ) ,
] )
@ -428,7 +428,7 @@ def AddEnvSetup(files, include_arm):
' Windows Kits \\ 10 \\ bin \\ SetEnv.arm64.json ' ) )
vs_version_file = os . path . join ( tempdir , ' VS_VERSION ' )
with open ( vs_version_file , ' wt ' , newline = ' ' ) as version :
print ( VS_VERSION , file = version )
print ( _vs_version , file = version )
files . append ( ( vs_version_file , ' VS_VERSION ' ) )
@ -494,17 +494,17 @@ def main():
print ( ' Invalid override directory - must contain bin/include/lib dirs ' )
return 1
global VS_VERSION
VS_VERSION = args [ 0 ]
global WIN_VERSION
WIN_VERSION = options . winver
global VC_TOOLS
global _vs_version
_vs_version = args [ 0 ]
global _win_version
_win_version = options . winver
global _vc_tools
vs_path = GetVSPath ( )
temp_tools_path = ExpandWildcards ( vs_path , ' VC/Tools/MSVC/14.*.* ' )
# Strip off the leading vs_path characters and switch back to / separators.
VC_TOOLS = temp_tools_path [ len ( vs_path ) + 1 : ] . replace ( ' \\ ' , ' / ' )
_vc_tools = temp_tools_path [ len ( vs_path ) + 1 : ] . replace ( ' \\ ' , ' / ' )
print ( ' Building file list for VS %s Windows %s ... ' % ( VS_VERSION, WIN_VERSION ) )
print ( ' Building file list for VS %s Windows %s ... ' % ( _vs_version, _win_version ) )
files = BuildFileList ( options . override_dir , options . arm )
AddEnvSetup ( files , options . arm )
@ -526,7 +526,7 @@ def main():
sys . stdout . write ( ' \r %d / %d ... %s ' % ( count , len ( files ) , disk_name [ - 40 : ] ) )
sys . stdout . flush ( )
count + = 1
if not options . repackage_dir and disk_name . count ( WIN_VERSION ) > 0 :
if not options . repackage_dir and disk_name . count ( _win_version ) > 0 :
version_match_count + = 1
if os . path . exists ( disk_name ) :
total_size + = os . path . getsize ( disk_name )
@ -537,7 +537,7 @@ def main():
sys . stdout . write ( ' \r %s does not exist. \n \n ' % disk_name )
sys . stdout . flush ( )
sys . stdout . write ( ' \r %1.3f GB of data in %d files, %d files for %s . %s \n ' %
( total_size / 1e9 , count , version_match_count , WIN_VERSION , ' ' * 50 ) )
( total_size / 1e9 , count , version_match_count , _win_version , ' ' * 50 ) )
if options . dryrun :
return 0
if missing_files :