1 cmake_minimum_required(VERSION 2.8)
3 if(COMMAND CMAKE_POLICY)
5 cmake_policy(SET CMP0009 NEW)
7 endif(COMMAND CMAKE_POLICY)
9 #Run Checkaliroot to get latest violations
10 execute_process(COMMAND make -k check-all
11 WORKING_DIRECTORY $ENV{ALICE_INSTALL}
12 OUTPUT_FILE CheckAliroot.log )
14 find_program(svn_command svn)
16 #Function to count no of lines in a file equivalent to wc -l
17 function (wcl _nLinesVar fileName)
18 file(READ ${fileName} fileData)
21 string(REGEX MATCHALL "\r\n" nLines ${fileData})
23 string(REGEX MATCHALL "[\r\n]" nLines ${fileData})
25 list(LENGTH nLines nLines)
26 set(${_nLinesVar} ${nLines} PARENT_SCOPE)
28 set(${_nLinesVar} -1 PARENT_SCOPE)
32 file(GLOB_RECURSE violExc "$ENV{ALICE_INSTALL}/*THerwig6.viol"
33 "$ENV{ALICE_INSTALL}/*AliRawReaderDateV3.viol"
34 "$ENV{ALICE_INSTALL}/*dateStream.viol"
35 "$ENV{ALICE_INSTALL}/TTherminator/*.viol"
36 "$ENV{ALICE_INSTALL}/*esdAna.viol"
37 "$ENV{ALICE_INSTALL}/*TIsajet*.viol"
38 "$ENV{ALICE_INSTALL}/*RecAna.viol"
39 "$ENV{ALICE_INSTALL}/*LHAPDFWrap.viol"
40 "$ENV{ALICE_INSTALL}/RAW/check/event.viol"
41 "$ENV{ALICE_INSTALL}/THerwig/check/HCommon.viol"
42 "$ENV{ALICE_INSTALL}/*HBTprocCOMMON.viol"
43 "$ENV{ALICE_INSTALL}/*EPOScommon.viol"
44 "$ENV{ALICE_INSTALL}/*DPMcommon.viol"
45 "$ENV{ALICE_INSTALL}/*Hcommon.viol"
46 "$ENV{ALICE_INSTALL}/*TPHICcommon.viol"
47 "$ENV{ALICE_INSTALL}/JETAN/check/fastjet/*.viol"
48 "$ENV{ALICE_INSTALL}/HLT/check/JET/fastjet/*.viol"
49 "$ENV{ALICE_INSTALL}/PYTHIA8/*.viol"
50 "$ENV{ALICE_INSTALL}/TEvtGen/*.viol"
51 "$ENV{ALICE_INSTALL}/LHAPDF/*.viol"
52 "$ENV{ALICE_INSTALL}/*HydCommon.viol"
53 "$ENV{ALICE_INSTALL}/*AliHLTDataBuffer.viol")
54 file(GLOB_RECURSE violFiles "$ENV{ALICE_INSTALL}/*.viol")
55 list(REMOVE_ITEM violFiles ${violExc})
58 list(LENGTH violFiles totf)
61 #Count the number Violations per file and sort
62 foreach( violFile ${violFiles} )
63 file(READ ${violFile} fileData)
64 math(EXPR violLen "0")
66 string(REGEX MATCHALL "violated:" violList ${fileData})
67 list(LENGTH violList violLen)
69 math(EXPR totl "${totl} + ${violLen}")
70 math(EXPR violLen "999999 - ${violLen}")
71 list(APPEND violCount "${violLen}:${violFile}")
72 endforeach( violFile )
74 list(LENGTH violCount max)
78 message("==============================Overall Violations==============================\n")
79 message("COUNT : VIOLATION FILE NAME\n------------------------------------------------------------------------------")
80 #Print out top 10 violations
81 foreach(i RANGE ${max})
82 list(GET violCount ${i} line)
83 string(LENGTH ${line} lineLen)
84 math(EXPR lineLen "${lineLen}-7")
85 string(SUBSTRING ${line} 0 6 count)
86 string(SUBSTRING ${line} 7 ${lineLen} lineLen)
88 string(REPLACE "check/" "" args ${lineLen})
89 string(REPLACE "viol" "*" args ${args})
90 string(REPLACE "$ENV{ALICE_INSTALL}" "$ENV{ALICE_ROOT}" args ${args})
91 file(GLOB args "${args}")
93 list(APPEND argList "${arg}")
96 string(REPLACE "$ENV{ALICE_INSTALL}/" "" module ${lineLen})
97 math(EXPR count "999999 - ${count}")
98 string(LENGTH ${count} digit)
101 elseif(${digit} EQUAL 2)
103 elseif(${digit} EQUAL 3)
105 endif(${digit} EQUAL 1)
106 message("${space}${count} : ${module}")
111 set (anlys "${anlys}\n\n==============================Detailed Analysis==============================\n")
113 set (anlys "${anlys}+--| AliRoot\n")
114 foreach( blameFile ${argList} )
115 string(REPLACE "$ENV{ALICE_ROOT}/" "" mainFile ${blameFile})
116 set(anlys "${anlys} |\n")
117 execute_process(COMMAND "${svn_command}" "blame" "${blameFile}"
118 WORKING_DIRECTORY "$ENV{ALICE_INSTALL}"
120 OUTPUT_VARIABLE tmpVio)
121 wcl(fileLen "$ENV{ALICE_INSTALL}/tmpViols")
122 set(anlys "${anlys} |--| ${mainFile} |-- ${fileLen} lines\n")
124 file(STRINGS "$ENV{ALICE_INSTALL}/tmpViols" violData)
125 # file(READ "tmpViols" violData)
126 # string(REGEX REPLACE "\n" ";" "violData" "${violData}")
127 foreach(violLine ${violData})
128 string(REGEX MATCH "[0-9]+[ ]+[a-zA-Z0-9]+" "name" "${violLine}")
129 string(REGEX REPLACE "^[0-9]+[ ]+" "" "name" "${name}")
130 list(APPEND nameList ${name})
131 list(APPEND fullViolList ${name})
133 list(LENGTH violData tot)
134 set (userList ${nameList})
137 list(REMOVE_DUPLICATES userList)
139 foreach(name ${userList})
140 string(REGEX MATCHALL "${name}" "nameCount" "${nameList}")
141 list(LENGTH nameCount nameCount)
142 math(EXPR num "(${nameCount}*100)/${tot}")
143 math(EXPR dec "((10000*${nameCount}/${tot}-100*${num}+5))")
144 if( ${dec} GREATER 99 )
146 math(EXPR num "${num}+1")
147 endif(${dec} GREATER 99)
148 math(EXPR dec "${dec}/10")
149 math(EXPR pcnt "99999 - ${num}${dec}")
150 string(LENGTH ${num} digit)
153 elseif(digit EQUAL 2)
156 list(APPEND finale "${pcnt}-${space}${num}.${dec}% | ${name} |-- ${nameCount} lines")
159 foreach(record ${finale})
160 string(LENGTH ${record} recLen)
161 math(EXPR recLen "${recLen}-6")
162 string(SUBSTRING ${record} 6 ${recLen} record)
163 set(anlys "${anlys} +--|${record}\n")
165 endforeach( blameFile)
167 list(LENGTH fullViolList tot)
168 set(nameList ${fullViolList})
172 list(REMOVE_DUPLICATES nameList)
174 foreach(name ${nameList})
175 string(REGEX MATCHALL "${name}" "nameCount" "${fullViolList}")
176 list(LENGTH nameCount nameCount)
177 math(EXPR num "(${nameCount}*100)/${tot}")
178 math(EXPR dec "((10000*${nameCount}/${tot}-100*${num}+5))")
179 if( ${dec} GREATER 99 )
181 math(EXPR num "${num}+1")
182 endif(${dec} GREATER 99)
183 math(EXPR dec "${dec}/10")
184 math(EXPR pcnt "99999 - ${num}${dec}")
185 string(LENGTH ${num} digit)
188 elseif(digit EQUAL 2)
191 list(APPEND finale "${pcnt}-${space}${num}.${dec}% | ${name}")
194 #Print Code Percentages
196 message("\n\n==============================Overall Percentages==============================\n")
197 foreach(record ${finale})
198 string(LENGTH ${record} recLen)
199 math(EXPR recLen "${recLen}-6")
200 string(SUBSTRING ${record} 6 ${recLen} record)
204 #Print Detailed Analysis