From afb07d59ffb07824a12e1ab5e88ac20f880d2995 Mon Sep 17 00:00:00 2001
From: Jorge Aparicio <japaricious@gmail.com>
Date: Thu, 6 Oct 2016 21:24:05 -0500
Subject: [PATCH] enable cache and drop target files

---
 .travis.yml                                |  9 ++++----
 Cargo.toml                                 |  4 ++--
 ci/docker/thumbv6m-none-eabi/Dockerfile    |  8 +++++--
 ci/docker/thumbv7em-none-eabi/Dockerfile   |  8 +++++--
 ci/docker/thumbv7em-none-eabihf/Dockerfile |  8 +++++--
 ci/docker/thumbv7m-none-eabi/Dockerfile    |  8 +++++--
 ci/run-docker.sh                           | 25 ++++++++++++++++------
 ci/run.sh                                  |  2 --
 thumbv6m-none-eabi.json                    |  9 --------
 thumbv7em-none-eabi.json                   |  8 -------
 thumbv7em-none-eabihf.json                 |  9 --------
 thumbv7m-none-eabi.json                    |  8 -------
 12 files changed, 49 insertions(+), 57 deletions(-)
 delete mode 100644 thumbv6m-none-eabi.json
 delete mode 100644 thumbv7em-none-eabi.json
 delete mode 100644 thumbv7em-none-eabihf.json
 delete mode 100644 thumbv7m-none-eabi.json

diff --git a/.travis.yml b/.travis.yml
index 1e9ac4f..b05f8d0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,3 +1,4 @@
+cache: cargo
 dist: trusty
 language: rust
 rust: nightly
@@ -5,20 +6,18 @@ services: docker
 sudo: required
 
 matrix:
-  exclude:
-    # first, clear the matrix
-    - rust: nightly
-  # then add the targets one by one
   include:
-    - env: TARGET=x86_64-unknown-linux-gnu
     - env: TARGET=thumbv6m-none-eabi
     - env: TARGET=thumbv7m-none-eabi
     - env: TARGET=thumbv7em-none-eabi
     - env: TARGET=thumbv7em-none-eabihf
+env: TARGET=x86_64-unknown-linux-gnu
 
 script:
   - cargo generate-lockfile
   - sh ci/run-docker.sh $TARGET
+  # Travis can't cache files that are not readable by "others"
+  - chmod -R a+r $HOME/.cargo
 
 branches:
   only:
diff --git a/Cargo.toml b/Cargo.toml
index b4e910a..de5489f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,9 +1,9 @@
 [package]
 authors = ["Jorge Aparicio <japaricious@gmail.com>"]
-documentation = "https://docs.rs/volatile-register"
 description = "Volatile access to memory mapped hardware registers"
-license = "MIT OR Apache-2.0"
+documentation = "https://docs.rs/volatile-register"
 keywords = ["volatile", "register"]
+license = "MIT OR Apache-2.0"
 name = "volatile-register"
 repository = "https://github.com/japaric/volatile-register"
 version = "0.1.1"
diff --git a/ci/docker/thumbv6m-none-eabi/Dockerfile b/ci/docker/thumbv6m-none-eabi/Dockerfile
index 25bf548..fa5439a 100644
--- a/ci/docker/thumbv6m-none-eabi/Dockerfile
+++ b/ci/docker/thumbv6m-none-eabi/Dockerfile
@@ -1,5 +1,9 @@
 FROM ubuntu:16.04
 RUN apt-get update
 RUN apt-get install -y --no-install-recommends \
-    ca-certificates curl libcurl4-openssl-dev libssh2-1
-ENV PATH=$PATH:/rust/bin
+    ca-certificates \
+    curl \
+    libcurl4-openssl-dev \
+    libssh2-1
+RUN curl -sf "https://raw.githubusercontent.com/japaric/rust-everywhere/master/install.sh" | \
+    bash -s -- --at /usr/bin --from japaric/xargo --for x86_64-unknown-linux-gnu --tag v0.1.13
diff --git a/ci/docker/thumbv7em-none-eabi/Dockerfile b/ci/docker/thumbv7em-none-eabi/Dockerfile
index 25bf548..fa5439a 100644
--- a/ci/docker/thumbv7em-none-eabi/Dockerfile
+++ b/ci/docker/thumbv7em-none-eabi/Dockerfile
@@ -1,5 +1,9 @@
 FROM ubuntu:16.04
 RUN apt-get update
 RUN apt-get install -y --no-install-recommends \
-    ca-certificates curl libcurl4-openssl-dev libssh2-1
-ENV PATH=$PATH:/rust/bin
+    ca-certificates \
+    curl \
+    libcurl4-openssl-dev \
+    libssh2-1
+RUN curl -sf "https://raw.githubusercontent.com/japaric/rust-everywhere/master/install.sh" | \
+    bash -s -- --at /usr/bin --from japaric/xargo --for x86_64-unknown-linux-gnu --tag v0.1.13
diff --git a/ci/docker/thumbv7em-none-eabihf/Dockerfile b/ci/docker/thumbv7em-none-eabihf/Dockerfile
index 25bf548..fa5439a 100644
--- a/ci/docker/thumbv7em-none-eabihf/Dockerfile
+++ b/ci/docker/thumbv7em-none-eabihf/Dockerfile
@@ -1,5 +1,9 @@
 FROM ubuntu:16.04
 RUN apt-get update
 RUN apt-get install -y --no-install-recommends \
