Changeset View
Standalone View
helpers/create-abi-dump.py
Show First 20 Lines • Show All 205 Lines • ▼ Show 20 Line(s) | 190 | def createABIDump(self, runtimeEnvironment=None) -> None: | |||
---|---|---|---|---|---|
206 | # Start preparations to run abi-compliance-checker | 206 | # Start preparations to run abi-compliance-checker | ||
207 | # Gather the information we'll need to write the XML configuration file it uses | 207 | # Gather the information we'll need to write the XML configuration file it uses | ||
208 | version = self.version | 208 | version = self.version | ||
209 | headers = set() # type: Set[str] | 209 | headers = set() # type: Set[str] | ||
210 | libs = set() # type: Set[str] | 210 | libs = set() # type: Set[str] | ||
211 | additionalIncludes = set() # type: Set[str] | 211 | additionalIncludes = set() # type: Set[str] | ||
212 | 212 | | |||
213 | # list of general include directories | 213 | # list of general include directories | ||
214 | noHeaders = set(buildEnvironment.get('CMAKE_PREFIX_PATH').split(":")) | 214 | prefixHeaders = [os.path.abspath(i) for i in buildEnvironment.get('CMAKE_PREFIX_PATH').split(":")] | ||
215 | noHeaders |= set([i+"/include" for i in buildEnvironment.get('CMAKE_PREFIX_PATH').split(":")]) | 215 | noHeaders = set(prefixHeaders) | ||
bcooksley: Not sure why you're storing the list of prefix paths in `prefixHeaders` and then duplicating it… | |||||
Do you know the concept in python about mutable and unmutable datatypes? a set is mutable, that means if I do: a = set([1]) b = a b |= set([2]) print(b) {1, 2} # excepted print(a) {1, 2} # not really expected In this case we reuse`prefixHeaders` only once, so we wouldn't have to care about it. But still prefixHeaders would be lost. IMO this copy makes it more easy to extend the code, as you don't need to remember, that a set is mutable. noHeaders = set([os.path.abspath(i) for i in buildEnvironment.get('CMAKE_PREFIX_PATH').split(":")]) noHeaders |= set([os.path.join(i,"include") for i in noHeaders]) knauss: Do you know the concept in python about mutable and unmutable datatypes?
a `set` is mutable… | |||||
I'm well aware of it, yes. I asked about that because it looked strange to see you prepare some data, then copy it to modify it again, while never referencing the original data again. If you are planning for the future, then that's fine, but it initially looked to me like it was a leftover from refactoring that had been done while writing this code. bcooksley: I'm well aware of it, yes.
I asked about that because it looked strange to see you prepare… | |||||
216 | noHeaders |= set([os.path.join(i,"include") for i in prefixHeaders]) | ||||
216 | 217 | | |||
217 | # From the target information we previously collected... | 218 | # From the target information we previously collected... | ||
218 | # Grab the list of libraries and include headers for abi-compliance-checker | 219 | # Grab the list of libraries and include headers for abi-compliance-checker | ||
219 | for target in self.targets.values(): | 220 | for target in self.targets.values(): | ||
220 | # Check each include directory to see if we need to add it.... | 221 | # Check each include directory to see if we need to add it.... | ||
221 | for i in target['include_dirs']: | 222 | for i in target['include_dirs']: | ||
223 | abspath = os.path.abspath(i) | ||||
222 | # ignore general folders, as there are no lib specific headers are placed | 224 | # ignore general folders, as there are no lib specific headers are placed | ||
223 | if i in noHeaders or i.endswith("/KF5"): | 225 | if abspath in noHeaders or abspath.endswith("/KF5"): | ||
224 | additionalIncludes.add(i) | 226 | additionalIncludes.add(abspath) | ||
225 | continue | 227 | continue | ||
226 | 228 | | |||
227 | # Otherwise, if we don't already have it - add it to the list! | 229 | # Otherwise, if we don't already have it - add it to the list! | ||
228 | headers.add(i) | 230 | headers.add(abspath) | ||
229 | 231 | | |||
230 | # If the library path isn't in the list, then we should add it to the list | 232 | # If the library path isn't in the list, then we should add it to the list | ||
231 | libs.add(target['path']) | 233 | libs.add(target['path']) | ||
232 | 234 | | |||
233 | # Now we can go ahead and generate the XML file for abi-compliance-checker | 235 | # Now we can go ahead and generate the XML file for abi-compliance-checker | ||
234 | xml = """ | 236 | xml = """ | ||
235 | <version>{version}</version> | 237 | <version>{version}</version> | ||
236 | <headers> | 238 | <headers> | ||
▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines |
Not sure why you're storing the list of prefix paths in prefixHeaders and then duplicating it here, unless you've plans to use prefixHeaders elsewhere?