Skip to content

Commit

Permalink
[XB1] Use full path for win sdk tools (youtube#1560)
Browse files Browse the repository at this point in the history
Use the full path when accessing windows sdk tools to avoid relying on
the PATH variable being set correctly for the running machine.

Versions of the WinAppDeployCmd prior to 10.0.22621.0 will fail to
install the appx on the newest Xbox firmware.

b/299672207

Change-Id: I0c15c52fa9e11281531396c81e00fd0b0eadf4a2
  • Loading branch information
TyHolc authored Sep 19, 2023
1 parent e6c8c4b commit 3da73c7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
15 changes: 9 additions & 6 deletions starboard/xb1/tools/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
'youtubetv': _INTERNAL_CERT_PATH,
}
_DEFAULT_SDK_BIN_DIR = 'C:\\Program Files (x86)\\Windows Kits\\10\\bin'
_DEFAULT_WIN_SDK_VERSION = '10.0.22000.0'
_DEFAULT_WIN_SDK_VERSION = '10.0.22621.0'
_SOURCE_SPLASH_SCREEN_SUB_PATH = os.path.join('internal', 'cobalt', 'browser',
'splash_screen')
# The splash screen file referenced in starboard/xb1/shared/configuration.cc
Expand All @@ -67,7 +67,7 @@
}


def _SelectBestPath(os_var_name, path):
def _SelectBestPath(os_var_name: str, path: str) -> str:
if os_var_name in os.environ:
return os.environ[os_var_name]
if os.path.exists(path):
Expand All @@ -86,6 +86,12 @@ def _GetSourceSplashScreenDir():
return os.path.join(src_dir, _SOURCE_SPLASH_SCREEN_SUB_PATH)


def GetWinToolsPath() -> str:
windows_sdk_bin_dir = _SelectBestPath('WindowsSdkBinPath',
_DEFAULT_SDK_BIN_DIR)
return os.path.join(windows_sdk_bin_dir, _DEFAULT_WIN_SDK_VERSION, 'x64')


class Package(package.PackageBase):
"""A class representing an installable UWP Appx package."""

Expand Down Expand Up @@ -145,10 +151,7 @@ def SupportedPlatforms(cls):
return []

def __init__(self, publisher, product, **kwargs):
windows_sdk_bin_dir = _SelectBestPath('WindowsSdkBinPath',
_DEFAULT_SDK_BIN_DIR)
self.windows_sdk_host_tools = os.path.join(windows_sdk_bin_dir,
_DEFAULT_WIN_SDK_VERSION, 'x64')
self.windows_sdk_host_tools = GetWinToolsPath()
self.publisher = publisher
self.product = product
super().__init__(**kwargs)
Expand Down
8 changes: 5 additions & 3 deletions starboard/xb1/tools/xb1_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,12 @@ def SignIn(self):
self._network_api.SetXboxLiveSignedInUserState(users[0]['EmailAddress'],
True)

def WinAppDeployCmd(self, command):
def WinAppDeployCmd(self, command: str):
try:
out = subprocess.check_output('WinAppDeployCmd ' + command + ' -ip ' +
self.GetDeviceIp()).decode()
exe_path = os.path.join(packager.GetWinToolsPath(), 'WinAppDeployCmd.exe')
command_str = f'{exe_path} {command} -ip {self.GetDeviceIp()}'
self._LogLn('Running: ' + command_str)
out = subprocess.check_output(command_str).decode()
except subprocess.CalledProcessError as e:
self._LogLn(e.output)
raise e
Expand Down

0 comments on commit 3da73c7

Please sign in to comment.