cache_extra.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. # This program is free software; you can redistribute it and/or modify
  14. # it under the terms of the GNU General Public License version 2 as
  15. # published by the Free Software Foundation.
  16. #
  17. # This program is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. # GNU General Public License for more details.
  21. #
  22. # You should have received a copy of the GNU General Public License along
  23. # with this program; if not, write to the Free Software Foundation, Inc.,
  24. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  25. from bb.cache import RecipeInfoCommon
  26. class HobRecipeInfo(RecipeInfoCommon):
  27. __slots__ = ()
  28. classname = "HobRecipeInfo"
  29. # please override this member with the correct data cache file
  30. # such as (bb_cache.dat, bb_extracache_hob.dat)
  31. cachefile = "bb_extracache_" + classname +".dat"
  32. # override this member with the list of extra cache fields
  33. # that this class will provide
  34. cachefields = ['summary', 'license', 'section',
  35. 'description', 'homepage', 'bugtracker',
  36. 'prevision', 'files_info']
  37. def __init__(self, filename, metadata):
  38. self.summary = self.getvar('SUMMARY', metadata)
  39. self.license = self.getvar('LICENSE', metadata)
  40. self.section = self.getvar('SECTION', metadata)
  41. self.description = self.getvar('DESCRIPTION', metadata)
  42. self.homepage = self.getvar('HOMEPAGE', metadata)
  43. self.bugtracker = self.getvar('BUGTRACKER', metadata)
  44. self.prevision = self.getvar('PR', metadata)
  45. self.files_info = self.getvar('FILES_INFO', metadata)
  46. @classmethod
  47. def init_cacheData(cls, cachedata):
  48. # CacheData in Hob RecipeInfo Class
  49. cachedata.summary = {}
  50. cachedata.license = {}
  51. cachedata.section = {}
  52. cachedata.description = {}
  53. cachedata.homepage = {}
  54. cachedata.bugtracker = {}
  55. cachedata.prevision = {}
  56. cachedata.files_info = {}
  57. def add_cacheData(self, cachedata, fn):
  58. cachedata.summary[fn] = self.summary
  59. cachedata.license[fn] = self.license
  60. cachedata.section[fn] = self.section
  61. cachedata.description[fn] = self.description
  62. cachedata.homepage[fn] = self.homepage
  63. cachedata.bugtracker[fn] = self.bugtracker
  64. cachedata.prevision[fn] = self.prevision
  65. cachedata.files_info[fn] = self.files_info