From 0a2a758c80d320a24a988c0b24109d11203f0d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 13 Nov 2013 19:25:57 +0200 Subject: [PATCH] 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. --- emsdk | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/emsdk b/emsdk index 53e02da..c96d3eb 100644 --- a/emsdk +++ b/emsdk @@ -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):