Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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>") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 11 | # * endianness: Return "be" for big endian targets, "le" for little endian |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | # |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 18 | def siteinfo_data_for_machine(arch, os, d): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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", |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 23 | "arc": "endian-little bit-32 arc-common", |
| 24 | "arceb": "endian-big bit-32 arc-common", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 25 | "arm": "endian-little bit-32 arm-common arm-32", |
| 26 | "armeb": "endian-big bit-32 arm-common arm-32", |
| 27 | "avr32": "endian-big bit-32 avr32-common", |
| 28 | "bfin": "endian-little bit-32 bfin-common", |
| 29 | "epiphany": "endian-little bit-32", |
| 30 | "i386": "endian-little bit-32 ix86-common", |
| 31 | "i486": "endian-little bit-32 ix86-common", |
| 32 | "i586": "endian-little bit-32 ix86-common", |
| 33 | "i686": "endian-little bit-32 ix86-common", |
| 34 | "ia64": "endian-little bit-64", |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 35 | "lm32": "endian-big bit-32", |
| 36 | "m68k": "endian-big bit-32", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 37 | "microblaze": "endian-big bit-32 microblaze-common", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 38 | "microblazeel": "endian-little bit-32 microblaze-common", |
| 39 | "mips": "endian-big bit-32 mips-common", |
| 40 | "mips64": "endian-big bit-64 mips-common", |
| 41 | "mips64el": "endian-little bit-64 mips-common", |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 42 | "mipsisa64r6": "endian-big bit-64 mips-common", |
| 43 | "mipsisa64r6el": "endian-little bit-64 mips-common", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 44 | "mipsel": "endian-little bit-32 mips-common", |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 45 | "mipsisa32r6": "endian-big bit-32 mips-common", |
| 46 | "mipsisa32r6el": "endian-little bit-32 mips-common", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 47 | "powerpc": "endian-big bit-32 powerpc-common", |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 48 | "powerpcle": "endian-little bit-32 powerpc-common", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 49 | "nios2": "endian-little bit-32 nios2-common", |
| 50 | "powerpc64": "endian-big bit-64 powerpc-common", |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 51 | "powerpc64le": "endian-little bit-64 powerpc-common", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 52 | "ppc": "endian-big bit-32 powerpc-common", |
| 53 | "ppc64": "endian-big bit-64 powerpc-common", |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 54 | "ppc64le" : "endian-little bit-64 powerpc-common", |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 55 | "riscv32": "endian-little bit-32 riscv-common", |
| 56 | "riscv64": "endian-little bit-64 riscv-common", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 57 | "sh3": "endian-little bit-32 sh-common", |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 58 | "sh3eb": "endian-big bit-32 sh-common", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 59 | "sh4": "endian-little bit-32 sh-common", |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 60 | "sh4eb": "endian-big bit-32 sh-common", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 61 | "sparc": "endian-big bit-32", |
| 62 | "viac3": "endian-little bit-32 ix86-common", |
| 63 | "x86_64": "endian-little", # bitinfo specified in targetinfo |
| 64 | } |
| 65 | osinfo = { |
| 66 | "darwin": "common-darwin", |
| 67 | "darwin9": "common-darwin", |
| 68 | "linux": "common-linux common-glibc", |
| 69 | "linux-gnu": "common-linux common-glibc", |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 70 | "linux-gnu_ilp32": "common-linux common-glibc", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 71 | "linux-gnux32": "common-linux common-glibc", |
| 72 | "linux-gnun32": "common-linux common-glibc", |
| 73 | "linux-gnueabi": "common-linux common-glibc", |
| 74 | "linux-gnuspe": "common-linux common-glibc", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 75 | "linux-musl": "common-linux common-musl", |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 76 | "linux-muslx32": "common-linux common-musl", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 77 | "linux-musleabi": "common-linux common-musl", |
| 78 | "linux-muslspe": "common-linux common-musl", |
| 79 | "uclinux-uclibc": "common-uclibc", |
| 80 | "cygwin": "common-cygwin", |
| 81 | "mingw32": "common-mingw", |
| 82 | } |
| 83 | targetinfo = { |
| 84 | "aarch64-linux-gnu": "aarch64-linux", |
| 85 | "aarch64_be-linux-gnu": "aarch64_be-linux", |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 86 | "aarch64-linux-gnu_ilp32": "bit-32 aarch64_be-linux arm-32", |
| 87 | "aarch64_be-linux-gnu_ilp32": "bit-32 aarch64_be-linux arm-32", |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 88 | "aarch64-linux-musl": "aarch64-linux", |
| 89 | "aarch64_be-linux-musl": "aarch64_be-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 90 | "arm-linux-gnueabi": "arm-linux", |
| 91 | "arm-linux-musleabi": "arm-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 92 | "armeb-linux-gnueabi": "armeb-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 93 | "armeb-linux-musleabi": "armeb-linux", |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 94 | "microblazeel-linux" : "microblaze-linux", |
| 95 | "microblazeel-linux-musl" : "microblaze-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 96 | "mips-linux-musl": "mips-linux", |
| 97 | "mipsel-linux-musl": "mipsel-linux", |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 98 | "mips64-linux-musl": "mips64-linux", |
| 99 | "mips64el-linux-musl": "mips64el-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 100 | "mips64-linux-gnun32": "mips-linux bit-32", |
| 101 | "mips64el-linux-gnun32": "mipsel-linux bit-32", |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 102 | "mipsisa64r6-linux-gnun32": "mipsisa32r6-linux bit-32", |
| 103 | "mipsisa64r6el-linux-gnun32": "mipsisa32r6el-linux bit-32", |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame^] | 104 | "powerpc-linux": "powerpc32-linux powerpc32-linux-glibc", |
| 105 | "powerpc-linux-musl": "powerpc-linux powerpc32-linux powerpc32-linux-musl", |
| 106 | "powerpcle-linux": "powerpc32-linux powerpc32-linux-glibc", |
| 107 | "powerpcle-linux-musl": "powerpc-linux powerpc32-linux powerpc32-linux-musl", |
| 108 | "powerpc-linux-gnuspe": "powerpc-linux powerpc32-linux powerpc32-linux-glibc", |
| 109 | "powerpc-linux-muslspe": "powerpc-linux powerpc32-linux powerpc32-linux-musl", |
| 110 | "powerpc64-linux-gnuspe": "powerpc-linux powerpc64-linux powerpc64-linux-glibc", |
| 111 | "powerpc64-linux-muslspe": "powerpc-linux powerpc64-linux powerpc64-linux-musl", |
| 112 | "powerpc64-linux": "powerpc-linux powerpc64-linux powerpc64-linux-glibc", |
| 113 | "powerpc64-linux-musl": "powerpc-linux powerpc64-linux powerpc64-linux-musl", |
| 114 | "powerpc64le-linux": "powerpc-linux powerpc64-linux powerpc64-linux-glibc", |
| 115 | "powerpc64le-linux-musl": "powerpc-linux powerpc64-linux powerpc64-linux-musl", |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 116 | "riscv32-linux": "riscv32-linux", |
| 117 | "riscv32-linux-musl": "riscv32-linux", |
| 118 | "riscv64-linux": "riscv64-linux", |
| 119 | "riscv64-linux-musl": "riscv64-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 120 | "x86_64-cygwin": "bit-64", |
| 121 | "x86_64-darwin": "bit-64", |
| 122 | "x86_64-darwin9": "bit-64", |
| 123 | "x86_64-linux": "bit-64", |
| 124 | "x86_64-linux-musl": "x86_64-linux bit-64", |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 125 | "x86_64-linux-muslx32": "bit-32 ix86-common x32-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 126 | "x86_64-elf": "bit-64", |
| 127 | "x86_64-linux-gnu": "bit-64 x86_64-linux", |
| 128 | "x86_64-linux-gnux32": "bit-32 ix86-common x32-linux", |
| 129 | "x86_64-mingw32": "bit-64", |
| 130 | } |
| 131 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 132 | # Add in any extra user supplied data which may come from a BSP layer, removing the |
| 133 | # need to always change this class directly |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 134 | extra_siteinfo = (d.getVar("SITEINFO_EXTRA_DATAFUNCS") or "").split() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 135 | for m in extra_siteinfo: |
| 136 | call = m + "(archinfo, osinfo, targetinfo, d)" |
| 137 | locs = { "archinfo" : archinfo, "osinfo" : osinfo, "targetinfo" : targetinfo, "d" : d} |
| 138 | archinfo, osinfo, targetinfo = bb.utils.better_eval(call, locs) |
| 139 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 140 | target = "%s-%s" % (arch, os) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 141 | |
| 142 | sitedata = [] |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 143 | if arch in archinfo: |
| 144 | sitedata.extend(archinfo[arch].split()) |
| 145 | if os in osinfo: |
| 146 | sitedata.extend(osinfo[os].split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 147 | if target in targetinfo: |
| 148 | sitedata.extend(targetinfo[target].split()) |
| 149 | sitedata.append(target) |
| 150 | sitedata.append("common") |
| 151 | |
| 152 | bb.debug(1, "SITE files %s" % sitedata); |
| 153 | return sitedata |
| 154 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 155 | def siteinfo_data(d): |
| 156 | return siteinfo_data_for_machine(d.getVar("HOST_ARCH"), d.getVar("HOST_OS"), d) |
| 157 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 158 | python () { |
| 159 | sitedata = set(siteinfo_data(d)) |
| 160 | if "endian-little" in sitedata: |
| 161 | d.setVar("SITEINFO_ENDIANNESS", "le") |
| 162 | elif "endian-big" in sitedata: |
| 163 | d.setVar("SITEINFO_ENDIANNESS", "be") |
| 164 | else: |
| 165 | bb.error("Unable to determine endianness for architecture '%s'" % |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 166 | d.getVar("HOST_ARCH")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 167 | bb.fatal("Please add your architecture to siteinfo.bbclass") |
| 168 | |
| 169 | if "bit-32" in sitedata: |
| 170 | d.setVar("SITEINFO_BITS", "32") |
| 171 | elif "bit-64" in sitedata: |
| 172 | d.setVar("SITEINFO_BITS", "64") |
| 173 | else: |
| 174 | bb.error("Unable to determine bit size for architecture '%s'" % |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 175 | d.getVar("HOST_ARCH")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 176 | bb.fatal("Please add your architecture to siteinfo.bbclass") |
| 177 | } |
| 178 | |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 179 | # Layers with siteconfig need to add a replacement path to this variable so the |
| 180 | # sstate isn't path specific |
| 181 | SITEINFO_PATHVARS = "COREBASE" |
| 182 | |
| 183 | def siteinfo_get_files(d, sysrootcache=False): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 184 | sitedata = siteinfo_data(d) |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 185 | sitefiles = [] |
| 186 | searched = [] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 187 | for path in d.getVar("BBPATH").split(":"): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 188 | for element in sitedata: |
| 189 | filename = os.path.join(path, "site", element) |
| 190 | if os.path.exists(filename): |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 191 | searched.append(filename + ":True") |
| 192 | sitefiles.append(filename) |
| 193 | else: |
| 194 | searched.append(filename + ":False") |
| 195 | |
| 196 | # Have to parameterise out hardcoded paths such as COREBASE for the main site files |
| 197 | for var in d.getVar("SITEINFO_PATHVARS").split(): |
| 198 | searched2 = [] |
| 199 | replace = os.path.normpath(d.getVar(var)) |
| 200 | for s in searched: |
| 201 | searched2.append(s.replace(replace, "${" + var + "}")) |
| 202 | searched = searched2 |
| 203 | |
| 204 | if bb.data.inherits_class('native', d) or bb.data.inherits_class('cross', d) or bb.data.inherits_class('crosssdk', d): |
| 205 | # We need sstate sigs for native/cross not to vary upon arch so we can't depend on the site files. |
| 206 | # In future we may want to depend upon all site files? |
| 207 | # This would show up as breaking sstatetests.SStateTests.test_sstate_32_64_same_hash for example |
| 208 | searched = [] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 209 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 210 | if not sysrootcache: |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 211 | return sitefiles, searched |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 212 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 213 | # Now check for siteconfig cache files in sysroots |
| 214 | path_siteconfig = d.getVar('SITECONFIG_SYSROOTCACHE') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 215 | if path_siteconfig and os.path.isdir(path_siteconfig): |
| 216 | for i in os.listdir(path_siteconfig): |
| 217 | if not i.endswith("_config"): |
| 218 | continue |
| 219 | filename = os.path.join(path_siteconfig, i) |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 220 | sitefiles.append(filename) |
| 221 | return sitefiles, searched |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 222 | |
| 223 | # |
| 224 | # Make some information available via variables |
| 225 | # |
| 226 | SITECONFIG_SYSROOTCACHE = "${STAGING_DATADIR}/${TARGET_SYS}_config_site.d" |