Silvestrs Timofejevs | f590dc7 | 2020-10-26 15:12:40 +0000 | [diff] [blame] | 1 | #!/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 | |
| 6 | set -e |
| 7 | |
| 8 | # invoke_cargo.sh is a wrapper to invoke Cargo from Meson. This is a workaround |
| 9 | # solution to read the rust-toolchain file and set the the relevant environment |
| 10 | # variables. |
| 11 | |
| 12 | CARGO="${1}" |
| 13 | CARGO_FLAGS="${2}" |
| 14 | export RUSTFLAGS="${3}" |
| 15 | |
| 16 | TOOLCHAIN_FILE="${4}" |
| 17 | if [[ -f $TOOLCHAIN_FILE ]]; then |
| 18 | TOOLCHAIN="$(cat ${TOOLCHAIN_FILE})" |
| 19 | fi |
| 20 | |
| 21 | export MESON_SOURCE_ROOT="${5}" |
| 22 | export MESON_BUILD_ROOT="${6}" |
| 23 | |
Silvestrs Timofejevs | f00a443 | 2021-03-30 17:53:34 +0100 | [diff] [blame] | 24 | if [ "${CARGO_TEST}" == 1 ]; then |
| 25 | echo "CARGO TEST BUILD!" |
| 26 | "${CARGO}" +"${TOOLCHAIN}" test ${CARGO_FLAGS} --workspace |
| 27 | "${CARGO}" +"${TOOLCHAIN}" build ${CARGO_FLAGS} |
| 28 | else |
| 29 | "${CARGO}" +"${TOOLCHAIN}" build ${CARGO_FLAGS} |
| 30 | fi |