Setup build scripts for Tock
Tock uses Make to invoke Cargo as its build systems. There's no real
reason to use Make on the out-of-tree opentitan board, but there is no
avoiding Cargo.
Attempt to draft a meson.build file that produces meaningful artifacts
from the Tock build. A small script at util/build_tock.sh is used to
wrap the actual call to Cargo as a workaround for some shortcomings of
Meson. build_tock.sh is intentionally kept as small as possible.
The build.meson file adds a few targets to build Tock and export the
resulting .elf and .bin files to build-bin/. The Tock build does not
produce a disassembled .dis file as generating it makes the build much
slower.
Signed-off-by: Jon Flatley <jflat@google.com>
diff --git a/util/build_tock.sh b/util/build_tock.sh
new file mode 100755
index 0000000..148bb1f
--- /dev/null
+++ b/util/build_tock.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+# Copyright lowRISC contributors.
+# Licensed under the Apache License, Version 2.0, see LICENSE for details.
+# SPDX-License-Identifier: Apache-2.0
+
+set -e
+
+# build_tock.sh is a wrapper to invoke Cargo from Meson. This is a workaround
+# solution to read the rust-toolchain file from the Tock repository and set the
+# RUSTFLAGS environment variable.
+
+TARGET="${1}"
+MANIFEST_PATH="${2}"
+TARGET_DIR="${3}"
+TOOLCHAIN_FILE="${4}"
+export RUSTFLAGS="${5}"
+
+cargo +"$(cat ${TOOLCHAIN_FILE})" build \
+ --target "${TARGET}" \
+ --manifest-path "${MANIFEST_PATH}" \
+ --target-dir "${TARGET_DIR}"