1bf215546Sopenharmony_ci#!/bin/bash 2bf215546Sopenharmony_ci 3bf215546Sopenharmony_ci# Note that this script is not actually "building" rust, but build- is the 4bf215546Sopenharmony_ci# convention for the shared helpers for putting stuff in our containers. 5bf215546Sopenharmony_ci 6bf215546Sopenharmony_ciset -ex 7bf215546Sopenharmony_ci 8bf215546Sopenharmony_ci# cargo (and rustup) wants to store stuff in $HOME/.cargo, and binaries in 9bf215546Sopenharmony_ci# $HOME/.cargo/bin. Make bin a link to a public bin directory so the commands 10bf215546Sopenharmony_ci# are just available to all build jobs. 11bf215546Sopenharmony_cimkdir -p $HOME/.cargo 12bf215546Sopenharmony_ciln -s /usr/local/bin $HOME/.cargo/bin 13bf215546Sopenharmony_ci 14bf215546Sopenharmony_ci# For rust in Mesa, we use rustup to install. This lets us pick an arbitrary 15bf215546Sopenharmony_ci# version of the compiler, rather than whatever the container's Debian comes 16bf215546Sopenharmony_ci# with. 17bf215546Sopenharmony_ci# 18bf215546Sopenharmony_ci# Pick the rust compiler (1.48) available in Debian stable, and pick a specific 19bf215546Sopenharmony_ci# snapshot from rustup so the compiler doesn't drift on us. 20bf215546Sopenharmony_ciwget https://sh.rustup.rs -O - | \ 21bf215546Sopenharmony_ci sh -s -- -y --default-toolchain 1.49.0-2020-12-31 22bf215546Sopenharmony_ci 23bf215546Sopenharmony_ci# Set up a config script for cross compiling -- cargo needs your system cc for 24bf215546Sopenharmony_ci# linking in cross builds, but doesn't know what you want to use for system cc. 25bf215546Sopenharmony_cicat > /root/.cargo/config <<EOF 26bf215546Sopenharmony_ci[target.armv7-unknown-linux-gnueabihf] 27bf215546Sopenharmony_cilinker = "arm-linux-gnueabihf-gcc" 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci[target.aarch64-unknown-linux-gnu] 30bf215546Sopenharmony_cilinker = "aarch64-linux-gnu-gcc" 31bf215546Sopenharmony_ciEOF 32