2 # Copyright 2016 The Rust Project Developers. See the COPYRIGHT
3 # file at the top-level directory of this distribution and at
4 # http://rust-lang.org/COPYRIGHT.
6 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9 # option. This file may not be copied, modified, or distributed
10 # except according to those terms.
14 export MSYS_NO_PATHCONV=1
16 script=`cd $(dirname $0) && pwd`/`basename $0`
19 docker_dir="`dirname $script`"
20 ci_dir="`dirname $docker_dir`"
21 src_dir="`dirname $ci_dir`"
22 root_dir="`dirname $src_dir`"
24 source "$ci_dir/shared.sh"
26 travis_fold start build_docker
29 if [ -f "$docker_dir/$image/Dockerfile" ]; then
30 if [ "$CI" != "" ]; then
31 cksum=$(find $docker_dir/$image $docker_dir/scripts -type f | \
36 s3url="s3://$SCCACHE_BUCKET/docker/$cksum"
37 url="https://s3-us-west-1.amazonaws.com/$SCCACHE_BUCKET/docker/$cksum"
38 echo "Attempting to download $s3url"
40 loaded_images=$(curl $url | docker load | sed 's/.* sha/sha/')
42 echo "Downloaded containers:\n$loaded_images"
45 dockerfile="$docker_dir/$image/Dockerfile"
46 if [ -x /usr/bin/cygpath ]; then
47 context="`cygpath -w $docker_dir`"
48 dockerfile="`cygpath -w $dockerfile`"
59 if [ "$s3url" != "" ]; then
60 digest=$(docker inspect rust-ci --format '{{.Id}}')
61 echo "Built container $digest"
62 if ! grep -q "$digest" <(echo "$loaded_images"); then
63 echo "Uploading finished image to $s3url"
65 docker history -q rust-ci | \
72 echo "Looks like docker image is the same as before, not uploading"
75 elif [ -f "$docker_dir/disabled/$image/Dockerfile" ]; then
76 if [ -n "$TRAVIS_OS_NAME" ]; then
77 echo Cannot run disabled images on travis!
80 # retry messes with the pipe from tar to docker. Not needed on non-travis
81 # Transform changes the context of disabled Dockerfiles to match the enabled ones
82 tar --transform 's#^./disabled/#./#' -C $docker_dir -c . | docker \
86 -f "$image/Dockerfile" \
89 echo Invalid image: $image
93 travis_fold end build_docker
102 if [ "$SCCACHE_BUCKET" != "" ]; then
103 args="$args --env SCCACHE_BUCKET"
104 args="$args --env SCCACHE_REGION"
105 args="$args --env AWS_ACCESS_KEY_ID"
106 args="$args --env AWS_SECRET_ACCESS_KEY"
108 mkdir -p $HOME/.cache/sccache
109 args="$args --env SCCACHE_DIR=/sccache --volume $HOME/.cache/sccache:/sccache"
112 # Run containers as privileged as it should give them access to some more
113 # syscalls such as ptrace and whatnot. In the upgrade to LLVM 5.0 it was
114 # discovered that the leak sanitizer apparently needs these syscalls nowadays so
115 # we'll need `--privileged` for at least the `x86_64-gnu` builder, so this just
116 # goes ahead and sets it for all builders.
117 args="$args --privileged"
121 --volume "$root_dir:/checkout:ro" \
122 --volume "$objdir:/checkout/obj" \
123 --workdir /checkout/obj \
124 --env SRC=/checkout \
126 --env CARGO_HOME=/cargo \
129 --env LOCAL_USER_ID=`id -u` \
131 --env TRAVIS_BRANCH \
132 --env TOOLSTATE_REPO_ACCESS_TOKEN \
133 --env CI_JOB_NAME="${CI_JOB_NAME-$IMAGE}" \
134 --volume "$HOME/.cargo:/cargo" \
135 --volume "$HOME/rustsrc:$HOME/rustsrc" \
139 /checkout/src/ci/run.sh