Cache git executable search into a variable. This helps reduce noise in the verbose debug logging output messages when EMSDK_VERBOSE=1 is enabled.
diff --git a/emsdk.py b/emsdk.py index e618e37..e87f9c7 100644 --- a/emsdk.py +++ b/emsdk.py
@@ -734,12 +734,15 @@ stdout, stderr = process.communicate() return (process.returncode, stdout, stderr) +cached_git_executable = None # must_succeed: If false, the search is performed silently without printing out # errors if not found. Empty string is returned if git is not found. # If true, the search is required to succeed, and the execution # will terminate with sys.exit(1) if not found. def GIT(must_succeed=True): + if cached_git_executable is not None: + return cached_git_executable # The order in the following is important, and specifies the preferred order # of using the git tools. Primarily use git from emsdk if installed. If not, # use system git. @@ -748,6 +751,7 @@ try: ret, stdout, stderr = run_get_output([git, '--version']) if ret == 0: + cached_git_executable = git return git except: pass