@ -201,45 +201,71 @@ def GenerateSetEnvCmd(target_dir):
This is normally generated by a full install of the SDK , but we
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 . """
do it here manually since we do not do a full install . """
with open ( os . path . join (
# All these paths are relative to the directory containing SetEnv.cmd.
target_dir , r ' win_sdk \ bin \ SetEnv.cmd ' ) , ' w ' ) as f :
include_dirs = [
[ ' .. ' , ' .. ' , ' win_sdk ' , ' Include ' , WIN_VERSION , ' um ' ] ,
[ ' .. ' , ' .. ' , ' win_sdk ' , ' Include ' , WIN_VERSION , ' shared ' ] ,
[ ' .. ' , ' .. ' , ' win_sdk ' , ' Include ' , WIN_VERSION , ' winrt ' ] ,
]
if VS_VERSION == ' 2015 ' :
include_dirs . append ( [ ' .. ' , ' .. ' , ' win_sdk ' , ' Include ' , WIN_VERSION , ' ucrt ' ] )
include_dirs . extend ( [
[ ' .. ' , ' .. ' , ' VC ' , ' include ' ] ,
[ ' .. ' , ' .. ' , ' VC ' , ' atlmfc ' , ' include ' ] ,
] )
# Common to x86 and x64
env = [
# Yuck: These two have a trailing \ character. No good way to represent this
# in an OS-independent way.
( ' VSINSTALLDIR ' , [ [ ' .. ' , ' .. \\ ' ] ] ) ,
( ' VCINSTALLDIR ' , [ [ ' .. ' , ' .. ' , ' VC \\ ' ] ] ) ,
( ' INCLUDE ' , include_dirs ) ,
]
# x86. Always use amd64_x86 cross, not x86 on x86.
env_x86 = [
( ' PATH ' , [
[ ' .. ' , ' .. ' , ' win_sdk ' , ' bin ' , ' x86 ' ] ,
[ ' .. ' , ' .. ' , ' VC ' , ' bin ' , ' amd64_x86 ' ] ,
[ ' .. ' , ' .. ' , ' VC ' , ' bin ' , ' amd64 ' ] , # Needed for mspdb1x0.dll.
] ) ,
( ' LIB ' , [
[ ' .. ' , ' .. ' , ' VC ' , ' lib ' ] ,
[ ' .. ' , ' .. ' , ' win_sdk ' , ' Lib ' , WIN_VERSION , ' um ' , ' x86 ' ] ,
[ ' .. ' , ' .. ' , ' win_sdk ' , ' Lib ' , WIN_VERSION , ' ucrt ' , ' x86 ' ] , # VS 2015
[ ' .. ' , ' .. ' , ' VC ' , ' atlmfc ' , ' lib ' ] ,
] ) ,
]
# x64.
env_x64 = [
( ' PATH ' , [
[ ' .. ' , ' .. ' , ' win_sdk ' , ' bin ' , ' x64 ' ] ,
[ ' .. ' , ' .. ' , ' VC ' , ' bin ' , ' amd64 ' ] ,
] ) ,
( ' LIB ' , [
[ ' .. ' , ' .. ' , ' VC ' , ' lib ' , ' amd64 ' ] ,
[ ' .. ' , ' .. ' , ' win_sdk ' , ' Lib ' , WIN_VERSION , ' um ' , ' x64 ' ] ,
[ ' .. ' , ' .. ' , ' win_sdk ' , ' Lib ' , WIN_VERSION , ' ucrt ' , ' x64 ' ] , # VS 2015
[ ' .. ' , ' .. ' , ' VC ' , ' atlmfc ' , ' lib ' , ' amd64 ' ] ,
] ) ,
]
def BatDirs ( dirs ) :
return ' ; ' . join ( [ ' % ~dp0 ' + os . path . join ( * d ) for d in dirs ] )
with open ( os . path . join ( target_dir , r ' win_sdk \ bin \ SetEnv.cmd ' ) , ' w ' ) as f :
f . write ( ' @echo off \n '
f . write ( ' @echo off \n '
' :: Generated by win_toolchain \\ package_from_installed.py. \n '
' :: Generated by win_toolchain \\ package_from_installed.py. \n ' )
# Common to x86 and x64
for var , dirs in env :
' set VSINSTALLDIR= % ~dp0.. \\ .. \\ \n '
f . write ( ' set %s = %s \n ' % ( var , BatDirs ( dirs ) ) )
' set VCINSTALLDIR= % ~dp0.. \\ .. \\ VC \\ \n '
f . write ( ' if " % 1 " == " /x64 " goto x64 \n ' )
' set INCLUDE= % ~dp0.. \\ .. \\ win_sdk \\ Include \\ WINVERSION \\ um; '
' % ~dp0.. \\ .. \\ win_sdk \\ Include \\ WINVERSION \\ shared; '
for var , dirs in env_x86 :
' % ~dp0.. \\ .. \\ win_sdk \\ Include \\ WINVERSION \\ winrt; ' . replace (
f . write ( ' set %s = %s %s \n ' % (
' WINVERSION ' , WIN_VERSION ) )
var , BatDirs ( dirs ) , ' ; % PATH % ' if var == ' PATH ' else ' ' ) )
if VS_VERSION == ' 2015 ' :
f . write ( ' goto :EOF \n ' )
f . write ( ' % ~dp0.. \\ .. \\ win_sdk \\ Include \\ WINVERSION \\ ucrt; ' . replace (
' WINVERSION ' , WIN_VERSION ) )
f . write ( ' :x64 \n ' )
f . write ( ' % ~dp0.. \\ .. \\ VC \\ include; '
for var , dirs in env_x64 :
' % ~dp0.. \\ .. \\ VC \\ atlmfc \\ include \n '
f . write ( ' set %s = %s %s \n ' % (
' if " % 1 " == " /x64 " goto x64 \n ' )
var , BatDirs ( dirs ) , ' ; % PATH % ' if var == ' PATH ' else ' ' ) )
# x86. Always use amd64_x86 cross, not x86 on x86.
f . write ( ' set PATH= % ~dp0.. \\ .. \\ win_sdk \\ bin \\ x86; '
' % ~dp0.. \\ .. \\ VC \\ bin \\ amd64_x86; '
' % ~dp0.. \\ .. \\ VC \\ bin \\ amd64; ' # Needed for mspdb1x0.dll.
' % PATH % \n ' )
f . write ( ' set LIB= % ~dp0.. \\ .. \\ VC \\ lib; '
' % ~dp0.. \\ .. \\ win_sdk \\ Lib \\ WINVERSION \\ um \\ x86; '
' % ~dp0.. \\ .. \\ win_sdk \\ Lib \\ WINVERSION \\ ucrt \\ x86; ' # VS 2015
' % ~dp0.. \\ .. \\ VC \\ atlmfc \\ lib \n '
' goto :EOF \n ' . replace ( ' WINVERSION ' , WIN_VERSION ) )
# x64.
f . write ( ' :x64 \n '
' set PATH= % ~dp0.. \\ .. \\ win_sdk \\ bin \\ x64; '
' % ~dp0.. \\ .. \\ VC \\ bin \\ amd64; '
' % PATH % \n ' )
f . write ( ' set LIB= % ~dp0.. \\ .. \\ VC \\ lib \\ amd64; '
' % ~dp0.. \\ .. \\ win_sdk \\ Lib \\ WINVERSION \\ um \\ x64; '
' % ~dp0.. \\ .. \\ win_sdk \\ Lib \\ WINVERSION \\ ucrt \\ x64; ' # VS 2015
' % ~dp0.. \\ .. \\ VC \\ atlmfc \\ lib \\ amd64 \n '
. replace ( ' WINVERSION ' , WIN_VERSION ) )
def AddEnvSetup ( files ) :
def AddEnvSetup ( files ) :