blob: 666a79b68227e6f1ff8eac75e74ee24371eba3b8 [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
31export CROSS_COMPILE="/opt/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf/bin/aarch64-none-elf-"
32
33PLAT="$1"
34
35export CC_ALIASES="${CROSS_COMPILE}gcc"
36export CXX_ALIASES="${CROSS_COMPILE}g++"
37export LD_ALIASES="${CROSS_COMPILE}ld"
38export AR_ALIASES="${CROSS_COMPILE}ar"
39export AS_ALIASES="${CROSS_COMPILE}as"
40export FILEMANIP_ALIASES="cp mv ${CROSS_COMPILE}objcopy"
41
42which ${CROSS_COMPILE}gcc
43${CROSS_COMPILE}gcc -v
44
45# ECLAIR binary data directory and workspace.
46export ECLAIR_DATA_DIR="${ECLAIR_OUTPUT_DIR}/.data"
47# ECLAIR workspace.
48export ECLAIR_WORKSPACE="${ECLAIR_DATA_DIR}/eclair_workspace"
49# Destination file for the ECLAIR diagnostics.
50export ECLAIR_DIAGNOSTICS_OUTPUT="${ECLAIR_OUTPUT_DIR}/DIAGNOSTICS.txt"
51
52# Identifies the particular build of the project.
53export ECLAIR_PROJECT_NAME="TF_A_${PLAT}"
54# All paths mentioned in ECLAIR reports that are below this directory
55# will be presented as relative to ECLAIR_PROJECT_ROOT.
56export ECLAIR_PROJECT_ROOT="${WORKSPACE}/trusted-firmware-a"
57
58# Erase and recreate the output directory and the data directory.
59rm -rf "${ECLAIR_OUTPUT_DIR}"
60mkdir -p "${ECLAIR_DATA_DIR}"
61
62(
63 # Perform the build (from scratch) in an ECLAIR environment.
64 "${ECLAIR_BIN_DIR}/eclair_env" \
65 "-eval_file='${SCRIPT_DIR}/MISRA_C_2012_selection.ecl'" \
66 -- "${SCRIPT_DIR}/build-tfa.sh" "${PLAT}"
67)
68
69# Create the project database.
70PROJECT_ECD="${ECLAIR_OUTPUT_DIR}/PROJECT.ecd"
71find "${ECLAIR_DATA_DIR}" -maxdepth 1 -name "FRAME.*.ecb" \
72 | sort | xargs cat \
73 | "${ECLAIR_BIN_DIR}/eclair_report" \
74 "-create_db='${PROJECT_ECD}'" \
75 -load=/dev/stdin
76
77
78function make_self_contained() {
79 dir=$1
80 mkdir -p $dir/lib
81
82 cp -r /opt/bugseng/eclair-3.12.0/lib/html $dir/lib
83
84 ${SCRIPT_DIR}/relativize_urls.py $dir
85}
86
87${ECLAIR_BIN_DIR}/eclair_report -db=${PROJECT_ECD} \
88 -summary_txt=${ECLAIR_OUTPUT_DIR}/../summary_txt \
89 -full_txt=${ECLAIR_OUTPUT_DIR}/../full_txt \
90 -full_html=${ECLAIR_OUTPUT_DIR}/../full_html
91
92# summary_txt contains just a single report file not present in full_txt, move it there and be done with it.
93mv ${ECLAIR_OUTPUT_DIR}/../summary_txt/by_service.txt ${ECLAIR_OUTPUT_DIR}/../full_txt/
94rm -rf ${ECLAIR_OUTPUT_DIR}/../summary_txt
95make_self_contained ${ECLAIR_OUTPUT_DIR}/../full_html
96
97# Create the Jenkins reports file.
98JENKINS_XML="${ECLAIR_OUTPUT_DIR}/../jenkins.xml"
99${ECLAIR_BIN_DIR}/eclair_report -db=${PROJECT_ECD} -reports_jenkins=${JENKINS_XML}
100
101
102# Compress database to take less disk space in Jenkins archive
103xz ${PROJECT_ECD}