cache_extra.py 3.1 KB

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