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", |
| 48 | "nios2": "endian-little bit-32 nios2-common", |
| 49 | "powerpc64": "endian-big bit-64 powerpc-common", |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 50 | "powerpc64le": "endian-little bit-64 powerpc-common", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 51 | "ppc": "endian-big bit-32 powerpc-common", |
| 52 | "ppc64": "endian-big bit-64 powerpc-common", |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 53 | "ppc64le" : "endian-little bit-64 powerpc-common", |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 54 | "riscv32": "endian-little bit-32 riscv-common", |
| 55 | "riscv64": "endian-little bit-64 riscv-common", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 56 | "sh3": "endian-little bit-32 sh-common", |
| 57 | "sh4": "endian-little bit-32 sh-common", |
| 58 | "sparc": "endian-big bit-32", |
| 59 | "viac3": "endian-little bit-32 ix86-common", |
| 60 | "x86_64": "endian-little", # bitinfo specified in targetinfo |
| 61 | } |
| 62 | osinfo = { |
| 63 | "darwin": "common-darwin", |
| 64 | "darwin9": "common-darwin", |
| 65 | "linux": "common-linux common-glibc", |
| 66 | "linux-gnu": "common-linux common-glibc", |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 67 | "linux-gnu_ilp32": "common-linux common-glibc", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 68 | "linux-gnux32": "common-linux common-glibc", |
| 69 | "linux-gnun32": "common-linux common-glibc", |
| 70 | "linux-gnueabi": "common-linux common-glibc", |
| 71 | "linux-gnuspe": "common-linux common-glibc", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 72 | "linux-musl": "common-linux common-musl", |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 73 | "linux-muslx32": "common-linux common-musl", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 74 | "linux-musleabi": "common-linux common-musl", |
| 75 | "linux-muslspe": "common-linux common-musl", |
| 76 | "uclinux-uclibc": "common-uclibc", |
| 77 | "cygwin": "common-cygwin", |
| 78 | "mingw32": "common-mingw", |
| 79 | } |
| 80 | targetinfo = { |
| 81 | "aarch64-linux-gnu": "aarch64-linux", |
| 82 | "aarch64_be-linux-gnu": "aarch64_be-linux", |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 83 | "aarch64-linux-gnu_ilp32": "bit-32 aarch64_be-linux arm-32", |
| 84 | "aarch64_be-linux-gnu_ilp32": "bit-32 aarch64_be-linux arm-32", |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 85 | "aarch64-linux-musl": "aarch64-linux", |
| 86 | "aarch64_be-linux-musl": "aarch64_be-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 87 | "arm-linux-gnueabi": "arm-linux", |
| 88 | "arm-linux-musleabi": "arm-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 89 | "armeb-linux-gnueabi": "armeb-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 90 | "armeb-linux-musleabi": "armeb-linux", |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 91 | "microblazeel-linux" : "microblaze-linux", |
| 92 | "microblazeel-linux-musl" : "microblaze-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 93 | "mips-linux-musl": "mips-linux", |
| 94 | "mipsel-linux-musl": "mipsel-linux", |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 95 | "mips64-linux-musl": "mips64-linux", |
| 96 | "mips64el-linux-musl": "mips64el-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 97 | "mips64-linux-gnun32": "mips-linux bit-32", |
| 98 | "mips64el-linux-gnun32": "mipsel-linux bit-32", |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 99 | "mipsisa64r6-linux-gnun32": "mipsisa32r6-linux bit-32", |
| 100 | "mipsisa64r6el-linux-gnun32": "mipsisa32r6el-linux bit-32", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 101 | "powerpc-linux": "powerpc32-linux", |
| 102 | "powerpc-linux-musl": "powerpc-linux powerpc32-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 103 | "powerpc-linux-gnuspe": "powerpc-linux powerpc32-linux", |
| 104 | "powerpc-linux-muslspe": "powerpc-linux powerpc32-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 105 | "powerpc64-linux-gnuspe": "powerpc-linux powerpc64-linux", |
| 106 | "powerpc64-linux-muslspe": "powerpc-linux powerpc64-linux", |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 107 | "powerpc64-linux": "powerpc-linux powerpc64-linux", |
| 108 | "powerpc64-linux-musl": "powerpc-linux powerpc64-linux", |
| 109 | "powerpc64le-linux": "powerpc-linux powerpc64-linux", |
| 110 | "powerpc64le-linux-musl": "powerpc-linux powerpc64-linux", |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 111 | "riscv32-linux": "riscv32-linux", |
| 112 | "riscv32-linux-musl": "riscv32-linux", |
| 113 | "riscv64-linux": "riscv64-linux", |
| 114 | "riscv64-linux-musl": "riscv64-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 115 | "x86_64-cygwin": "bit-64", |
| 116 | "x86_64-darwin": "bit-64", |
| 117 | "x86_64-darwin9": "bit-64", |
| 118 | "x86_64-linux": "bit-64", |
| 119 | "x86_64-linux-musl": "x86_64-linux bit-64", |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 120 | "x86_64-linux-muslx32": "bit-32 ix86-common x32-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 121 | "x86_64-elf": "bit-64", |
| 122 | "x86_64-linux-gnu": "bit-64 x86_64-linux", |
| 123 | "x86_64-linux-gnux32": "bit-32 ix86-common x32-linux", |
| 124 | "x86_64-mingw32": "bit-64", |
| 125 | } |
| 126 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 127 | # Add in any extra user supplied data which may come from a BSP layer, removing the |
| 128 | # need to always change this class directly |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 129 | extra_siteinfo = (d.getVar("SITEINFO_EXTRA_DATAFUNCS") or "").split() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 130 | for m in extra_siteinfo: |
| 131 | call = m + "(archinfo, osinfo, targetinfo, d)" |
| 132 | locs = { "archinfo" : archinfo, "osinfo" : osinfo, "targetinfo" : targetinfo, "d" : d} |
| 133 | archinfo, osinfo, targetinfo = bb.utils.better_eval(call, locs) |
| 134 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 135 | target = "%s-%s" % (arch, os) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 136 | |
| 137 | sitedata = [] |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 138 | if arch in archinfo: |
| 139 | sitedata.extend(archinfo[arch].split()) |
| 140 | if os in osinfo: |
| 141 | sitedata.extend(osinfo[os].split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 142 | if target in targetinfo: |
| 143 | sitedata.extend(targetinfo[target].split()) |
| 144 | sitedata.append(target) |
| 145 | sitedata.append("common") |
| 146 | |
| 147 | bb.debug(1, "SITE files %s" % sitedata); |
| 148 | return sitedata |
| 149 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 150 | def siteinfo_data(d): |
| 151 | return siteinfo_data_for_machine(d.getVar("HOST_ARCH"), d.getVar("HOST_OS"), d) |
| 152 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 153 | python () { |
| 154 | sitedata = set(siteinfo_data(d)) |
| 155 | if "endian-little" in sitedata: |
| 156 | d.setVar("SITEINFO_ENDIANNESS", "le") |
| 157 | elif "endian-big" in sitedata: |
| 158 | d.setVar("SITEINFO_ENDIANNESS", "be") |
| 159 | else: |
| 160 | bb.error("Unable to determine endianness for architecture '%s'" % |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 161 | d.getVar("HOST_ARCH")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 162 | bb.fatal("Please add your architecture to siteinfo.bbclass") |
| 163 | |
| 164 | if "bit-32" in sitedata: |
| 165 | d.setVar("SITEINFO_BITS", "32") |
| 166 | elif "bit-64" in sitedata: |
| 167 | d.setVar("SITEINFO_BITS", "64") |
| 168 | else: |
| 169 | bb.error("Unable to determine bit size for architecture '%s'" % |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 170 | d.getVar("HOST_ARCH")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 171 | bb.fatal("Please add your architecture to siteinfo.bbclass") |
| 172 | } |
| 173 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 174 | def siteinfo_get_files(d, sysrootcache = False): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 175 | sitedata = siteinfo_data(d) |
| 176 | sitefiles = "" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 177 | for path in d.getVar("BBPATH").split(":"): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 178 | for element in sitedata: |
| 179 | filename = os.path.join(path, "site", element) |
| 180 | if os.path.exists(filename): |
| 181 | sitefiles += filename + " " |
| 182 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 183 | if not sysrootcache: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 184 | return sitefiles |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 185 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 186 | # Now check for siteconfig cache files in sysroots |
| 187 | path_siteconfig = d.getVar('SITECONFIG_SYSROOTCACHE') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 188 | if path_siteconfig and os.path.isdir(path_siteconfig): |
| 189 | for i in os.listdir(path_siteconfig): |
| 190 | if not i.endswith("_config"): |
| 191 | continue |
| 192 | filename = os.path.join(path_siteconfig, i) |
| 193 | sitefiles += filename + " " |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 194 | return sitefiles |
| 195 | |
| 196 | # |
| 197 | # Make some information available via variables |
| 198 | # |
| 199 | SITECONFIG_SYSROOTCACHE = "${STAGING_DATADIR}/${TARGET_SYS}_config_site.d" |