MCPcopy
hub / github.com/emscripten-core/emsdk / install_tool

Method install_tool

emsdk.py:2125–2194  ·  view source on GitHub ↗

Returns True if the SDK was installed of False if was skipped due to already being installed.

(self)

Source from the content-addressed store, hash-verified

2123 return True
2124
2125 def install_tool(self):
2126 """Returns True if the SDK was installed of False if was skipped due to
2127 already being installed.
2128 """
2129 # Avoid doing a redundant reinstall of the tool, if it has already been installed.
2130 # However all tools that are sourced directly from git branches do need to be
2131 # installed every time when requested, since the install step is then used to git
2132 # pull the tool to a newer version.
2133 if self.is_installed() and not self.git_branch:
2134 print(f"Skipped installing {self.name}, already installed.")
2135 return False
2136
2137 print(f"Installing tool '{self}'..")
2138 url = self.download_url()
2139
2140 custom_install_scripts = {
2141 'build_llvm': build_llvm,
2142 'build_ninja': build_ninja,
2143 'build_ccache': build_ccache,
2144 'download_node_nightly': download_node_nightly,
2145 'download_firefox': download_firefox,
2146 }
2147 if self.custom_install_script in custom_install_scripts:
2148 success = custom_install_scripts[self.custom_install_script](self)
2149 elif self.git_branch:
2150 success = git_clone_checkout_and_pull(url, self.installation_path(), self.git_branch, getattr(self, 'remote_name', 'origin'))
2151 elif url.endswith(ARCHIVE_SUFFIXES):
2152 success = download_and_extract(url, self.installation_path(),
2153 filename_prefix=getattr(self, 'download_prefix', ''))
2154 else:
2155 assert False, 'unhandled url type: ' + url
2156
2157 if not success:
2158 exit_with_error("installation failed!")
2159
2160 if self.custom_install_script:
2161 if self.custom_install_script == 'emscripten_npm_install':
2162 success = emscripten_npm_install(self, self.installation_path())
2163 elif self.custom_install_script in {'build_llvm', 'build_ninja', 'build_ccache', 'download_node_nightly', 'download_firefox'}:
2164 # 'build_llvm' is a special one that does the download on its
2165 # own, others do the download manually.
2166 pass
2167 elif self.custom_install_script == 'build_binaryen':
2168 success = build_binaryen_tool(self)
2169 else:
2170 raise Exception(f'Unknown custom_install_script: "{self.custom_install_script}"')
2171
2172 if not success:
2173 exit_with_error("installation failed!")
2174
2175 # Install an emscripten-version.txt file if told to, and if there is one.
2176 # (If this is not an actual release, but some other build, then we do not
2177 # write anything.)
2178 if self.emscripten_releases_hash:
2179 emscripten_version_file_path = os.path.join(to_native_path(self.expand_vars(self.activated_path)), 'emscripten-version.txt')
2180 version = get_emscripten_release_version(self.emscripten_releases_hash)
2181 if version:
2182 with open(emscripten_version_file_path, 'w') as f:

Callers 1

installMethod · 0.95

Calls 13

is_installedMethod · 0.95
download_urlMethod · 0.95
installation_pathMethod · 0.95
expand_varsMethod · 0.95
download_and_extractFunction · 0.85
exit_with_errorFunction · 0.85
emscripten_npm_installFunction · 0.85
build_binaryen_toolFunction · 0.85
to_native_pathFunction · 0.85

Tested by

no test coverage detected