Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions tools/maint/sync_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def sync_repo(name, repo_dir, revision, url):
cur_rev = get_current_revision(repo_dir)
if cur_rev.startswith(revision) or revision.startswith(cur_rev):
print(' already at the requested revision')
return
return False

if is_dirty(repo_dir):
utils.exit_with_error(f"Directory for {name} is dirty: '{repo_dir}'")
Expand All @@ -144,6 +144,8 @@ def sync_repo(name, repo_dir, revision, url):
if not DRY_RUN:
subprocess.check_call(['git', '-C', repo_dir, 'checkout', revision])

return True


def main():
parent_dir = os.path.dirname(utils.path_from_root())
Expand Down Expand Up @@ -175,7 +177,17 @@ def main():

revisions = get_deps_revisions()
sync_repo('llvm-project', args.llvm_dir, revisions['llvm_project_revision'], LLVM_URL)
sync_repo('binaryen', args.binaryen_dir, revisions['binaryen_revision'], BINARYEN_URL)
if sync_repo('binaryen', args.binaryen_dir, revisions['binaryen_revision'], BINARYEN_URL):
# Binaryen only runs `git describe` when configuring CMake, so switching
# git revisions without re-running CMake leaves `config.h` (and `wasm-opt
# --version`) stale. Touch `config.h.in` to force CMake to re-run on the
# next build. See https://github.com/WebAssembly/binaryen/pull/9299.
config_h_in = os.path.join(args.binaryen_dir, 'config.h.in')
if os.path.exists(config_h_in):
if VERBOSE:
print(f' Touching {config_h_in}')
if not DRY_RUN:
os.utime(config_h_in)
Comment on lines +189 to +190

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Wrapping the os.utime call in a try-except block is safer. Since the main repository synchronization has already completed successfully, any unexpected file system permission issue or OS error when touching config.h.in shouldn't cause the entire script to crash with a traceback.

Suggested change
if not DRY_RUN:
os.utime(config_h_in)
if not DRY_RUN:
try:
os.utime(config_h_in)
except OSError as e:
print(f' Warning: Failed to touch {config_h_in}: {e}')

print('Done.')


Expand Down
Loading