]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/run.sh
Auto merge of #43568 - arielb1:constant-recovery, r=eddyb
[rust.git] / src / ci / docker / run.sh
1 #!/bin/bash
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.
5 #
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.
11
12 set -e
13
14 script=`cd $(dirname $0) && pwd`/`basename $0`
15 image=$1
16
17 docker_dir="`dirname $script`"
18 ci_dir="`dirname $docker_dir`"
19 src_dir="`dirname $ci_dir`"
20 root_dir="`dirname $src_dir`"
21
22 source "$ci_dir/shared.sh"
23
24 travis_fold start build_docker
25 travis_time_start
26
27 if [ -f "$docker_dir/$image/Dockerfile" ]; then
28     retry docker \
29       build \
30       --rm \
31       -t rust-ci \
32       -f "$docker_dir/$image/Dockerfile" \
33       "$docker_dir"
34 elif [ -f "$docker_dir/disabled/$image/Dockerfile" ]; then
35     if [ -n "$TRAVIS_OS_NAME" ]; then
36         echo Cannot run disabled images on travis!
37         exit 1
38     fi
39     retry docker \
40       build \
41       --rm \
42       -t rust-ci \
43       -f "$docker_dir/disabled/$image/Dockerfile" \
44       "$docker_dir"
45 else
46     echo Invalid image: $image
47     exit 1
48 fi
49
50 travis_fold end build_docker
51 travis_time_finish
52
53 objdir=$root_dir/obj
54
55 mkdir -p $HOME/.cargo
56 mkdir -p $objdir/tmp
57
58 args=
59 if [ "$SCCACHE_BUCKET" != "" ]; then
60     args="$args --env SCCACHE_BUCKET=$SCCACHE_BUCKET"
61     args="$args --env AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID"
62     args="$args --env AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY"
63     args="$args --env SCCACHE_ERROR_LOG=/tmp/sccache/sccache.log"
64     args="$args --volume $objdir/tmp:/tmp/sccache"
65 else
66     mkdir -p $HOME/.cache/sccache
67     args="$args --env SCCACHE_DIR=/sccache --volume $HOME/.cache/sccache:/sccache"
68 fi
69
70 # Run containers as privileged as it should give them access to some more
71 # syscalls such as ptrace and whatnot. In the upgrade to LLVM 5.0 it was
72 # discovered that the leak sanitizer apparently needs these syscalls nowadays so
73 # we'll need `--privileged` for at least the `x86_64-gnu` builder, so this just
74 # goes ahead and sets it for all builders.
75 args="$args --privileged"
76
77 exec docker \
78   run \
79   --volume "$root_dir:/checkout:ro" \
80   --volume "$objdir:/checkout/obj" \
81   --workdir /checkout/obj \
82   --env SRC=/checkout \
83   $args \
84   --env CARGO_HOME=/cargo \
85   --env DEPLOY=$DEPLOY \
86   --env DEPLOY_ALT=$DEPLOY_ALT \
87   --env LOCAL_USER_ID=`id -u` \
88   --env TRAVIS=${TRAVIS-false} \
89   --env TRAVIS_BRANCH \
90   --volume "$HOME/.cargo:/cargo" \
91   --volume "$HOME/rustsrc:$HOME/rustsrc" \
92   --rm \
93   rust-ci \
94   /checkout/src/ci/run.sh