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", |
| 65 | "linux-uclibc": "common-linux common-uclibc", |
| 66 | "linux-uclibceabi": "common-linux common-uclibc", |
| 67 | "linux-uclibcspe": "common-linux common-uclibc", |
| 68 | "linux-musl": "common-linux common-musl", |
| 69 | "linux-musleabi": "common-linux common-musl", |
| 70 | "linux-muslspe": "common-linux common-musl", |
| 71 | "uclinux-uclibc": "common-uclibc", |
| 72 | "cygwin": "common-cygwin", |
| 73 | "mingw32": "common-mingw", |
| 74 | } |
| 75 | targetinfo = { |
| 76 | "aarch64-linux-gnu": "aarch64-linux", |
| 77 | "aarch64_be-linux-gnu": "aarch64_be-linux", |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 78 | "aarch64-linux-musl": "aarch64-linux", |
| 79 | "aarch64_be-linux-musl": "aarch64_be-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 80 | "arm-linux-gnueabi": "arm-linux", |
| 81 | "arm-linux-musleabi": "arm-linux", |
| 82 | "arm-linux-uclibceabi": "arm-linux-uclibc", |
| 83 | "armeb-linux-gnueabi": "armeb-linux", |
| 84 | "armeb-linux-uclibceabi": "armeb-linux-uclibc", |
| 85 | "armeb-linux-musleabi": "armeb-linux", |
| 86 | "mips-linux-musl": "mips-linux", |
| 87 | "mipsel-linux-musl": "mipsel-linux", |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 88 | "mips64-linux-musl": "mips64-linux", |
| 89 | "mips64el-linux-musl": "mips64el-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 90 | "mips64-linux-gnun32": "mips-linux bit-32", |
| 91 | "mips64el-linux-gnun32": "mipsel-linux bit-32", |
| 92 | "powerpc-linux": "powerpc32-linux", |
| 93 | "powerpc-linux-musl": "powerpc-linux powerpc32-linux", |
| 94 | "powerpc-linux-uclibc": "powerpc-linux powerpc32-linux", |
| 95 | "powerpc-linux-gnuspe": "powerpc-linux powerpc32-linux", |
| 96 | "powerpc-linux-muslspe": "powerpc-linux powerpc32-linux", |
| 97 | "powerpc-linux-uclibcspe": "powerpc-linux powerpc32-linux powerpc-linux-uclibc", |
| 98 | "powerpc64-linux-gnuspe": "powerpc-linux powerpc64-linux", |
| 99 | "powerpc64-linux-muslspe": "powerpc-linux powerpc64-linux", |
| 100 | "powerpc64-linux": "powerpc-linux", |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 101 | "powerpc64-linux-musl": "powerpc-linux", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 102 | "x86_64-cygwin": "bit-64", |
| 103 | "x86_64-darwin": "bit-64", |
| 104 | "x86_64-darwin9": "bit-64", |
| 105 | "x86_64-linux": "bit-64", |
| 106 | "x86_64-linux-musl": "x86_64-linux bit-64", |
| 107 | "x86_64-linux-uclibc": "bit-64", |
| 108 | "x86_64-elf": "bit-64", |
| 109 | "x86_64-linux-gnu": "bit-64 x86_64-linux", |
| 110 | "x86_64-linux-gnux32": "bit-32 ix86-common x32-linux", |
| 111 | "x86_64-mingw32": "bit-64", |
| 112 | } |
| 113 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 114 | # Add in any extra user supplied data which may come from a BSP layer, removing the |
| 115 | # need to always change this class directly |
| 116 | extra_siteinfo = (d.getVar("SITEINFO_EXTRA_DATAFUNCS", True) or "").split() |
| 117 | for m in extra_siteinfo: |
| 118 | call = m + "(archinfo, osinfo, targetinfo, d)" |
| 119 | locs = { "archinfo" : archinfo, "osinfo" : osinfo, "targetinfo" : targetinfo, "d" : d} |
| 120 | archinfo, osinfo, targetinfo = bb.utils.better_eval(call, locs) |
| 121 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 122 | hostarch = d.getVar("HOST_ARCH", True) |
| 123 | hostos = d.getVar("HOST_OS", True) |
| 124 | target = "%s-%s" % (hostarch, hostos) |
| 125 | |
| 126 | sitedata = [] |
| 127 | if hostarch in archinfo: |
| 128 | sitedata.extend(archinfo[hostarch].split()) |
| 129 | if hostos in osinfo: |
| 130 | sitedata.extend(osinfo[hostos].split()) |
| 131 | if target in targetinfo: |
| 132 | sitedata.extend(targetinfo[target].split()) |
| 133 | sitedata.append(target) |
| 134 | sitedata.append("common") |
| 135 | |
| 136 | bb.debug(1, "SITE files %s" % sitedata); |
| 137 | return sitedata |
| 138 | |
| 139 | python () { |
| 140 | sitedata = set(siteinfo_data(d)) |
| 141 | if "endian-little" in sitedata: |
| 142 | d.setVar("SITEINFO_ENDIANNESS", "le") |
| 143 | elif "endian-big" in sitedata: |
| 144 | d.setVar("SITEINFO_ENDIANNESS", "be") |
| 145 | else: |
| 146 | bb.error("Unable to determine endianness for architecture '%s'" % |
| 147 | d.getVar("HOST_ARCH", True)) |
| 148 | bb.fatal("Please add your architecture to siteinfo.bbclass") |
| 149 | |
| 150 | if "bit-32" in sitedata: |
| 151 | d.setVar("SITEINFO_BITS", "32") |
| 152 | elif "bit-64" in sitedata: |
| 153 | d.setVar("SITEINFO_BITS", "64") |
| 154 | else: |
| 155 | bb.error("Unable to determine bit size for architecture '%s'" % |
| 156 | d.getVar("HOST_ARCH", True)) |
| 157 | bb.fatal("Please add your architecture to siteinfo.bbclass") |
| 158 | } |
| 159 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 160 | def siteinfo_get_files(d, aclocalcache = False): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 161 | sitedata = siteinfo_data(d) |
| 162 | sitefiles = "" |
| 163 | for path in d.getVar("BBPATH", True).split(":"): |
| 164 | for element in sitedata: |
| 165 | filename = os.path.join(path, "site", element) |
| 166 | if os.path.exists(filename): |
| 167 | sitefiles += filename + " " |
| 168 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 169 | if not aclocalcache: |
| 170 | return sitefiles |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 171 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 172 | # Now check for siteconfig cache files in the directory setup by autotools.bbclass to |
| 173 | # avoid races. |
| 174 | # |
| 175 | # ACLOCALDIR may or may not exist so cache should only be set to True from autotools.bbclass |
| 176 | # after files have been copied into this location. To do otherwise risks parsing/signature |
| 177 | # issues and the directory being created/removed whilst this code executes. This can happen |
| 178 | # when a multilib recipe is parsed along with its base variant which may be running at the time |
| 179 | # causing rare but nasty failures |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 180 | path_siteconfig = d.getVar('ACLOCALDIR', True) |
| 181 | if path_siteconfig and os.path.isdir(path_siteconfig): |
| 182 | for i in os.listdir(path_siteconfig): |
| 183 | if not i.endswith("_config"): |
| 184 | continue |
| 185 | filename = os.path.join(path_siteconfig, i) |
| 186 | sitefiles += filename + " " |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 187 | return sitefiles |
| 188 | |
| 189 | # |
| 190 | # Make some information available via variables |
| 191 | # |
| 192 | SITECONFIG_SYSROOTCACHE = "${STAGING_DATADIR}/${TARGET_SYS}_config_site.d" |