blob: 71908de1a25f51017035cd3cb52926e2c1beb6cc [file] [log] [blame]
Jon Flatley61a033f2020-02-05 14:28:51 -05001#!/bin/bash
2# Copyright lowRISC contributors.
3# Licensed under the Apache License, Version 2.0, see LICENSE for details.
4# SPDX-License-Identifier: Apache-2.0
5
6set -e
7
8# build_tock.sh is a wrapper to invoke Cargo from Meson. This is a workaround
9# solution to read the rust-toolchain file from the Tock repository and set the
10# RUSTFLAGS environment variable.
11
12TARGET="${1}"
Jon Flatley3d958882020-02-25 07:38:31 -050013MODE="${2}"
14MANIFEST_PATH="${3}"
15TARGET_DIR="${4}"
16TOOLCHAIN_FILE="${5}"
Jon Flatley1ea5bf02020-02-20 12:47:49 -050017export MESON_SOURCE_ROOT="${6}"
18export MESON_BUILD_ROOT="${7}"
19export RUSTFLAGS="${8}"
Jon Flatley3d958882020-02-25 07:38:31 -050020
21if [[ "${MODE}" == "release" ]]; then
22 RELEASE_FLAG="--release"
23fi
Jon Flatley61a033f2020-02-05 14:28:51 -050024
25cargo +"$(cat ${TOOLCHAIN_FILE})" build \
26 --target "${TARGET}" \
27 --manifest-path "${MANIFEST_PATH}" \
Jon Flatley3d958882020-02-25 07:38:31 -050028 --target-dir "${TARGET_DIR}" \
Silvestrs Timofejevsee0e68a2020-05-04 15:03:21 +010029 --features="${TOCK_FEATURES}" \
Jon Flatley3d958882020-02-25 07:38:31 -050030 ${RELEASE_FLAG}