Jayanth Dodderi Chidanand | 5babb77 | 2025-05-28 19:17:49 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # Copyright 2025 The Hafnium Authors. |
| 4 | # |
| 5 | # Use of this source code is governed by a BSD-style |
| 6 | # license that can be found in the LICENSE file or at |
| 7 | # https://opensource.org/licenses/BSD-3-Clause. |
| 8 | |
| 9 | |
| 10 | # ------------------------------------------------------------------------------ |
| 11 | # Note for Developers: |
| 12 | # |
| 13 | # This script sets up the Shrinkwrap environment for local standalone use. |
| 14 | # It is intended for local workflows where you run Shrinkwrap directly, |
| 15 | # outside of `hftest.py`, to build and run Hafnium along with TF-A and TF-A-Test |
| 16 | # projects — particularly when validating SPM-related test suites from TF-A-Test. |
| 17 | # |
| 18 | # If you are running hafnium CI tests via hftest.py, Shrinkwrap is automatically |
| 19 | # configured internally by the test script (hftest.py) — sourcing this script |
| 20 | # is optional. |
| 21 | # |
| 22 | # Usage: |
| 23 | # source ./../shrinkwrap_setup_env.sh |
| 24 | # shrinkwrap build ... |
| 25 | # shrinkwrap run ... |
| 26 | # |
| 27 | # This script ensures the necessary PATH and SHRINKWRAP_* variables are exported |
| 28 | # for use in manual shell workflows. |
| 29 | # Note: Hafnium CI and automation rely on the Python-based setup in |
| 30 | # `ShrinkwrapManager.setup_env()`. If any environment paths or variables change |
| 31 | # here, please update the Python logic accordingly — and vice versa. |
| 32 | |
| 33 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then |
| 34 | echo "Please source this script to retain environment changes:" |
| 35 | echo "source $0" |
| 36 | return 1 2>/dev/null || exit 1 |
| 37 | fi |
| 38 | |
| 39 | HAFNIUM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" |
| 40 | SHRINKWRAP_DIR="$HAFNIUM_ROOT/third_party" |
| 41 | |
| 42 | echo "[+] Hafnium root: $HAFNIUM_ROOT" |
| 43 | echo "[+] Shrinkwrap directory: $SHRINKWRAP_DIR" |
| 44 | |
| 45 | # Add Shrinkwrap to PATH |
| 46 | export PATH="$SHRINKWRAP_DIR/shrinkwrap/shrinkwrap:$PATH" |
| 47 | |
| 48 | # Set up Shrinkwrap environment variables for Build and Packaging |
| 49 | export SHRINKWRAP_CONFIG="${HAFNIUM_ROOT}/tools/shrinkwrap/configs" |
| 50 | export WORKSPACE="${HAFNIUM_ROOT}/out" |
| 51 | export SHRINKWRAP_BUILD="${WORKSPACE}/build" |
| 52 | export SHRINKWRAP_PACKAGE="${WORKSPACE}/package" |
| 53 | |
| 54 | echo "[+] Environment ready. Shrinkwrap is now in PATH." |
| 55 | |
| 56 | # Print Shrinkwrap version to confirm availability |
| 57 | echo -n "[+] Shrinkwrap version: " |
| 58 | shrinkwrap --version |