aboutsummaryrefslogtreecommitdiff
path: root/ci/install.sh
blob: e4bd198d25543e5e5cc0aa13049217d57c03004d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# `install` phase: install stuff needed for the `script` phase

set -ex

case $TARGET in
  # Install standard libraries needed for cross compilation
  arm-unknown-linux-gnueabihf | \
  i686-apple-darwin | \
  i686-unknown-linux-gnu | \
  x86_64-unknown-linux-musl)
    if [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then
      # information about the cross compiler
      arm-linux-gnueabihf-gcc -v

      # tell cargo which linker to use for cross compilation
      mkdir -p .cargo
      cat >.cargo/config <<EOF
[target.$TARGET]
linker = "arm-linux-gnueabihf-gcc"
EOF
    fi

    # e.g. 1.6.0
    # doesn't work for nightly
    # version=$(rustc -V | cut -d' ' -f2)
    version=$(rustc -V | cut -d' ' -f2 | cut -d'-' -f2)

    if [ "$TARGET" = "x86_64-unknown-linux-musl" ]; then
        version="nightly"
    fi
    tarball=rust-std-${version}-${TARGET}

    curl -Os http://static.rust-lang.org/dist/${tarball}.tar.gz

    tar xzf ${tarball}.tar.gz

    ${tarball}/install.sh --prefix=$(rustc --print sysroot)

    rm -r ${tarball}
    rm ${tarball}.tar.gz
    ;;
  # Nothing to do for native builds
  *)
    ;;
esac

# TODO if you need to install extra stuff add it here