summaryrefslogtreecommitdiffstats
path: root/meta/classes/siteinfo.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/siteinfo.bbclass')
-rw-r--r--meta/classes/siteinfo.bbclass164
1 files changed, 164 insertions, 0 deletions
diff --git a/meta/classes/siteinfo.bbclass b/meta/classes/siteinfo.bbclass
new file mode 100644
index 0000000000..e90632aeef
--- /dev/null
+++ b/meta/classes/siteinfo.bbclass
@@ -0,0 +1,164 @@
1# 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",
22 "aarch64_be": "endian-big bit-64 arm-common",
23 "arm": "endian-little bit-32 arm-common",
24 "armeb": "endian-big bit-32 arm-common",
25 "avr32": "endian-big bit-32 avr32-common",
26 "bfin": "endian-little bit-32 bfin-common",
27 "i386": "endian-little bit-32 ix86-common",
28 "i486": "endian-little bit-32 ix86-common",
29 "i586": "endian-little bit-32 ix86-common",
30 "i686": "endian-little bit-32 ix86-common",
31 "ia64": "endian-little bit-64",
32 "microblaze": "endian-big bit-32 microblaze-common",
33 "microblazeel": "endian-little bit-32 microblaze-common",
34 "mips": "endian-big bit-32 mips-common",
35 "mips64": "endian-big bit-64 mips-common",
36 "mips64el": "endian-little bit-64 mips-common",
37 "mipsel": "endian-little bit-32 mips-common",
38 "powerpc": "endian-big bit-32 powerpc-common",
39 "nios2": "endian-little bit-32 nios2-common",
40 "powerpc64": "endian-big bit-64 powerpc-common",
41 "ppc": "endian-big bit-32 powerpc-common",
42 "ppc64": "endian-big bit-64 powerpc-common",
43 "sh3": "endian-little bit-32 sh-common",
44 "sh4": "endian-little bit-32 sh-common",
45 "sparc": "endian-big bit-32",
46 "viac3": "endian-little bit-32 ix86-common",
47 "x86_64": "endian-little", # bitinfo specified in targetinfo
48 }
49 osinfo = {
50 "darwin": "common-darwin",
51 "darwin9": "common-darwin",
52 "linux": "common-linux common-glibc",
53 "linux-gnu": "common-linux common-glibc",
54 "linux-gnux32": "common-linux common-glibc",
55 "linux-gnun32": "common-linux common-glibc",
56 "linux-gnueabi": "common-linux common-glibc",
57 "linux-gnuspe": "common-linux common-glibc",
58 "linux-uclibc": "common-linux common-uclibc",
59 "linux-uclibceabi": "common-linux common-uclibc",
60 "linux-uclibcspe": "common-linux common-uclibc",
61 "linux-musl": "common-linux common-musl",
62 "linux-musleabi": "common-linux common-musl",
63 "linux-muslspe": "common-linux common-musl",
64 "uclinux-uclibc": "common-uclibc",
65 "cygwin": "common-cygwin",
66 "mingw32": "common-mingw",
67 }
68 targetinfo = {
69 "aarch64-linux-gnu": "aarch64-linux",
70 "aarch64_be-linux-gnu": "aarch64_be-linux",
71 "arm-linux-gnueabi": "arm-linux",
72 "arm-linux-musleabi": "arm-linux",
73 "arm-linux-uclibceabi": "arm-linux-uclibc",
74 "armeb-linux-gnueabi": "armeb-linux",
75 "armeb-linux-uclibceabi": "armeb-linux-uclibc",
76 "armeb-linux-musleabi": "armeb-linux",
77 "mips-linux-musl": "mips-linux",
78 "mipsel-linux-musl": "mipsel-linux",
79 "mips64-linux-musl": "mips-linux",
80 "mips64el-linux-musl": "mipsel-linux",
81 "mips64-linux-gnun32": "mips-linux bit-32",
82 "mips64el-linux-gnun32": "mipsel-linux bit-32",
83 "powerpc-linux": "powerpc32-linux",
84 "powerpc-linux-musl": "powerpc-linux powerpc32-linux",
85 "powerpc-linux-uclibc": "powerpc-linux powerpc32-linux",
86 "powerpc-linux-gnuspe": "powerpc-linux powerpc32-linux",
87 "powerpc-linux-muslspe": "powerpc-linux powerpc32-linux",
88 "powerpc-linux-uclibcspe": "powerpc-linux powerpc32-linux powerpc-linux-uclibc",
89 "powerpc64-linux-gnuspe": "powerpc-linux powerpc64-linux",
90 "powerpc64-linux-muslspe": "powerpc-linux powerpc64-linux",
91 "powerpc64-linux": "powerpc-linux",
92 "x86_64-cygwin": "bit-64",
93 "x86_64-darwin": "bit-64",
94 "x86_64-darwin9": "bit-64",
95 "x86_64-linux": "bit-64",
96 "x86_64-linux-musl": "x86_64-linux bit-64",
97 "x86_64-linux-uclibc": "bit-64",
98 "x86_64-linux-gnu": "bit-64 x86_64-linux",
99 "x86_64-linux-gnux32": "bit-32 ix86-common x32-linux",
100 "x86_64-mingw32": "bit-64",
101 }
102
103 hostarch = d.getVar("HOST_ARCH", True)
104 hostos = d.getVar("HOST_OS", True)
105 target = "%s-%s" % (hostarch, hostos)
106
107 sitedata = []
108 if hostarch in archinfo:
109 sitedata.extend(archinfo[hostarch].split())
110 if hostos in osinfo:
111 sitedata.extend(osinfo[hostos].split())
112 if target in targetinfo:
113 sitedata.extend(targetinfo[target].split())
114 sitedata.append(target)
115 sitedata.append("common")
116
117 bb.debug(1, "SITE files %s" % sitedata);
118 return sitedata
119
120python () {
121 sitedata = set(siteinfo_data(d))
122 if "endian-little" in sitedata:
123 d.setVar("SITEINFO_ENDIANNESS", "le")
124 elif "endian-big" in sitedata:
125 d.setVar("SITEINFO_ENDIANNESS", "be")
126 else:
127 bb.error("Unable to determine endianness for architecture '%s'" %
128 d.getVar("HOST_ARCH", True))
129 bb.fatal("Please add your architecture to siteinfo.bbclass")
130
131 if "bit-32" in sitedata:
132 d.setVar("SITEINFO_BITS", "32")
133 elif "bit-64" in sitedata:
134 d.setVar("SITEINFO_BITS", "64")
135 else:
136 bb.error("Unable to determine bit size for architecture '%s'" %
137 d.getVar("HOST_ARCH", True))
138 bb.fatal("Please add your architecture to siteinfo.bbclass")
139}
140
141def siteinfo_get_files(d, no_cache = False):
142 sitedata = siteinfo_data(d)
143 sitefiles = ""
144 for path in d.getVar("BBPATH", True).split(":"):
145 for element in sitedata:
146 filename = os.path.join(path, "site", element)
147 if os.path.exists(filename):
148 sitefiles += filename + " "
149
150 if no_cache: return sitefiles
151
152 # Now check for siteconfig cache files
153 path_siteconfig = d.getVar('SITECONFIG_SYSROOTCACHE', True)
154 if os.path.isdir(path_siteconfig):
155 for i in os.listdir(path_siteconfig):
156 filename = os.path.join(path_siteconfig, i)
157 sitefiles += filename + " "
158
159 return sitefiles
160
161#
162# Make some information available via variables
163#
164SITECONFIG_SYSROOTCACHE = "${STAGING_DATADIR}/${TARGET_SYS}_config_site.d"