blob: f24f5c3ec4572b1f64fb6d4f162d4ed004131036 [file] [log] [blame]
Paul Sokolovsky3486b4e2022-09-06 13:33:57 +03001#!/bin/bash
2#
3# Copyright (c) 2021-2022 BUGSENG srl. All rights reserved.
4# Copyright (c) 2022 Arm Limited. All rights reserved.
5#
6# SPDX-License-Identifier: BSD-3-Clause
7
8# Stop immediately if any executed command has exit status different from 0.
9set -ex
10
11usage() {
12 echo "Usage: analyze.sh CONF" 1>&2
13 echo " where CONF is the build configuration id passed to build.sh" 1>&2
14}
15
16if [ $# -ne 1 ]
17then
18 usage
19 exit 1
20fi
21
22# Absolute path of the ECLAIR bin directory.
23ECLAIR_BIN_DIR="/opt/bugseng/eclair/bin"
24
25# Directory where this script resides: usually in a directory named "ECLAIR".
26SCRIPT_DIR="$(cd "$(dirname "$0")" ; echo "${PWD}")"
27
28# Directory where to put all ECLAIR output and temporary files.
29ECLAIR_OUTPUT_DIR="${WORKSPACE}/ECLAIR/out"
30
Paul Sokolovskyb3f73992022-10-05 18:27:22 +030031TF_CONFIG="$1"
Paul Sokolovsky3486b4e2022-09-06 13:33:57 +030032
Paul Sokolovskyb3f73992022-10-05 18:27:22 +030033# Automatically export vars
34set -a
35source ${WORKSPACE}/tf-a-ci-scripts/tf_config/${TF_CONFIG}
36set +a
Paul Sokolovsky3486b4e2022-09-06 13:33:57 +030037
38export CC_ALIASES="${CROSS_COMPILE}gcc"
39export CXX_ALIASES="${CROSS_COMPILE}g++"
40export LD_ALIASES="${CROSS_COMPILE}ld"
41export AR_ALIASES="${CROSS_COMPILE}ar"
42export AS_ALIASES="${CROSS_COMPILE}as"
43export FILEMANIP_ALIASES="cp mv ${CROSS_COMPILE}objcopy"
44
45which ${CROSS_COMPILE}gcc
46${CROSS_COMPILE}gcc -v
47
48# ECLAIR binary data directory and workspace.
49export ECLAIR_DATA_DIR="${ECLAIR_OUTPUT_DIR}/.data"
50# ECLAIR workspace.
51export ECLAIR_WORKSPACE="${ECLAIR_DATA_DIR}/eclair_workspace"
52# Destination file for the ECLAIR diagnostics.
53export ECLAIR_DIAGNOSTICS_OUTPUT="${ECLAIR_OUTPUT_DIR}/DIAGNOSTICS.txt"
54
55# Identifies the particular build of the project.
Paul Sokolovskyb3f73992022-10-05 18:27:22 +030056export ECLAIR_PROJECT_NAME="TF_A_${TF_CONFIG}"
Paul Sokolovsky3486b4e2022-09-06 13:33:57 +030057# All paths mentioned in ECLAIR reports that are below this directory
58# will be presented as relative to ECLAIR_PROJECT_ROOT.
59export ECLAIR_PROJECT_ROOT="${WORKSPACE}/trusted-firmware-a"
60
61# Erase and recreate the output directory and the data directory.
62rm -rf "${ECLAIR_OUTPUT_DIR}"
63mkdir -p "${ECLAIR_DATA_DIR}"
64
65(
66 # Perform the build (from scratch) in an ECLAIR environment.
67 "${ECLAIR_BIN_DIR}/eclair_env" \
68 "-eval_file='${SCRIPT_DIR}/MISRA_C_2012_selection.ecl'" \
Paul Sokolovskyb3f73992022-10-05 18:27:22 +030069 -- "${SCRIPT_DIR}/build-tfa.sh" "${TF_CONFIG}"
Paul Sokolovsky3486b4e2022-09-06 13:33:57 +030070)
71
72# Create the project database.
73PROJECT_ECD="${ECLAIR_OUTPUT_DIR}/PROJECT.ecd"
74find "${ECLAIR_DATA_DIR}" -maxdepth 1 -name "FRAME.*.ecb" \
75 | sort | xargs cat \
76 | "${ECLAIR_BIN_DIR}/eclair_report" \
77 "-create_db='${PROJECT_ECD}'" \
78 -load=/dev/stdin
79
80
81function make_self_contained() {
82 dir=$1
83 mkdir -p $dir/lib
84
85 cp -r /opt/bugseng/eclair-3.12.0/lib/html $dir/lib
86
87 ${SCRIPT_DIR}/relativize_urls.py $dir
88}
89
90${ECLAIR_BIN_DIR}/eclair_report -db=${PROJECT_ECD} \
91 -summary_txt=${ECLAIR_OUTPUT_DIR}/../summary_txt \
92 -full_txt=${ECLAIR_OUTPUT_DIR}/../full_txt \
93 -full_html=${ECLAIR_OUTPUT_DIR}/../full_html
94
95# summary_txt contains just a single report file not present in full_txt, move it there and be done with it.
96mv ${ECLAIR_OUTPUT_DIR}/../summary_txt/by_service.txt ${ECLAIR_OUTPUT_DIR}/../full_txt/
97rm -rf ${ECLAIR_OUTPUT_DIR}/../summary_txt
98make_self_contained ${ECLAIR_OUTPUT_DIR}/../full_html
99
100# Create the Jenkins reports file.
101JENKINS_XML="${ECLAIR_OUTPUT_DIR}/../jenkins.xml"
102${ECLAIR_BIN_DIR}/eclair_report -db=${PROJECT_ECD} -reports_jenkins=${JENKINS_XML}
103
104
105# Compress database to take less disk space in Jenkins archive
106xz ${PROJECT_ECD}