1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 """ IO classes for handling build-related objects, e.g. log files.
21 """
22
23 import logging
24 import re
25 import symbian.log
26
27
28 _logger = logging.getLogger('build.io')
29
30
32 """ Reader that parses a Symbian build log and extracts abld -what sections.
33
34 This reader will return, using the iterator protocol, tuples containing:
35 * Unit name.
36 * List of binaries for that unit.
37
38 """
40 symbian.log.Parser.__init__(self, open(logpath, 'r'))
41 self.__match_what = re.compile("abld(\.bat)?(\s+.*)*\s+-w(hat)?", re.I)
42 self._releasable = {}
43 self.parse()
44
46 for key in self._releasable.keys():
47 yield (key, self._releasable[key])
48
49 - def task(self, name, cmdline, path, output):
50 """ Scans abld what build jobs to extract the list of releasable. """
51 _logger.debug("%s, %s, %s, %s" % (name, cmdline, path, output))
52 if self.__match_what.match(cmdline) == None:
53 return
54
55 if name not in self._releasable:
56 self._releasable[name] = []
57 for line in output.splitlines():
58 line = line.strip()
59 if line.startswith("\\") or line.startswith("/"):
60 self._releasable[name].append(line)
61
62
64 """ Reader that parses a Symbian ROM build log and extracts binary sizes.
65
66 This reader will return, using the iterator protocol, tuples containing:
67 * Binary name.
68 * Size of binary.\t(\d+)
69 """
70 rom_binary_size_regex = re.compile(r'(\\epoc32[\w\\\.]+)\t(\d+)')
71 rofs_binary_size_regex = re.compile(r"ile '([\w\\\.]+)' size: (\w+)")
72 image_type_regex = re.compile(r'[._]([^._]+)\.log')
73
75 """ Initialisation.
76
77 :param logpath: The path to the Symbian log file.
78 """
79 self._logpath = logpath
80
82 """ Implement the iterator protocol. """
83 loghandle = open(self._logpath, 'r')
84
85
86 type_match = self.image_type_regex.search(self._logpath)
87 image_type = type_match.group(1)
88 if image_type == 'rom' or image_type.startswith('rofs'):
89
90 for line in loghandle:
91 if image_type == 'rom':
92 match = self.rom_binary_size_regex.match(line)
93 if match != None:
94
95 size = int(match.group(2))
96 yield (match.group(1), size, image_type)
97 elif image_type.startswith('rofs'):
98 match = self.rofs_binary_size_regex.search(line)
99 if match != None:
100
101 size = int(match.group(2), 16)
102 yield (match.group(1), size, image_type)
103 else:
104 _logger.error('ROM type not matched')
105