blob: 50141a353f9d3e4dcd5e1b3c922b741cdd8fc5ae [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",
39 "mipsel": "endian-little bit-32 mips-common",
40 "powerpc": "endian-big bit-32 powerpc-common",
41 "nios2": "endian-little bit-32 nios2-common",
42 "powerpc64": "endian-big bit-64 powerpc-common",
43 "ppc": "endian-big bit-32 powerpc-common",
44 "ppc64": "endian-big bit-64 powerpc-common",
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050045 "ppc64le" : "endian-little bit-64 powerpc-common",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046 "sh3": "endian-little bit-32 sh-common",
47 "sh4": "endian-little bit-32 sh-common",
48 "sparc": "endian-big bit-32",
49 "viac3": "endian-little bit-32 ix86-common",
50 "x86_64": "endian-little", # bitinfo specified in targetinfo
51 }
52 osinfo = {
53 "darwin": "common-darwin",
54 "darwin9": "common-darwin",
55 "linux": "common-linux common-glibc",
56 "linux-gnu": "common-linux common-glibc",
57 "linux-gnux32": "common-linux common-glibc",
58 "linux-gnun32": "common-linux common-glibc",
59 "linux-gnueabi": "common-linux common-glibc",
60 "linux-gnuspe": "common-linux common-glibc",
61 "linux-uclibc": "common-linux common-uclibc",
62 "linux-uclibceabi": "common-linux common-uclibc",
63 "linux-uclibcspe": "common-linux common-uclibc",
64 "linux-musl": "common-linux common-musl",
65 "linux-musleabi": "common-linux common-musl",
66 "linux-muslspe": "common-linux common-musl",
67 "uclinux-uclibc": "common-uclibc",
68 "cygwin": "common-cygwin",
69 "mingw32": "common-mingw",
70 }
71 targetinfo = {
72 "aarch64-linux-gnu": "aarch64-linux",
73 "aarch64_be-linux-gnu": "aarch64_be-linux",
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050074 "aarch64-linux-musl": "aarch64-linux",
75 "aarch64_be-linux-musl": "aarch64_be-linux",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050076 "arm-linux-gnueabi": "arm-linux",
77 "arm-linux-musleabi": "arm-linux",
78 "arm-linux-uclibceabi": "arm-linux-uclibc",
79 "armeb-linux-gnueabi": "armeb-linux",
80 "armeb-linux-uclibceabi": "armeb-linux-uclibc",
81 "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",
88 "powerpc-linux": "powerpc32-linux",
89 "powerpc-linux-musl": "powerpc-linux powerpc32-linux",
90 "powerpc-linux-uclibc": "powerpc-linux powerpc32-linux",
91 "powerpc-linux-gnuspe": "powerpc-linux powerpc32-linux",
92 "powerpc-linux-muslspe": "powerpc-linux powerpc32-linux",
93 "powerpc-linux-uclibcspe": "powerpc-linux powerpc32-linux powerpc-linux-uclibc",
94 "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",
103 "x86_64-linux-uclibc": "bit-64",
104 "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
110 hostarch = d.getVar("HOST_ARCH", True)
111 hostos = d.getVar("HOST_OS", True)
112 target = "%s-%s" % (hostarch, hostos)
113
114 sitedata = []
115 if hostarch in archinfo:
116 sitedata.extend(archinfo[hostarch].split())
117 if hostos in osinfo:
118 sitedata.extend(osinfo[hostos].split())
119 if target in targetinfo:
120 sitedata.extend(targetinfo[target].split())
121 sitedata.append(target)
122 sitedata.append("common")
123
124 bb.debug(1, "SITE files %s" % sitedata);
125 return sitedata
126
127python () {
128 sitedata = set(siteinfo_data(d))
129 if "endian-little" in sitedata:
130 d.setVar("SITEINFO_ENDIANNESS", "le")
131 elif "endian-big" in sitedata:
132 d.setVar("SITEINFO_ENDIANNESS", "be")
133 else:
134 bb.error("Unable to determine endianness for architecture '%s'" %
135 d.getVar("HOST_ARCH", True))
136 bb.fatal("Please add your architecture to siteinfo.bbclass")
137
138 if "bit-32" in sitedata:
139 d.setVar("SITEINFO_BITS", "32")
140 elif "bit-64" in sitedata:
141 d.setVar("SITEINFO_BITS", "64")
142 else:
143 bb.error("Unable to determine bit size for architecture '%s'" %
144 d.getVar("HOST_ARCH", True))
145 bb.fatal("Please add your architecture to siteinfo.bbclass")
146}
147
148def siteinfo_get_files(d, no_cache = False):
149 sitedata = siteinfo_data(d)
150 sitefiles = ""
151 for path in d.getVar("BBPATH", True).split(":"):
152 for element in sitedata:
153 filename = os.path.join(path, "site", element)
154 if os.path.exists(filename):
155 sitefiles += filename + " "
156
157 if no_cache: return sitefiles
158
159 # Now check for siteconfig cache files
160 # Use the files copied to the aclocal cache generated by autotools.bbclass
161 # to avoid races
162 path_siteconfig = d.getVar('ACLOCALDIR', True)
163 if path_siteconfig and os.path.isdir(path_siteconfig):
164 for i in os.listdir(path_siteconfig):
165 if not i.endswith("_config"):
166 continue
167 filename = os.path.join(path_siteconfig, i)
168 sitefiles += filename + " "
169
170 return sitefiles
171
172#
173# Make some information available via variables
174#
175SITECONFIG_SYSROOTCACHE = "${STAGING_DATADIR}/${TARGET_SYS}_config_site.d"