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