]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/patch_deps.sh
added generation of KLOCs in dot diagrams
[helm.git] / helm / ocaml / patch_deps.sh
index cd9f09c8976277102a8ce1dbf84b3d9cb5dce574..dbdd27c1111489c9511ff7c18d6cf12868065579 100755 (executable)
@@ -10,10 +10,30 @@ fi
 # file will be modified in place
 include_dot_snippet ()
 {
-  echo "Adding to $1 graphviz snipet $2 ..."
+  echo "Adding to $1 graphviz snippet $2 ..."
   sed -i "/digraph/r $2" $1
 }
 
+# args: stats file
+# file will be modified in place
+include_loc_stats ()
+{
+  echo "Adding to $1 KLOCs stats from $2 ..."
+  tmp=`mktemp tmp.stats.XXXXXX`
+  for l in `cat $2`; do
+    module=$(basename $(echo $l | cut -d : -f 1))
+    stat=$(echo $l | cut -d : -f 2)
+    if [ "$stat" = "LOC" ]; then
+      locs=$(echo $l | cut -d : -f 3)
+      klocs=$(echo "scale=1; $locs / 1000" | bc)
+      if [ "$klocs" = "0" ]; then klocs=".1"; fi
+      printf '  %s [label="%s\\n%s klocs"];\n' $module $module $klocs >> $tmp
+    fi
+  done
+  include_dot_snippet $1 $tmp
+  rm $tmp
+}
+
 # args: file patch
 apply_patch ()
 {
@@ -24,6 +44,7 @@ apply_patch ()
 }
 
 cp $1 $2
+include_loc_stats $2 .stats
 apply_patch $2 deps.patch
 include_dot_snippet $2 daemons.dot
 if [ "$use_clusters" = "yes" ]; then