1# 2# Copyright (c) 2011-2012, ARM Limited. All rights reserved. 3# 4# This program and the accompanying materials 5# are licensed and made available under the terms and conditions of the BSD License 6# which accompanies this distribution. The full text of the license may be found at 7# http://opensource.org/licenses/bsd-license.php 8# 9# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 10# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 11# 12 13import re 14 15class BuildReport: 16 PCDs = {} 17 18 def parse_platform_summary(self, file): 19 pass 20 21 def parse_pcd_report(self, report_file): 22 pcd_reg = re.compile(" (\*P|\*F|\*M| ) (\w+)(\ +)\: (.*) \((\w+)\) = (.*)\n") 23 24 for line in report_file.xreadlines(): 25 stripped_line = line.strip() 26 if re.match("\<=+\>", stripped_line): 27 return 28 elif re.match("g.*Guid", stripped_line): 29 guid = stripped_line 30 self.PCDs[guid] = {} 31 else: 32 m = pcd_reg.match(line) 33 if m: 34 self.PCDs[guid][m.group(2)] = (m.group(6).strip(),m.group(5)) 35 36 def parse_firmware_device(self, file): 37 pass 38 39 def parse_module_summary(self, file): 40 #print "Module Summary" 41 pass 42 43 CONST_SECTION_HEADERS = [('Platform Summary', parse_platform_summary), 44 ('Platform Configuration Database Report',parse_pcd_report), 45 ('Firmware Device (FD)',parse_firmware_device), 46 ('Module Summary',parse_module_summary)] 47 48 def __init__(self, filename = 'report.log'): 49 report_file = open(filename, 'r') 50 for line in report_file.xreadlines(): 51 for section_header in BuildReport.CONST_SECTION_HEADERS: 52 if line.strip() == section_header[0]: 53 section_header[1](self, report_file) 54 #print self.PCDs 55