diff options
-rw-r--r-- | classes/siteinfo.bbclass | 218 |
1 files changed, 218 insertions, 0 deletions
diff --git a/classes/siteinfo.bbclass b/classes/siteinfo.bbclass new file mode 100644 index 0000000000..c0db539e29 --- /dev/null +++ b/classes/siteinfo.bbclass | |||
@@ -0,0 +1,218 @@ | |||
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 | # | ||
18 | def siteinfo_data(d): | ||
19 | archinfo = { | ||
20 | "arm": "endian-little bit-32 arm-common", | ||
21 | "armeb": "endian-big bit-32 arm-common", | ||
22 | "avr32": "endian-big bit-32 avr32-common", | ||
23 | "bfin": "endian-little bit-32 bfin-common", | ||
24 | "i386": "endian-little bit-32 ix86-common", | ||
25 | "i486": "endian-little bit-32 ix86-common", | ||
26 | "i586": "endian-little bit-32 ix86-common", | ||
27 | "i686": "endian-little bit-32 ix86-common", | ||
28 | "ia64": "endian-little bit-64", | ||
29 | "mips": "endian-big bit-32 mips-common", | ||
30 | "mips64": "endian-big bit-64 mips64-common", | ||
31 | "mips64el": "endian-little bit-64 mips64-common", | ||
32 | "mipsel": "endian-little bit-32 mips-common", | ||
33 | "powerpc": "endian-big bit-32 powerpc-common", | ||
34 | "nios2": "endian-little bit-32 nios2-common", | ||
35 | "powerpc64": "endian-big bit-64 powerpc-common powerpc64-linux", | ||
36 | "ppc": "endian-big bit-32 powerpc-common", | ||
37 | "ppc64": "endian-big bit-64 powerpc-common powerpc64-linux", | ||
38 | "sh3": "endian-little bit-32 sh-common", | ||
39 | "sh4": "endian-little bit-32 sh-common", | ||
40 | "sparc": "endian-big bit-32", | ||
41 | "viac3": "endian-little bit-32 ix86-common", | ||
42 | "x86_64": "endian-little bit-64", | ||
43 | } | ||
44 | osinfo = { | ||
45 | "darwin": "common-darwin", | ||
46 | "darwin9": "common-darwin", | ||
47 | "linux": "common-linux common-glibc", | ||
48 | "linux-gnueabi": "common-linux common-glibc", | ||
49 | "linux-gnuspe": "common-linux common-glibc", | ||
50 | "linux-uclibc": "common-linux common-uclibc", | ||
51 | "linux-uclibceabi": "common-linux common-uclibc", | ||
52 | "linux-uclibcspe": "common-linux common-uclibc", | ||
53 | "uclinux-uclibc": "common-uclibc", | ||
54 | "cygwin": "common-cygwin", | ||
55 | "mingw32": "common-mingw", | ||
56 | } | ||
57 | targetinfo = { | ||
58 | "arm-linux-gnueabi": "arm-linux", | ||
59 | "arm-linux-uclibceabi": "arm-linux-uclibc", | ||
60 | "armeb-linux-gnueabi": "armeb-linux", | ||
61 | "armeb-linux-uclibceabi": "armeb-linux-uclibc", | ||
62 | "powerpc-linux-gnuspe": "powerpc-linux", | ||
63 | "powerpc-linux-uclibcspe": "powerpc-linux-uclibc", | ||
64 | } | ||
65 | |||
66 | arch = d.getVar("HOST_ARCH", True) | ||
67 | os = d.getVar("HOST_OS", True) | ||
68 | target = "%s-%s" % (arch, os) | ||
69 | |||
70 | sitedata = [] | ||
71 | if arch in archinfo: | ||
72 | sitedata.extend(archinfo[arch].split()) | ||
73 | if os in osinfo: | ||
74 | sitedata.extend(osinfo[os].split()) | ||
75 | if target in targetinfo: | ||
76 | sitedata.extend(targetinfo[target].split()) | ||
77 | sitedata.append(target) | ||
78 | sitedata.append("common") | ||
79 | |||
80 | return sitedata | ||
81 | |||
82 | python () { | ||
83 | sitedata = set(siteinfo_data(d)) | ||
84 | if "endian-little" in sitedata: | ||
85 | d.setVar("SITEINFO_ENDIANNESS", "le") | ||
86 | elif "endian-big" in sitedata: | ||
87 | d.setVar("SITEINFO_ENDIANNESS", "be") | ||
88 | else: | ||
89 | bb.error("Unable to determine endianness for architecture '%s'" % | ||
90 | d.getVar("HOST_ARCH", True)) | ||
91 | bb.fatal("Please add your architecture to siteinfo.bbclass") | ||
92 | |||
93 | if "bit-32" in sitedata: | ||
94 | d.setVar("SITEINFO_BITS", "32") | ||
95 | elif "bit-64" in sitedata: | ||
96 | d.setVar("SITEINFO_BITS", "64") | ||
97 | else: | ||
98 | bb.error("Unable to determine bit size for architecture '%s'" % | ||
99 | d.getVar("HOST_ARCH", True)) | ||
100 | bb.fatal("Please add your architecture to siteinfo.bbclass") | ||
101 | } | ||
102 | |||
103 | # Old class from yocto pasted in below for compat | ||
104 | |||
105 | def get_siteinfo_list(d): | ||
106 | target = bb.data.getVar('HOST_ARCH', d, 1) + "-" + bb.data.getVar('HOST_OS', d, 1) | ||
107 | |||
108 | targetinfo = {\ | ||
109 | "armeb-linux": "endian-big bit-32 common-glibc arm-common",\ | ||
110 | "armeb-linux-gnueabi": "endian-big bit-32 common-glibc arm-common armeb-linux",\ | ||
111 | "armeb-linux-uclibc": "endian-big bit-32 common-uclibc arm-common",\ | ||
112 | "armeb-linux-uclibcgnueabi": "endian-big bit-32 common-uclibc arm-common armeb-linux-uclibc",\ | ||
113 | "arm-darwin": "endian-little bit-32 common-darwin",\ | ||
114 | "arm-darwin8": "endian-little bit-32 common-darwin",\ | ||
115 | "arm-linux": "endian-little bit-32 common-glibc arm-common",\ | ||
116 | "arm-linux-gnueabi": "endian-little bit-32 common-glibc arm-common arm-linux",\ | ||
117 | "arm-linux-uclibc": "endian-little bit-32 common-uclibc arm-common",\ | ||
118 | "arm-linux-uclibcgnueabi": "endian-little bit-32 common-uclibc arm-common arm-linux-uclibc",\ | ||
119 | "avr32-linux": "endian-big bit-32 common-glibc avr32-common",\ | ||
120 | "avr32-linux-uclibc": "endian-big bit-32 common-uclibc avr32-common",\ | ||
121 | "bfin-uclinux-uclibc": "endian-little bit-32 common-uclibc bfin-common",\ | ||
122 | "i386-linux": "endian-little bit-32 common-glibc ix86-common",\ | ||
123 | "i486-linux": "endian-little bit-32 common-glibc ix86-common",\ | ||
124 | "i586-linux": "endian-little bit-32 common-glibc ix86-common",\ | ||
125 | "i686-linux": "endian-little bit-32 common-glibc ix86-common",\ | ||
126 | "i386-linux-uclibc": "endian-little bit-32 common-uclibc ix86-common",\ | ||
127 | "i486-linux-uclibc": "endian-little bit-32 common-uclibc ix86-common",\ | ||
128 | "i586-linux-uclibc": "endian-little bit-32 common-uclibc ix86-common",\ | ||
129 | "i686-linux-uclibc": "endian-little bit-32 common-uclibc ix86-common",\ | ||
130 | "mipsel-linux": "endian-little bit-32 common-glibc mips-common",\ | ||
131 | "mipsel-linux-uclibc": "endian-little bit-32 common-uclibc mips-common",\ | ||
132 | "mips-linux": "endian-big bit-32 common-glibc mips-common",\ | ||
133 | "mips-linux-uclibc": "endian-big bit-32 common-uclibc mips-common",\ | ||
134 | "powerpc-darwin": "endian-big bit-32 common-darwin",\ | ||
135 | "ppc-linux": "endian-big bit-32 common-glibc powerpc-common",\ | ||
136 | "powerpc-linux": "endian-big bit-32 common-glibc powerpc-common",\ | ||
137 | "powerpc-linux-uclibc": "endian-big bit-32 common-uclibc powerpc-common",\ | ||
138 | "sh3-linux": "endian-little bit-32 common-glibc sh-common",\ | ||
139 | "sh4-linux": "endian-little bit-32 common-glibc sh-common",\ | ||
140 | "sh4-linux-uclibc": "endian-little bit-32 common-uclibc sh-common",\ | ||
141 | "sparc-linux": "endian-big bit-32 common-glibc",\ | ||
142 | "x86_64-linux": "endian-little bit-64 common-glibc",\ | ||
143 | "x86_64-linux-uclibc": "endian-little bit-64 common-uclibc"} | ||
144 | if target in targetinfo: | ||
145 | info = targetinfo[target].split() | ||
146 | info.append(target) | ||
147 | info.append("common") | ||
148 | return info | ||
149 | else: | ||
150 | bb.error("Information not available for target '%s'" % target) | ||
151 | |||
152 | |||
153 | # | ||
154 | # Define which site files to use. We check for several site files and | ||
155 | # use each one that is found, based on the list returned by get_siteinfo_list() | ||
156 | # | ||
157 | # Search for the files in the following directories: | ||
158 | # 1) ${BBPATH}/site (in reverse) - app specific, then site wide | ||
159 | # 2) ${FILE_DIRNAME}/site-${PV} - app version specific | ||
160 | # | ||
161 | def siteinfo_get_files(d): | ||
162 | sitefiles = "" | ||
163 | |||
164 | # Determine which site files to look for | ||
165 | sites = get_siteinfo_list(d) | ||
166 | |||
167 | # Check along bbpath for site files and append in reverse order so | ||
168 | # the application specific sites files are last and system site | ||
169 | # files first. | ||
170 | path_bb = bb.data.getVar('BBPATH', d, 1) | ||
171 | for p in (path_bb or "").split(':'): | ||
172 | tmp = "" | ||
173 | for i in sites: | ||
174 | fname = os.path.join(p, 'site', i) | ||
175 | if os.path.exists(fname): | ||
176 | tmp += fname + " " | ||
177 | sitefiles = tmp + sitefiles; | ||
178 | |||
179 | # Now check for the applications version specific site files | ||
180 | path_pkgv = os.path.join(bb.data.getVar('FILE_DIRNAME', d, 1), "site-" + bb.data.getVar('PV', d, 1)) | ||
181 | for i in sites: | ||
182 | fname = os.path.join(path_pkgv, i) | ||
183 | if os.path.exists(fname): | ||
184 | sitefiles += fname + " " | ||
185 | |||
186 | # Now check for siteconfig cache files | ||
187 | path_siteconfig = bb.data.getVar('SITECONFIG_SYSROOTCACHE', d, 1) | ||
188 | if os.path.isdir(path_siteconfig): | ||
189 | for i in os.listdir(path_siteconfig): | ||
190 | fname = os.path.join(path_siteconfig, i) | ||
191 | sitefiles += fname + " " | ||
192 | |||
193 | bb.debug(1, "SITE files " + sitefiles); | ||
194 | return sitefiles | ||
195 | |||
196 | def siteinfo_get_endianess(d): | ||
197 | info = get_siteinfo_list(d) | ||
198 | if 'endian-little' in info: | ||
199 | return "le" | ||
200 | elif 'endian-big' in info: | ||
201 | return "be" | ||
202 | bb.error("Site info could not determine endianess for target") | ||
203 | |||
204 | def siteinfo_get_bits(d): | ||
205 | info = get_siteinfo_list(d) | ||
206 | if 'bit-32' in info: | ||
207 | return "32" | ||
208 | elif 'bit-64' in info: | ||
209 | return "64" | ||
210 | bb.error("Site info could not determine bit size for target") | ||
211 | |||
212 | # | ||
213 | # Make some information available via variables | ||
214 | # | ||
215 | SITEINFO_ENDIANESS = "${@siteinfo_get_endianess(d)}" | ||
216 | SITEINFO_BITS = "${@siteinfo_get_bits(d)}" | ||
217 | SITECONFIG_SYSROOTCACHE = "${STAGING_DATADIR}/${TARGET_SYS}_config_site.d" | ||
218 | |||