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