-    ca-certificates curl libcurl4-openssl-dev libssh2-1
-ENV PATH=$PATH:/rust/bin
+    ca-certificates \
+    curl \
+    libcurl4-openssl-dev \
+    libssh2-1
+RUN curl -sf "https://raw.githubusercontent.com/japaric/rust-everywhere/master/install.sh" | \
+    bash -s -- --at /usr/bin --from japaric/xargo --for x86_64-unknown-linux-gnu --tag v0.1.13
diff --git a/ci/docker/thumbv7m-none-eabi/Dockerfile b/ci/docker/thumbv7m-none-eabi/Dockerfile
index 25bf548..fa5439a 100644
--- a/ci/docker/thumbv7m-none-eabi/Dockerfile
+++ b/ci/docker/thumbv7m-none-eabi/Dockerfile
@@ -1,5 +1,9 @@
 FROM ubuntu:16.04
 RUN apt-get update
 RUN apt-get install -y --no-install-recommends \
-    ca-certificates curl libcurl4-openssl-dev libssh2-1
-ENV PATH=$PATH:/rust/bin
+    ca-certificates \
+    curl \
+    libcurl4-openssl-dev \
+    libssh2-1
+RUN curl -sf "https://raw.githubusercontent.com/japaric/rust-everywhere/master/install.sh" | \
+    bash -s -- --at /usr/bin --from japaric/xargo --for x86_64-unknown-linux-gnu --tag v0.1.13
diff --git a/ci/run-docker.sh b/ci/run-docker.sh
index 85b2c28..5a4762d 100755
--- a/ci/run-docker.sh
+++ b/ci/run-docker.sh
@@ -1,18 +1,31 @@
 set -ex
 
 run() {
-    echo $1
+    local target=$1
 
-    docker build -t rust ci/docker/$1
+    echo $target
+
+    # This directory needs to exist before calling docker, otherwise docker will create it but it
+    # will be owned by root
+    mkdir -p target
+
+    docker build -t $target ci/docker/$target
     docker run \
-           -v `rustc --print sysroot`:/rust:ro \
+           --rm \
+           --user $(id -u):$(id -g) \
+           -e CARGO_HOME=/cargo \
+           -e CARGO_TARGET_DIR=/target \
+           -e HOME=/tmp \
+           -v $HOME/.cargo:/cargo \
+           -v `pwd`/target:/target \
            -v `pwd`:/checkout:ro \
-           -e CARGO_TARGET_DIR=/tmp/target \
+           -v `rustc --print sysroot`:/rust:ro \
            -w /checkout \
-           -it rust \
-           ci/run.sh $1
+           -it $target \
+           sh -c "PATH=\$PATH:/rust/bin ci/run.sh $target"
 }
 
+
 if [ -z "$1" ]; then
     for d in `ls ci/docker/`; do
         run $d
diff --git a/ci/run.sh b/ci/run.sh
index c1f2a5a..fdd3fd2 100755
--- a/ci/run.sh
+++ b/ci/run.sh
@@ -4,8 +4,6 @@ set -ex
 
 case $1 in
     thumbv*)
-        curl -sf "https://raw.githubusercontent.com/japaric/rust-everywhere/master/install.sh" | \
-            bash -s -- --at /usr/bin --from japaric/xargo --tag v0.1.9
         xargo build --target $1
     ;;
     *)
diff --git a/thumbv6m-none-eabi.json b/thumbv6m-none-eabi.json
deleted file mode 100644
index 4a31e30..0000000
--- a/thumbv6m-none-eabi.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
-    "arch": "arm",
-    "data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64",
-    "features": "+strict-align",
-    "llvm-target": "thumbv6m-none-eabi",
-    "os": "none",
-    "target-endian": "little",
-    "target-pointer-width": "32"
-}
diff --git a/thumbv7em-none-eabi.json b/thumbv7em-none-eabi.json
deleted file mode 100644
index ce49c83..0000000
--- a/thumbv7em-none-eabi.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-    "arch": "arm",
-    "data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64",
-    "llvm-target": "thumbv7em-none-eabi",
-    "os": "none",
-    "target-endian": "little",
-    "target-pointer-width": "32"
-}
diff --git a/thumbv7em-none-eabihf.json b/thumbv7em-none-eabihf.json
deleted file mode 100644
index bb0b87e..0000000
--- a/thumbv7em-none-eabihf.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
-    "arch": "arm",
-    "data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64",
-    "features": "+vfp4",
-    "llvm-target": "thumbv7em-none-eabihf",
-    "os": "none",
-    "target-endian": "little",
-    "target-pointer-width": "32"
-}
diff --git a/thumbv7m-none-eabi.json b/thumbv7m-none-eabi.json
deleted file mode 100644
index 313a5e6..0000000
--- a/thumbv7m-none-eabi.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-    "arch": "arm",
-    "data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64",
-    "llvm-target": "thumbv7m-none-eabi",
-    "os": "none",
-    "target-endian": "little",
-    "target-pointer-width": "32"
-}
-- 
GitLab