[Tools] Add script for SAM with SVACE 3.0 engine 20/229620/2
authorRafal Walczyna <r.walczyna@samsung.com>
Thu, 2 Apr 2020 07:59:47 +0000 (09:59 +0200)
committerRafal Walczyna <r.walczyna@samsung.com>
Mon, 6 Apr 2020 09:05:33 +0000 (11:05 +0200)
Change-Id: I421dad53fc79ae0ab45d26b4b9c75af0f2a1f725
Signed-off-by: Rafal Walczyna <r.walczyna@samsung.com>
tools/sam/README.md
tools/sam/run_sam.sh
tools/sam/run_sam_svace3.0.sh [new file with mode: 0755]

index 079c59d..d220f32 100644 (file)
@@ -19,11 +19,11 @@ with gbs profile and one of the parameter below:
 
 i.e:
 
-    webapi-plugins(SAM)$ tools/sam/run_sam.sh -a 55unified
+    webapi-plugins(SAM)$ tools/sam/run_sam.sh -a unified
 
 Analysis Report will be located in output/html/ directory.
 
-Script assumes that `55unified` profile exists in ~/.gbs.conf file.
+Script assumes that `unified` profile exists in ~/.gbs.conf file.
 
 # Links
 
@@ -31,4 +31,10 @@ Script assumes that `55unified` profile exists in ~/.gbs.conf file.
 
 [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
+[SAM Metric](https://github.sec.samsung.net/RS7-Architectural-Refactoring/SAM-Tools/wiki/Metrics-in-SAM)
+
+# Troubleshooting
+
+In case of problems with processing files - too small Lines of Code number - use `tools/sam/run_sam_svace3.0.sh`.
+
+More details [here](https://github.sec.samsung.net/RS7-Architectural-Refactoring/SAM-Tools/issues/708).
\ No newline at end of file
index 01de705..b43e7d9 100755 (executable)
@@ -3,7 +3,7 @@
 export WEBAPI_DIRECTORY="${PWD}"
 DIR_NAME="${PWD##*/}"
 
-export BUILD_PROFILE="55unified"
+export BUILD_PROFILE="unified"
 
 PATH_TO_SAM_TOOLS="$WEBAPI_DIRECTORY/../SAM-Tools"
 
diff --git a/tools/sam/run_sam_svace3.0.sh b/tools/sam/run_sam_svace3.0.sh
new file mode 100755 (executable)
index 0000000..e5e0d19
--- /dev/null
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+WEBAPI_DIRECTORY="${PWD}"
+DIR_NAME="${PWD##*/}"
+
+BUILD_PROFILE="unified"
+
+PATH_TO_SAM_TOOLS="$WEBAPI_DIRECTORY/../SAM-Tools"
+
+if [ "$PWD" != "$(git rev-parse --show-toplevel)" ] ; then
+  echo "Script must be executed from root directory of git repository"
+  exit 0
+fi
+
+function generate {
+  if [ -z "$1" ] ; then
+    echo "No gbs profile provided, using $BUILD_PROFILE"
+  else
+    BUILD_PROFILE="$1"
+  fi
+
+  if [ ! -f "$PATH_TO_SAM_TOOLS/hub/code-analysis-hub/scap/plugins/scra/svace-3.0.0-x64-linux/bin/svace" ] ; then
+    echo "ERROR: SVACE binary not found in $PATH_TO_SAM_TOOLS/hub/code-analysis-hub/scap/plugins/scra/svace-3.0.0-x64-linux/bin/svace"
+    exit 0
+  fi
+  "$PATH_TO_SAM_TOOLS/hub/code-analysis-hub/bin/scap" init
+  "$PATH_TO_SAM_TOOLS/hub/code-analysis-hub/scap/plugins/scra/svace-3.0.0-x64-linux/bin/svace" init
+  "$PATH_TO_SAM_TOOLS/hub/code-analysis-hub/scap/plugins/scra/svace-3.0.0-x64-linux/bin/svace" scra-params SCRA_RUNLINK_DYNAMIC_LIBS on
+  "$PATH_TO_SAM_TOOLS/hub/code-analysis-hub/scap/plugins/scra/svace-3.0.0-x64-linux/bin/svace" scra-params SCRA_BUILD_IGNORE_MACRO_METRIC on
+
+  mkdir -p ".scap/workspace/scra/"
+  "$PATH_TO_SAM_TOOLS/hub/code-analysis-hub/scap/plugins/scra/svace-3.0.0-x64-linux/bin/svace" build gbs build -A armv7l --profile="$BUILD_PROFILE" --include-all
+
+  "$PATH_TO_SAM_TOOLS/hub/code-analysis-hub/scap/plugins/scra/svace-3.0.0-x64-linux/bin/svace" scra-analyze -T -o ".scap/workspace/scra/"
+
+  $WEBAPI_DIRECTORY/tools/sam/run_sam.sh -g "$BUILD_PROFILE"
+}
+
+function usage {
+echo "Usage:
+$0 GBS_PROFILE
+
+Be sure that you have SVACE 3.0 engine in your SAM-Tools directory.
+1. Download the latest version of SVACE3.0 engine from at http://code.sec.samsung.net/ahub/resources/scra/dev/to-sam/
+2. Extract it to <SAM-Tools path>/hub/code-analysis-hub/scap/plugins/scra/
+"
+}
+
+function main {
+  LOOP=false
+  while getopts "h" opt; do
+    LOOP=true
+    case "$opt" in
+      "h")
+            usage
+            ;;
+    esac
+  done
+  if [ "$LOOP" = false ] ; then
+      generate $@
+  fi
+}
+
+main "$@"