2 # Check out all our submodules, but more quickly than using git by using one of
9 if [ ! -d ".git" ]; then
10 echo "Error: This must run in the root of the repository"
14 ci_dir=$(cd $(dirname $0) && pwd)/..
17 # On the beta channel we'll be automatically calculating the prerelease version
18 # via the git history, so unshallow our shallow clone from CI.
19 if [ "$(releaseChannel)" = "beta" ]; then
20 git fetch origin --unshallow beta master
23 function fetch_github_commit_archive {
25 local cached="download-${module//\//-}.tar.gz"
26 retry sh -c "rm -f $cached && \
27 curl -f -sSL -o $cached $2"
30 # On Windows, the default behavior is to emulate symlinks by copying
31 # files. However, that ends up being order-dependent while extracting,
32 # which can cause a failure if the symlink comes first. This env var
33 # causes tar to use real symlinks instead, which are allowed to dangle.
34 export MSYS=winsymlinks:nativestrict
35 tar -C $module --strip-components=1 -xf $cached
39 # Archive downloads are temporarily disabled due to sudden 504
40 # gateway timeout errors.
41 # included="src/llvm-project src/doc/book src/doc/rust-by-example"
43 modules="$(git config --file .gitmodules --get-regexp '\.path$' | cut -d' ' -f2)"
46 urls="$(git config --file .gitmodules --get-regexp '\.url$' | cut -d' ' -f2)"
48 # shellcheck disable=SC2068
49 for i in ${!modules[@]}; do
51 if [[ " $included " = *" $module "* ]]; then
52 commit="$(git ls-tree HEAD $module | awk '{print $3}')"
56 fetch_github_commit_archive $module "$url/archive/$commit.tar.gz" &
60 use_git="$use_git $module"
63 retry sh -c "git submodule deinit -f $use_git && \
64 git submodule sync && \
65 git submodule update -j 16 --init --recursive --depth 1 $use_git"
67 # for pid in ${bg_pids[*]}
69 # wait $pid || STATUS=1