blob: 1aada40695a787d01389ceff8828e216d47257ee [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#
18def siteinfo_data(d):
19 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",
23 "arm": "endian-little bit-32 arm-common arm-32",
24 "armeb": "endian-big bit-32 arm-common arm-32",
25 "avr32": "endian-big bit-32 avr32-common",
26 "bfin": "endian-little bit-32 bfin-common",
27 "epiphany": "endian-little bit-32",
28 "i386": "endian-little bit-32 ix86-common",
29 "i486": "endian-little bit-32 ix86-common",
30 "i586": "endian-little bit-32 ix86-common",
31 "i686": "endian-little bit-32 ix86-common",
32 "ia64": "endian-little bit-64",
33 "microblaze": "endian-big bit-32 microblaze-common",
34 "microblazeeb": "endian-big bit-32 microblaze-common",
35 "microblazeel": "endian-little bit-32 microblaze-common",
36 "mips": "endian-big bit-32 mips-common",
37 "mips64": "endian-big bit-64 mips-common",
38 "mips64el": "endian-little bit-64 mips-common",
Patrick Williamsc0f7c042017-02-23 20:41:17 -060039 "mipsisa64r6": "endian-big bit-64 mips-common",
40 "mipsisa64r6el": "endian-little bit-64 mips-common",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050041 "mipsel": "endian-little bit-32 mips-common",
Patrick Williamsc0f7c042017-02-23 20:41:17 -060042 "mipsisa32r6": "endian-big bit-32 mips-common",
43 "mipsisa32r6el": "endian-little bit-32 mips-common",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050044 "powerpc": "endian-big bit-32 powerpc-common",
45 "nios2": "endian-little bit-32 nios2-common",
46 "powerpc64": "endian-big bit-64 powerpc-common",
47 "ppc": "endian-big bit-32 powerpc-common",
48 "ppc64": "endian-big bit-64 powerpc-common",
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050049 "ppc64le" : "endian-little bit-64 powerpc-common",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050 "sh3": "endian-little bit-32 sh-common",
51 "sh4": "endian-little bit-32 sh-common",
52 "sparc": "endian-big bit-32",
53 "viac3": "endian-little bit-32 ix86-common",
54 "x86_64": "endian-little", # bitinfo specified in targetinfo
55 }
56 osinfo = {
57 "darwin": "common-darwin",
58 "darwin9": "common-darwin",
59 "linux": "common-linux common-glibc",
60 "linux-gnu": "common-linux common-glibc",
61 "linux-gnux32": "common-linux common-glibc",
62 "linux-gnun32": "common-linux common-glibc",
63 "linux-gnueabi": "common-linux common-glibc",
64 "linux-gnuspe": "common-linux common-glibc",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050065 "linux-musl": "common-linux common-musl",
Brad Bishopd7bf8c12018-02-25 22:55:05 -050066 "linux-muslx32": "common-linux common-musl",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067 "linux-musleabi": "common-linux common-musl",
68 "linux-muslspe": "common-linux common-musl",
69 "uclinux-uclibc": "common-uclibc",
70 "cygwin": "common-cygwin",
71 "mingw32": "common-mingw",
72 }
73 targetinfo = {
74 "aarch64-linux-gnu": "aarch64-linux",
75 "aarch64_be-linux-gnu": "aarch64_be-linux",
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050076 "aarch64-linux-musl": "aarch64-linux",
77 "aarch64_be-linux-musl": "aarch64_be-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050078 "arm-linux-gnueabi": "arm-linux",
79 "arm-linux-musleabi": "arm-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050080 "armeb-linux-gnueabi": "armeb-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050081 "armeb-linux-musleabi": "armeb-linux",
82 "mips-linux-musl": "mips-linux",
83 "mipsel-linux-musl": "mipsel-linux",
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050084 "mips64-linux-musl": "mips64-linux",
85 "mips64el-linux-musl": "mips64el-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086 "mips64-linux-gnun32": "mips-linux bit-32",
87 "mips64el-linux-gnun32": "mipsel-linux bit-32",
Brad Bishop6e60e8b2018-02-01 10:27:11 -050088 "mipsisa64r6-linux-gnun32": "mipsisa32r6-linux bit-32",
89 "mipsisa64r6el-linux-gnun32": "mipsisa32r6el-linux bit-32",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050090 "powerpc-linux": "powerpc32-linux",
91 "powerpc-linux-musl": "powerpc-linux powerpc32-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050092 "powerpc-linux-gnuspe": "powerpc-linux powerpc32-linux",
93 "powerpc-linux-muslspe": "powerpc-linux powerpc32-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050094 "powerpc64-linux-gnuspe": "powerpc-linux powerpc64-linux",
95 "powerpc64-linux-muslspe": "powerpc-linux powerpc64-linux",
96 "powerpc64-linux": "powerpc-linux",
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050097 "powerpc64-linux-musl": "powerpc-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050098 "x86_64-cygwin": "bit-64",
99 "x86_64-darwin": "bit-64",
100 "x86_64-darwin9": "bit-64",
101 "x86_64-linux": "bit-64",
102 "x86_64-linux-musl": "x86_64-linux bit-64",
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500103 "x86_64-linux-muslx32": "bit-32 ix86-common x32-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104 "x86_64-elf": "bit-64",
105 "x86_64-linux-gnu": "bit-64 x86_64-linux",
106 "x86_64-linux-gnux32": "bit-32 ix86-common x32-linux",
107 "x86_64-mingw32": "bit-64",
108 }
109
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600110 # Add in any extra user supplied data which may come from a BSP layer, removing the
111 # need to always change this class directly
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500112 extra_siteinfo = (d.getVar("SITEINFO_EXTRA_DATAFUNCS") or "").split()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600113 for m in extra_siteinfo:
114 call = m + "(archinfo, osinfo, targetinfo, d)"
115 locs = { "archinfo" : archinfo, "osinfo" : osinfo, "targetinfo" : targetinfo, "d" : d}
116 archinfo, osinfo, targetinfo = bb.utils.better_eval(call, locs)
117
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500118 hostarch = d.getVar("HOST_ARCH")
119 hostos = d.getVar("HOST_OS")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500120 target = "%s-%s" % (hostarch, hostos)
121
122 sitedata = []
123 if hostarch in archinfo:
124 sitedata.extend(archinfo[hostarch].split())
125 if hostos in osinfo:
126 sitedata.extend(osinfo[hostos].split())
127 if target in targetinfo:
128 sitedata.extend(targetinfo[target].split())
129 sitedata.append(target)
130 sitedata.append("common")
131
132 bb.debug(1, "SITE files %s" % sitedata);
133 return sitedata
134
135python () {
136 sitedata = set(siteinfo_data(d))
137 if "endian-little" in sitedata:
138 d.setVar("SITEINFO_ENDIANNESS", "le")
139 elif "endian-big" in sitedata:
140 d.setVar("SITEINFO_ENDIANNESS", "be")
141 else:
142 bb.error("Unable to determine endianness for architecture '%s'" %
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500143 d.getVar("HOST_ARCH"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500144 bb.fatal("Please add your architecture to siteinfo.bbclass")
145
146 if "bit-32" in sitedata:
147 d.setVar("SITEINFO_BITS", "32")
148 elif "bit-64" in sitedata:
149 d.setVar("SITEINFO_BITS", "64")
150 else:
151 bb.error("Unable to determine bit size for architecture '%s'" %
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500152 d.getVar("HOST_ARCH"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500153 bb.fatal("Please add your architecture to siteinfo.bbclass")
154}
155
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500156def siteinfo_get_files(d, sysrootcache = False):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500157 sitedata = siteinfo_data(d)
158 sitefiles = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500159 for path in d.getVar("BBPATH").split(":"):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500160 for element in sitedata:
161 filename = os.path.join(path, "site", element)
162 if os.path.exists(filename):
163 sitefiles += filename + " "
164
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500165 if not sysrootcache:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600166 return sitefiles
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500167
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500168 # Now check for siteconfig cache files in sysroots
169 path_siteconfig = d.getVar('SITECONFIG_SYSROOTCACHE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500170 if path_siteconfig and os.path.isdir(path_siteconfig):
171 for i in os.listdir(path_siteconfig):
172 if not i.endswith("_config"):
173 continue
174 filename = os.path.join(path_siteconfig, i)
175 sitefiles += filename + " "
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500176 return sitefiles
177
178#
179# Make some information available via variables
180#
181SITECONFIG_SYSROOTCACHE = "${STAGING_DATADIR}/${TARGET_SYS}_config_site.d"