create a coverity builder

The Coverity Scanner requires a 'platform builder' which in this case,
it is a makefile (cov-makefile) that take cares of platform
compilation under the trusted-firmware-m folder. The compiled files
are the only source files scanned by Coverity, thus the more platforms
included on the platform builder, the better is the static check
scan. So far, the only platform considered is mps2/an521 but much more
are desired as explained above.

Signed-off-by: Leonardo Sandoval <leonardo.sandoval@linaro.org>
Change-Id: If8ce6a70e8568c5e8b0116555b20377855ac9a55
diff --git a/run-coverity.py b/run-coverity.py
index b603d5b..e38c337 100755
--- a/run-coverity.py
+++ b/run-coverity.py
@@ -17,6 +17,9 @@
 import os
 import subprocess
 import re
+
+# local libraries
+sys.path.append(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "script", "tf-coverity")))
 import utils
 import coverity_tf_conf
 
@@ -89,7 +92,7 @@
     with open(coverity_build_log, encoding="utf-8") as build_log:
         for line in build_log:
             line = re.sub('//','/', line)
-            results = re.search("(?:COMPILING|EXECUTING):.*-c *(.*\.c).*-o.*\.o", line)
+            results = re.search("(?:COMPILING|EXECUTING):.*-o.*\.o .*-c (.*\.c)", line)
             if results is not None:
                 filename = results.group(1)
                 if filename not in analyzed:
@@ -109,6 +112,9 @@
         # Remove final \n in filename
         filename = filename.strip()
 
+        # Expand to absolute path
+        filename = os.path.abspath(filename)
+
         def is_excluded(filename, excludes):
             for pattern in excludes:
                 if re.match(pattern[0], filename):
@@ -142,6 +148,11 @@
         for exc in excluded:
             log_file.write(" - {0:50}   (Reason: {1})\n".format(exc[0], exc[1]))
 
+    if len(analyzed) > 0:
+        log_file.write("\n%d files analyzed:\n" % len(analyzed))
+        for f in analyzed:
+            log_file.write(" - %s\n" % f)
+
     if len(not_analyzed) > 0:
         log_file.write("\n%d files were not analyzed:\n" % len(not_analyzed))
         for f in not_analyzed:
@@ -223,15 +234,12 @@
         sys.exit(1)
 
     # Get some important paths in the platform-ci scripts
-    tf_scripts_dir = os.path.abspath(os.path.dirname(prog_name))
-    tf_coverity_dir = os.path.join(os.path.normpath(
-        os.path.join(tf_scripts_dir, os.pardir, os.pardir)),"coverity")
+    tf_root_dir = os.path.abspath(os.path.dirname(prog_name))
 
     if not args.build_cmd:
-        tf_build_script = os.path.join(tf_scripts_dir, "tf-cov-make")
-        args.build_cmd = tf_build_script + " " + args.tf
+        args.build_cmd = os.path.join(tf_root_dir, "script", "tf-coverity", "tf-cov-make")
 
-    run_coverity_script = os.path.join(tf_coverity_dir, "run_coverity.sh")
+    run_coverity_script = os.path.join(tf_root_dir, "coverity", "run_coverity.sh")
 
     ret = subprocess.call([run_coverity_script, "check_tools", args.mode])
     if ret != 0: