siteinfo.bbclass 8.3 KB

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