cache_extra.py 2.4 KB

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