rust/src/ci/init_repo.sh

73 lines
1.9 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2017-03-24 00:33:15 +01:00
set -o errexit
set -o pipefail
set -o nounset
ci_dir=$(cd $(dirname $0) && pwd)
. "$ci_dir/shared.sh"
travis_fold start init_repo
2018-03-16 20:11:48 +01:00
travis_time_start
2017-03-24 00:33:15 +01:00
REPO_DIR="$1"
CACHE_DIR="$2"
cache_src_dir="$CACHE_DIR/src"
if [ ! -d "$REPO_DIR" -o ! -d "$REPO_DIR/.git" ]; then
echo "Error: $REPO_DIR does not exist or is not a git repo"
exit 1
fi
cd $REPO_DIR
if [ ! -d "$CACHE_DIR" ]; then
echo "Error: $CACHE_DIR does not exist or is not an absolute path"
exit 1
fi
rm -rf "$CACHE_DIR"
mkdir "$CACHE_DIR"
2017-03-24 00:33:15 +01:00
# On the beta channel we'll be automatically calculating the prerelease version
# via the git history, so unshallow our shallow clone from CI.
if grep -q RUST_RELEASE_CHANNEL=beta src/ci/run.sh; then
git fetch origin --unshallow beta master
fi
2018-03-16 20:11:48 +01:00
function fetch_submodule {
local module=$1
local cached="download-${module//\//-}.tar.gz"
retry sh -c "rm -f $cached && \
curl -sSL -o $cached $2"
mkdir $module
touch "$module/.git"
tar -C $module --strip-components=1 -xf $cached
rm $cached
}
included="src/llvm-project src/llvm-emscripten src/doc/book src/doc/rust-by-example"
2017-03-24 00:33:15 +01:00
modules="$(git config --file .gitmodules --get-regexp '\.path$' | cut -d' ' -f2)"
2018-03-16 20:11:48 +01:00
modules=($modules)
use_git=""
urls="$(git config --file .gitmodules --get-regexp '\.url$' | cut -d' ' -f2)"
urls=($urls)
for i in ${!modules[@]}; do
module=${modules[$i]}
if [[ " $included " = *" $module "* ]]; then
rustc: Split Emscripten to a separate codegen backend This commit introduces a separately compiled backend for Emscripten, avoiding compiling the `JSBackend` target in the main LLVM codegen backend. This builds on the foundation provided by #47671 to create a new codegen backend dedicated solely to Emscripten, removing the `JSBackend` of the main codegen backend in the process. A new field was added to each target for this commit which specifies the backend to use for translation, the default being `llvm` which is the main backend that we use. The Emscripten targets specify an `emscripten` backend instead of the main `llvm` one. There's a whole bunch of consequences of this change, but I'll try to enumerate them here: * A *second* LLVM submodule was added in this commit. The main LLVM submodule will soon start to drift from the Emscripten submodule, but currently they're both at the same revision. * Logic was added to rustbuild to *not* build the Emscripten backend by default. This is gated behind a `--enable-emscripten` flag to the configure script. By default users should neither check out the emscripten submodule nor compile it. * The `init_repo.sh` script was updated to fetch the Emscripten submodule from GitHub the same way we do the main LLVM submodule (a tarball fetch). * The Emscripten backend, turned off by default, is still turned on for a number of targets on CI. We'll only be shipping an Emscripten backend with Tier 1 platforms, though. All cross-compiled platforms will not be receiving an Emscripten backend yet. This commit means that when you download the `rustc` package in Rustup for Tier 1 platforms you'll be receiving two trans backends, one for Emscripten and one that's the general LLVM backend. If you never compile for Emscripten you'll never use the Emscripten backend, so we may update this one day to only download the Emscripten backend when you add the Emscripten target. For now though it's just an extra 10MB gzip'd. Closes #46819
2018-01-24 17:22:34 +01:00
commit="$(git ls-tree HEAD $module | awk '{print $3}')"
git rm $module
2018-03-16 20:11:48 +01:00
url=${urls[$i]}
url=${url/\.git/}
fetch_submodule $module "$url/archive/$commit.tar.gz" &
2017-03-24 00:33:15 +01:00
continue
2018-03-16 20:11:48 +01:00
else
use_git="$use_git $module"
2017-03-24 00:33:15 +01:00
fi
done
2018-03-16 20:11:48 +01:00
retry sh -c "git submodule deinit -f $use_git && \
git submodule sync && \
git submodule update -j 16 --init --recursive $use_git"
wait
travis_fold end init_repo
2018-03-16 20:11:48 +01:00
travis_time_finish