17ec681f3Smrg#!/bin/bash
27ec681f3Smrg
37ec681f3Smrg# Note that this script is not actually "building" rust, but build- is the
47ec681f3Smrg# convention for the shared helpers for putting stuff in our containers.
57ec681f3Smrg
67ec681f3Smrgset -ex
77ec681f3Smrg
87ec681f3Smrg# cargo (and rustup) wants to store stuff in $HOME/.cargo, and binaries in
97ec681f3Smrg# $HOME/.cargo/bin.  Make bin a link to a public bin directory so the commands
107ec681f3Smrg# are just available to all build jobs.
117ec681f3Smrgmkdir -p $HOME/.cargo
127ec681f3Smrgln -s /usr/local/bin $HOME/.cargo/bin
137ec681f3Smrg
147ec681f3Smrg# For rust in Mesa, we use rustup to install.  This lets us pick an arbitrary
157ec681f3Smrg# version of the compiler, rather than whatever the container's Debian comes
167ec681f3Smrg# with.
177ec681f3Smrg#
187ec681f3Smrg# Pick the rust compiler (1.48) available in Debian stable, and pick a specific
197ec681f3Smrg# snapshot from rustup so the compiler doesn't drift on us.
207ec681f3Smrgwget https://sh.rustup.rs -O - | \
217ec681f3Smrg    sh -s -- -y --default-toolchain 1.49.0-2020-12-31
227ec681f3Smrg
237ec681f3Smrg# Set up a config script for cross compiling -- cargo needs your system cc for
247ec681f3Smrg# linking in cross builds, but doesn't know what you want to use for system cc.
257ec681f3Smrgcat > /root/.cargo/config <<EOF
267ec681f3Smrg[target.armv7-unknown-linux-gnueabihf]
277ec681f3Smrglinker = "arm-linux-gnueabihf-gcc"
287ec681f3Smrg
297ec681f3Smrg[target.aarch64-unknown-linux-gnu]
307ec681f3Smrglinker = "aarch64-linux-gnu-gcc"
317ec681f3SmrgEOF
32