@ -21,7 +21,7 @@ class WindowsSDKApi(recipe_api.RecipeApi):
self . _sdk_properties = sdk_properties
@contextmanager
def __call__ ( self , path = None , version = None , enabled = True ):
def __call__ ( self , path = None , version = None , enabled = True , target_arch = ' x64 ' ):
""" Setups the SDK environment when enabled.
Args :
@ -30,6 +30,7 @@ class WindowsSDKApi(recipe_api.RecipeApi):
version ( str ) : CIPD version of the SDK
( default is set via $ infra / windows_sdk . version property )
enabled ( bool ) : Whether the SDK should be used or not .
target_arch ( str ) : ' x86 ' or ' x64 ' .
Raises :
StepFailure or InfraFailure .
@ -39,7 +40,7 @@ class WindowsSDKApi(recipe_api.RecipeApi):
path or self . m . path [ ' cache ' ] . join ( ' windows_sdk ' ) ,
version or self . _sdk_properties [ ' version ' ] )
try :
with self . m . context ( * * self . _sdk_env ( sdk_dir )) :
with self . m . context ( * * self . _sdk_env ( sdk_dir , target_arch )) :
yield
finally :
# cl.exe automatically starts background mspdbsrv.exe daemon which
@ -68,13 +69,14 @@ class WindowsSDKApi(recipe_api.RecipeApi):
self . m . cipd . ensure ( sdk_dir , pkgs )
return sdk_dir
def _sdk_env ( self , sdk_dir ):
def _sdk_env ( self , sdk_dir , target_arch ):
""" Constructs the environment for the SDK.
Returns environment and environment prefixes .
Args :
sdk_dir ( path ) : Path to a directory containing the SDK .
target_arch ( str ) : ' x86 ' or ' x64 '
"""
env = { }
env_prefixes = { }
@ -89,7 +91,8 @@ class WindowsSDKApi(recipe_api.RecipeApi):
# }
# All these environment variables need to be added to the environment
# for the compiler and linker to work.
filename = ' SetEnv. %s .json ' % { 32 : ' x86 ' , 64 : ' x64 ' } [ self . m . platform . bits ]
assert target_arch in ( ' x86 ' , ' x64 ' )
filename = ' SetEnv. %s .json ' % target_arch
step_result = self . m . json . read (
' read %s ' % filename , sdk_dir . join ( ' win_sdk ' , ' bin ' , filename ) ,
step_test_data = lambda : self . m . json . test_api . output ( {