Avoid re-downloading files that are already downloaded (#460)
* Writes a .emsdk_version file to output directories using the name (which contains a version number and/or hash) once all installation steps have completed successfully. * If that file exists, skip downloading/installation hooks.
This commit is contained in:
10
emsdk.py
10
emsdk.py
@@ -1885,6 +1885,14 @@ class Tool(object):
|
|||||||
print("Skipped installing " + self.name + ", already installed.")
|
print("Skipped installing " + self.name + ", already installed.")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
version_id = self.name
|
||||||
|
version_file_path = os.path.join(self.installation_path(), '.emsdk_version')
|
||||||
|
if os.path.isfile(version_file_path):
|
||||||
|
with open(version_file_path, 'r') as version_file:
|
||||||
|
if version_id == version_file.read():
|
||||||
|
print("Skipped installing " + self.name + ", already installed.")
|
||||||
|
return True
|
||||||
|
|
||||||
print("Installing tool '" + str(self) + "'..")
|
print("Installing tool '" + str(self) + "'..")
|
||||||
url = self.download_url()
|
url = self.download_url()
|
||||||
|
|
||||||
@@ -1945,6 +1953,8 @@ class Tool(object):
|
|||||||
# leftover installation files.
|
# leftover installation files.
|
||||||
if self.is_installed():
|
if self.is_installed():
|
||||||
self.cleanup_temp_install_files()
|
self.cleanup_temp_install_files()
|
||||||
|
with open(version_file_path, 'w') as version_file:
|
||||||
|
version_file.write(version_id)
|
||||||
else:
|
else:
|
||||||
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.")
|
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
|
return True
|
||||||
|
|||||||
29
test.py
29
test.py
@@ -6,6 +6,19 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
WINDOWS = sys.platform.startswith('win')
|
||||||
|
MACOS = sys.platform == 'darwin'
|
||||||
|
|
||||||
|
upstream_emcc = os.path.join('upstream', 'emscripten', 'emcc')
|
||||||
|
fastcomp_emcc = os.path.join('fastcomp', 'emscripten', 'emcc')
|
||||||
|
emsdk = './emsdk'
|
||||||
|
if WINDOWS:
|
||||||
|
upstream_emcc += '.bat'
|
||||||
|
fastcomp_emcc += '.bat'
|
||||||
|
emsdk = 'emsdk.bat'
|
||||||
|
else:
|
||||||
|
emsdk = './emsdk'
|
||||||
|
|
||||||
# Utilities
|
# Utilities
|
||||||
|
|
||||||
|
|
||||||
@@ -71,6 +84,9 @@ print('test .emscripten contents (latest was installed/activated in test.sh)')
|
|||||||
assert 'fastcomp' not in open(os.path.expanduser('~/.emscripten')).read()
|
assert 'fastcomp' not in open(os.path.expanduser('~/.emscripten')).read()
|
||||||
assert 'upstream' in open(os.path.expanduser('~/.emscripten')).read()
|
assert 'upstream' in open(os.path.expanduser('~/.emscripten')).read()
|
||||||
|
|
||||||
|
# Test we don't re-download unnecessarily
|
||||||
|
checked_call_with_output(emsdk + ' install latest', expected='already installed', unexpected='Downloading:')
|
||||||
|
|
||||||
print('building proper system libraries')
|
print('building proper system libraries')
|
||||||
|
|
||||||
|
|
||||||
@@ -108,19 +124,6 @@ def run_emsdk(cmd):
|
|||||||
check_call([emsdk] + cmd)
|
check_call([emsdk] + cmd)
|
||||||
|
|
||||||
|
|
||||||
WINDOWS = sys.platform.startswith('win')
|
|
||||||
MACOS = sys.platform == 'darwin'
|
|
||||||
|
|
||||||
upstream_emcc = os.path.join('upstream', 'emscripten', 'emcc')
|
|
||||||
fastcomp_emcc = os.path.join('fastcomp', 'emscripten', 'emcc')
|
|
||||||
emsdk = './emsdk'
|
|
||||||
if WINDOWS:
|
|
||||||
upstream_emcc += '.bat'
|
|
||||||
fastcomp_emcc += '.bat'
|
|
||||||
emsdk = 'emsdk.bat'
|
|
||||||
else:
|
|
||||||
emsdk = './emsdk'
|
|
||||||
|
|
||||||
test_lib_building(upstream_emcc, use_asmjs_optimizer=True)
|
test_lib_building(upstream_emcc, use_asmjs_optimizer=True)
|
||||||
|
|
||||||
print('update')
|
print('update')
|
||||||
|
|||||||
Reference in New Issue
Block a user