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 = [] |
| 16 | for v in d.keys(): |
| 17 | if v.startswith("PREFERRED_VERSION_"): |
| 18 | versions.append(v) |
| 19 | if v.startswith("PREFERRED_PROVIDER_"): |
| 20 | providers.append(v) |
| 21 | |
| 22 | for v in versions: |
| 23 | val = d.getVar(v, False) |
| 24 | pkg = v.replace("PREFERRED_VERSION_", "") |
| 25 | if pkg.endswith("-native") or "-crosssdk-" in pkg or pkg.startswith(("nativesdk-", "virtual/nativesdk-")): |
| 26 | continue |
| 27 | if '-cross-' in pkg and '${' in pkg: |
| 28 | for p in prefixes: |
| 29 | localdata = bb.data.createCopy(d) |
| 30 | override = ":virtclass-multilib-" + p |
| 31 | localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 32 | if "-canadian-" in pkg: |
| 33 | newname = localdata.expand(v) |
| 34 | else: |
| 35 | newname = localdata.expand(v).replace("PREFERRED_VERSION_", "PREFERRED_VERSION_" + p + '-') |
| 36 | if newname != v: |
| 37 | newval = localdata.expand(val) |
| 38 | d.setVar(newname, newval) |
| 39 | # Avoid future variable key expansion |
| 40 | vexp = d.expand(v) |
| 41 | if v != vexp and d.getVar(v, False): |
| 42 | d.renameVar(v, vexp) |
| 43 | continue |
| 44 | for p in prefixes: |
| 45 | newname = "PREFERRED_VERSION_" + p + "-" + pkg |
| 46 | if not d.getVar(newname, False): |
| 47 | d.setVar(newname, val) |
| 48 | |
| 49 | for prov in providers: |
| 50 | val = d.getVar(prov, False) |
| 51 | pkg = prov.replace("PREFERRED_PROVIDER_", "") |
| 52 | if pkg.endswith("-native") or "-crosssdk-" in pkg or pkg.startswith(("nativesdk-", "virtual/nativesdk-")): |
| 53 | continue |
| 54 | if 'cross-canadian' in pkg: |
| 55 | for p in prefixes: |
| 56 | localdata = bb.data.createCopy(d) |
| 57 | override = ":virtclass-multilib-" + p |
| 58 | localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 59 | newname = localdata.expand(prov) |
| 60 | if newname != prov: |
| 61 | newval = localdata.expand(val) |
| 62 | d.setVar(newname, newval) |
| 63 | # Avoid future variable key expansion |
| 64 | provexp = d.expand(prov) |
| 65 | if prov != provexp and d.getVar(prov, False): |
| 66 | d.renameVar(prov, provexp) |
| 67 | continue |
| 68 | virt = "" |
| 69 | if pkg.startswith("virtual/"): |
| 70 | pkg = pkg.replace("virtual/", "") |
| 71 | virt = "virtual/" |
| 72 | for p in prefixes: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 73 | newval = None |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 74 | if pkg != "kernel": |
| 75 | newval = p + "-" + val |
| 76 | |
| 77 | # implement variable keys |
| 78 | localdata = bb.data.createCopy(d) |
| 79 | override = ":virtclass-multilib-" + p |
| 80 | localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 81 | newname = localdata.expand(prov) |
| 82 | if newname != prov and not d.getVar(newname, False): |
| 83 | d.setVar(newname, localdata.expand(newval)) |
| 84 | |
| 85 | # implement alternative multilib name |
| 86 | newname = localdata.expand("PREFERRED_PROVIDER_" + virt + p + "-" + pkg) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 87 | if not d.getVar(newname, False) and newval != None: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 88 | d.setVar(newname, localdata.expand(newval)) |
| 89 | # Avoid future variable key expansion |
| 90 | provexp = d.expand(prov) |
| 91 | if prov != provexp and d.getVar(prov, False): |
| 92 | d.renameVar(prov, provexp) |
| 93 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 94 | def translate_provide(prefix, prov): |
| 95 | if not prov.startswith("virtual/"): |
| 96 | return prefix + "-" + prov |
| 97 | if prov == "virtual/kernel": |
| 98 | return prov |
| 99 | prov = prov.replace("virtual/", "") |
| 100 | return "virtual/" + prefix + "-" + prov |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 101 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 102 | mp = (d.getVar("MULTI_PROVIDER_WHITELIST") or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 103 | extramp = [] |
| 104 | for p in mp: |
| 105 | if p.endswith("-native") or "-crosssdk-" in p or p.startswith(("nativesdk-", "virtual/nativesdk-")) or 'cross-canadian' in p: |
| 106 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 107 | for pref in prefixes: |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 108 | extramp.append(translate_provide(pref, p)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 109 | d.setVar("MULTI_PROVIDER_WHITELIST", " ".join(mp + extramp)) |
| 110 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 111 | abisafe = (d.getVar("SIGGEN_EXCLUDERECIPES_ABISAFE") or "").split() |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 112 | extras = [] |
| 113 | for p in prefixes: |
| 114 | for a in abisafe: |
| 115 | extras.append(p + "-" + a) |
| 116 | d.appendVar("SIGGEN_EXCLUDERECIPES_ABISAFE", " " + " ".join(extras)) |
| 117 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 118 | siggen_exclude = (d.getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS") or "").split() |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 119 | extras = [] |
| 120 | for p in prefixes: |
| 121 | for a in siggen_exclude: |
| 122 | a1, a2 = a.split("->") |
| 123 | extras.append(translate_provide(p, a1) + "->" + translate_provide(p, a2)) |
| 124 | d.appendVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS", " " + " ".join(extras)) |
| 125 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 126 | python multilib_virtclass_handler_vendor () { |
| 127 | if isinstance(e, bb.event.ConfigParsed): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 128 | for v in e.data.getVar("MULTILIB_VARIANTS").split(): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 129 | if e.data.getVar("TARGET_VENDOR_virtclass-multilib-" + v, False) is None: |
| 130 | e.data.setVar("TARGET_VENDOR_virtclass-multilib-" + v, e.data.getVar("TARGET_VENDOR", False) + "ml" + v) |
| 131 | preferred_ml_updates(e.data) |
| 132 | } |
| 133 | addhandler multilib_virtclass_handler_vendor |
| 134 | multilib_virtclass_handler_vendor[eventmask] = "bb.event.ConfigParsed" |
| 135 | |
| 136 | python multilib_virtclass_handler_global () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 137 | variant = e.data.getVar("BBEXTENDVARIANT") |
| 138 | if variant: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 139 | return |
| 140 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 141 | if bb.data.inherits_class('kernel', e.data) or \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 142 | bb.data.inherits_class('module-base', e.data) or \ |
| 143 | (bb.data.inherits_class('allarch', e.data) and\ |
| 144 | not bb.data.inherits_class('packagegroup', e.data)): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 145 | variants = (e.data.getVar("MULTILIB_VARIANTS") or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 146 | |
| 147 | import oe.classextend |
| 148 | clsextends = [] |
| 149 | for variant in variants: |
| 150 | clsextends.append(oe.classextend.ClassExtender(variant, e.data)) |
| 151 | |
| 152 | # Process PROVIDES |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 153 | origprovs = provs = e.data.getVar("PROVIDES") or "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 154 | for clsextend in clsextends: |
| 155 | provs = provs + " " + clsextend.map_variable("PROVIDES", setvar=False) |
| 156 | e.data.setVar("PROVIDES", provs) |
| 157 | |
| 158 | # Process RPROVIDES |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 159 | origrprovs = rprovs = e.data.getVar("RPROVIDES") or "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 160 | for clsextend in clsextends: |
| 161 | rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES", setvar=False) |
| 162 | if rprovs.strip(): |
| 163 | e.data.setVar("RPROVIDES", rprovs) |
| 164 | |
| 165 | # Process RPROVIDES_${PN}... |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 166 | for pkg in (e.data.getVar("PACKAGES") or "").split(): |
| 167 | origrprovs = rprovs = e.data.getVar("RPROVIDES_%s" % pkg) or "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 168 | for clsextend in clsextends: |
| 169 | rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES_%s" % pkg, setvar=False) |
| 170 | rprovs = rprovs + " " + clsextend.extname + "-" + pkg |
| 171 | e.data.setVar("RPROVIDES_%s" % pkg, rprovs) |
| 172 | } |
| 173 | |
| 174 | addhandler multilib_virtclass_handler_global |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 175 | multilib_virtclass_handler_global[eventmask] = "bb.event.RecipeParsed" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 176 | |