no_suffix = last_dot < last_slash or last_dot == -1
if no_suffix:
return True
suffix = path[last_dot:]
if suffix == '.exe' or suffix == '.zip': # Very simple logic for the only file suffixes used by emsdk downloader. Other suffixes, like 'clang-3.2' are treated as dirs.
print "ERROR: git executable was not found. Either install git manually and add it to PATH, or install the git tool via 'emsdk install git-1.8.3'"
else:
print "ERROR: git executable was not found. Please install git for this operation! This can be done from http://git-scm.com/ , or by installing XCode and then the XCode Command Line Tools (see http://stackoverflow.com/questions/9329243/xcode-4-4-command-line-tools )"
run([GIT(), 'checkout', '--quiet', branch], repo_path) # this line assumes that the user has not gone and manually messed with the repo and added new remotes to ambiguate the checkout.
run([GIT(), 'merge', '--ff-only', 'origin/'+branch], repo_path) # this line assumes that the user has not gone and made local changes to the repo
except:
print 'git operation failed!'
return False
print "Successfully updated and checked out branch '" + branch + "' on repository '" + repo_path + "'"
print "The following tool directories have been set for you in " + dot_emscripten_path() + ":"
print ''
print cfg
path_add = get_required_path(active_tools)
print "To conveniently access the selected set of tools from the command line, consider adding the following directories to PATH, or call '" + ('' if WINDOWS else 'source ') + os.path.relpath(sdk_path('emsdk_add_path')) + "' to do this for you."
tool_cfg = tool_cfg.replace('%.exe%', '.exe' if WINDOWS else '')
return tool_cfg
else:
return ''
def compatible_with_this_os(self):
if hasattr(self, 'os'):
if (WINDOWS and 'win' in self.os) or (LINUX and 'linux' in self.os) or (OSX and 'osx' in self.os):
return True
else:
return False
if OSX and hasattr(self, 'osx_url'):
return True
if WINDOWS and (hasattr(self, 'windows_url') or hasattr(self, 'windows_install_path')):
return True
if LINUX or OSX and hasattr(self, 'unix_url'):
return True
return hasattr(self, 'url')
def is_installed(self):
# If this tool/sdk depends on other tools, require that all dependencies are installed for this tool to count as being installed.
if hasattr(self, 'uses'):
for tool_name in self.uses:
tool = find_tool(tool_name)
if tool == None:
print "Manifest error: No tool by name '" + tool_name + "' found! This may indicate an internal SDK error!"
return False
if not tool.is_installed():
return False
if self.download_url() != None:
content_exists = os.path.exists(self.installation_path()) and (os.path.isfile(self.installation_path()) or num_files_in_directory(self.installation_path()) > 0)
if self.id == 'vs-tool': # vs-tool is a special tool since all versions must be installed to the same dir, so dir name will not differentiate the version.
return content_exists and get_installed_vstool_version(self.installation_path()) == self.version
else:
return content_exists
else:
return True # This tool does not contain downloadable elements, so it is installed by default.
def is_active(self):
if not self.is_installed():
return False
if self.id == 'vs-tool':
return True # vs-tool is a special tool since all versions must be installed to the same dir, which means that if this tool is installed, it is also active.
# All dependencies of this tool must be active as well.
print "Warning: The installation of '" + str(self) + "' seems to have failed, but no error was detected. Either something went wrong with the installation, or this may indicate an internal emsdk error."
return True
def uninstall(self):
if not self.is_installed():
print "Tool '" + str(self) + "' was not installed. No need to uninstall."
print 'The items marked with * are activated for the current user.'
return 0
elif cmd == 'active_path':
if len(sys.argv) <= 2:
sdk = currently_active_sdk()
if sdk == None:
print "Missing tool/SDK name and no active SDK detected. Type 'emsdk active_path <tool/sdk name>' to query a list of directories that should be added to PATH to use the specified tool or SDK."
return 1
else:
sys.argv += [str(sdk)]
if sys.argv[2] == 'latest':
sys.argv[2] = str(find_latest_sdk())
tool = find_tool(sys.argv[2])
if tool == None:
tool = find_sdk(sys.argv[2])
if tool == None:
print "Error: No tool or SDK found by name '" + sys.argv[2] + "'."
new_path = [item for item in path_add if item not in existing_path]
# print existing_path
# print set(path_add)
#uniq = list(set(existing_path) - set(path_add))
#print uniq
#new_path = path_add +
print ENVPATH_SEPARATOR.join(new_path)
return 0
elif cmd == 'update':
update_emsdk()
return 0
elif cmd == 'activate':
if len(sys.argv) <= 2:
print "Missing parameter. Type 'emsdk activate <tool name>' to install a tool or an SDK. Type 'emsdk list' to obtain a list of available tools. Type 'emsdk install latest' to automatically install the newest version of the SDK."
return 1
if sys.argv[2] == 'latest':
sys.argv[2] = str(find_latest_sdk())
tools_to_activate = []
for i in range(2, len(sys.argv)):
tool = find_tool(sys.argv[i])
if tool == None:
tool = find_sdk(sys.argv[i])
if tool == None:
print "Error: No tool or SDK found by name '" + sys.argv[i] + "'."
return 1
tools_to_activate += [tool]
activate(tools_to_activate)
return 0
elif cmd == 'install':
if len(sys.argv) <= 2:
print "Missing parameter. Type 'emsdk install <tool name>' to install a tool or an SDK. Type 'emsdk list' to obtain a list of available tools. Type 'emsdk install latest' to automatically install the newest version of the SDK."
return 1
if sys.argv[2] == 'latest':
sys.argv[2] = str(find_latest_sdk())
tool = find_tool(sys.argv[2])
if tool == None:
tool = find_sdk(sys.argv[2])
if tool == None:
print "Error: No tool or SDK found by name '" + sys.argv[2] + "'."
return 1
tool.install()
elif cmd == 'uninstall':
if len(sys.argv) <= 2:
print "Syntax error. Call 'emsdk uninstall <tool name>'. Call 'emsdk list' to obtain a list of available tools."
return 1
tool = find_tool(sys.argv[2])
if tool == None:
print "Error: Tool by name '" + sys.argv[2] + "' was not found."