|
13 | 13 | import compiletools.configutils |
14 | 14 | import compiletools.apptools |
15 | 15 | from compiletools.file_analyzer import create_file_analyzer |
| 16 | +import compiletools.timing |
16 | 17 |
|
17 | 18 |
|
18 | 19 | def create(args, headerdeps): |
@@ -79,7 +80,8 @@ def readfile(self, filename): |
79 | 80 | raise NotImplemented |
80 | 81 |
|
81 | 82 | def __call__(self, filename): |
82 | | - return self.parse(filename) |
| 83 | + with compiletools.timing.time_operation(f"magic_flags_analysis_{os.path.basename(filename)}"): |
| 84 | + return self.parse(filename) |
83 | 85 |
|
84 | 86 | def _handle_source(self, flag, text): |
85 | 87 | # Find the include before the //#SOURCE= |
@@ -160,43 +162,49 @@ def _parse(self, filename): |
160 | 162 | # When used in the "usual" fashion this is true. |
161 | 163 | # However, it is possible to call directly so we must |
162 | 164 | # ensure that the headerdeps exist manually. |
163 | | - self._headerdeps.process(filename) |
| 165 | + with compiletools.timing.time_operation(f"magic_flags_headerdeps_{os.path.basename(filename)}"): |
| 166 | + self._headerdeps.process(filename) |
164 | 167 |
|
165 | | - text = self.readfile(filename) |
166 | | - flagsforfilename = defaultdict(list) |
167 | | - |
168 | | - for match in self.magicpattern.finditer(text): |
169 | | - magic, flag = match.groups() |
170 | | - |
171 | | - # If the magic was SOURCE then fix up the path in the flag |
172 | | - if magic == "SOURCE": |
173 | | - flag = self._handle_source(flag, text) |
174 | | - |
175 | | - # If the magic was INCLUDE then modify that into the equivalent CPPFLAGS, CFLAGS, and CXXFLAGS |
176 | | - if magic == "INCLUDE": |
177 | | - extrafff = self._handle_include(flag) |
178 | | - for key, values in extrafff.items(): |
179 | | - for value in values: |
180 | | - flagsforfilename[key].append(value) |
181 | | - |
182 | | - # If the magic was PKG-CONFIG then call pkg-config |
183 | | - if magic == "PKG-CONFIG": |
184 | | - extrafff = self._handle_pkg_config(flag) |
185 | | - for key, values in extrafff.items(): |
186 | | - for value in values: |
187 | | - flagsforfilename[key].append(value) |
188 | | - |
189 | | - flagsforfilename[magic].append(flag) |
190 | | - if self._args.verbose >= 5: |
191 | | - print( |
192 | | - "Using magic flag {0}={1} extracted from {2}".format( |
193 | | - magic, flag, filename |
194 | | - ) |
195 | | - ) |
| 168 | + with compiletools.timing.time_operation(f"magic_flags_readfile_{os.path.basename(filename)}"): |
| 169 | + text = self.readfile(filename) |
196 | 170 |
|
197 | | - # Deduplicate all flags while preserving order |
198 | | - for key in flagsforfilename: |
199 | | - flagsforfilename[key] = compiletools.utils.ordered_unique(flagsforfilename[key]) |
| 171 | + with compiletools.timing.time_operation(f"magic_flags_parsing_{os.path.basename(filename)}"): |
| 172 | + flagsforfilename = defaultdict(list) |
| 173 | + |
| 174 | + for match in self.magicpattern.finditer(text): |
| 175 | + magic, flag = match.groups() |
| 176 | + |
| 177 | + # If the magic was SOURCE then fix up the path in the flag |
| 178 | + if magic == "SOURCE": |
| 179 | + flag = self._handle_source(flag, text) |
| 180 | + |
| 181 | + # If the magic was INCLUDE then modify that into the equivalent CPPFLAGS, CFLAGS, and CXXFLAGS |
| 182 | + if magic == "INCLUDE": |
| 183 | + with compiletools.timing.time_operation(f"magic_flags_include_handling_{flag}"): |
| 184 | + extrafff = self._handle_include(flag) |
| 185 | + for key, values in extrafff.items(): |
| 186 | + for value in values: |
| 187 | + flagsforfilename[key].append(value) |
| 188 | + |
| 189 | + # If the magic was PKG-CONFIG then call pkg-config |
| 190 | + if magic == "PKG-CONFIG": |
| 191 | + with compiletools.timing.time_operation(f"magic_flags_pkgconfig_{flag}"): |
| 192 | + extrafff = self._handle_pkg_config(flag) |
| 193 | + for key, values in extrafff.items(): |
| 194 | + for value in values: |
| 195 | + flagsforfilename[key].append(value) |
| 196 | + |
| 197 | + flagsforfilename[magic].append(flag) |
| 198 | + if self._args.verbose >= 5: |
| 199 | + print( |
| 200 | + "Using magic flag {0}={1} extracted from {2}".format( |
| 201 | + magic, flag, filename |
| 202 | + ) |
| 203 | + ) |
| 204 | + |
| 205 | + # Deduplicate all flags while preserving order |
| 206 | + for key in flagsforfilename: |
| 207 | + flagsforfilename[key] = compiletools.utils.ordered_unique(flagsforfilename[key]) |
200 | 208 |
|
201 | 209 | return flagsforfilename |
202 | 210 |
|
|
0 commit comments