Treat relative paths in installation relative to emsdk root, not the cwd root. This enables invoking 'emsdk' from directories outside the sdk root directory. Fixes https://github.com/kripken/emscripten/issues/1786.

This commit is contained in:
Jukka Jylänki
2013-11-13 19:25:57 +02:00
parent 8d299c5a8b
commit 0a2a758c80

13
emsdk
View File

@@ -34,7 +34,11 @@ if platform.mac_ver()[0] != '':
ENVPATH_SEPARATOR = ':'
# Returns the absolute pathname to the given path inside the Emscripten SDK.
def sdk_path(path): return to_unix_path(os.path.join(os.path.dirname(os.path.realpath(__file__)), path))
def sdk_path(path):
if os.path.isabs(path):
return path
else:
return to_unix_path(os.path.join(os.path.dirname(os.path.realpath(__file__)), path))
def emsdk_path(): return to_unix_path(os.path.dirname(os.path.realpath(__file__)))
@@ -177,6 +181,9 @@ def download_file(url, dstpath, download_even_if_exists=False):
else:
file_name = dstpath
# Treat all relative destination paths as relative to the SDK root directory, not the current working directory.
file_name = sdk_path(file_name)
if os.path.exists(file_name) and not download_even_if_exists:
print "File '" + file_name + "' already downloaded, skipping."
return file_name
@@ -410,11 +417,11 @@ class Tool:
def installation_path(self):
if WINDOWS and hasattr(self, 'windows_install_path'):
pth = self.windows_install_path.replace("%MSBuildPlatformsDir%", find_msbuild_dir())
return pth
return sdk_path(pth)
p = self.version
if hasattr(self, 'bitness'):
p += '_' + str(self.bitness) + 'bit'
return os.path.join(self.id, p)
return sdk_path(os.path.join(self.id, p))
# Specifies the target directory this tool will be installed to.
def installation_dir(self):