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