From 182d50719dca5eab2e23974ba6097da3cc8ac7a5 Mon Sep 17 00:00:00 2001 From: David Mapstone <david@mapstone.me> Date: Tue, 28 Feb 2023 15:06:58 +0000 Subject: [PATCH] Added Environment Sourcing Script --- set_env.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 set_env.sh diff --git a/set_env.sh b/set_env.sh new file mode 100644 index 0000000..809582f --- /dev/null +++ b/set_env.sh @@ -0,0 +1,40 @@ +#----------------------------------------------------------------------------- +# SoC Labs Environment Setup Script +# A joint work commissioned on behalf of SoC Labs, under Arm Academic Access license. +# +# Contributors +# +# David Mapstone (d.a.mapstone@soton.ac.uk) +# +# Copyright 2023, SoC Labs (www.soclabs.org) +#----------------------------------------------------------------------------- +#!/bin/bash + +# Get Root Location of Repository +if [ -z $DESIGN_ROOT ]; then + # If $DESIGN_ROOT hasn't been set yet + DESIGN_ROOT=`git rev-parse --show-superproject-working-tree` + if [ -z $DESIGN_ROOT ]; then + # If not in a submodule + DESIGN_ROOT=`git rev-parse --show-toplevel` + fi +fi + +# Set Environment Variable for this Repository +export WRAP_ACC_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" + +# If this Repo is root of workspace +if [ $WRAP_ACC_DIR = $DESIGN_ROOT ]; then + echo "Design Workspace: $WRAP_ACC_DIR" + export $DESIGN_ROOT +fi + +# Source environment variables for all submodules +for d in $WRAP_ACC_DIR/* ; do + if [ -f "$d/.git" ]; then + if [ -f "$d/set_env.sh" ]; then + # If .git file exists - submodule + source $d/set_env.sh + fi + fi +done \ No newline at end of file -- GitLab