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