Zachary Leaf | 782c54a | 2024-09-24 14:33:24 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # Copyright (c) 2024 Arm Limited. All rights reserved. |
| 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | pre_tf_build() { |
Zachary Leaf | 2a7aebf | 2024-10-11 15:25:49 +0100 | [diff] [blame] | 8 | # pre_tf_build() and other call hooks are invoked from within subshells, so |
Tomás González | 024a556 | 2024-10-02 17:24:16 +0100 | [diff] [blame^] | 9 | # environment variables are lost when calling them (except $PATH somehow is |
Zachary Leaf | 2a7aebf | 2024-10-11 15:25:49 +0100 | [diff] [blame] | 10 | # retained) |
Tomás González | 024a556 | 2024-10-02 17:24:16 +0100 | [diff] [blame^] | 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 |
Zachary Leaf | 2a7aebf | 2024-10-11 15:25:49 +0100 | [diff] [blame] | 14 | # |
Tomás González | 024a556 | 2024-10-02 17:24:16 +0100 | [diff] [blame^] | 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 |
Zachary Leaf | 2a7aebf | 2024-10-11 15:25:49 +0100 | [diff] [blame] | 18 | # |
Tomás González | 024a556 | 2024-10-02 17:24:16 +0100 | [diff] [blame^] | 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 |
Zachary Leaf | 2a7aebf | 2024-10-11 15:25:49 +0100 | [diff] [blame] | 23 | # |
Tomás González | 024a556 | 2024-10-02 17:24:16 +0100 | [diff] [blame^] | 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 |
Zachary Leaf | 2a7aebf | 2024-10-11 15:25:49 +0100 | [diff] [blame] | 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 |
Tomás González | 024a556 | 2024-10-02 17:24:16 +0100 | [diff] [blame^] | 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 |
Zachary Leaf | 2a7aebf | 2024-10-11 15:25:49 +0100 | [diff] [blame] | 37 | export RUSTUP_HOME=/usr/local/rustup |
Tomás González | 024a556 | 2024-10-02 17:24:16 +0100 | [diff] [blame^] | 38 | make PLAT=qemu -C "$tf_root/rust" clippy |
Zachary Leaf | 782c54a | 2024-09-24 14:33:24 +0100 | [diff] [blame] | 39 | } |