]> git.uio.no Git - u/mrichter/AliRoot.git/blob - test/Warnings.cmake
Missing macros for PWGCF, PWGDQ and PWGLF
[u/mrichter/AliRoot.git] / test / Warnings.cmake
1 cmake_minimum_required(VERSION 2.8)
2
3 if(COMMAND CMAKE_POLICY)
4   if(POLICY CMP0009)
5     cmake_policy(SET CMP0009 NEW)
6   endif(POLICY CMP0009)
7 endif(COMMAND CMAKE_POLICY)
8 set(rs "$ENV{ROOTSYS}")
9 set(ar "$ENV{ALICE_ROOT}")
10 #warnings exceptions
11 set(exceptions "always evaluates both arguments" "std::" "TGeoMatrix::operator\\*" "struct AliRawDataHeader" "/usr/local/dim" " from " "JETAN/fastjet/fastjet/" "G__" "base class .struct AliHLTCaloChannelDataStruct. has a non-virtual destructor")
12
13 #Function to count no of lines in a file equivalent to wc -l
14 function (wcl _nLinesVar fileName)
15   file(READ ${fileName} fileData)
16   if(fileData)
17     if(WIN32)
18       string(REGEX MATCHALL "\r\n" nLines ${fileData})
19     else()
20       string(REGEX MATCHALL "[\r\n]" nLines ${fileData})
21     endif(WIN32)
22     list(LENGTH nLines nLines)
23     set(${_nLinesVar} ${nLines} PARENT_SCOPE)
24   else()
25     set(${_nLinesVar} -1 PARENT_SCOPE)
26   endif()
27 endfunction()
28
29 find_program(svn_command svn)
30
31 if(ar AND rs)
32   #Read build log from (default - make.log)
33   set(buildLog "$ENV{ALICE_INSTALL}/make.log")
34   file(READ ${buildLog} lineList)
35   string(REGEX REPLACE "\n" ";" "lineList" "${lineList}")
36   foreach (line ${lineList})
37     set(warning "")
38     string(REGEX MATCH ".+warning:.+" "warning" "${line}")
39     if(warning)
40       #    message("${warning}")
41       list(APPEND warnList "${line}")
42       string(REGEX MATCH "(.+):[0-9]+" "file" "${line}")
43       string(REGEX REPLACE ":[0-9]+" "" "file" "${file}")
44       list(APPEND fileList "${file}")
45     endif(warning)
46   endforeach(line)
47   list(REMOVE_DUPLICATES fileList)
48   set(rootOut "+--| ROOT\n")
49   set(aliOut "+--| ALIROOT\n")
50   list(SORT fileList)
51   foreach(file ${fileList})
52     set(root "")
53     set(aliroot "")
54     string(REGEX MATCH "${rs}" "root" "${file}")  
55     string(REGEX MATCH "${ar}" "aliroot" "${aliroot}")
56     if(root)
57       string(REGEX REPLACE "${root}[/]*" "" "file" "${file}")
58       set(rootOut "${rootOut}   |\n")
59       set(rootOut "${rootOut}   +--| ${file}\n")
60     else()
61       set(aliroot ${ar})
62       string(REGEX REPLACE "${aliroot}[/]*" "" "file" "${file}")
63       set(aliOut "${aliOut}   |\n")
64       set(aliOut "${aliOut}   +--| ${file}\n")
65     endif(root)
66     list(REMOVE_DUPLICATES warnList)
67     foreach(line ${warnList})
68       set(match "")
69       string(REGEX MATCH "${file}[:]*" "match" "${line}")
70       if(match)
71         string(REGEX REPLACE "${match}" "" "line" "${line}")
72         if(aliroot)
73           string(REGEX REPLACE "${aliroot}" "" "line" "${line}")
74           set(aliOut "${aliOut}      +--| ${line}\n")
75         elseif(root)
76             string(REGEX REPLACE "${root}" "" "line" "${line}")
77             set(rootOut "${rootOut}      +--| ${line}\n")
78           endif(aliroot)
79         endif(match)
80       endforeach(line)
81     endforeach(file)
82
83 set(tot 0)
84 set (anlys "${anlys}\n\n==============================Detailed Analysis==============================\n")
85 #Blaming people
86 set (anlys "${anlys}+--| AliRoot\n")
87 foreach( blameFile ${fileList} )
88   string(REPLACE "$ENV{ALICE_ROOT}/" "" mainFile ${blameFile})
89   set(anlys "${anlys}   |\n")
90   execute_process(COMMAND "${svn_command}" "blame" "${blameFile}"
91     WORKING_DIRECTORY "$ENV{ALICE_ROOT}"
92     OUTPUT_FILE tmpViols
93     OUTPUT_VARIABLE tmpVio)
94   wcl(fileLen "$ENV{ALICE_ROOT}/tmpViols")
95   set(anlys "${anlys}   |--| ${mainFile} |-- ${fileLen} lines\n")  
96   set(nameList "")
97   file(STRINGS "$ENV{ALICE_ROOT}/tmpViols" violData)
98   # file(READ "tmpViols" violData)
99   # string(REGEX REPLACE "\n" ";" "violData" "${violData}")
100   foreach(violLine ${violData})
101     string(REGEX MATCH "[0-9]+[ ]+[a-zA-Z0-9]+" "name" "${violLine}")
102     string(REGEX REPLACE "^[0-9]+[ ]+" "" "name" "${name}")
103     list(APPEND nameList ${name})
104     list(APPEND fullViolList ${name})
105   endforeach(violLine)
106   list(LENGTH violData tot)
107   set (userList ${nameList})
108   set(finale "")  
109   if(userList)
110     list(REMOVE_DUPLICATES userList)
111   endif(userList)
112   foreach(name ${userList})
113     string(REGEX MATCHALL "${name}" "nameCount" "${nameList}")
114     list(LENGTH nameCount nameCount)
115     math(EXPR num "(${nameCount}*100)/${tot}")
116     math(EXPR dec "((10000*${nameCount}/${tot}-100*${num}+5))")
117     if( ${dec} GREATER 99 )
118       set(dec 0)
119       math(EXPR num "${num}+1")
120     endif(${dec} GREATER 99)
121     math(EXPR dec "${dec}/10")
122     math(EXPR pcnt "99999 - ${num}${dec}")
123     string(LENGTH ${num} digit)
124     if(digit EQUAL 1)
125       set(space "  ")
126     elseif(digit EQUAL 2)
127       set(space " ")
128     endif(digit EQUAL 1) 
129     list(APPEND finale "${pcnt}-${space}${num}.${dec}% | ${name} |-- ${nameCount} lines")
130   endforeach(name)
131   list(SORT finale)
132   foreach(record ${finale})
133     string(LENGTH ${record} recLen)
134     math(EXPR recLen "${recLen}-6")
135     string(SUBSTRING ${record} 6 ${recLen}  record)
136     set(anlys "${anlys}      +--|${record}\n")
137   endforeach(record)
138 endforeach( blameFile)
139
140
141
142 message("${anlys}")
143     message("==============================ROOT FILE  WARNINGS==============================\n")
144     message("${rootOut}")
145     message("\n\n==============================ALIROOT FILE WARNINGS==============================\n")
146     message("${aliOut}")
147   else()
148     message(WARNING "Environment Variable ALICE_ROOT and ROOTSYS must be set")
149   endif(ar AND rs)