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