blob: 441df716a960ade6795e5411713c2c5524709ed5 [file] [log] [blame]
Jayanth Dodderi Chidanand5babb772025-05-28 19:17:49 +01001#!/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
33if [[ "${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
37fi
38
39HAFNIUM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
40SHRINKWRAP_DIR="$HAFNIUM_ROOT/third_party"
41
42echo "[+] Hafnium root: $HAFNIUM_ROOT"
43echo "[+] Shrinkwrap directory: $SHRINKWRAP_DIR"
44
45# Add Shrinkwrap to PATH
46export PATH="$SHRINKWRAP_DIR/shrinkwrap/shrinkwrap:$PATH"
47
48# Set up Shrinkwrap environment variables for Build and Packaging
49export SHRINKWRAP_CONFIG="${HAFNIUM_ROOT}/tools/shrinkwrap/configs"
50export WORKSPACE="${HAFNIUM_ROOT}/out"
51export SHRINKWRAP_BUILD="${WORKSPACE}/build"
52export SHRINKWRAP_PACKAGE="${WORKSPACE}/package"
53
54echo "[+] Environment ready. Shrinkwrap is now in PATH."
55
56# Print Shrinkwrap version to confirm availability
57echo -n "[+] Shrinkwrap version: "
58shrinkwrap --version