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