Skip to content

Commit 548d233

Browse files
danakjAravind Vasudevan
authored andcommitted
Retry git submodule and vendoring
These operations require a lot of network requests and networks are flaky. If they fail, we don't want to take out the whole clang/rustc build. So retry a few times. Bug: 1401042 Change-Id: I705f876d75d3d36b91e102d6a0818e83f649c847 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4366440 Auto-Submit: danakj <[email protected]> Reviewed-by: Collin Baker <[email protected]> Commit-Queue: Collin Baker <[email protected]> Cr-Commit-Position: refs/heads/main@{#1121822} NOKEYCHECK=True GitOrigin-RevId: 1abde5b0067c21e7061ae7ad75f6f2670d1d96ce
1 parent 1c775e9 commit 548d233

File tree

1 file changed

+35
-21
lines changed

1 file changed

+35
-21
lines changed

build_rust.py

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -248,27 +248,41 @@ def CargoVendor(cargo_bin):
248248
'''Runs `cargo vendor` to pull down dependencies.'''
249249
os.chdir(RUST_SRC_DIR)
250250

251-
# Some Submodules are part of the workspace and need to exist (so we can
252-
# read their Cargo.toml files) before we can vendor their deps.
253-
RunCommand([
254-
'git', 'submodule', 'update', '--init', '--recursive', '--depth', '1'
255-
])
256-
257-
# From https://github.com/rust-lang/rust/blob/master/src/bootstrap/dist.rs#L986-L995
258-
# The additional `--sync` Cargo.toml files are not part of the top level
259-
# workspace.
260-
RunCommand([
261-
cargo_bin,
262-
'vendor',
263-
'--locked',
264-
'--versioned-dirs',
265-
'--sync',
266-
'src/tools/rust-analyzer/Cargo.toml',
267-
'--sync',
268-
'compiler/rustc_codegen_cranelift/Cargo.toml',
269-
'--sync',
270-
'src/bootstrap/Cargo.toml',
271-
])
251+
for i in range(0, 3):
252+
# Some Submodules are part of the workspace and need to exist (so we can
253+
# read their Cargo.toml files) before we can vendor their deps.
254+
submod_cmd = [
255+
'git', 'submodule', 'update', '--init', '--recursive', '--depth',
256+
'1'
257+
]
258+
if not RunCommand(submod_cmd, fail_hard=False):
259+
if i < 2:
260+
print('Failed git submodule, retrying...')
261+
continue
262+
else:
263+
sys.exit(1)
264+
265+
# From https://github.com/rust-lang/rust/blob/master/src/bootstrap/dist.rs#L986-L995:
266+
# The additional `--sync` Cargo.toml files are not part of the top level
267+
# workspace.
268+
vendor_cmd = [
269+
cargo_bin,
270+
'vendor',
271+
'--locked',
272+
'--versioned-dirs',
273+
'--sync',
274+
'src/tools/rust-analyzer/Cargo.toml',
275+
'--sync',
276+
'compiler/rustc_codegen_cranelift/Cargo.toml',
277+
'--sync',
278+
'src/bootstrap/Cargo.toml',
279+
]
280+
if not RunCommand(vendor_cmd, fail_hard=False):
281+
if i < 2:
282+
print('Failed cargo vendor, retrying...')
283+
continue
284+
else:
285+
sys.exit(1)
272286

273287
# Make a `.cargo/config.toml` the points to the `vendor` directory for all
274288
# dependency crates.

0 commit comments

Comments
 (0)