blob: 2c33732be3d91e676e41cbcbbbf45d3a3ef1014b [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",
65 "linux-uclibc": "common-linux common-uclibc",
66 "linux-uclibceabi": "common-linux common-uclibc",
67 "linux-uclibcspe": "common-linux common-uclibc",
68 "linux-musl": "common-linux common-musl",
69 "linux-musleabi": "common-linux common-musl",
70 "linux-muslspe": "common-linux common-musl",
71 "uclinux-uclibc": "common-uclibc",
72 "cygwin": "common-cygwin",
73 "mingw32": "common-mingw",
74 }
75 targetinfo = {
76 "aarch64-linux-gnu": "aarch64-linux",
77 "aarch64_be-linux-gnu": "aarch64_be-linux",
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050078 "aarch64-linux-musl": "aarch64-linux",
79 "aarch64_be-linux-musl": "aarch64_be-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050080 "arm-linux-gnueabi": "arm-linux",
81 "arm-linux-musleabi": "arm-linux",
82 "arm-linux-uclibceabi": "arm-linux-uclibc",
83 "armeb-linux-gnueabi": "armeb-linux",
84 "armeb-linux-uclibceabi": "armeb-linux-uclibc",
85 "armeb-linux-musleabi": "armeb-linux",
86 "mips-linux-musl": "mips-linux",
87 "mipsel-linux-musl": "mipsel-linux",
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050088 "mips64-linux-musl": "mips64-linux",
89 "mips64el-linux-musl": "mips64el-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050090 "mips64-linux-gnun32": "mips-linux bit-32",
91 "mips64el-linux-gnun32": "mipsel-linux bit-32",
Brad Bishop6e60e8b2018-02-01 10:27:11 -050092 "mipsisa64r6-linux-gnun32": "mipsisa32r6-linux bit-32",
93 "mipsisa64r6el-linux-gnun32": "mipsisa32r6el-linux bit-32",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050094 "powerpc-linux": "powerpc32-linux",
95 "powerpc-linux-musl": "powerpc-linux powerpc32-linux",
96 "powerpc-linux-uclibc": "powerpc-linux powerpc32-linux",
97 "powerpc-linux-gnuspe": "powerpc-linux powerpc32-linux",
98 "powerpc-linux-muslspe": "powerpc-linux powerpc32-linux",
99 "powerpc-linux-uclibcspe": "powerpc-linux powerpc32-linux powerpc-linux-uclibc",
100 "powerpc64-linux-gnuspe": "powerpc-linux powerpc64-linux",
101 "powerpc64-linux-muslspe": "powerpc-linux powerpc64-linux",
102 "powerpc64-linux": "powerpc-linux",
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500103 "powerpc64-linux-musl": "powerpc-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104 "x86_64-cygwin": "bit-64",
105 "x86_64-darwin": "bit-64",
106 "x86_64-darwin9": "bit-64",
107 "x86_64-linux": "bit-64",
108 "x86_64-linux-musl": "x86_64-linux bit-64",
109 "x86_64-linux-uclibc": "bit-64",
110 "x86_64-elf": "bit-64",
111 "x86_64-linux-gnu": "bit-64 x86_64-linux",
112 "x86_64-linux-gnux32": "bit-32 ix86-common x32-linux",
113 "x86_64-mingw32": "bit-64",
114 }
115
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600116 # Add in any extra user supplied data which may come from a BSP layer, removing the
117 # need to always change this class directly
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500118 extra_siteinfo = (d.getVar("SITEINFO_EXTRA_DATAFUNCS") or "").split()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600119 for m in extra_siteinfo:
120 call = m + "(archinfo, osinfo, targetinfo, d)"
121 locs = { "archinfo" : archinfo, "osinfo" : osinfo, "targetinfo" : targetinfo, "d" : d}
122 archinfo, osinfo, targetinfo = bb.utils.better_eval(call, locs)
123
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500124 hostarch = d.getVar("HOST_ARCH")
125 hostos = d.getVar("HOST_OS")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500126 target = "%s-%s" % (hostarch, hostos)
127
128 sitedata = []
129 if hostarch in archinfo:
130 sitedata.extend(archinfo[hostarch].split())
131 if hostos in osinfo:
132 sitedata.extend(osinfo[hostos].split())
133 if target in targetinfo:
134 sitedata.extend(targetinfo[target].split())
135 sitedata.append(target)
136 sitedata.append("common")
137
138 bb.debug(1, "SITE files %s" % sitedata);
139 return sitedata
140
141python () {
142 sitedata = set(siteinfo_data(d))
143 if "endian-little" in sitedata:
144 d.setVar("SITEINFO_ENDIANNESS", "le")
145 elif "endian-big" in sitedata:
146 d.setVar("SITEINFO_ENDIANNESS", "be")
147 else:
148 bb.error("Unable to determine endianness for architecture '%s'" %
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500149 d.getVar("HOST_ARCH"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500150 bb.fatal("Please add your architecture to siteinfo.bbclass")
151
152 if "bit-32" in sitedata:
153 d.setVar("SITEINFO_BITS", "32")
154 elif "bit-64" in sitedata:
155 d.setVar("SITEINFO_BITS", "64")
156 else:
157 bb.error("Unable to determine bit size for architecture '%s'" %
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500158 d.getVar("HOST_ARCH"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500159 bb.fatal("Please add your architecture to siteinfo.bbclass")
160}
161
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600162def siteinfo_get_files(d, aclocalcache = False):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500163 sitedata = siteinfo_data(d)
164 sitefiles = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500165 for path in d.getVar("BBPATH").split(":"):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500166 for element in sitedata:
167 filename = os.path.join(path, "site", element)
168 if os.path.exists(filename):
169 sitefiles += filename + " "
170
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600171 if not aclocalcache:
172 return sitefiles
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500173
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600174 # Now check for siteconfig cache files in the directory setup by autotools.bbclass to
175 # avoid races.
176 #
177 # ACLOCALDIR may or may not exist so cache should only be set to True from autotools.bbclass
178 # after files have been copied into this location. To do otherwise risks parsing/signature
179 # issues and the directory being created/removed whilst this code executes. This can happen
180 # when a multilib recipe is parsed along with its base variant which may be running at the time
181 # causing rare but nasty failures
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500182 path_siteconfig = d.getVar('ACLOCALDIR')
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"