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:
13
emsdk
13
emsdk
@@ -34,7 +34,11 @@ if platform.mac_ver()[0] != '':
|
|||||||
ENVPATH_SEPARATOR = ':'
|
ENVPATH_SEPARATOR = ':'
|
||||||
|
|
||||||
# Returns the absolute pathname to the given path inside the Emscripten SDK.
|
# 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__)))
|
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:
|
else:
|
||||||
file_name = dstpath
|
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:
|
if os.path.exists(file_name) and not download_even_if_exists:
|
||||||
print "File '" + file_name + "' already downloaded, skipping."
|
print "File '" + file_name + "' already downloaded, skipping."
|
||||||
return file_name
|
return file_name
|
||||||
@@ -410,11 +417,11 @@ class Tool:
|
|||||||
def installation_path(self):
|
def installation_path(self):
|
||||||
if WINDOWS and hasattr(self, 'windows_install_path'):
|
if WINDOWS and hasattr(self, 'windows_install_path'):
|
||||||
pth = self.windows_install_path.replace("%MSBuildPlatformsDir%", find_msbuild_dir())
|
pth = self.windows_install_path.replace("%MSBuildPlatformsDir%", find_msbuild_dir())
|
||||||
return pth
|
return sdk_path(pth)
|
||||||
p = self.version
|
p = self.version
|
||||||
if hasattr(self, 'bitness'):
|
if hasattr(self, 'bitness'):
|
||||||
p += '_' + str(self.bitness) + 'bit'
|
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.
|
# Specifies the target directory this tool will be installed to.
|
||||||
def installation_dir(self):
|
def installation_dir(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user