eclair/analyze.sh: Factor out common code to analyze_common.sh

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Change-Id: Ib7fe2daea086dc5ed549f091928d751b4474d74e
diff --git a/eclair/analyze.sh b/eclair/analyze.sh
index f24f5c3..e5e52b7 100755
--- a/eclair/analyze.sh
+++ b/eclair/analyze.sh
@@ -19,32 +19,16 @@
     exit 1
 fi
 
-# Absolute path of the ECLAIR bin directory.
-ECLAIR_BIN_DIR="/opt/bugseng/eclair/bin"
+TF_CONFIG="$1"
 
-# Directory where this script resides: usually in a directory named "ECLAIR".
+# Directory where this script resides.
 SCRIPT_DIR="$(cd "$(dirname "$0")" ; echo "${PWD}")"
 
+. ${SCRIPT_DIR}/analyze_common.sh
+
 # Directory where to put all ECLAIR output and temporary files.
 ECLAIR_OUTPUT_DIR="${WORKSPACE}/ECLAIR/out"
 
-TF_CONFIG="$1"
-
-# Automatically export vars
-set -a
-source ${WORKSPACE}/tf-a-ci-scripts/tf_config/${TF_CONFIG}
-set +a
-
-export CC_ALIASES="${CROSS_COMPILE}gcc"
-export CXX_ALIASES="${CROSS_COMPILE}g++"
-export LD_ALIASES="${CROSS_COMPILE}ld"
-export AR_ALIASES="${CROSS_COMPILE}ar"
-export AS_ALIASES="${CROSS_COMPILE}as"
-export FILEMANIP_ALIASES="cp mv ${CROSS_COMPILE}objcopy"
-
-which ${CROSS_COMPILE}gcc
-${CROSS_COMPILE}gcc -v
-
 # ECLAIR binary data directory and workspace.
 export ECLAIR_DATA_DIR="${ECLAIR_OUTPUT_DIR}/.data"
 # ECLAIR workspace.
@@ -52,12 +36,6 @@
 # Destination file for the ECLAIR diagnostics.
 export ECLAIR_DIAGNOSTICS_OUTPUT="${ECLAIR_OUTPUT_DIR}/DIAGNOSTICS.txt"
 
-# Identifies the particular build of the project.
-export ECLAIR_PROJECT_NAME="TF_A_${TF_CONFIG}"
-# All paths mentioned in ECLAIR reports that are below this directory
-# will be presented as relative to ECLAIR_PROJECT_ROOT.
-export ECLAIR_PROJECT_ROOT="${WORKSPACE}/trusted-firmware-a"
-
 # Erase and recreate the output directory and the data directory.
 rm -rf "${ECLAIR_OUTPUT_DIR}"
 mkdir -p "${ECLAIR_DATA_DIR}"
diff --git a/eclair/analyze_common.sh b/eclair/analyze_common.sh
new file mode 100644
index 0000000..bef6cbd
--- /dev/null
+++ b/eclair/analyze_common.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+#
+# Copyright (c) 2021-2022 BUGSENG srl. All rights reserved.
+# Copyright (c) 2022 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Common code to setup analysis environment.
+
+# Absolute path of the ECLAIR bin directory.
+ECLAIR_BIN_DIR="/opt/bugseng/eclair/bin"
+
+# Automatically export vars
+set -a
+source ${WORKSPACE}/tf-a-ci-scripts/tf_config/${TF_CONFIG}
+set +a
+
+export CC_ALIASES="${CROSS_COMPILE}gcc"
+export CXX_ALIASES="${CROSS_COMPILE}g++"
+export LD_ALIASES="${CROSS_COMPILE}ld"
+export AR_ALIASES="${CROSS_COMPILE}ar"
+export AS_ALIASES="${CROSS_COMPILE}as"
+export FILEMANIP_ALIASES="cp mv ${CROSS_COMPILE}objcopy"
+
+which ${CROSS_COMPILE}gcc
+${CROSS_COMPILE}gcc -v
+
+# Identifies the particular build of the project.
+export ECLAIR_PROJECT_NAME="TF_A_${TF_CONFIG}"
+# All paths mentioned in ECLAIR reports that are below this directory
+# will be presented as relative to ECLAIR_PROJECT_ROOT.
+export ECLAIR_PROJECT_ROOT="${WORKSPACE}/trusted-firmware-a"