Fix race between install tot and active tot (#749)
Since #732 we lookup tot release dynamically, but we don't necessarily want to do this for the `activate` command otherwise `install` followed by `activate` a can fail if a new build was produced inbetween.
This commit is contained in:
33
emsdk.py
33
emsdk.py
@@ -2155,6 +2155,15 @@ def load_releases_info():
|
|||||||
return load_releases_info.cached_info
|
return load_releases_info.cached_info
|
||||||
|
|
||||||
|
|
||||||
|
def get_installed_sdk_version():
|
||||||
|
version_file = sdk_path(os.path.join('upstream', '.emsdk_version'))
|
||||||
|
if not os.path.exists(version_file):
|
||||||
|
return None
|
||||||
|
with open(version_file) as f:
|
||||||
|
version = f.read()
|
||||||
|
return version.split('-')[2]
|
||||||
|
|
||||||
|
|
||||||
# Get a list of tags for emscripten-releases.
|
# Get a list of tags for emscripten-releases.
|
||||||
def load_releases_tags():
|
def load_releases_tags():
|
||||||
tags = []
|
tags = []
|
||||||
@@ -2172,13 +2181,9 @@ def load_releases_tags():
|
|||||||
|
|
||||||
# Explicitly add the currently installed SDK version. This could be a custom
|
# Explicitly add the currently installed SDK version. This could be a custom
|
||||||
# version (installed explicitly) so it might not be part of the main list loaded above.
|
# version (installed explicitly) so it might not be part of the main list loaded above.
|
||||||
version_file = sdk_path(os.path.join('upstream', '.emsdk_version'))
|
installed = get_installed_sdk_version()
|
||||||
if os.path.exists(version_file):
|
if installed and installed not in tags:
|
||||||
with open(version_file) as f:
|
tags.append(installed)
|
||||||
version = f.read()
|
|
||||||
version = version.split('-')[2]
|
|
||||||
if version not in tags:
|
|
||||||
tags.append(version)
|
|
||||||
|
|
||||||
return tags, tags_fastcomp
|
return tags, tags_fastcomp
|
||||||
|
|
||||||
@@ -2578,7 +2583,7 @@ def exit_with_fastcomp_error():
|
|||||||
exit_with_error('The fastcomp backend is not getting new builds or releases. Please use the upstream llvm backend or use an older version than 2.0.0 (such as 1.40.1).')
|
exit_with_error('The fastcomp backend is not getting new builds or releases. Please use the upstream llvm backend or use an older version than 2.0.0 (such as 1.40.1).')
|
||||||
|
|
||||||
|
|
||||||
def expand_sdk_name(name):
|
def expand_sdk_name(name, activating):
|
||||||
if name in ('latest-fastcomp', 'latest-releases-fastcomp', 'tot-fastcomp', 'sdk-nightly-latest'):
|
if name in ('latest-fastcomp', 'latest-releases-fastcomp', 'tot-fastcomp', 'sdk-nightly-latest'):
|
||||||
exit_with_fastcomp_error()
|
exit_with_fastcomp_error()
|
||||||
if name in ('latest', 'sdk-latest', 'latest-64bit', 'sdk-latest-64bit'):
|
if name in ('latest', 'sdk-latest', 'latest-64bit', 'sdk-latest-64bit'):
|
||||||
@@ -2587,6 +2592,15 @@ def expand_sdk_name(name):
|
|||||||
elif name in ('latest-upstream', 'latest-clang-upstream', 'latest-releases-upstream'):
|
elif name in ('latest-upstream', 'latest-clang-upstream', 'latest-releases-upstream'):
|
||||||
return str(find_latest_releases_sdk('upstream'))
|
return str(find_latest_releases_sdk('upstream'))
|
||||||
elif name in ('tot', 'sdk-tot', 'tot-upstream'):
|
elif name in ('tot', 'sdk-tot', 'tot-upstream'):
|
||||||
|
if activating:
|
||||||
|
# When we are activating a tot release, assume that the currently
|
||||||
|
# installed SDK, if any, is the tot release we want to activate.
|
||||||
|
# Without this `install tot && activate tot` will race with the builders
|
||||||
|
# that are producing new builds.
|
||||||
|
installed = get_installed_sdk_version()
|
||||||
|
if installed:
|
||||||
|
debug_print('activating currently installed SDK; not updating tot version')
|
||||||
|
return 'sdk-releases-upstream-%s-64bit' % installed
|
||||||
return str(find_tot_sdk())
|
return str(find_tot_sdk())
|
||||||
else:
|
else:
|
||||||
# check if it's a release handled by an emscripten-releases version,
|
# check if it's a release handled by an emscripten-releases version,
|
||||||
@@ -2770,7 +2784,8 @@ def main(args):
|
|||||||
|
|
||||||
# Replace meta-packages with the real package names.
|
# Replace meta-packages with the real package names.
|
||||||
if cmd in ('update', 'install', 'activate'):
|
if cmd in ('update', 'install', 'activate'):
|
||||||
args = [expand_sdk_name(a) for a in args]
|
activating = cmd == 'activate'
|
||||||
|
args = [expand_sdk_name(a, activating=activating) for a in args]
|
||||||
|
|
||||||
load_dot_emscripten()
|
load_dot_emscripten()
|
||||||
load_sdk_manifest()
|
load_sdk_manifest()
|
||||||
|
|||||||
Reference in New Issue
Block a user