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): |
| 121 | if not prov.startswith("virtual/"): |
| 122 | return prefix + "-" + prov |
| 123 | if prov == "virtual/kernel": |
| 124 | return prov |
| 125 | prov = prov.replace("virtual/", "") |
| 126 | return "virtual/" + prefix + "-" + prov |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 127 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 128 | mp = (d.getVar("MULTI_PROVIDER_WHITELIST") or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 129 | extramp = [] |
| 130 | for p in mp: |
| 131 | if p.endswith("-native") or "-crosssdk-" in p or p.startswith(("nativesdk-", "virtual/nativesdk-")) or 'cross-canadian' in p: |
| 132 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 133 | for pref in prefixes: |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 134 | extramp.append(translate_provide(pref, p)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 135 | d.setVar("MULTI_PROVIDER_WHITELIST", " ".join(mp + extramp)) |
| 136 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 137 | abisafe = (d.getVar("SIGGEN_EXCLUDERECIPES_ABISAFE") or "").split() |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 138 | extras = [] |
| 139 | for p in prefixes: |
| 140 | for a in abisafe: |
| 141 | extras.append(p + "-" + a) |
| 142 | d.appendVar("SIGGEN_EXCLUDERECIPES_ABISAFE", " " + " ".join(extras)) |
| 143 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 144 | siggen_exclude = (d.getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS") or "").split() |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 145 | extras = [] |
| 146 | for p in prefixes: |
| 147 | for a in siggen_exclude: |
| 148 | a1, a2 = a.split("->") |
| 149 | extras.append(translate_provide(p, a1) + "->" + translate_provide(p, a2)) |
| 150 | d.appendVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS", " " + " ".join(extras)) |
| 151 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 152 | python multilib_virtclass_handler_vendor () { |
| 153 | if isinstance(e, bb.event.ConfigParsed): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 154 | for v in e.data.getVar("MULTILIB_VARIANTS").split(): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 155 | if e.data.getVar("TARGET_VENDOR_virtclass-multilib-" + v, False) is None: |
| 156 | e.data.setVar("TARGET_VENDOR_virtclass-multilib-" + v, e.data.getVar("TARGET_VENDOR", False) + "ml" + v) |
| 157 | preferred_ml_updates(e.data) |
| 158 | } |
| 159 | addhandler multilib_virtclass_handler_vendor |
| 160 | multilib_virtclass_handler_vendor[eventmask] = "bb.event.ConfigParsed" |
| 161 | |
| 162 | python multilib_virtclass_handler_global () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 163 | variant = e.data.getVar("BBEXTENDVARIANT") |
| 164 | if variant: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 165 | return |
| 166 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 167 | non_ml_recipes = d.getVar('NON_MULTILIB_RECIPES').split() |
| 168 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 169 | if bb.data.inherits_class('kernel', e.data) or \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 170 | bb.data.inherits_class('module-base', e.data) or \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 171 | d.getVar('BPN') in non_ml_recipes: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 172 | variants = (e.data.getVar("MULTILIB_VARIANTS") or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 173 | |
| 174 | import oe.classextend |
| 175 | clsextends = [] |
| 176 | for variant in variants: |
| 177 | clsextends.append(oe.classextend.ClassExtender(variant, e.data)) |
| 178 | |
| 179 | # Process PROVIDES |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 180 | origprovs = provs = e.data.getVar("PROVIDES") or "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 181 | for clsextend in clsextends: |
| 182 | provs = provs + " " + clsextend.map_variable("PROVIDES", setvar=False) |
| 183 | e.data.setVar("PROVIDES", provs) |
| 184 | |
| 185 | # Process RPROVIDES |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 186 | origrprovs = rprovs = e.data.getVar("RPROVIDES") or "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 187 | for clsextend in clsextends: |
| 188 | rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES", setvar=False) |
| 189 | if rprovs.strip(): |
| 190 | e.data.setVar("RPROVIDES", rprovs) |
| 191 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 192 | # Process RPROVIDES_${PN}... |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 193 | for pkg in (e.data.getVar("PACKAGES") or "").split(): |
| 194 | origrprovs = rprovs = e.data.getVar("RPROVIDES_%s" % pkg) or "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 195 | for clsextend in clsextends: |
| 196 | rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES_%s" % pkg, setvar=False) |
| 197 | rprovs = rprovs + " " + clsextend.extname + "-" + pkg |
| 198 | e.data.setVar("RPROVIDES_%s" % pkg, rprovs) |
| 199 | } |
| 200 | |
| 201 | addhandler multilib_virtclass_handler_global |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 202 | multilib_virtclass_handler_global[eventmask] = "bb.event.RecipeParsed" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 203 | |