eclair/utils.sh: Support running analyses in different dirs
Based on ECLAIR_ANALYSIS envvar. Required to support delta reports for
varying codebases (e.g. before and after a patch).
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Change-Id: Ifac31e042269cada1b2e7ae789118a8a7e33b4da
diff --git a/eclair/utils.sh b/eclair/utils.sh
index 7b88793..c6f18cc 100644
--- a/eclair/utils.sh
+++ b/eclair/utils.sh
@@ -12,20 +12,33 @@
# Absolute path of the ECLAIR bin directory.
ECLAIR_BIN_DIR="/opt/bugseng/eclair/bin"
-# Directory where to put all ECLAIR output and temporary files.
-ECLAIR_OUTPUT_DIR="${WORKSPACE}/ECLAIR/out"
-# ECLAIR binary data directory and workspace.
-export ECLAIR_DATA_DIR="${ECLAIR_OUTPUT_DIR}/.data"
+# Set various path variables based on ECLAIR_ANALYSIS var (which is a name
+# of top-level dir to hold internal files and results of anaylisis). We
+# need to support this variability to e.g. support delta reports
+# between two analyses (before and after a patch).
+eclair_set_paths() {
+ if [ -z "${ECLAIR_ANALYSIS}" ]; then
+ echo "ECLAIR_ANALYSIS is not defined"
+ exit 1
+ fi
-PROJECT_ECD="${ECLAIR_OUTPUT_DIR}/PROJECT.ecd"
+ # Directory where to put all ECLAIR output and temporary files.
+ ECLAIR_OUTPUT_DIR="${WORKSPACE}/ECLAIR/out"
+ # ECLAIR binary data directory and workspace.
+ export ECLAIR_DATA_DIR="${ECLAIR_OUTPUT_DIR}/.data"
+
+ PROJECT_ECD="${ECLAIR_OUTPUT_DIR}/PROJECT.ecd"
+}
eclair_prepare() {
+ eclair_set_paths
mkdir -p "${ECLAIR_DATA_DIR}"
}
eclair_analyze() {
+ eclair_set_paths
(
# Run a build in the ECLAIR environment.
"${ECLAIR_BIN_DIR}/eclair_env" \
@@ -34,8 +47,9 @@
)
}
+# Create the project database.
eclair_make_ecd() {
- # Create the project database.
+ eclair_set_paths
find "${ECLAIR_DATA_DIR}" -maxdepth 1 -name "FRAME.*.ecb" \
| sort | xargs cat \
| "${ECLAIR_BIN_DIR}/eclair_report" \
@@ -53,6 +67,7 @@
}
eclair_make_reports() {
+ eclair_set_paths
${ECLAIR_BIN_DIR}/eclair_report -db=${PROJECT_ECD} \
-summary_txt=${ECLAIR_OUTPUT_DIR}/../summary_txt \
-full_txt=${ECLAIR_OUTPUT_DIR}/../full_txt \