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