Skip to content

Commit

Permalink
Rename zipfile to archive or download as appropriate. NFC (emsc…
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 authored and shlomif committed Sep 29, 2023
1 parent c3870d4 commit 8c1d600
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ exclude =
./node
./python
./temp
./zips
./downloads
./crunch
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ __pycache__
/node
/python
/temp
/zips
/downloads
/crunch
/java
/mingw
Expand Down
23 changes: 12 additions & 11 deletions emsdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
# `main.zip` perhaps.
emsdk_zip_download_url = 'https://github.com/emscripten-core/emsdk/archive/HEAD.zip'

zips_subdir = 'zips/'
download_dir = 'downloads/'

extra_release_tag = None

Expand Down Expand Up @@ -1407,13 +1407,13 @@ def build_binaryen_tool(tool):
return success


def download_and_unzip(zipfile, dest_dir, filename_prefix='', clobber=True):
debug_print('download_and_unzip(zipfile=' + zipfile + ', dest_dir=' + dest_dir + ')')
def download_and_extract(archive, dest_dir, filename_prefix='', clobber=True):
debug_print('download_and_extract(archive=' + archive + ', dest_dir=' + dest_dir + ')')

url = urljoin(emsdk_packages_url, zipfile)
download_target = get_download_target(url, zips_subdir, filename_prefix)
url = urljoin(emsdk_packages_url, archive)
download_target = get_download_target(url, download_dir, filename_prefix)

received_download_target = download_file(url, zips_subdir, not KEEP_DOWNLOADS, filename_prefix)
received_download_target = download_file(url, download_dir, not KEEP_DOWNLOADS, filename_prefix)
if not received_download_target:
return False
assert received_download_target == download_target
Expand All @@ -1423,7 +1423,7 @@ def download_and_unzip(zipfile, dest_dir, filename_prefix='', clobber=True):
# could remain.
if clobber:
remove_tree(dest_dir)
if zipfile.endswith('.zip'):
if archive.endswith('.zip'):
return unzip(download_target, dest_dir)
else:
return untargz(download_target, dest_dir)
Expand Down Expand Up @@ -1880,7 +1880,8 @@ def install_tool(self):
elif hasattr(self, 'git_branch'):
success = git_clone_checkout_and_pull(url, self.installation_path(), self.git_branch)
elif url.endswith(ARCHIVE_SUFFIXES):
success = download_and_unzip(url, self.installation_path(), filename_prefix=getattr(self, 'zipfile_prefix', ''))
success = download_and_extract(url, self.installation_path(),
filename_prefix=getattr(self, 'download_prefix', ''))
else:
assert False, 'unhandled url type: ' + url

Expand Down Expand Up @@ -1930,8 +1931,8 @@ def cleanup_temp_install_files(self):
return
url = self.download_url()
if url.endswith(ARCHIVE_SUFFIXES):
download_target = get_download_target(url, zips_subdir, getattr(self, 'zipfile_prefix', ''))
debug_print("Deleting temporary zip file " + download_target)
download_target = get_download_target(url, download_dir, getattr(self, 'download_prefix', ''))
debug_print("Deleting temporary download: " + download_target)
rmfile(download_target)

def uninstall(self):
Expand Down Expand Up @@ -2116,7 +2117,7 @@ def update_emsdk():
if is_emsdk_sourced_from_github():
errlog('You seem to have bootstrapped Emscripten SDK by cloning from GitHub. In this case, use "git pull" instead of "emsdk update" to update emsdk. (Not doing that automatically in case you have local changes)')
sys.exit(1)
if not download_and_unzip(emsdk_zip_download_url, EMSDK_PATH, clobber=False):
if not download_and_extract(emsdk_zip_download_url, EMSDK_PATH, clobber=False):
sys.exit(1)


Expand Down
10 changes: 5 additions & 5 deletions emsdk_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"linux_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/linux/%releases-tag%/wasm-binaries.tbz2",
"macos_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/mac/%releases-tag%/wasm-binaries.tbz2",
"windows_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/win/%releases-tag%/wasm-binaries.zip",
"zipfile_prefix": "%releases-tag%-",
"download_prefix": "%releases-tag%-",
"install_path": "upstream",
"activated_path": "%installation_dir%/emscripten",
"activated_cfg": "LLVM_ROOT='%installation_dir%/bin';BINARYEN_ROOT='%installation_dir%';EMSCRIPTEN_ROOT='%installation_dir%/emscripten'",
Expand All @@ -50,7 +50,7 @@
"arch": "arm64",
"macos_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/mac/%releases-tag%/wasm-binaries-arm64.tbz2",
"linux_url": "https://storage.googleapis.com/webassembly/emscripten-releases-builds/linux/%releases-tag%/wasm-binaries-arm64.tbz2",
"zipfile_prefix": "%releases-tag%-",
"download_prefix": "%releases-tag%-",
"install_path": "upstream",
"activated_path": "%installation_dir%/emscripten",
"activated_cfg": "LLVM_ROOT='%installation_dir%/bin';BINARYEN_ROOT='%installation_dir%';EMSCRIPTEN_ROOT='%installation_dir%/emscripten'",
Expand Down Expand Up @@ -478,7 +478,7 @@
"append_bitness": false,
"windows_url": "https://github.com/emscripten-core/emscripten/archive/%tag%.zip",
"unix_url": "https://github.com/emscripten-core/emscripten/archive/%tag%.tar.gz",
"zipfile_prefix": "emscripten-e",
"download_prefix": "emscripten-e",
"activated_cfg": "EMSCRIPTEN_ROOT='%installation_dir%';EMSCRIPTEN_NATIVE_OPTIMIZER='%installation_dir%%generator_prefix%_32bit_optimizer/%cmake_build_type_on_win%optimizer%.exe%'",
"activated_path": "%installation_dir%",
"activated_env": "EMSCRIPTEN=%installation_dir%;EMSCRIPTEN_NATIVE_OPTIMIZER=%installation_dir%%generator_prefix%_32bit_optimizer/%cmake_build_type_on_win%optimizer%.exe%",
Expand Down Expand Up @@ -518,7 +518,7 @@
"append_bitness": false,
"windows_url": "https://github.com/WebAssembly/binaryen/archive/%binaryen_tag%.zip",
"unix_url": "https://github.com/WebAssembly/binaryen/archive/%binaryen_tag%.tar.gz",
"zipfile_prefix": "binaryen-e",
"download_prefix": "binaryen-e",
"activated_cfg": "BINARYEN_ROOT='%installation_dir%%generator_prefix%_64bit_binaryen'",
"activated_path": "%installation_dir%%generator_prefix%_64bit_binaryen/bin",
"activated_env": "BINARYEN_ROOT=%installation_dir%%generator_prefix%_64bit_binaryen",
Expand All @@ -534,7 +534,7 @@
"append_bitness": false,
"windows_url": "https://github.com/WebAssembly/binaryen/archive/%binaryen_tag%.zip",
"unix_url": "https://github.com/WebAssembly/binaryen/archive/%binaryen_tag%.tar.gz",
"zipfile_prefix": "binaryen-e",
"download_prefix": "binaryen-e",
"activated_cfg": "BINARYEN_ROOT='%installation_dir%%generator_prefix%_64bit_binaryen'",
"activated_path": "%installation_dir%%generator_prefix%_64bit_binaryen/bin",
"activated_env": "BINARYEN_ROOT=%installation_dir%%generator_prefix%_64bit_binaryen",
Expand Down
2 changes: 1 addition & 1 deletion test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def test_keep_downloads(self):
# With EMSDK_KEEP_DOWNLOADS the downloading should happen on the first
# install of 2.0.28, and again when we install 2.0.29, but not on the
# second install of 2.0.28 because the zip should already be local.
shutil.rmtree('zips')
shutil.rmtree('downloads')
checked_call_with_output(emsdk + ' install 2.0.28', expected='Downloading:', env=env)
checked_call_with_output(emsdk + ' install 2.0.29', expected='Downloading:', env=env)
checked_call_with_output(emsdk + ' install 2.0.28', expected='already downloaded, skipping', unexpected='Downloading:', env=env)
Expand Down

0 comments on commit 8c1d600

Please sign in to comment.