Error on downloading a 64-bit package on a non-64-bit OS (#265)

Also fix the can_be_installed which was always broken it seems - it returns True for success or a string for error, but didn't check if the output is True.

Includes a test, which hacks up emsdk to make it think it's on 32-bit, and verifies the error and message.
This commit is contained in:
Alon Zakai
2019-06-06 09:04:05 -07:00
committed by GitHub
parent bab28f9a71
commit 169a3ac27c
2 changed files with 27 additions and 3 deletions

10
emsdk
View File

@@ -1480,12 +1480,16 @@ class Tool(object):
# If this tool can be installed on this system, this function returns True.
# Otherwise, this function returns a string that describes the reason why this tool is not available.
def can_be_installed(self):
if hasattr(self, 'bitness'):
if self.bitness == 64 and not is_os_64bit():
return "this tool is only provided for 64-bit OSes"
if self.id == 'vs-tool':
msbuild_dir = find_msbuild_dir()
if len(msbuild_dir) > 0:
return True
else:
return "Visual Studio 2010 was not found!"
return "Visual Studio 2010 was not found"
else:
return True
@@ -1504,7 +1508,7 @@ class Tool(object):
return None
def install(self):
if not self.can_be_installed():
if self.can_be_installed() is not True:
print("The tool '" + str(self) + "' is not available due to the reason: " + self.can_be_installed())
return False
@@ -2488,7 +2492,7 @@ def main():
for tool in t:
if tool.is_old and not arg_old:
continue
if tool.can_be_installed():
if tool.can_be_installed() is True:
installed = '\tINSTALLED' if tool.is_installed() else ''
else:
installed = '\tNot available: ' + tool.can_be_installed()