cache_extra.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # ex:ts=4:sw=4:sts=4:et
  2. # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
  3. #
  4. # Extra RecipeInfo will be all defined in this file. Currently,
  5. # Only Hob (Image Creator) Requests some extra fields. So
  6. # HobRecipeInfo is defined. It's named HobRecipeInfo because it
  7. # is introduced by 'hob'. Users could also introduce other
  8. # RecipeInfo or simply use those already defined RecipeInfo.
  9. # In the following patch, this newly defined new extra RecipeInfo
  10. # will be dynamically loaded and used for loading/saving the extra
  11. # cache fields
  12. # Copyright (C) 2011, Intel Corporation. All rights reserved.
  13. # SPDX-License-Identifier: GPL-2.0-only
  14. #
  15. from bb.cache import RecipeInfoCommon
  16. class HobRecipeInfo(RecipeInfoCommon):
  17. __slots__ = ()
  18. classname = "HobRecipeInfo"
  19. # please override this member with the correct data cache file
  20. # such as (bb_cache.dat, bb_extracache_hob.dat)
  21. cachefile = "bb_extracache_" + classname +".dat"
  22. # override this member with the list of extra cache fields
  23. # that this class will provide
  24. cachefields = ['summary', 'license', 'section',
  25. 'description', 'homepage', 'bugtracker',
  26. 'prevision', 'files_info']
  27. def __init__(self, filename, metadata):
  28. self.summary = self.getvar('SUMMARY', metadata)
  29. self.license = self.getvar('LICENSE', metadata)
  30. self.section = self.getvar('SECTION', metadata)
  31. self.description = self.getvar('DESCRIPTION', metadata)
  32. self.homepage = self.getvar('HOMEPAGE', metadata)
  33. self.bugtracker = self.getvar('BUGTRACKER', metadata)
  34. self.prevision = self.getvar('PR', metadata)
  35. self.files_info = self.getvar('FILES_INFO', metadata)
  36. @classmethod
  37. def init_cacheData(cls, cachedata):
  38. # CacheData in Hob RecipeInfo Class
  39. cachedata.summary = {}
  40. cachedata.license = {}
  41. cachedata.section = {}
  42. cachedata.description = {}
  43. cachedata.homepage = {}
  44. cachedata.bugtracker = {}
  45. cachedata.prevision = {}
  46. cachedata.files_info = {}
  47. def add_cacheData(self, cachedata, fn):
  48. cachedata.summary[fn] = self.summary
  49. cachedata.license[fn] = self.license
  50. cachedata.section[fn] = self.section
  51. cachedata.description[fn] = self.description
  52. cachedata.homepage[fn] = self.homepage
  53. cachedata.bugtracker[fn] = self.bugtracker
  54. cachedata.prevision[fn] = self.prevision
  55. cachedata.files_info[fn] = self.files_info