Support target_arch for WindowsSDK

Bug: chromium:892712
Change-Id: I68e1822a9a7205aaab3836be3f57a2f1feb1c9a6
Reviewed-on: https://chromium-review.googlesource.com/c/1289231
Commit-Queue: Scott Graham <scottmg@chromium.org>
Auto-Submit: Scott Graham <scottmg@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
changes/31/1289231/4
Scott Graham 7 years ago committed by Commit Bot
parent 488362624b
commit e660e3fb9a

@ -854,7 +854,7 @@ This means we started running actual tests (not prerequisite steps
like checkout or compile), and some of these tests have failed. like checkout or compile), and some of these tests have failed.
### *recipe_modules* / [windows\_sdk](/recipes/recipe_modules/windows_sdk) ### *recipe_modules* / [windows\_sdk](/recipes/recipe_modules/windows_sdk)
[DEPS](/recipes/recipe_modules/windows_sdk/__init__.py#5): [recipe\_engine/cipd][recipe_engine/recipe_modules/cipd], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/step][recipe_engine/recipe_modules/step] [DEPS](/recipes/recipe_modules/windows_sdk/__init__.py#5): [recipe\_engine/cipd][recipe_engine/recipe_modules/cipd], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/step][recipe_engine/recipe_modules/step]
The `windows_sdk` module provides safe functions to access a hermetic The `windows_sdk` module provides safe functions to access a hermetic
Microsoft Visual Studio installation. Microsoft Visual Studio installation.
@ -865,7 +865,7 @@ Available only to Google-run bots.
API for using Windows SDK distributed via CIPD. API for using Windows SDK distributed via CIPD.
&emsp; **@contextmanager**<br>&mdash; **def [\_\_call\_\_](/recipes/recipe_modules/windows_sdk/api.py#23)(self, path=None, version=None, enabled=True):** &emsp; **@contextmanager**<br>&mdash; **def [\_\_call\_\_](/recipes/recipe_modules/windows_sdk/api.py#23)(self, path=None, version=None, enabled=True, target_arch='x64'):**
Setups the SDK environment when enabled. Setups the SDK environment when enabled.
@ -875,6 +875,7 @@ Args:
version (str): CIPD version of the SDK version (str): CIPD version of the SDK
(default is set via $infra/windows_sdk.version property) (default is set via $infra/windows_sdk.version property)
enabled (bool): Whether the SDK should be used or not. enabled (bool): Whether the SDK should be used or not.
target_arch (str): 'x86' or 'x64'.
Raises: Raises:
StepFailure or InfraFailure. StepFailure or InfraFailure.
@ -887,9 +888,9 @@ Raises:
&mdash; **def [RunSteps](/recipes/recipe_modules/bot_update/examples/full.py#18)(api):** &mdash; **def [RunSteps](/recipes/recipe_modules/bot_update/examples/full.py#18)(api):**
### *recipes* / [bot\_update:tests/ensure\_checkout](/recipes/recipe_modules/bot_update/tests/ensure_checkout.py) ### *recipes* / [bot\_update:tests/ensure\_checkout](/recipes/recipe_modules/bot_update/tests/ensure_checkout.py)
[DEPS](/recipes/recipe_modules/bot_update/tests/ensure_checkout.py#6): [bot\_update](#recipe_modules-bot_update), [gclient](#recipe_modules-gclient), [recipe\_engine/json][recipe_engine/recipe_modules/json] [DEPS](/recipes/recipe_modules/bot_update/tests/ensure_checkout.py#7): [bot\_update](#recipe_modules-bot_update), [gclient](#recipe_modules-gclient), [recipe\_engine/json][recipe_engine/recipe_modules/json]
&mdash; **def [RunSteps](/recipes/recipe_modules/bot_update/tests/ensure_checkout.py#13)(api):** &mdash; **def [RunSteps](/recipes/recipe_modules/bot_update/tests/ensure_checkout.py#14)(api):**
### *recipes* / [cipd:examples/full](/recipes/recipe_modules/cipd/examples/full.py) ### *recipes* / [cipd:examples/full](/recipes/recipe_modules/cipd/examples/full.py)
[DEPS](/recipes/recipe_modules/cipd/examples/full.py#8): [cipd](#recipe_modules-cipd), [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/step][recipe_engine/recipe_modules/step] [DEPS](/recipes/recipe_modules/cipd/examples/full.py#8): [cipd](#recipe_modules-cipd), [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/step][recipe_engine/recipe_modules/step]

@ -7,7 +7,6 @@ DEPS = [
'recipe_engine/context', 'recipe_engine/context',
'recipe_engine/json', 'recipe_engine/json',
'recipe_engine/path', 'recipe_engine/path',
'recipe_engine/platform',
'recipe_engine/step', 'recipe_engine/step',
] ]

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

Loading…
Cancel
Save