Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | def preferred_ml_updates(d): |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 2 | # If any of PREFERRED_PROVIDER, PREFERRED_RPROVIDER, REQUIRED_VERSION |
| 3 | # or PREFERRED_VERSION are set, we need to mirror these variables in |
| 4 | # the multilib case; |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 5 | multilibs = d.getVar('MULTILIBS') or "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6 | if not multilibs: |
| 7 | return |
| 8 | |
| 9 | prefixes = [] |
| 10 | for ext in multilibs.split(): |
| 11 | eext = ext.split(':') |
| 12 | if len(eext) > 1 and eext[0] == 'multilib': |
| 13 | prefixes.append(eext[1]) |
| 14 | |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 15 | required_versions = [] |
| 16 | preferred_versions = [] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | providers = [] |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 18 | rproviders = [] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 19 | for v in d.keys(): |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 20 | if v.startswith("REQUIRED_VERSION_"): |
| 21 | required_versions.append(v) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 22 | if v.startswith("PREFERRED_VERSION_"): |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 23 | preferred_versions.append(v) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 24 | if v.startswith("PREFERRED_PROVIDER_"): |
| 25 | providers.append(v) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 26 | if v.startswith("PREFERRED_RPROVIDER_"): |
| 27 | rproviders.append(v) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 28 | |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 29 | def sort_versions(versions, keyword): |
| 30 | version_str = "_".join([keyword, "VERSION", ""]) |
| 31 | for v in versions: |
| 32 | val = d.getVar(v, False) |
| 33 | pkg = v.replace(version_str, "") |
| 34 | if pkg.endswith("-native") or "-crosssdk-" in pkg or pkg.startswith(("nativesdk-", "virtual/nativesdk-")): |
| 35 | continue |
| 36 | if '-cross-' in pkg and '${' in pkg: |
| 37 | for p in prefixes: |
| 38 | localdata = bb.data.createCopy(d) |
| 39 | override = ":virtclass-multilib-" + p |
| 40 | localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override) |
| 41 | if "-canadian-" in pkg: |
| 42 | newname = localdata.expand(v) |
| 43 | else: |
| 44 | newname = localdata.expand(v).replace(version_str, version_str + p + '-') |
| 45 | if newname != v: |
| 46 | newval = localdata.expand(val) |
| 47 | d.setVar(newname, newval) |
| 48 | # Avoid future variable key expansion |
| 49 | vexp = d.expand(v) |
| 50 | if v != vexp and d.getVar(v, False): |
| 51 | d.renameVar(v, vexp) |
| 52 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 53 | for p in prefixes: |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 54 | newname = version_str + p + "-" + pkg |
| 55 | if not d.getVar(newname, False): |
| 56 | d.setVar(newname, val) |
| 57 | |
| 58 | sort_versions(required_versions, "REQUIRED") |
| 59 | sort_versions(preferred_versions, "PREFERRED") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 60 | |
| 61 | for prov in providers: |
| 62 | val = d.getVar(prov, False) |
| 63 | pkg = prov.replace("PREFERRED_PROVIDER_", "") |
| 64 | if pkg.endswith("-native") or "-crosssdk-" in pkg or pkg.startswith(("nativesdk-", "virtual/nativesdk-")): |
| 65 | continue |
| 66 | if 'cross-canadian' in pkg: |
| 67 | for p in prefixes: |
| 68 | localdata = bb.data.createCopy(d) |
| 69 | override = ":virtclass-multilib-" + p |
| 70 | localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 71 | newname = localdata.expand(prov) |
| 72 | if newname != prov: |
| 73 | newval = localdata.expand(val) |
| 74 | d.setVar(newname, newval) |
| 75 | # Avoid future variable key expansion |
| 76 | provexp = d.expand(prov) |
| 77 | if prov != provexp and d.getVar(prov, False): |
| 78 | d.renameVar(prov, provexp) |
| 79 | continue |
| 80 | virt = "" |
| 81 | if pkg.startswith("virtual/"): |
| 82 | pkg = pkg.replace("virtual/", "") |
| 83 | virt = "virtual/" |
| 84 | for p in prefixes: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 85 | newval = None |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 86 | if pkg != "kernel": |
| 87 | newval = p + "-" + val |
| 88 | |
| 89 | # implement variable keys |
| 90 | localdata = bb.data.createCopy(d) |
| 91 | override = ":virtclass-multilib-" + p |
| 92 | localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 93 | newname = localdata.expand(prov) |
| 94 | if newname != prov and not d.getVar(newname, False): |
| 95 | d.setVar(newname, localdata.expand(newval)) |
| 96 | |
| 97 | # implement alternative multilib name |
| 98 | newname = localdata.expand("PREFERRED_PROVIDER_" + virt + p + "-" + pkg) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 99 | if not d.getVar(newname, False) and newval != None: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 100 | d.setVar(newname, localdata.expand(newval)) |
| 101 | # Avoid future variable key expansion |
| 102 | provexp = d.expand(prov) |
| 103 | if prov != provexp and d.getVar(prov, False): |
| 104 | d.renameVar(prov, provexp) |
| 105 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 106 | for prov in rproviders: |
| 107 | val = d.getVar(prov, False) |
| 108 | pkg = prov.replace("PREFERRED_RPROVIDER_", "") |
| 109 | for p in prefixes: |
| 110 | newval = p + "-" + val |
| 111 | |
| 112 | # implement variable keys |
| 113 | localdata = bb.data.createCopy(d) |
| 114 | override = ":virtclass-multilib-" + p |
| 115 | localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override) |
| 116 | newname = localdata.expand(prov) |
| 117 | if newname != prov and not d.getVar(newname, False): |
| 118 | d.setVar(newname, localdata.expand(newval)) |
| 119 | |
| 120 | # implement alternative multilib name |
| 121 | newname = localdata.expand("PREFERRED_RPROVIDER_" + p + "-" + pkg) |
| 122 | if not d.getVar(newname, False) and newval != None: |
| 123 | d.setVar(newname, localdata.expand(newval)) |
| 124 | # Avoid future variable key expansion |
| 125 | provexp = d.expand(prov) |
| 126 | if prov != provexp and d.getVar(prov, False): |
| 127 | d.renameVar(prov, provexp) |
| 128 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 129 | def translate_provide(prefix, prov): |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 130 | # Really need to know if kernel modules class is inherited somehow |
| 131 | if prov == "lttng-modules": |
| 132 | return prov |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 133 | if not prov.startswith("virtual/"): |
| 134 | return prefix + "-" + prov |
| 135 | if prov == "virtual/kernel": |
| 136 | return prov |
| 137 | prov = prov.replace("virtual/", "") |
| 138 | return "virtual/" + prefix + "-" + prov |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 139 | |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame^] | 140 | mp = (d.getVar("BB_MULTI_PROVIDER_ALLOWED") or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 141 | extramp = [] |
| 142 | for p in mp: |
| 143 | if p.endswith("-native") or "-crosssdk-" in p or p.startswith(("nativesdk-", "virtual/nativesdk-")) or 'cross-canadian' in p: |
| 144 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 145 | for pref in prefixes: |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 146 | extramp.append(translate_provide(pref, p)) |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame^] | 147 | d.setVar("BB_MULTI_PROVIDER_ALLOWED", " ".join(mp + extramp)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 148 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 149 | abisafe = (d.getVar("SIGGEN_EXCLUDERECIPES_ABISAFE") or "").split() |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 150 | extras = [] |
| 151 | for p in prefixes: |
| 152 | for a in abisafe: |
| 153 | extras.append(p + "-" + a) |
| 154 | d.appendVar("SIGGEN_EXCLUDERECIPES_ABISAFE", " " + " ".join(extras)) |
| 155 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 156 | siggen_exclude = (d.getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS") or "").split() |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 157 | extras = [] |
| 158 | for p in prefixes: |
| 159 | for a in siggen_exclude: |
| 160 | a1, a2 = a.split("->") |
| 161 | extras.append(translate_provide(p, a1) + "->" + translate_provide(p, a2)) |
| 162 | d.appendVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS", " " + " ".join(extras)) |
| 163 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 164 | python multilib_virtclass_handler_vendor () { |
| 165 | if isinstance(e, bb.event.ConfigParsed): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 166 | for v in e.data.getVar("MULTILIB_VARIANTS").split(): |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 167 | if e.data.getVar("TARGET_VENDOR:virtclass-multilib-" + v, False) is None: |
| 168 | e.data.setVar("TARGET_VENDOR:virtclass-multilib-" + v, e.data.getVar("TARGET_VENDOR", False) + "ml" + v) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 169 | preferred_ml_updates(e.data) |
| 170 | } |
| 171 | addhandler multilib_virtclass_handler_vendor |
| 172 | multilib_virtclass_handler_vendor[eventmask] = "bb.event.ConfigParsed" |
| 173 | |
| 174 | python multilib_virtclass_handler_global () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 175 | variant = e.data.getVar("BBEXTENDVARIANT") |
| 176 | if variant: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 177 | return |
| 178 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 179 | non_ml_recipes = d.getVar('NON_MULTILIB_RECIPES').split() |
| 180 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 181 | if bb.data.inherits_class('kernel', e.data) or \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 182 | bb.data.inherits_class('module-base', e.data) or \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 183 | d.getVar('BPN') in non_ml_recipes: |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 184 | |
| 185 | # We need to avoid expanding KERNEL_VERSION which we can do by deleting it |
| 186 | # from a copy of the datastore |
| 187 | localdata = bb.data.createCopy(d) |
| 188 | localdata.delVar("KERNEL_VERSION") |
| 189 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 190 | variants = (e.data.getVar("MULTILIB_VARIANTS") or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 191 | |
| 192 | import oe.classextend |
| 193 | clsextends = [] |
| 194 | for variant in variants: |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 195 | clsextends.append(oe.classextend.ClassExtender(variant, localdata)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 196 | |
| 197 | # Process PROVIDES |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 198 | origprovs = provs = localdata.getVar("PROVIDES") or "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 199 | for clsextend in clsextends: |
| 200 | provs = provs + " " + clsextend.map_variable("PROVIDES", setvar=False) |
| 201 | e.data.setVar("PROVIDES", provs) |
| 202 | |
| 203 | # Process RPROVIDES |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 204 | origrprovs = rprovs = localdata.getVar("RPROVIDES") or "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 205 | for clsextend in clsextends: |
| 206 | rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES", setvar=False) |
| 207 | if rprovs.strip(): |
| 208 | e.data.setVar("RPROVIDES", rprovs) |
| 209 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 210 | # Process RPROVIDES:${PN}... |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 211 | for pkg in (e.data.getVar("PACKAGES") or "").split(): |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 212 | origrprovs = rprovs = localdata.getVar("RPROVIDES:%s" % pkg) or "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 213 | for clsextend in clsextends: |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 214 | rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES:%s" % pkg, setvar=False) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 215 | rprovs = rprovs + " " + clsextend.extname + "-" + pkg |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 216 | e.data.setVar("RPROVIDES:%s" % pkg, rprovs) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | addhandler multilib_virtclass_handler_global |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 220 | multilib_virtclass_handler_global[eventmask] = "bb.event.RecipeTaskPreProcess" |