bump product version to 4.1.6.2
[LibreOffice.git] / solenv / bin / buildalyzer
blob77d8d413eccb861d82c0d3e9b8bfc65f151652be
1 #!/usr/bin/env python
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 import sys
20 import os
22 class CxxTarget:
23 def __init__(self, line):
24 self.directory = ''
25 self.outputfile = ''
26 self.includeflags = []
27 self.cxxflags = []
28 self.inputfiles = []
29 self.nolink = False
30 options = line[:-1].split(' ')
31 self.directory = options.pop(0)
32 parsing_outputfile = False
33 for option in options:
34 if parsing_outputfile:
35 self.outputfile = option
36 parsing_outputfile = False
37 elif option == '-o':
38 parsing_outputfile = True
39 elif option == '-c':
40 self.nolink = True
41 elif option.startswith('-I'):
42 self.includeflags.append(CxxFlag(option))
43 elif option.startswith('-'):
44 self.cxxflags.append(CxxFlag(option))
45 else:
46 self.inputfiles.append(option)
47 self.cxxflags.sort()
48 self.includeflags.sort()
49 cxxflags_tmp = dict()
50 for flag in self.cxxflags:
51 cxxflags_tmp[flag.name] = flag
52 self.cxxflags = cxxflags_tmp.values()
53 includeflags_tmp = dict()
54 for flag in self.includeflags:
55 includeflags_tmp[flag.name] = flag
56 self.includeflags = includeflags_tmp.values()
57 CxxTargets.by_name[self.getFullOutputname()] = self
58 def __str__(self):
59 return '%s' % (self.getFullOutputname())
60 def getFullOutputname(self):
61 return self.directory + '/' + self.outputfile
62 def __cmp__(self, other):
63 return cmp(self.getFullOutputname(), other.getFullOutputname())
65 class CxxFlag:
66 def __init__(self, name):
67 self.name = name
68 CxxFlags.by_name[self.name] = self
69 def __str__(self):
70 return 'Flag %s' % (self.name)
71 def __cmp__(self, other):
72 return cmp(self.name, other.name)
74 class CxxFlags:
75 by_name = dict()
77 class CxxTargets:
78 by_name = dict()
80 if __name__ == '__main__':
81 [CxxTarget(line) for line in sys.stdin.readlines()]
82 compile_targets = [target for target in CxxTargets.by_name.values() if target.nolink]
83 link_targets = [target for target in CxxTargets.by_name.values() if not target.nolink]
84 common_compile_flags = []
85 for flag in CxxFlags.by_name.values():
86 if sum((flag in target.cxxflags for target in compile_targets)) == len(compile_targets):
87 common_compile_flags.append(flag)
88 common_link_flags = []
89 for flag in CxxFlags.by_name.values():
90 if sum((flag in target.cxxflags for target in compile_targets)) == len(compile_targets):
91 common_link_flags.append(flag)
93 for target in compile_targets:
94 target.cxxflags = [flag for flag in target.cxxflags if flag not in common_compile_flags]
95 target.cxxflags.sort()
96 for target in link_targets:
97 target.cxxflags = [flag for flag in target.cxxflags if flag not in common_link_flags]
98 target.cxxflags.sort()
100 common_compile_flags.sort()
101 common_link_flags.sort()
102 print 'common compile flags: %s' % (' '.join(flag.name for flag in common_compile_flags))
103 print 'common link flags: %s' % (' '.join(flag.name for flag in common_link_flags))
105 by_flagset = dict()
106 for target in CxxTargets.by_name.values():
107 flagset = ' '.join((flag.name for flag in target.cxxflags))
108 if flagset not in by_flagset:
109 by_flagset[flagset] = list()
110 by_flagset[flagset].append(target)
111 for targetlist in by_flagset.values():
112 targetlist.sort()
113 flagsets = by_flagset.keys()
114 flagsets.sort()
115 print '%d compilerflag groups:' % (len(flagsets))
116 for flagset in flagsets:
117 print flagset
118 for target in by_flagset[flagset]:
119 print '%s' % (target)
120 print
122 by_flagset = dict()
123 for target in CxxTargets.by_name.values():
124 flagset = ' '.join((flag.name for flag in target.includeflags))
125 if flagset not in by_flagset:
126 by_flagset[flagset] = list()
127 by_flagset[flagset].append(target)
128 for targetlist in by_flagset.values():
129 targetlist.sort()
130 flagsets = by_flagset.keys()
131 flagsets.sort()
132 print '%d include flag groups:' % (len(flagsets))
133 for flagset in flagsets:
134 print flagset
135 for target in by_flagset[flagset]:
136 print '%s' % (target)
137 print
139 print 'sources:'
140 by_name = dict()
141 for target in CxxTargets.by_name.values():
142 by_name[os.path.basename(target.outputfile)] = target
143 names = by_name.keys()
144 names.sort()
145 for target in CxxTargets.by_name.values():
146 if len(target.inputfiles) > 1:
147 objects = [os.path.basename(object) for object in target.inputfiles]
148 sources = list()
149 for object in objects:
150 if object in by_name:
151 sources.append(by_name[object].inputfiles[0])
152 else:
153 sources.append('!!!!' + object)
154 sources.sort()
155 print '%s %s' % (target.getFullOutputname(), ' '.join(sources))