• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2# Copyright 2021 The ChromiumOS Authors
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5set -ex
6
7# mdformat is not available as a debian package. Install via pipx instead.
8pipx install mdformat
9pipx inject mdformat mdformat-gfm mdformat-footnote
10pipx ensurepath
11
12# Install rustup if not available yet
13if ! command -v rustup &>/dev/null; then
14    wget "https://static.rust-lang.org/rustup/archive/1.25.1/x86_64-unknown-linux-gnu/rustup-init"
15    echo "5cc9ffd1026e82e7fb2eec2121ad71f4b0f044e88bca39207b3f6b769aaa799c *rustup-init" | sha256sum -c -
16    chmod +x rustup-init
17    ./rustup-init -y --no-modify-path --profile minimal --default-toolchain none
18    source ${CARGO_HOME:-~/.cargo}/env
19    rm rustup-init
20fi
21
22# Install required rust components.
23# This will also ensure the toolchain required by ./rust-toolchain is installed.
24rustup component add cargo clippy rustfmt
25
26# LLVM tools are used to generate and process coverage files
27rustup component add llvm-tools-preview
28
29# Allow cross-compilation via mingw64
30rustup target add x86_64-pc-windows-gnu
31
32# Allow cross-compilation for android
33rustup target add aarch64-linux-android
34
35# Install nightly toolchain. Only used for rustfmt
36rustup toolchain install nightly --profile minimal --component rustfmt
37
38# Cargo extension to install binary packages from github
39curl -L https://github.com/cargo-bins/cargo-binstall/releases/download/v1.4.4/cargo-binstall-x86_64-unknown-linux-gnu.tgz | tar -xzvvf - -C ${CARGO_HOME:-~/.cargo}/bin
40
41# The bindgen tool is required to build a crosvm dependency.
42cargo binstall --no-confirm bindgen-cli --version "0.68.1"
43
44# binutils are wrappers to call the rustup bundled versions of llvm tools.
45cargo binstall --no-confirm cargo-binutils
46
47# The mdbook tools are used to build the crosvm book.
48cargo binstall --no-confirm mdbook --version "0.4.25"
49cargo binstall --no-confirm mdbook-linkcheck --version "0.7.7"
50
51# Nextest is an improved test runner for cargo
52cargo binstall --no-confirm cargo-nextest --version "0.9.49"
53
54Red='\033[0;31m'
55Reset='\033[0m'
56# Check if submodules were initialized. If a submodule is not initialized, git
57# submodule status will be prefixed with `-`
58if git submodule status | grep '^-'; then
59    >&2 echo -e "${Red}ERROR${Reset}: Git modules were not initialized. Run 'git submodule update --init' to initialize them."
60fi
61