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