blob: ec066014cb3636a8c6a5e35bf926c607a5c819fc [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() {
Zachary Leaf2a7aebf2024-10-11 15:25:49 +01008 # pre_tf_build() and other call hooks are invoked from within subshells, so
Tomás González024a5562024-10-02 17:24:16 +01009 # environment variables are lost when calling them (except $PATH somehow is
Zachary Leaf2a7aebf2024-10-11 15:25:49 +010010 # retained)
Tomás González024a5562024-10-02 17:24:16 +010011 # - 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
Zachary Leaf2a7aebf2024-10-11 15:25:49 +010014 #
Tomás González024a5562024-10-02 17:24:16 +010015 # 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
Zachary Leaf2a7aebf2024-10-11 15:25:49 +010018 #
Tomás González024a5562024-10-02 17:24:16 +010019 # 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
Zachary Leaf2a7aebf2024-10-11 15:25:49 +010023 #
Tomás González024a5562024-10-02 17:24:16 +010024 # 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
Zachary Leaf2a7aebf2024-10-11 15:25:49 +010027 #
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
Tomás González024a5562024-10-02 17:24:16 +010032 #
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
Zachary Leaf2a7aebf2024-10-11 15:25:49 +010037 export RUSTUP_HOME=/usr/local/rustup
Tomás González024a5562024-10-02 17:24:16 +010038 make PLAT=qemu -C "$tf_root/rust" clippy
Zachary Leaf782c54a2024-09-24 14:33:24 +010039}