siteinfo.bbclass 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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_for_machine(arch, os, 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. "arc": "endian-little bit-32 arc-common",
  23. "arceb": "endian-big bit-32 arc-common",
  24. "arm": "endian-little bit-32 arm-common arm-32",
  25. "armeb": "endian-big bit-32 arm-common arm-32",
  26. "avr32": "endian-big bit-32 avr32-common",
  27. "bfin": "endian-little bit-32 bfin-common",
  28. "epiphany": "endian-little bit-32",
  29. "i386": "endian-little bit-32 ix86-common",
  30. "i486": "endian-little bit-32 ix86-common",
  31. "i586": "endian-little bit-32 ix86-common",
  32. "i686": "endian-little bit-32 ix86-common",
  33. "ia64": "endian-little bit-64",
  34. "lm32": "endian-big bit-32",
  35. "m68k": "endian-big bit-32",
  36. "microblaze": "endian-big bit-32 microblaze-common",
  37. "microblazeel": "endian-little bit-32 microblaze-common",
  38. "mips": "endian-big bit-32 mips-common",
  39. "mips64": "endian-big bit-64 mips-common",
  40. "mips64el": "endian-little bit-64 mips-common",
  41. "mipsisa64r6": "endian-big bit-64 mips-common",
  42. "mipsisa64r6el": "endian-little bit-64 mips-common",
  43. "mipsel": "endian-little bit-32 mips-common",
  44. "mipsisa32r6": "endian-big bit-32 mips-common",
  45. "mipsisa32r6el": "endian-little bit-32 mips-common",
  46. "powerpc": "endian-big bit-32 powerpc-common",
  47. "powerpcle": "endian-little bit-32 powerpc-common",
  48. "nios2": "endian-little bit-32 nios2-common",
  49. "powerpc64": "endian-big bit-64 powerpc-common",
  50. "powerpc64le": "endian-little bit-64 powerpc-common",
  51. "ppc": "endian-big bit-32 powerpc-common",
  52. "ppc64": "endian-big bit-64 powerpc-common",
  53. "ppc64le" : "endian-little bit-64 powerpc-common",
  54. "riscv32": "endian-little bit-32 riscv-common",
  55. "riscv64": "endian-little bit-64 riscv-common",
  56. "csky": "endian-little bit-32 csky-common",
  57. "sh3": "endian-little bit-32 sh-common",
  58. "sh3eb": "endian-big bit-32 sh-common",
  59. "sh4": "endian-little bit-32 sh-common",
  60. "sh4eb": "endian-big bit-32 sh-common",
  61. "sparc": "endian-big bit-32",
  62. "viac3": "endian-little bit-32 ix86-common",
  63. "x86_64": "endian-little", # bitinfo specified in targetinfo
  64. }
  65. osinfo = {
  66. "darwin": "common-darwin",
  67. "darwin9": "common-darwin",
  68. "linux": "common-linux common-glibc",
  69. "linux-gnu": "common-linux common-glibc",
  70. "linux-gnu_ilp32": "common-linux common-glibc",
  71. "linux-gnux32": "common-linux common-glibc",
  72. "linux-gnun32": "common-linux common-glibc",
  73. "linux-gnueabi": "common-linux common-glibc",
  74. "linux-gnuspe": "common-linux common-glibc",
  75. "linux-musl": "common-linux common-musl",
  76. "linux-muslx32": "common-linux common-musl",
  77. "linux-musleabi": "common-linux common-musl",
  78. "linux-muslspe": "common-linux common-musl",
  79. "uclinux-uclibc": "common-uclibc",
  80. "cygwin": "common-cygwin",
  81. "mingw32": "common-mingw",
  82. }
  83. targetinfo = {
  84. "aarch64-linux-gnu": "aarch64-linux",
  85. "aarch64_be-linux-gnu": "aarch64_be-linux",
  86. "aarch64-linux-gnu_ilp32": "bit-32 aarch64_be-linux arm-32",
  87. "aarch64_be-linux-gnu_ilp32": "bit-32 aarch64_be-linux arm-32",
  88. "aarch64-linux-musl": "aarch64-linux",
  89. "aarch64_be-linux-musl": "aarch64_be-linux",
  90. "arm-linux-gnueabi": "arm-linux",
  91. "arm-linux-musleabi": "arm-linux",
  92. "armeb-linux-gnueabi": "armeb-linux",
  93. "armeb-linux-musleabi": "armeb-linux",
  94. "microblazeel-linux" : "microblaze-linux",
  95. "microblazeel-linux-musl" : "microblaze-linux",
  96. "mips-linux-musl": "mips-linux",
  97. "mipsel-linux-musl": "mipsel-linux",
  98. "mips64-linux-musl": "mips64-linux",
  99. "mips64el-linux-musl": "mips64el-linux",
  100. "mips64-linux-gnun32": "mips-linux bit-32",
  101. "mips64el-linux-gnun32": "mipsel-linux bit-32",
  102. "mipsisa64r6-linux-gnun32": "mipsisa32r6-linux bit-32",
  103. "mipsisa64r6el-linux-gnun32": "mipsisa32r6el-linux bit-32",
  104. "powerpc-linux": "powerpc32-linux",
  105. "powerpc-linux-musl": "powerpc-linux powerpc32-linux",
  106. "powerpcle-linux": "powerpc32-linux",
  107. "powerpcle-linux-musl": "powerpc-linux powerpc32-linux",
  108. "powerpc-linux-gnuspe": "powerpc-linux powerpc32-linux",
  109. "powerpc-linux-muslspe": "powerpc-linux powerpc32-linux",
  110. "powerpc64-linux-gnuspe": "powerpc-linux powerpc64-linux",
  111. "powerpc64-linux-muslspe": "powerpc-linux powerpc64-linux",
  112. "powerpc64-linux": "powerpc-linux powerpc64-linux",
  113. "powerpc64-linux-musl": "powerpc-linux powerpc64-linux",
  114. "powerpc64le-linux": "powerpc-linux powerpc64-linux",
  115. "powerpc64le-linux-musl": "powerpc-linux powerpc64-linux",
  116. "riscv32-linux": "riscv32-linux",
  117. "riscv32-linux-musl": "riscv32-linux",
  118. "riscv64-linux": "riscv64-linux",
  119. "riscv64-linux-musl": "riscv64-linux",
  120. "x86_64-cygwin": "bit-64",
  121. "csky-linux": "csky-linux",
  122. "csky-linux-musl": "csky-linux",
  123. "x86_64-darwin": "bit-64",
  124. "x86_64-darwin9": "bit-64",
  125. "x86_64-linux": "bit-64",
  126. "x86_64-linux-musl": "x86_64-linux bit-64",
  127. "x86_64-linux-muslx32": "bit-32 ix86-common x32-linux",
  128. "x86_64-elf": "bit-64",
  129. "x86_64-linux-gnu": "bit-64 x86_64-linux",
  130. "x86_64-linux-gnux32": "bit-32 ix86-common x32-linux",
  131. "x86_64-mingw32": "bit-64",
  132. }
  133. # Add in any extra user supplied data which may come from a BSP layer, removing the
  134. # need to always change this class directly
  135. extra_siteinfo = (d.getVar("SITEINFO_EXTRA_DATAFUNCS") or "").split()
  136. for m in extra_siteinfo:
  137. call = m + "(archinfo, osinfo, targetinfo, d)"
  138. locs = { "archinfo" : archinfo, "osinfo" : osinfo, "targetinfo" : targetinfo, "d" : d}
  139. archinfo, osinfo, targetinfo = bb.utils.better_eval(call, locs)
  140. target = "%s-%s" % (arch, os)
  141. sitedata = []
  142. if arch in archinfo:
  143. sitedata.extend(archinfo[arch].split())
  144. if os in osinfo:
  145. sitedata.extend(osinfo[os].split())
  146. if target in targetinfo:
  147. sitedata.extend(targetinfo[target].split())
  148. sitedata.append(target)
  149. sitedata.append("common")
  150. bb.debug(1, "SITE files %s" % sitedata);
  151. return sitedata
  152. def siteinfo_data(d):
  153. return siteinfo_data_for_machine(d.getVar("HOST_ARCH"), d.getVar("HOST_OS"), d)
  154. python () {
  155. sitedata = set(siteinfo_data(d))
  156. if "endian-little" in sitedata:
  157. d.setVar("SITEINFO_ENDIANNESS", "le")
  158. elif "endian-big" in sitedata:
  159. d.setVar("SITEINFO_ENDIANNESS", "be")
  160. else:
  161. bb.error("Unable to determine endianness for architecture '%s'" %
  162. d.getVar("HOST_ARCH"))
  163. bb.fatal("Please add your architecture to siteinfo.bbclass")
  164. if "bit-32" in sitedata:
  165. d.setVar("SITEINFO_BITS", "32")
  166. elif "bit-64" in sitedata:
  167. d.setVar("SITEINFO_BITS", "64")
  168. else:
  169. bb.error("Unable to determine bit size for architecture '%s'" %
  170. d.getVar("HOST_ARCH"))
  171. bb.fatal("Please add your architecture to siteinfo.bbclass")
  172. }
  173. def siteinfo_get_files(d, sysrootcache = False):
  174. sitedata = siteinfo_data(d)
  175. sitefiles = ""
  176. for path in d.getVar("BBPATH").split(":"):
  177. for element in sitedata:
  178. filename = os.path.join(path, "site", element)
  179. if os.path.exists(filename):
  180. sitefiles += filename + " "
  181. if not sysrootcache:
  182. return sitefiles
  183. # Now check for siteconfig cache files in sysroots
  184. path_siteconfig = d.getVar('SITECONFIG_SYSROOTCACHE')
  185. if path_siteconfig and os.path.isdir(path_siteconfig):
  186. for i in os.listdir(path_siteconfig):
  187. if not i.endswith("_config"):
  188. continue
  189. filename = os.path.join(path_siteconfig, i)
  190. sitefiles += filename + " "
  191. return sitefiles
  192. #
  193. # Make some information available via variables
  194. #
  195. SITECONFIG_SYSROOTCACHE = "${STAGING_DATADIR}/${TARGET_SYS}_config_site.d"