blob: 1a048c053f7c604b1066dd551e33ab4f729a5abc [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# 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#
6# Returns information about 'what' for the named target 'target'
7# where 'target' == "<arch>-<os>"
8#
9# 'what' can be one of
10# * target: Returns the target name ("<arch>-<os>")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050011# * endianness: Return "be" for big endian targets, "le" for little endian
Patrick Williamsc124f4f2015-09-15 14:41:29 -050012# * bits: Returns the bit size of the target, either "32" or "64"
13# * libc: Returns the name of the c library used by the target
14#
15# It is an error for the target not to exist.
16# If 'what' doesn't exist then an empty value is returned
17#
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080018def siteinfo_data_for_machine(arch, os, d):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019 archinfo = {
20 "allarch": "endian-little bit-32", # bogus, but better than special-casing the checks below for allarch
21 "aarch64": "endian-little bit-64 arm-common arm-64",
22 "aarch64_be": "endian-big bit-64 arm-common arm-64",
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080023 "arc": "endian-little bit-32 arc-common",
24 "arceb": "endian-big bit-32 arc-common",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025 "arm": "endian-little bit-32 arm-common arm-32",
26 "armeb": "endian-big bit-32 arm-common arm-32",
27 "avr32": "endian-big bit-32 avr32-common",
28 "bfin": "endian-little bit-32 bfin-common",
29 "epiphany": "endian-little bit-32",
30 "i386": "endian-little bit-32 ix86-common",
31 "i486": "endian-little bit-32 ix86-common",
32 "i586": "endian-little bit-32 ix86-common",
33 "i686": "endian-little bit-32 ix86-common",
34 "ia64": "endian-little bit-64",
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080035 "lm32": "endian-big bit-32",
36 "m68k": "endian-big bit-32",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037 "microblaze": "endian-big bit-32 microblaze-common",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050038 "microblazeel": "endian-little bit-32 microblaze-common",
39 "mips": "endian-big bit-32 mips-common",
40 "mips64": "endian-big bit-64 mips-common",
41 "mips64el": "endian-little bit-64 mips-common",
Patrick Williamsc0f7c042017-02-23 20:41:17 -060042 "mipsisa64r6": "endian-big bit-64 mips-common",
43 "mipsisa64r6el": "endian-little bit-64 mips-common",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050044 "mipsel": "endian-little bit-32 mips-common",
Patrick Williamsc0f7c042017-02-23 20:41:17 -060045 "mipsisa32r6": "endian-big bit-32 mips-common",
46 "mipsisa32r6el": "endian-little bit-32 mips-common",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050047 "powerpc": "endian-big bit-32 powerpc-common",
48 "nios2": "endian-little bit-32 nios2-common",
49 "powerpc64": "endian-big bit-64 powerpc-common",
Andrew Geissler82c905d2020-04-13 13:39:40 -050050 "powerpc64le": "endian-little bit-64 powerpc-common",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050051 "ppc": "endian-big bit-32 powerpc-common",
52 "ppc64": "endian-big bit-64 powerpc-common",
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050053 "ppc64le" : "endian-little bit-64 powerpc-common",
Brad Bishop316dfdd2018-06-25 12:45:53 -040054 "riscv32": "endian-little bit-32 riscv-common",
55 "riscv64": "endian-little bit-64 riscv-common",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050056 "sh3": "endian-little bit-32 sh-common",
57 "sh4": "endian-little bit-32 sh-common",
58 "sparc": "endian-big bit-32",
59 "viac3": "endian-little bit-32 ix86-common",
60 "x86_64": "endian-little", # bitinfo specified in targetinfo
61 }
62 osinfo = {
63 "darwin": "common-darwin",
64 "darwin9": "common-darwin",
65 "linux": "common-linux common-glibc",
66 "linux-gnu": "common-linux common-glibc",
Brad Bishop316dfdd2018-06-25 12:45:53 -040067 "linux-gnu_ilp32": "common-linux common-glibc",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050068 "linux-gnux32": "common-linux common-glibc",
69 "linux-gnun32": "common-linux common-glibc",
70 "linux-gnueabi": "common-linux common-glibc",
71 "linux-gnuspe": "common-linux common-glibc",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050072 "linux-musl": "common-linux common-musl",
Brad Bishopd7bf8c12018-02-25 22:55:05 -050073 "linux-muslx32": "common-linux common-musl",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074 "linux-musleabi": "common-linux common-musl",
75 "linux-muslspe": "common-linux common-musl",
76 "uclinux-uclibc": "common-uclibc",
77 "cygwin": "common-cygwin",
78 "mingw32": "common-mingw",
79 }
80 targetinfo = {
81 "aarch64-linux-gnu": "aarch64-linux",
82 "aarch64_be-linux-gnu": "aarch64_be-linux",
Brad Bishop316dfdd2018-06-25 12:45:53 -040083 "aarch64-linux-gnu_ilp32": "bit-32 aarch64_be-linux arm-32",
84 "aarch64_be-linux-gnu_ilp32": "bit-32 aarch64_be-linux arm-32",
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050085 "aarch64-linux-musl": "aarch64-linux",
86 "aarch64_be-linux-musl": "aarch64_be-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050087 "arm-linux-gnueabi": "arm-linux",
88 "arm-linux-musleabi": "arm-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050089 "armeb-linux-gnueabi": "armeb-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050090 "armeb-linux-musleabi": "armeb-linux",
Brad Bishop316dfdd2018-06-25 12:45:53 -040091 "microblazeel-linux" : "microblaze-linux",
92 "microblazeel-linux-musl" : "microblaze-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050093 "mips-linux-musl": "mips-linux",
94 "mipsel-linux-musl": "mipsel-linux",
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050095 "mips64-linux-musl": "mips64-linux",
96 "mips64el-linux-musl": "mips64el-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097 "mips64-linux-gnun32": "mips-linux bit-32",
98 "mips64el-linux-gnun32": "mipsel-linux bit-32",
Brad Bishop6e60e8b2018-02-01 10:27:11 -050099 "mipsisa64r6-linux-gnun32": "mipsisa32r6-linux bit-32",
100 "mipsisa64r6el-linux-gnun32": "mipsisa32r6el-linux bit-32",
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500101 "powerpc-linux": "powerpc32-linux",
102 "powerpc-linux-musl": "powerpc-linux powerpc32-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500103 "powerpc-linux-gnuspe": "powerpc-linux powerpc32-linux",
104 "powerpc-linux-muslspe": "powerpc-linux powerpc32-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500105 "powerpc64-linux-gnuspe": "powerpc-linux powerpc64-linux",
106 "powerpc64-linux-muslspe": "powerpc-linux powerpc64-linux",
Andrew Geissler82c905d2020-04-13 13:39:40 -0500107 "powerpc64-linux": "powerpc-linux powerpc64-linux",
108 "powerpc64-linux-musl": "powerpc-linux powerpc64-linux",
109 "powerpc64le-linux": "powerpc-linux powerpc64-linux",
110 "powerpc64le-linux-musl": "powerpc-linux powerpc64-linux",
Brad Bishop316dfdd2018-06-25 12:45:53 -0400111 "riscv32-linux": "riscv32-linux",
112 "riscv32-linux-musl": "riscv32-linux",
113 "riscv64-linux": "riscv64-linux",
114 "riscv64-linux-musl": "riscv64-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500115 "x86_64-cygwin": "bit-64",
116 "x86_64-darwin": "bit-64",
117 "x86_64-darwin9": "bit-64",
118 "x86_64-linux": "bit-64",
119 "x86_64-linux-musl": "x86_64-linux bit-64",
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500120 "x86_64-linux-muslx32": "bit-32 ix86-common x32-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500121 "x86_64-elf": "bit-64",
122 "x86_64-linux-gnu": "bit-64 x86_64-linux",
123 "x86_64-linux-gnux32": "bit-32 ix86-common x32-linux",
124 "x86_64-mingw32": "bit-64",
125 }
126
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600127 # Add in any extra user supplied data which may come from a BSP layer, removing the
128 # need to always change this class directly
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500129 extra_siteinfo = (d.getVar("SITEINFO_EXTRA_DATAFUNCS") or "").split()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600130 for m in extra_siteinfo:
131 call = m + "(archinfo, osinfo, targetinfo, d)"
132 locs = { "archinfo" : archinfo, "osinfo" : osinfo, "targetinfo" : targetinfo, "d" : d}
133 archinfo, osinfo, targetinfo = bb.utils.better_eval(call, locs)
134
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800135 target = "%s-%s" % (arch, os)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500136
137 sitedata = []
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800138 if arch in archinfo:
139 sitedata.extend(archinfo[arch].split())
140 if os in osinfo:
141 sitedata.extend(osinfo[os].split())
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500142 if target in targetinfo:
143 sitedata.extend(targetinfo[target].split())
144 sitedata.append(target)
145 sitedata.append("common")
146
147 bb.debug(1, "SITE files %s" % sitedata);
148 return sitedata
149
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800150def siteinfo_data(d):
151 return siteinfo_data_for_machine(d.getVar("HOST_ARCH"), d.getVar("HOST_OS"), d)
152
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500153python () {
154 sitedata = set(siteinfo_data(d))
155 if "endian-little" in sitedata:
156 d.setVar("SITEINFO_ENDIANNESS", "le")
157 elif "endian-big" in sitedata:
158 d.setVar("SITEINFO_ENDIANNESS", "be")
159 else:
160 bb.error("Unable to determine endianness for architecture '%s'" %
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500161 d.getVar("HOST_ARCH"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500162 bb.fatal("Please add your architecture to siteinfo.bbclass")
163
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'" %
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500170 d.getVar("HOST_ARCH"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500171 bb.fatal("Please add your architecture to siteinfo.bbclass")
172}
173
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500174def siteinfo_get_files(d, sysrootcache = False):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500175 sitedata = siteinfo_data(d)
176 sitefiles = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500177 for path in d.getVar("BBPATH").split(":"):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500178 for element in sitedata:
179 filename = os.path.join(path, "site", element)
180 if os.path.exists(filename):
181 sitefiles += filename + " "
182
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500183 if not sysrootcache:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600184 return sitefiles
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500185
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500186 # Now check for siteconfig cache files in sysroots
187 path_siteconfig = d.getVar('SITECONFIG_SYSROOTCACHE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500188 if path_siteconfig and os.path.isdir(path_siteconfig):
189 for i in os.listdir(path_siteconfig):
190 if not i.endswith("_config"):
191 continue
192 filename = os.path.join(path_siteconfig, i)
193 sitefiles += filename + " "
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500194 return sitefiles
195
196#
197# Make some information available via variables
198#
199SITECONFIG_SYSROOTCACHE = "${STAGING_DATADIR}/${TARGET_SYS}_config_site.d"