siteinfo.bbclass 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. # This class exists to provide information about the targets that
  2. # may be needed by other classes and/or recipes. If you add a new
  3. # target this will probably need to be updated.
  4. #
  5. # Returns information about 'what' for the named target 'target'
  6. # where 'target' == "<arch>-<os>"
  7. #
  8. # 'what' can be one of
  9. # * target: Returns the target name ("<arch>-<os>")
  10. # * endianness: Return "be" for big endian targets, "le" for little endian
  11. # * bits: Returns the bit size of the target, either "32" or "64"
  12. # * libc: Returns the name of the c library used by the target
  13. #
  14. # It is an error for the target not to exist.
  15. # If 'what' doesn't exist then an empty value is returned
  16. #
  17. def siteinfo_data(d):
  18. archinfo = {
  19. "allarch": "endian-little bit-32", # bogus, but better than special-casing the checks below for allarch
  20. "aarch64": "endian-little bit-64 arm-common arm-64",
  21. "aarch64_be": "endian-big bit-64 arm-common arm-64",
  22. "arm": "endian-little bit-32 arm-common arm-32",
  23. "armeb": "endian-big bit-32 arm-common arm-32",
  24. "avr32": "endian-big bit-32 avr32-common",
  25. "bfin": "endian-little bit-32 bfin-common",
  26. "epiphany": "endian-little bit-32",
  27. "i386": "endian-little bit-32 ix86-common",
  28. "i486": "endian-little bit-32 ix86-common",
  29. "i586": "endian-little bit-32 ix86-common",
  30. "i686": "endian-little bit-32 ix86-common",
  31. "ia64": "endian-little bit-64",
  32. "microblaze": "endian-big bit-32 microblaze-common",
  33. "microblazeeb": "endian-big bit-32 microblaze-common",
  34. "microblazeel": "endian-little bit-32 microblaze-common",
  35. "mips": "endian-big bit-32 mips-common",
  36. "mips64": "endian-big bit-64 mips-common",
  37. "mips64el": "endian-little bit-64 mips-common",
  38. "mipsisa64r6": "endian-big bit-64 mips-common",
  39. "mipsisa64r6el": "endian-little bit-64 mips-common",
  40. "mipsel": "endian-little bit-32 mips-common",
  41. "mipsisa32r6": "endian-big bit-32 mips-common",
  42. "mipsisa32r6el": "endian-little bit-32 mips-common",
  43. "powerpc": "endian-big bit-32 powerpc-common",
  44. "nios2": "endian-little bit-32 nios2-common",
  45. "powerpc64": "endian-big bit-64 powerpc-common",
  46. "ppc": "endian-big bit-32 powerpc-common",
  47. "ppc64": "endian-big bit-64 powerpc-common",
  48. "ppc64le" : "endian-little bit-64 powerpc-common",
  49. "sh3": "endian-little bit-32 sh-common",
  50. "sh4": "endian-little bit-32 sh-common",
  51. "sparc": "endian-big bit-32",
  52. "viac3": "endian-little bit-32 ix86-common",
  53. "x86_64": "endian-little", # bitinfo specified in targetinfo
  54. }
  55. osinfo = {
  56. "darwin": "common-darwin",
  57. "darwin9": "common-darwin",
  58. "linux": "common-linux common-glibc",
  59. "linux-gnu": "common-linux common-glibc",
  60. "linux-gnux32": "common-linux common-glibc",
  61. "linux-gnun32": "common-linux common-glibc",
  62. "linux-gnueabi": "common-linux common-glibc",
  63. "linux-gnuspe": "common-linux common-glibc",
  64. "linux-musl": "common-linux common-musl",
  65. "linux-muslx32": "common-linux common-musl",
  66. "linux-musleabi": "common-linux common-musl",
  67. "linux-muslspe": "common-linux common-musl",
  68. "uclinux-uclibc": "common-uclibc",
  69. "cygwin": "common-cygwin",
  70. "mingw32": "common-mingw",
  71. }
  72. targetinfo = {
  73. "aarch64-linux-gnu": "aarch64-linux",
  74. "aarch64_be-linux-gnu": "aarch64_be-linux",
  75. "aarch64-linux-musl": "aarch64-linux",
  76. "aarch64_be-linux-musl": "aarch64_be-linux",
  77. "arm-linux-gnueabi": "arm-linux",
  78. "arm-linux-musleabi": "arm-linux",
  79. "armeb-linux-gnueabi": "armeb-linux",
  80. "armeb-linux-musleabi": "armeb-linux",
  81. "mips-linux-musl": "mips-linux",
  82. "mipsel-linux-musl": "mipsel-linux",
  83. "mips64-linux-musl": "mips64-linux",
  84. "mips64el-linux-musl": "mips64el-linux",
  85. "mips64-linux-gnun32": "mips-linux bit-32",
  86. "mips64el-linux-gnun32": "mipsel-linux bit-32",
  87. "mipsisa64r6-linux-gnun32": "mipsisa32r6-linux bit-32",
  88. "mipsisa64r6el-linux-gnun32": "mipsisa32r6el-linux bit-32",
  89. "powerpc-linux": "powerpc32-linux",
  90. "powerpc-linux-musl": "powerpc-linux powerpc32-linux",
  91. "powerpc-linux-gnuspe": "powerpc-linux powerpc32-linux",
  92. "powerpc-linux-muslspe": "powerpc-linux powerpc32-linux",
  93. "powerpc64-linux-gnuspe": "powerpc-linux powerpc64-linux",
  94. "powerpc64-linux-muslspe": "powerpc-linux powerpc64-linux",
  95. "powerpc64-linux": "powerpc-linux",
  96. "powerpc64-linux-musl": "powerpc-linux",
  97. "x86_64-cygwin": "bit-64",
  98. "x86_64-darwin": "bit-64",
  99. "x86_64-darwin9": "bit-64",
  100. "x86_64-linux": "bit-64",
  101. "x86_64-linux-musl": "x86_64-linux bit-64",
  102. "x86_64-linux-muslx32": "bit-32 ix86-common x32-linux",
  103. "x86_64-elf": "bit-64",
  104. "x86_64-linux-gnu": "bit-64 x86_64-linux",
  105. "x86_64-linux-gnux32": "bit-32 ix86-common x32-linux",
  106. "x86_64-mingw32": "bit-64",
  107. }
  108. # Add in any extra user supplied data which may come from a BSP layer, removing the
  109. # need to always change this class directly
  110. extra_siteinfo = (d.getVar("SITEINFO_EXTRA_DATAFUNCS") or "").split()
  111. for m in extra_siteinfo:
  112. call = m + "(archinfo, osinfo, targetinfo, d)"
  113. locs = { "archinfo" : archinfo, "osinfo" : osinfo, "targetinfo" : targetinfo, "d" : d}
  114. archinfo, osinfo, targetinfo = bb.utils.better_eval(call, locs)
  115. hostarch = d.getVar("HOST_ARCH")
  116. hostos = d.getVar("HOST_OS")
  117. target = "%s-%s" % (hostarch, hostos)
  118. sitedata = []
  119. if hostarch in archinfo:
  120. sitedata.extend(archinfo[hostarch].split())
  121. if hostos in osinfo:
  122. sitedata.extend(osinfo[hostos].split())
  123. if target in targetinfo:
  124. sitedata.extend(targetinfo[target].split())
  125. sitedata.append(target)
  126. sitedata.append("common")
  127. bb.debug(1, "SITE files %s" % sitedata);
  128. return sitedata
  129. python () {
  130. sitedata = set(siteinfo_data(d))
  131. if "endian-little" in sitedata:
  132. d.setVar("SITEINFO_ENDIANNESS", "le")
  133. elif "endian-big" in sitedata:
  134. d.setVar("SITEINFO_ENDIANNESS", "be")
  135. else:
  136. bb.error("Unable to determine endianness for architecture '%s'" %
  137. d.getVar("HOST_ARCH"))
  138. bb.fatal("Please add your architecture to siteinfo.bbclass")
  139. if "bit-32" in sitedata:
  140. d.setVar("SITEINFO_BITS", "32")
  141. elif "bit-64" in sitedata:
  142. d.setVar("SITEINFO_BITS", "64")
  143. else:
  144. bb.error("Unable to determine bit size for architecture '%s'" %
  145. d.getVar("HOST_ARCH"))
  146. bb.fatal("Please add your architecture to siteinfo.bbclass")
  147. }
  148. def siteinfo_get_files(d, sysrootcache = False):
  149. sitedata = siteinfo_data(d)
  150. sitefiles = ""
  151. for path in d.getVar("BBPATH").split(":"):
  152. for element in sitedata:
  153. filename = os.path.join(path, "site", element)
  154. if os.path.exists(filename):
  155. sitefiles += filename + " "
  156. if not sysrootcache:
  157. return sitefiles
  158. # Now check for siteconfig cache files in sysroots
  159. path_siteconfig = d.getVar('SITECONFIG_SYSROOTCACHE')
  160. if path_siteconfig and os.path.isdir(path_siteconfig):
  161. for i in os.listdir(path_siteconfig):
  162. if not i.endswith("_config"):
  163. continue
  164. filename = os.path.join(path_siteconfig, i)
  165. sitefiles += filename + " "
  166. return sitefiles
  167. #
  168. # Make some information available via variables
  169. #
  170. SITECONFIG_SYSROOTCACHE = "${STAGING_DATADIR}/${TARGET_SYS}_config_site.d"