blob: 7b88793f4971f96939bc6a04e691ea5c8be77b5f [file] [log] [blame]
Paul Sokolovsky5772f922023-05-30 20:57:26 +03001#!/usr/bin/env python3
2#
3# Copyright (c) 2022-2023 Arm Limited. All rights reserved.
4#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7# Common utility functions for Bugseng ECLAIR tool.
8
9# Directory where this script resides (assuming it was sourced).
10export _ECLAIR_UTILS_DIR="$(cd "$(dirname "$BASH_SOURCE")" ; echo "${PWD}")"
11
12# Absolute path of the ECLAIR bin directory.
13ECLAIR_BIN_DIR="/opt/bugseng/eclair/bin"
14
15# Directory where to put all ECLAIR output and temporary files.
16ECLAIR_OUTPUT_DIR="${WORKSPACE}/ECLAIR/out"
17
18# ECLAIR binary data directory and workspace.
19export ECLAIR_DATA_DIR="${ECLAIR_OUTPUT_DIR}/.data"
20
21PROJECT_ECD="${ECLAIR_OUTPUT_DIR}/PROJECT.ecd"
22
23
24eclair_prepare() {
25 mkdir -p "${ECLAIR_DATA_DIR}"
26}
27
28eclair_analyze() {
29 (
30 # Run a build in the ECLAIR environment.
31 "${ECLAIR_BIN_DIR}/eclair_env" \
32 "-eval_file='${ECLAIR_CONFIG_DIR}/MISRA_C_2012_selection.ecl'" \
33 -- "$@"
34 )
35}
36
37eclair_make_ecd() {
38 # Create the project database.
39 find "${ECLAIR_DATA_DIR}" -maxdepth 1 -name "FRAME.*.ecb" \
40 | sort | xargs cat \
41 | "${ECLAIR_BIN_DIR}/eclair_report" \
42 "-create_db='${PROJECT_ECD}'" \
43 -load=/dev/stdin
44}
45
46eclair_make_report_self_contained() {
47 dir=$1
48 mkdir -p $dir/lib
49
50 cp -r /opt/bugseng/eclair-3.12.0/lib/html $dir/lib
51
52 ${_ECLAIR_UTILS_DIR}/relativize_urls.py $dir
53}
54
55eclair_make_reports() {
56 ${ECLAIR_BIN_DIR}/eclair_report -db=${PROJECT_ECD} \
57 -summary_txt=${ECLAIR_OUTPUT_DIR}/../summary_txt \
58 -full_txt=${ECLAIR_OUTPUT_DIR}/../full_txt \
59 -reports1_html=strictness,${ECLAIR_OUTPUT_DIR}/../full_html/by_strictness/@TAG@.html \
60 -full_html=${ECLAIR_OUTPUT_DIR}/../full_html \
61 -full_xml=${ECLAIR_OUTPUT_DIR}/../full_xml
62
63 # summary_txt contains just a single report file not present in full_txt, move it there and be done with it.
64 mv ${ECLAIR_OUTPUT_DIR}/../summary_txt/by_service.txt ${ECLAIR_OUTPUT_DIR}/../full_txt/
65 rm -rf ${ECLAIR_OUTPUT_DIR}/../summary_txt
66
67 eclair_make_report_self_contained ${ECLAIR_OUTPUT_DIR}/../full_html
68}