blob: 86bb853be229f02ef5d2e73a0c47e9c8e544c3af [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",
Brad Bishop316dfdd2018-06-25 12:45:53 -040050 "riscv32": "endian-little bit-32 riscv-common",
51 "riscv64": "endian-little bit-64 riscv-common",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050052 "sh3": "endian-little bit-32 sh-common",
53 "sh4": "endian-little bit-32 sh-common",
54 "sparc": "endian-big bit-32",
55 "viac3": "endian-little bit-32 ix86-common",
56 "x86_64": "endian-little", # bitinfo specified in targetinfo
57 }
58 osinfo = {
59 "darwin": "common-darwin",
60 "darwin9": "common-darwin",
61 "linux": "common-linux common-glibc",
62 "linux-gnu": "common-linux common-glibc",
Brad Bishop316dfdd2018-06-25 12:45:53 -040063 "linux-gnu_ilp32": "common-linux common-glibc",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050064 "linux-gnux32": "common-linux common-glibc",
65 "linux-gnun32": "common-linux common-glibc",
66 "linux-gnueabi": "common-linux common-glibc",
67 "linux-gnuspe": "common-linux common-glibc",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050068 "linux-musl": "common-linux common-musl",
Brad Bishopd7bf8c12018-02-25 22:55:05 -050069 "linux-muslx32": "common-linux common-musl",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050070 "linux-musleabi": "common-linux common-musl",
71 "linux-muslspe": "common-linux common-musl",
72 "uclinux-uclibc": "common-uclibc",
73 "cygwin": "common-cygwin",
74 "mingw32": "common-mingw",
75 }
76 targetinfo = {
77 "aarch64-linux-gnu": "aarch64-linux",
78 "aarch64_be-linux-gnu": "aarch64_be-linux",
Brad Bishop316dfdd2018-06-25 12:45:53 -040079 "aarch64-linux-gnu_ilp32": "bit-32 aarch64_be-linux arm-32",
80 "aarch64_be-linux-gnu_ilp32": "bit-32 aarch64_be-linux arm-32",
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050081 "aarch64-linux-musl": "aarch64-linux",
82 "aarch64_be-linux-musl": "aarch64_be-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050083 "arm-linux-gnueabi": "arm-linux",
84 "arm-linux-musleabi": "arm-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050085 "armeb-linux-gnueabi": "armeb-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086 "armeb-linux-musleabi": "armeb-linux",
Brad Bishop316dfdd2018-06-25 12:45:53 -040087 "microblazeeb-linux" : "microblaze-linux",
88 "microblazeeb-linux-musl" : "microblaze-linux",
89 "microblazeel-linux" : "microblaze-linux",
90 "microblazeel-linux-musl" : "microblaze-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050091 "mips-linux-musl": "mips-linux",
92 "mipsel-linux-musl": "mipsel-linux",
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050093 "mips64-linux-musl": "mips64-linux",
94 "mips64el-linux-musl": "mips64el-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050095 "mips64-linux-gnun32": "mips-linux bit-32",
96 "mips64el-linux-gnun32": "mipsel-linux bit-32",
Brad Bishop6e60e8b2018-02-01 10:27:11 -050097 "mipsisa64r6-linux-gnun32": "mipsisa32r6-linux bit-32",
98 "mipsisa64r6el-linux-gnun32": "mipsisa32r6el-linux bit-32",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050099 "powerpc-linux": "powerpc32-linux",
100 "powerpc-linux-musl": "powerpc-linux powerpc32-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500101 "powerpc-linux-gnuspe": "powerpc-linux powerpc32-linux",
102 "powerpc-linux-muslspe": "powerpc-linux powerpc32-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500103 "powerpc64-linux-gnuspe": "powerpc-linux powerpc64-linux",
104 "powerpc64-linux-muslspe": "powerpc-linux powerpc64-linux",
105 "powerpc64-linux": "powerpc-linux",
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500106 "powerpc64-linux-musl": "powerpc-linux",
Brad Bishop316dfdd2018-06-25 12:45:53 -0400107 "riscv32-linux": "riscv32-linux",
108 "riscv32-linux-musl": "riscv32-linux",
109 "riscv64-linux": "riscv64-linux",
110 "riscv64-linux-musl": "riscv64-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500111 "x86_64-cygwin": "bit-64",
112 "x86_64-darwin": "bit-64",
113 "x86_64-darwin9": "bit-64",
114 "x86_64-linux": "bit-64",
115 "x86_64-linux-musl": "x86_64-linux bit-64",
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500116 "x86_64-linux-muslx32": "bit-32 ix86-common x32-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500117 "x86_64-elf": "bit-64",
118 "x86_64-linux-gnu": "bit-64 x86_64-linux",
119 "x86_64-linux-gnux32": "bit-32 ix86-common x32-linux",
120 "x86_64-mingw32": "bit-64",
121 }
122
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600123 # Add in any extra user supplied data which may come from a BSP layer, removing the
124 # need to always change this class directly
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500125 extra_siteinfo = (d.getVar("SITEINFO_EXTRA_DATAFUNCS") or "").split()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600126 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
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500131 hostarch = d.getVar("HOST_ARCH")
132 hostos = d.getVar("HOST_OS")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500133 target = "%s-%s" % (hostarch, hostos)
134
135 sitedata = []
136 if hostarch in archinfo:
137 sitedata.extend(archinfo[hostarch].split())
138 if hostos in osinfo:
139 sitedata.extend(osinfo[hostos].split())
140 if target in targetinfo:
141 sitedata.extend(targetinfo[target].split())
142 sitedata.append(target)
143 sitedata.append("common")
144
145 bb.debug(1, "SITE files %s" % sitedata);
146 return sitedata
147
148python () {
149 sitedata = set(siteinfo_data(d))
150 if "endian-little" in sitedata:
151 d.setVar("SITEINFO_ENDIANNESS", "le")
152 elif "endian-big" in sitedata:
153 d.setVar("SITEINFO_ENDIANNESS", "be")
154 else:
155 bb.error("Unable to determine endianness for architecture '%s'" %
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500156 d.getVar("HOST_ARCH"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500157 bb.fatal("Please add your architecture to siteinfo.bbclass")
158
159 if "bit-32" in sitedata:
160 d.setVar("SITEINFO_BITS", "32")
161 elif "bit-64" in sitedata:
162 d.setVar("SITEINFO_BITS", "64")
163 else:
164 bb.error("Unable to determine bit size for architecture '%s'" %
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500165 d.getVar("HOST_ARCH"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500166 bb.fatal("Please add your architecture to siteinfo.bbclass")
167}
168
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500169def siteinfo_get_files(d, sysrootcache = False):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500170 sitedata = siteinfo_data(d)
171 sitefiles = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500172 for path in d.getVar("BBPATH").split(":"):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500173 for element in sitedata:
174 filename = os.path.join(path, "site", element)
175 if os.path.exists(filename):
176 sitefiles += filename + " "
177
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500178 if not sysrootcache:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600179 return sitefiles
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500180
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500181 # Now check for siteconfig cache files in sysroots
182 path_siteconfig = d.getVar('SITECONFIG_SYSROOTCACHE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500183 if path_siteconfig and os.path.isdir(path_siteconfig):
184 for i in os.listdir(path_siteconfig):
185 if not i.endswith("_config"):
186 continue
187 filename = os.path.join(path_siteconfig, i)
188 sitefiles += filename + " "
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500189 return sitefiles
190
191#
192# Make some information available via variables
193#
194SITECONFIG_SYSROOTCACHE = "${STAGING_DATADIR}/${TARGET_SYS}_config_site.d"