Paul Sokolovsky | 3486b4e | 2022-09-06 13:33:57 +0300 | [diff] [blame] | 1 | #!/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. |
| 9 | set -ex |
| 10 | |
| 11 | usage() { |
| 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 | |
| 16 | if [ $# -ne 1 ] |
| 17 | then |
| 18 | usage |
| 19 | exit 1 |
| 20 | fi |
| 21 | |
Paul Sokolovsky | 1f10d8b | 2022-10-08 14:27:30 +0300 | [diff] [blame] | 22 | TF_CONFIG="$1" |
Paul Sokolovsky | 3486b4e | 2022-09-06 13:33:57 +0300 | [diff] [blame] | 23 | |
Paul Sokolovsky | 1f10d8b | 2022-10-08 14:27:30 +0300 | [diff] [blame] | 24 | # Directory where this script resides. |
Paul Sokolovsky | 3486b4e | 2022-09-06 13:33:57 +0300 | [diff] [blame] | 25 | SCRIPT_DIR="$(cd "$(dirname "$0")" ; echo "${PWD}")" |
| 26 | |
Paul Sokolovsky | 1f10d8b | 2022-10-08 14:27:30 +0300 | [diff] [blame] | 27 | . ${SCRIPT_DIR}/analyze_common.sh |
| 28 | |
Paul Sokolovsky | 3486b4e | 2022-09-06 13:33:57 +0300 | [diff] [blame] | 29 | # Directory where to put all ECLAIR output and temporary files. |
| 30 | ECLAIR_OUTPUT_DIR="${WORKSPACE}/ECLAIR/out" |
| 31 | |
Paul Sokolovsky | 3486b4e | 2022-09-06 13:33:57 +0300 | [diff] [blame] | 32 | # ECLAIR binary data directory and workspace. |
| 33 | export ECLAIR_DATA_DIR="${ECLAIR_OUTPUT_DIR}/.data" |
| 34 | # ECLAIR workspace. |
| 35 | export ECLAIR_WORKSPACE="${ECLAIR_DATA_DIR}/eclair_workspace" |
| 36 | # Destination file for the ECLAIR diagnostics. |
| 37 | export ECLAIR_DIAGNOSTICS_OUTPUT="${ECLAIR_OUTPUT_DIR}/DIAGNOSTICS.txt" |
| 38 | |
Paul Sokolovsky | 3486b4e | 2022-09-06 13:33:57 +0300 | [diff] [blame] | 39 | # Erase and recreate the output directory and the data directory. |
| 40 | rm -rf "${ECLAIR_OUTPUT_DIR}" |
| 41 | mkdir -p "${ECLAIR_DATA_DIR}" |
| 42 | |
| 43 | ( |
| 44 | # Perform the build (from scratch) in an ECLAIR environment. |
| 45 | "${ECLAIR_BIN_DIR}/eclair_env" \ |
| 46 | "-eval_file='${SCRIPT_DIR}/MISRA_C_2012_selection.ecl'" \ |
Paul Sokolovsky | b3f7399 | 2022-10-05 18:27:22 +0300 | [diff] [blame] | 47 | -- "${SCRIPT_DIR}/build-tfa.sh" "${TF_CONFIG}" |
Paul Sokolovsky | 3486b4e | 2022-09-06 13:33:57 +0300 | [diff] [blame] | 48 | ) |
| 49 | |
| 50 | # Create the project database. |
| 51 | PROJECT_ECD="${ECLAIR_OUTPUT_DIR}/PROJECT.ecd" |
| 52 | find "${ECLAIR_DATA_DIR}" -maxdepth 1 -name "FRAME.*.ecb" \ |
| 53 | | sort | xargs cat \ |
| 54 | | "${ECLAIR_BIN_DIR}/eclair_report" \ |
| 55 | "-create_db='${PROJECT_ECD}'" \ |
| 56 | -load=/dev/stdin |
| 57 | |
| 58 | |
| 59 | function make_self_contained() { |
| 60 | dir=$1 |
| 61 | mkdir -p $dir/lib |
| 62 | |
| 63 | cp -r /opt/bugseng/eclair-3.12.0/lib/html $dir/lib |
| 64 | |
| 65 | ${SCRIPT_DIR}/relativize_urls.py $dir |
| 66 | } |
| 67 | |
| 68 | ${ECLAIR_BIN_DIR}/eclair_report -db=${PROJECT_ECD} \ |
| 69 | -summary_txt=${ECLAIR_OUTPUT_DIR}/../summary_txt \ |
| 70 | -full_txt=${ECLAIR_OUTPUT_DIR}/../full_txt \ |
Paul Sokolovsky | dfd77db | 2022-10-26 20:40:00 +0300 | [diff] [blame] | 71 | -reports1_html=strictness,${ECLAIR_OUTPUT_DIR}/../full_html/by_strictness/@TAG@.html \ |
Paul Sokolovsky | 3486b4e | 2022-09-06 13:33:57 +0300 | [diff] [blame] | 72 | -full_html=${ECLAIR_OUTPUT_DIR}/../full_html |
| 73 | |
| 74 | # summary_txt contains just a single report file not present in full_txt, move it there and be done with it. |
| 75 | mv ${ECLAIR_OUTPUT_DIR}/../summary_txt/by_service.txt ${ECLAIR_OUTPUT_DIR}/../full_txt/ |
| 76 | rm -rf ${ECLAIR_OUTPUT_DIR}/../summary_txt |
| 77 | make_self_contained ${ECLAIR_OUTPUT_DIR}/../full_html |
| 78 | |
| 79 | # Create the Jenkins reports file. |
| 80 | JENKINS_XML="${ECLAIR_OUTPUT_DIR}/../jenkins.xml" |
| 81 | ${ECLAIR_BIN_DIR}/eclair_report -db=${PROJECT_ECD} -reports_jenkins=${JENKINS_XML} |
| 82 | |
| 83 | |
| 84 | # Compress database to take less disk space in Jenkins archive |
| 85 | xz ${PROJECT_ECD} |
Paul Sokolovsky | ceb6c89 | 2022-10-25 19:44:20 +0300 | [diff] [blame] | 86 | |
| 87 | |
| 88 | cat <<EOF >index.html |
| 89 | <html> |
| 90 | <body> |
| 91 | <h1>MISRA reports</h1> |
| 92 | |
| 93 | <p> |
| 94 | TF-A Config: ${TF_CONFIG} |
| 95 | CI Build: <a href="${BUILD_URL}">${BUILD_URL}</a> |
| 96 | </p> |
| 97 | |
| 98 | <li><a href="ECLAIR/full_txt/">Full TXT report</a> |
| 99 | <li><a href="ECLAIR/full_html/index.html">Full HTML report</a> |
| 100 | <li><a href="ECLAIR/full_html/by_service.html#strictness/service/first_file&strictness">Report by issue strictness (Mandatory/Required/Advisory) (HTML).</a> |
| 101 | </body> |
| 102 | </html> |
| 103 | EOF |