output like this:
"build-pkg.include/common/ist.h:warning:unused-parameter‘count’[-Wunused-parameter]": 1,
"build-pkg.include/common/ist.h:warning:unused-parameter‘count’[-Wunused-parameter].message": [
"include/common/ist.h:488:74: warning: unused parameter ‘count’ [-Wunused-parameter]\n static inline struct ist ist2str(char *dst, const struct ist src, size_t count)\n
^~~~~\n",
"include/common/ist.h:533:77: warning: unused parameter ‘count’ [-Wunused-parameter]\n static inline struct ist ist2str_lc(char *dst, const struct ist src, size_t count
)\n ^~~~~\n",
"include/common/ist.h:578:77: warning: unused parameter ‘count’ [-Wunused-parameter]\n static inline struct ist ist2str_uc(char *dst, const struct ist src, size_t count
)\n ^~~~~\n"
]
Signed-off-by: Lin Jiaxin <ljx.joe(a)qq.com>
---
stats/build-pkg.rb | 74 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
create mode 100755 stats/build-pkg.rb
diff --git a/stats/build-pkg.rb b/stats/build-pkg.rb
new file mode 100755
index 00000000..4515bf23
--- /dev/null
+++ b/stats/build-pkg.rb
@@ -0,0 +1,74 @@
+#!/usr/bin/env ruby
+
+LKP_SRC ||= ENV['LKP_SRC'] || File.dirname(File.dirname(File.realpath($PROGRAM_NAME)))
+
+require 'set'
+require "#{LKP_SRC}/lib/common"
+
+class ErrorMessages
+ def initialize
+ @seqno = ''
+ @in_stderr = false
+ @error_line = ''
+ @error_details = ''
+ @error_message = {}
+ @error_messages = Hash.new { |h, k| h[k] = Set.new }
+ end
+
+ def obtain_error_messages(log_lines)
+ log_lines.each do |line|
+ next if extract_error_message(line)
+ next unless @in_stderr
+ next unless @error_message['error_line'] =~ /(error|warning):[^:]/i
+
+ error_id = build_pkg_error_id(@error_message['error_line'])
+ @error_messages[error_id] << @error_message['error_line'] + @error_message['error_details']
+ end
+ return @error_messages
+ end
+
+ private
+
+ def extract_error_message(line)
+ if line =~ /^ /
+ @error_details += line
+ else
+ update_error_message(line)
+ case line
+ when /^## ______________([0-9.]+):stderr$/
+ @in_stderr = true
+ @seqno = $1
+ return true
+
+ when /^## ______________#{@seqno}:enderr$/
+ @in_stderr = false
+ @seqno = ''
+ add_error_message
+ end
+ end
+ end
+
+ def update_error_message(line)
+ @error_message['error_line'] = @error_line
+ @error_message['error_details'] = @error_details
+ @error_line = line
+ @error_details = ''
+ end
+
+ def add_error_message
+ return unless @error_message['error_line'] =~ /(error|warning):[^:]/i
+
+ error_id = build_pkg_error_id(@error_message['error_line'])
+ @error_messages[error_id] << @error_message['error_line'] + @error_message['error_details']
+ end
+end
+
+def build_pkg(log_lines)
+ message = {}
+ ErrorMessages.new.obtain_error_messages(log_lines).each do |k, v|
+ message[k] = '1'
+ message["#{k}.message"] = v.to_a
+ end
+
+ return message
+end
--
2.23.0