]> git.lizzy.rs Git - rust.git/blob - src/ci/docker/run.sh
Rollup merge of #44562 - eddyb:ugh-rustdoc, r=nikomatsakis
[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"
61     args="$args --env SCCACHE_REGION"
62     args="$args --env AWS_ACCESS_KEY_ID"
63     args="$args --env AWS_SECRET_ACCESS_KEY"
64     args="$args --env SCCACHE_ERROR_LOG=/tmp/sccache/sccache.log"
65     args="$args --volume $objdir/tmp:/tmp/sccache"
66 else
67     mkdir -p $HOME/.cache/sccache
68     args="$args --env SCCACHE_DIR=/sccache --volume $HOME/.cache/sccache:/sccache"
69 fi
70
71 # Run containers as privileged as it should give them access to some more
72 # syscalls such as ptrace and whatnot. In the upgrade to LLVM 5.0 it was
73 # discovered that the leak sanitizer apparently needs these syscalls nowadays so
74 # we'll need `--privileged` for at least the `x86_64-gnu` builder, so this just
75 # goes ahead and sets it for all builders.
76 args="$args --privileged"
77
78 exec docker \
79   run \
80   --volume "$root_dir:/checkout:ro" \
81   --volume "$objdir:/checkout/obj" \
82   --workdir /checkout/obj \
83   --env SRC=/checkout \
84   $args \
85   --env CARGO_HOME=/cargo \
86   --env DEPLOY \
87   --env DEPLOY_ALT \
88   --env LOCAL_USER_ID=`id -u` \
89   --env TRAVIS \
90   --env TRAVIS_BRANCH \
91   --volume "$HOME/.cargo:/cargo" \
92   --volume "$HOME/rustsrc:$HOME/rustsrc" \
93   --init \
94   --rm \
95   rust-ci \
96   /checkout/src/ci/run.sh