From 289b14fa814c880dc824465e84fcbc5d812a4630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 15 Oct 2013 17:48:04 +0300 Subject: [PATCH] Add pseudo-SDKs 'latest-32bit' and 'latest-64bit' to point to the latest SDKs with given bitness. Have 'latest' SDK download the bitness that the current OS is. --- emsdk | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) mode change 100755 => 100644 emsdk diff --git a/emsdk b/emsdk old mode 100755 new mode 100644 index baf054c..d1023cc --- a/emsdk +++ b/emsdk @@ -575,8 +575,26 @@ def find_sdk(name): return sdk return None +def is_os_64bit(): # http://stackoverflow.com/questions/2208828/detect-64bit-os-windows-in-python + return platform.machine().endswith('64') + +def find_latest_32bit_sdk(): + for sdk in reversed(sdks): # Newest SDK is always at the end of the list. + if not hasattr(sdk, 'bitness') or sdk.bitness == 32: # If no 'bitness' field, it means the SDK is universal. + return sdk + return None + +def find_latest_64bit_sdk(): + for sdk in reversed(sdks): # Newest SDK is always at the end of the list. + if not hasattr(sdk, 'bitness') or sdk.bitness == 64: # If no 'bitness' field, it means the SDK is universal. + return sdk + return None + def find_latest_sdk(): - return sdks[-1] # Newest SDK is always at the end of the list. + if is_os_64bit(): + return find_latest_64bit_sdk() + else: + return find_latest_32bit_sdk() def update_emsdk(): if WINDOWS: @@ -745,6 +763,10 @@ def main(): sys.argv += [str(sdk)] if sys.argv[2] == 'latest': sys.argv[2] = str(find_latest_sdk()) + elif sys.argv[2] == 'latest-32bit': + sys.argv[2] = str(find_latest_32bit_sdk()) + elif sys.argv[2] == 'latest-64bit': + sys.argv[2] = str(find_latest_64bit_sdk()) tool = find_tool(sys.argv[2]) if tool == None: tool = find_sdk(sys.argv[2])