blob: 1ca7bdee43ceb73a7809a20b0746ebd93056d16b [file] [log] [blame]
Tomás González024a5562024-10-02 17:24:16 +01001#!/usr/bin/env bash
Zachary Leaf782c54a2024-09-24 14:33:24 +01002#
3# Copyright (c) 2024 Arm Limited. All rights reserved.
4#
5# SPDX-License-Identifier: BSD-3-Clause
6#
Tomás González024a5562024-10-02 17:24:16 +01007pre_tf_build() {
8 # pre_tf_build() and other call hooks are invoked from within subshells, so
9 # environment variables are lost when calling them (except $PATH somehow is
10 # retained)
11 # - use `set_hook_var` to propagate to other levels, e.g. the actual
12 # tf_build() stage
13 # - use `export $VAR=` for use inside this pre_tf_build() stage
14 #
15 # In the CI Dockerfile, rustup is installed by the root user in the
16 # non-default location /usr/local/rustup, so $RUSTUP_HOME is required to
17 # access rust config e.g. default toolchains and run cargo
18 #
19 # Leave $CARGO_HOME blank so when this script is run in CI by the buildslave
20 # user, it uses the default /home/buildslave/.cargo directory which it has
21 # write permissions for - that allows it to download new crates during
22 # compilation
23 #
24 # The buildslave user does not have write permissions to the default
25 # $CARGO_HOME=/usr/local/cargo dir and so will error when trying to download
26 # new crates otherwise
27 #
28 # note: $PATH still contains /usr/local/cargo/bin at this point so cargo is
29 # still run via the root installation
30 #
31 # see https://github.com/rust-lang/rustup/issues/1085
32 #
33 # set_hook_var propagates RUSTUP_HOME var to lower levels...
34 set_hook_var RUSTUP_HOME /usr/local/rustup
35 # ...but not to pre_tf_build() - explicit exporting is required to run
36 # clippy here
37 export RUSTUP_HOME=/usr/local/rustup
38 make PLAT=fvp -C "$tf_root/rust" clippy
39}