From ed2bb29c95e6bc813e6b25c9c0572142f35ae2b3 Mon Sep 17 00:00:00 2001 From: Rafal Walczyna Date: Fri, 23 Aug 2019 12:04:02 +0200 Subject: [PATCH] [Tools] SAM script added Added script for S/W Architecture Maturity checking Change-Id: I87e1836e77197740935c4252699e3f4aee08f66e Signed-off-by: Rafal Walczyna --- tools/sam/.gitignore | 1 + tools/sam/README.md | 34 +++++++++++++++++ tools/sam/config/src_exclude.cfg | 2 + tools/sam/run_sam.sh | 63 ++++++++++++++++++++++++++++++ tools/sam/sam_cli.cfg | 82 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 182 insertions(+) create mode 100644 tools/sam/.gitignore create mode 100644 tools/sam/README.md create mode 100755 tools/sam/config/src_exclude.cfg create mode 100755 tools/sam/run_sam.sh create mode 100755 tools/sam/sam_cli.cfg diff --git a/tools/sam/.gitignore b/tools/sam/.gitignore new file mode 100644 index 0000000..afb491f --- /dev/null +++ b/tools/sam/.gitignore @@ -0,0 +1 @@ +config/src_scope.cfg \ No newline at end of file diff --git a/tools/sam/README.md b/tools/sam/README.md new file mode 100644 index 0000000..079c59d --- /dev/null +++ b/tools/sam/README.md @@ -0,0 +1,34 @@ +# SAM +SAM-Tools is a set of tools for measuring S/W Architecture Maturity (SAM). +SAM analyzes both code and architecture in order to identify problems which may impact +software maintenance. + +# Requirements + +[**SAM-Tools** repository](https://github.sec.samsung.net/RS7-Architectural-Refactoring/SAM-Tools) - clone it into directory on the same level as webapi-plugins - This path can be changed in `tools/sam/sam_cli.cfg` file. + +# Usage +Simply run tools/sam/run_sam.sh script - from webapi-plugins/ directory +with gbs profile and one of the parameter below: + + -a Build project and generate report. + + -b Build project and scan for files - without generating report. + + -g Generate report - without building - assumes that first step was made earlier. + +i.e: + + webapi-plugins(SAM)$ tools/sam/run_sam.sh -a 55unified + +Analysis Report will be located in output/html/ directory. + +Script assumes that `55unified` profile exists in ~/.gbs.conf file. + +# Links + +[Architecture Manager](https://code.sec.samsung.net/architecturemanager/app/sam/Tizen_Unified/Tizen_Unified/latest/overview) + +[Getting Started](https://github.sec.samsung.net/RS7-Architectural-Refactoring/SAM-Tools/wiki/Getting-Started) + +[SAM Metric](https://github.sec.samsung.net/RS7-Architectural-Refactoring/SAM-Tools/wiki/Metrics-in-SAM) \ No newline at end of file diff --git a/tools/sam/config/src_exclude.cfg b/tools/sam/config/src_exclude.cfg new file mode 100755 index 0000000..52ed71e --- /dev/null +++ b/tools/sam/config/src_exclude.cfg @@ -0,0 +1,2 @@ +#~/git/webapi-plugins/src/googletest +#~/git/webapi-plugins/src/googlemock \ No newline at end of file diff --git a/tools/sam/run_sam.sh b/tools/sam/run_sam.sh new file mode 100755 index 0000000..01de705 --- /dev/null +++ b/tools/sam/run_sam.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +export WEBAPI_DIRECTORY="${PWD}" +DIR_NAME="${PWD##*/}" + +export BUILD_PROFILE="55unified" + +PATH_TO_SAM_TOOLS="$WEBAPI_DIRECTORY/../SAM-Tools" + +export WEBAPI_VERSION=$(sed packaging/webapi-plugins.spec -n -e "s/Version: *\(.*\)/\1/p") + +if [ "$DIR_NAME" != "webapi-plugins" ] ; then + echo "Script must be executed from webapi-plugins directory" + exit 0 +fi + +function usage { +echo "Usage: +$0 GBS_PROFILE + +Parameters: + -a Build project and generate report. + + -b Build project and scan for files - without generating report. + + -g Generate report - without building - assumes that first step was made earlier." +} + +function build { + "$PATH_TO_SAM_TOOLS/1_sam_cli_scan.sh" "tools/sam/sam_cli.cfg" +} + +function generate { + echo "# This file is autogenerated, do not modify it manually" > "tools/sam/config/src_scope.cfg" + echo "/home/abuild/rpmbuild/BUILD/webapi-plugins-$WEBAPI_VERSION" >> "tools/sam/config/src_scope.cfg" + echo "$WEBAPI_DIRECTORY" >> "tools/sam/config/src_scope.cfg" + + "$PATH_TO_SAM_TOOLS/2_sam_cli_sam.sh" "tools/sam/sam_cli.cfg" +} + +function main { + LOOP=false + while getopts "a:b:g:" opt; do + LOOP=true + case "$opt" in + "a") BUILD_PROFILE=$OPTARG + build + generate + ;; + "b") BUILD_PROFILE=$OPTARG + build + ;; + "g") BUILD_PROFILE=$OPTARG + generate + ;; + esac + done + if [ "$LOOP" = false ] ; then + usage + fi +} + +main "$@" diff --git a/tools/sam/sam_cli.cfg b/tools/sam/sam_cli.cfg new file mode 100755 index 0000000..5d5a27f --- /dev/null +++ b/tools/sam/sam_cli.cfg @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2019 The SAM Tool Authors. All rights reserved. +# +# SAM (S/W Architecture Maturity) +# +# Samsung Research, +# Samsung Electronics Co., Ltd. +# +# This software and its documentation are confidential and proprietary +# information of Samsung Electronics Co., Ltd. No part of the software and +# documents may be copied, reproduced, transmitted, translated, or reduced to +# any electronic medium or machine-readable form without the prior written +# consent of Samsung Electronics. +# +# Samsung Electronics makes no representations with respect to the contents, +# and assumes no responsibility for any errors that might appear in the +# software and documents. This publication and the contents here of are subject +# to change without notice. +# + +################################ +# Project Name +################################ +SAM_PRJ_NAME="webapi-plugins" + + +################################ +# Source Code +################################ +BUILD_CMD="gbs build -A armv7l -P $BUILD_PROFILE --include-all" +CLEAN_CMD="" +SRC_PATH="$WEBAPI_DIRECTORY" +SRC_LANG="auto_c_cpp" # Supported languages : c, cpp, auto_c_cpp, java, cs +SRC_SCOPE="tools/sam/config/src_scope.cfg" # Scoping list +SRC_EXCLUDE="tools/sam/config/src_exclude.cfg" # Excluding list + + +################################ +# SCRA +################################ +SCRA_SKIP=FALSE # Options : TRUE, FALSE +SCRA_RAW_DATA_PATH=".scap/workspace/scra" +SCRA_ROOT_TO_CUT="/home/abuild/rpmbuild/BUILD/webapi-plugins-$WEBAPI_VERSION" +# SCRA_USE_PARAM=TRUE + + +################################ +# ART_BEAN (Convert SCRA data) +################################ +ART_BEAN_SKIP=FALSE # Options : TRUE, FALSE + + +################################ +# PMD CPD (Duplicated Code) +################################ +PMD_SKIP=FALSE # Options : TRUE, FALSE +PMD_RAW_DATA_PATH=".scap/workspace/pmd" +PMD_USE_BUILT_PATH=FALSE # Options : TRUE, FALSE +PMD_ROOT_TO_CUT=$SRC_PATH +#PMD_EXCLUDE_LIST="config/src_exclude.cfg" # Excluding list of PMD +#PMD_RESULT_DETAIL_MODE=FALSE # Options : TRUE, FALSE +#PMD_HEAP_SIZE=2048m +#PMD_ENCODING="utf-8" + + +################################ +# Metrix++ (Preprocessor) +############################### +MPP_SKIP=FALSE +MPP_RAW_DATA_PATH=".scap/workspace/metrixpp" +MPP_ROOT_TO_CUT=$SRC_PATH + + +################################ +# Advanced Option +################################ +#ADVANCED_SAM_OPTION="config/sam.cfg" +#USE_EMBEDDED_LIB=TRUE + +SCAP_TOOL_PATH="hub/code-analysis-hub/bin/scap" +SCAP=$SCAP_TOOL_PATH -- 2.7.4