Remove error duplication around missing git executable
Make git a requirement for fetch_emscripten_tags but in the case
when we run it from "emsdk update" we can check for git first.
This cleans up fetch_emscripten_tags and removed the duplication
of the git-missing error messages.
diff --git a/emsdk.py b/emsdk.py
index f3ab07d..4f965c0 100755
--- a/emsdk.py
+++ b/emsdk.py
@@ -735,17 +735,17 @@
return git
except:
pass
- if must_succeed:
- if WINDOWS:
- msg = "ERROR: git executable was not found. Please install it by typing 'emsdk install git-1.9.4', or alternatively by installing it manually from http://git-scm.com/downloads . If you install git manually, remember to add it to PATH"
- elif MACOS:
- msg = "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 )"
- elif LINUX:
- msg = "ERROR: git executable was not found. Please install git for this operation! This can be probably be done using your package manager, see http://git-scm.com/book/en/Getting-Started-Installing-Git"
- else:
- msg = "ERROR: git executable was not found. Please install git for this operation!"
- exit_with_error(msg)
+
# Not found
+ if WINDOWS:
+ msg = "git executable was not found. Please install it by typing 'emsdk install git-1.9.4', or alternatively by installing it manually from http://git-scm.com/downloads . If you install git manually, remember to add it to PATH"
+ elif MACOS:
+ msg = "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 )"
+ else:
+ msg = "git executable was not found. Please install git for this operation! This can be probably be done using your package manager, see http://git-scm.com/book/en/Getting-Started-Installing-Git"
+ if must_succeed:
+ exit_with_error(msg)
+ print(msg, file=sys.stderr)
return ''
@@ -2009,12 +2009,10 @@
def find_tot_sdk(which):
if not os.path.exists(tot_path()):
- print('Tip-of-tree information was not found, run emsdk update-tags')
- sys.exit(1)
+ exit_with_error('Tip-of-tree information was not found, run emsdk update-tags')
tot = find_tot()
if not tot:
- print('Tip-of-tree build was not found, run emsdk update-tags (however, if there is no recent tip-of-tree build, you may need to wait)')
- sys.exit(1)
+ exit_with_error('Tip-of-tree build was not found, run emsdk update-tags (however, if there is no recent tip-of-tree build, you may need to wait)')
return 'sdk-releases-%s-%s-64bit' % (which, tot)
@@ -2087,24 +2085,10 @@
def fetch_emscripten_tags():
- git = GIT(must_succeed=False)
-
- if git:
- print('Fetching emscripten-releases repository...')
- emscripten_releases_tot = get_emscripten_releases_tot()
- if emscripten_releases_tot:
- open(tot_path(), 'w').write(emscripten_releases_tot)
- else:
- print('Update complete, however skipped fetching the Emscripten tags, since git was not found, which is necessary for update-tags.')
- if WINDOWS:
- print("Please install git by typing 'emsdk install git-1.9.4', or alternatively by installing it manually from http://git-scm.com/downloads . If you install git manually, remember to add it to PATH.")
- elif MACOS:
- print("Please install git 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 ).")
- elif LINUX:
- print("Pease install git using your package manager, see http://git-scm.com/book/en/Getting-Started-Installing-Git .")
- else:
- print("Please install git.")
- return
+ print('Fetching emscripten-releases repository...')
+ emscripten_releases_tot = get_emscripten_releases_tot()
+ if emscripten_releases_tot:
+ open(tot_path(), 'w').write(emscripten_releases_tot)
def is_emsdk_sourced_from_github():
@@ -2118,6 +2102,12 @@
sys.exit(1)
if not download_and_unzip(emsdk_zip_download_url, emsdk_path(), download_even_if_exists=True, clobber=False):
sys.exit(1)
+
+ # attempt to run fetch_emscripten_tags if git is available.
+ git = GIT(must_succeed=False)
+ if not git:
+ print('Update complete, however skipped fetching the Emscripten tags, since git was not found, which is necessary for update-tags.', file=sys.stderr)
+ return
fetch_emscripten_tags()
@@ -2773,10 +2763,6 @@
cmd = sys.argv[1]
- # On first run when tag list is not present, populate it to bootstrap.
- if (cmd == 'install' or cmd == 'list') and not os.path.isfile(sdk_path('llvm-tags-64bit.txt')):
- fetch_emscripten_tags()
-
load_dot_emscripten()
load_sdk_manifest()