diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-08-15 18:00:45 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-08-18 10:06:26 +0100 |
commit | 97ce9126a6de2faf78441f686a1b52b5f68f9a62 (patch) | |
tree | 972e1f7c930fb2aa003d3725e813601f8ea997b8 /bitbake | |
parent | 4cd5647f125f61a45d3145b54277471fa1a31433 (diff) | |
download | poky-97ce9126a6de2faf78441f686a1b52b5f68f9a62.tar.gz |
bitbake: cache: Make virtualfn2realfn/realfn2virtual standalone functions
Needing to access these static methods through a class doesn't
make sense. Move these to become module level standalone functions.
(Bitbake rev: 6d06e93c6a2204af6d2cf747a4610bd0eeb9f202)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/cache.py | 55 | ||||
-rw-r--r-- | bitbake/lib/bb/cooker.py | 10 | ||||
-rw-r--r-- | bitbake/lib/bblayers/query.py | 10 |
3 files changed, 35 insertions, 40 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py index 658f30ff59..c915bb93fc 100644 --- a/bitbake/lib/bb/cache.py +++ b/bitbake/lib/bb/cache.py | |||
@@ -244,7 +244,26 @@ class CoreRecipeInfo(RecipeInfoCommon): | |||
244 | cachedata.fakerootdirs[fn] = self.fakerootdirs | 244 | cachedata.fakerootdirs[fn] = self.fakerootdirs |
245 | cachedata.extradepsfunc[fn] = self.extradepsfunc | 245 | cachedata.extradepsfunc[fn] = self.extradepsfunc |
246 | 246 | ||
247 | def virtualfn2realfn(virtualfn): | ||
248 | """ | ||
249 | Convert a virtual file name to a real one + the associated subclass keyword | ||
250 | """ | ||
247 | 251 | ||
252 | fn = virtualfn | ||
253 | cls = "" | ||
254 | if virtualfn.startswith('virtual:'): | ||
255 | elems = virtualfn.split(':') | ||
256 | cls = ":".join(elems[1:-1]) | ||
257 | fn = elems[-1] | ||
258 | return (fn, cls) | ||
259 | |||
260 | def realfn2virtual(realfn, cls): | ||
261 | """ | ||
262 | Convert a real filename + the associated subclass keyword to a virtual filename | ||
263 | """ | ||
264 | if cls == "": | ||
265 | return realfn | ||
266 | return "virtual:" + cls + ":" + realfn | ||
248 | 267 | ||
249 | class Cache(object): | 268 | class Cache(object): |
250 | """ | 269 | """ |
@@ -355,30 +374,6 @@ class Cache(object): | |||
355 | len(self.depends_cache)), | 374 | len(self.depends_cache)), |
356 | self.data) | 375 | self.data) |
357 | 376 | ||
358 | |||
359 | @staticmethod | ||
360 | def virtualfn2realfn(virtualfn): | ||
361 | """ | ||
362 | Convert a virtual file name to a real one + the associated subclass keyword | ||
363 | """ | ||
364 | |||
365 | fn = virtualfn | ||
366 | cls = "" | ||
367 | if virtualfn.startswith('virtual:'): | ||
368 | elems = virtualfn.split(':') | ||
369 | cls = ":".join(elems[1:-1]) | ||
370 | fn = elems[-1] | ||
371 | return (fn, cls) | ||
372 | |||
373 | @staticmethod | ||
374 | def realfn2virtual(realfn, cls): | ||
375 | """ | ||
376 | Convert a real filename + the associated subclass keyword to a virtual filename | ||
377 | """ | ||
378 | if cls == "": | ||
379 | return realfn | ||
380 | return "virtual:" + cls + ":" + realfn | ||
381 | |||
382 | @classmethod | 377 | @classmethod |
383 | def loadDataFull(cls, virtualfn, appends, cfgData): | 378 | def loadDataFull(cls, virtualfn, appends, cfgData): |
384 | """ | 379 | """ |
@@ -386,7 +381,7 @@ class Cache(object): | |||
386 | To do this, we need to parse the file. | 381 | To do this, we need to parse the file. |
387 | """ | 382 | """ |
388 | 383 | ||
389 | (fn, virtual) = cls.virtualfn2realfn(virtualfn) | 384 | (fn, virtual) = virtualfn2realfn(virtualfn) |
390 | 385 | ||
391 | logger.debug(1, "Parsing %s (full)", fn) | 386 | logger.debug(1, "Parsing %s (full)", fn) |
392 | 387 | ||
@@ -406,7 +401,7 @@ class Cache(object): | |||
406 | for variant, data in sorted(datastores.items(), | 401 | for variant, data in sorted(datastores.items(), |
407 | key=lambda i: i[0], | 402 | key=lambda i: i[0], |
408 | reverse=True): | 403 | reverse=True): |
409 | virtualfn = cls.realfn2virtual(filename, variant) | 404 | virtualfn = realfn2virtual(filename, variant) |
410 | variants.append(variant) | 405 | variants.append(variant) |
411 | depends = depends + (data.getVar("__depends", False) or []) | 406 | depends = depends + (data.getVar("__depends", False) or []) |
412 | if depends and not variant: | 407 | if depends and not variant: |
@@ -435,7 +430,7 @@ class Cache(object): | |||
435 | # info_array item is a list of [CoreRecipeInfo, XXXRecipeInfo] | 430 | # info_array item is a list of [CoreRecipeInfo, XXXRecipeInfo] |
436 | info_array = self.depends_cache[filename] | 431 | info_array = self.depends_cache[filename] |
437 | for variant in info_array[0].variants: | 432 | for variant in info_array[0].variants: |
438 | virtualfn = self.realfn2virtual(filename, variant) | 433 | virtualfn = realfn2virtual(filename, variant) |
439 | infos.append((virtualfn, self.depends_cache[virtualfn])) | 434 | infos.append((virtualfn, self.depends_cache[virtualfn])) |
440 | else: | 435 | else: |
441 | return self.parse(filename, appends, configdata, self.caches_array) | 436 | return self.parse(filename, appends, configdata, self.caches_array) |
@@ -556,7 +551,7 @@ class Cache(object): | |||
556 | 551 | ||
557 | invalid = False | 552 | invalid = False |
558 | for cls in info_array[0].variants: | 553 | for cls in info_array[0].variants: |
559 | virtualfn = self.realfn2virtual(fn, cls) | 554 | virtualfn = realfn2virtual(fn, cls) |
560 | self.clean.add(virtualfn) | 555 | self.clean.add(virtualfn) |
561 | if virtualfn not in self.depends_cache: | 556 | if virtualfn not in self.depends_cache: |
562 | logger.debug(2, "Cache: %s is not cached", virtualfn) | 557 | logger.debug(2, "Cache: %s is not cached", virtualfn) |
@@ -568,7 +563,7 @@ class Cache(object): | |||
568 | # If any one of the variants is not present, mark as invalid for all | 563 | # If any one of the variants is not present, mark as invalid for all |
569 | if invalid: | 564 | if invalid: |
570 | for cls in info_array[0].variants: | 565 | for cls in info_array[0].variants: |
571 | virtualfn = self.realfn2virtual(fn, cls) | 566 | virtualfn = realfn2virtual(fn, cls) |
572 | if virtualfn in self.clean: | 567 | if virtualfn in self.clean: |
573 | logger.debug(2, "Cache: Removing %s from cache", virtualfn) | 568 | logger.debug(2, "Cache: Removing %s from cache", virtualfn) |
574 | self.clean.remove(virtualfn) | 569 | self.clean.remove(virtualfn) |
@@ -645,7 +640,7 @@ class Cache(object): | |||
645 | Save data we need into the cache | 640 | Save data we need into the cache |
646 | """ | 641 | """ |
647 | 642 | ||
648 | realfn = self.virtualfn2realfn(file_name)[0] | 643 | realfn = virtualfn2realfn(file_name)[0] |
649 | 644 | ||
650 | info_array = [] | 645 | info_array = [] |
651 | for cache_class in self.caches_array: | 646 | for cache_class in self.caches_array: |
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index d4dd23f09c..11c611de72 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -601,9 +601,9 @@ class BBCooker: | |||
601 | # this showEnvironment() code path doesn't use the cache | 601 | # this showEnvironment() code path doesn't use the cache |
602 | self.parseConfiguration() | 602 | self.parseConfiguration() |
603 | 603 | ||
604 | fn, cls = bb.cache.Cache.virtualfn2realfn(buildfile) | 604 | fn, cls = bb.cache.virtualfn2realfn(buildfile) |
605 | fn = self.matchFile(fn) | 605 | fn = self.matchFile(fn) |
606 | fn = bb.cache.Cache.realfn2virtual(fn, cls) | 606 | fn = bb.cache.realfn2virtual(fn, cls) |
607 | elif len(pkgs_to_build) == 1: | 607 | elif len(pkgs_to_build) == 1: |
608 | ignore = self.expanded_data.getVar("ASSUME_PROVIDED", True) or "" | 608 | ignore = self.expanded_data.getVar("ASSUME_PROVIDED", True) or "" |
609 | if pkgs_to_build[0] in set(ignore.split()): | 609 | if pkgs_to_build[0] in set(ignore.split()): |
@@ -1249,7 +1249,7 @@ class BBCooker: | |||
1249 | if (task == None): | 1249 | if (task == None): |
1250 | task = self.configuration.cmd | 1250 | task = self.configuration.cmd |
1251 | 1251 | ||
1252 | fn, cls = bb.cache.Cache.virtualfn2realfn(buildfile) | 1252 | fn, cls = bb.cache.virtualfn2realfn(buildfile) |
1253 | fn = self.matchFile(fn) | 1253 | fn = self.matchFile(fn) |
1254 | 1254 | ||
1255 | self.buildSetVars() | 1255 | self.buildSetVars() |
@@ -1259,7 +1259,7 @@ class BBCooker: | |||
1259 | self.caches_array) | 1259 | self.caches_array) |
1260 | infos = dict(infos) | 1260 | infos = dict(infos) |
1261 | 1261 | ||
1262 | fn = bb.cache.Cache.realfn2virtual(fn, cls) | 1262 | fn = bb.cache.realfn2virtual(fn, cls) |
1263 | try: | 1263 | try: |
1264 | info_array = infos[fn] | 1264 | info_array = infos[fn] |
1265 | except KeyError: | 1265 | except KeyError: |
@@ -1822,7 +1822,7 @@ class CookerCollectFiles(object): | |||
1822 | # Calculate priorities for each file | 1822 | # Calculate priorities for each file |
1823 | matched = set() | 1823 | matched = set() |
1824 | for p in pkgfns: | 1824 | for p in pkgfns: |
1825 | realfn, cls = bb.cache.Cache.virtualfn2realfn(p) | 1825 | realfn, cls = bb.cache.virtualfn2realfn(p) |
1826 | priorities[p] = self.calc_bbfile_priority(realfn, matched) | 1826 | priorities[p] = self.calc_bbfile_priority(realfn, matched) |
1827 | 1827 | ||
1828 | # Don't show the warning if the BBFILE_PATTERN did match .bbappend files | 1828 | # Don't show the warning if the BBFILE_PATTERN did match .bbappend files |
diff --git a/bitbake/lib/bblayers/query.py b/bitbake/lib/bblayers/query.py index 0a496810f2..6e62082a2e 100644 --- a/bitbake/lib/bblayers/query.py +++ b/bitbake/lib/bblayers/query.py | |||
@@ -170,7 +170,7 @@ skipped recipes will also be listed, with a " (skipped)" suffix. | |||
170 | 170 | ||
171 | if len(allproviders[p]) > 1 or not show_multi_provider_only: | 171 | if len(allproviders[p]) > 1 or not show_multi_provider_only: |
172 | pref = preferred_versions[p] | 172 | pref = preferred_versions[p] |
173 | realfn = bb.cache.Cache.virtualfn2realfn(pref[1]) | 173 | realfn = bb.cache.virtualfn2realfn(pref[1]) |
174 | preffile = realfn[0] | 174 | preffile = realfn[0] |
175 | 175 | ||
176 | # We only display once per recipe, we should prefer non extended versions of the | 176 | # We only display once per recipe, we should prefer non extended versions of the |
@@ -200,7 +200,7 @@ skipped recipes will also be listed, with a " (skipped)" suffix. | |||
200 | same_ver = True | 200 | same_ver = True |
201 | provs = [] | 201 | provs = [] |
202 | for prov in allproviders[p]: | 202 | for prov in allproviders[p]: |
203 | provfile = bb.cache.Cache.virtualfn2realfn(prov[1])[0] | 203 | provfile = bb.cache.virtualfn2realfn(prov[1])[0] |
204 | provlayer = self.get_file_layer(provfile) | 204 | provlayer = self.get_file_layer(provfile) |
205 | provs.append((provfile, provlayer, prov[0])) | 205 | provs.append((provfile, provlayer, prov[0])) |
206 | if provlayer != preflayer: | 206 | if provlayer != preflayer: |
@@ -297,7 +297,7 @@ Lists recipes with the bbappends that apply to them as subitems. | |||
297 | def get_appends_for_files(self, filenames): | 297 | def get_appends_for_files(self, filenames): |
298 | appended, notappended = [], [] | 298 | appended, notappended = [], [] |
299 | for filename in filenames: | 299 | for filename in filenames: |
300 | _, cls = bb.cache.Cache.virtualfn2realfn(filename) | 300 | _, cls = bb.cache.virtualfn2realfn(filename) |
301 | if cls: | 301 | if cls: |
302 | continue | 302 | continue |
303 | 303 | ||
@@ -328,7 +328,7 @@ NOTE: .bbappend files can impact the dependencies. | |||
328 | 328 | ||
329 | # The bb's DEPENDS and RDEPENDS | 329 | # The bb's DEPENDS and RDEPENDS |
330 | for f in pkg_fn: | 330 | for f in pkg_fn: |
331 | f = bb.cache.Cache.virtualfn2realfn(f)[0] | 331 | f = bb.cache.virtualfn2realfn(f)[0] |
332 | # Get the layername that the file is in | 332 | # Get the layername that the file is in |
333 | layername = self.get_file_layer(f) | 333 | layername = self.get_file_layer(f) |
334 | 334 | ||
@@ -471,7 +471,7 @@ NOTE: .bbappend files can impact the dependencies. | |||
471 | 471 | ||
472 | def check_cross_depends(self, keyword, layername, f, needed_file, show_filenames, ignore_layers): | 472 | def check_cross_depends(self, keyword, layername, f, needed_file, show_filenames, ignore_layers): |
473 | """Print the DEPENDS/RDEPENDS file that crosses a layer boundary""" | 473 | """Print the DEPENDS/RDEPENDS file that crosses a layer boundary""" |
474 | best_realfn = bb.cache.Cache.virtualfn2realfn(needed_file)[0] | 474 | best_realfn = bb.cache.virtualfn2realfn(needed_file)[0] |
475 | needed_layername = self.get_file_layer(best_realfn) | 475 | needed_layername = self.get_file_layer(best_realfn) |
476 | if needed_layername != layername and not needed_layername in ignore_layers: | 476 | if needed_layername != layername and not needed_layername in ignore_layers: |
477 | if not show_filenames: | 477 | if not show_filenames: |