blob: fd0bfe127387066c7151e0d753888b0f35dff80c [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001def 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 Bishop6e60e8b2018-02-01 10:27:11 -05004 multilibs = d.getVar('MULTILIBS') or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -05005 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 Williamsc124f4f2015-09-15 14:41:29 -050032 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 Williamsc124f4f2015-09-15 14:41:29 -050059 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 Williamsc0f7c042017-02-23 20:41:17 -060073 newval = None
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074 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 Williamsc124f4f2015-09-15 14:41:29 -050081 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 Williamsc0f7c042017-02-23 20:41:17 -060087 if not d.getVar(newname, False) and newval != None:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088 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 Williamsf1e5d692016-03-30 15:21:19 -050094 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 Williamsc124f4f2015-09-15 14:41:29 -0500101
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500102 mp = (d.getVar("MULTI_PROVIDER_WHITELIST") or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500103 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 Williamsc124f4f2015-09-15 14:41:29 -0500107 for pref in prefixes:
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500108 extramp.append(translate_provide(pref, p))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500109 d.setVar("MULTI_PROVIDER_WHITELIST", " ".join(mp + extramp))
110
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500111 abisafe = (d.getVar("SIGGEN_EXCLUDERECIPES_ABISAFE") or "").split()
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500112 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 Bishop6e60e8b2018-02-01 10:27:11 -0500118 siggen_exclude = (d.getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS") or "").split()
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500119 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 Williamsc124f4f2015-09-15 14:41:29 -0500126python multilib_virtclass_handler_vendor () {
127 if isinstance(e, bb.event.ConfigParsed):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500128 for v in e.data.getVar("MULTILIB_VARIANTS").split():
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500129 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}
133addhandler multilib_virtclass_handler_vendor
134multilib_virtclass_handler_vendor[eventmask] = "bb.event.ConfigParsed"
135
136python multilib_virtclass_handler_global () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500137 variant = e.data.getVar("BBEXTENDVARIANT")
138 if variant:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500139 return
140
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500141 if bb.data.inherits_class('kernel', e.data) or \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500142 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 Bishop6e60e8b2018-02-01 10:27:11 -0500145 variants = (e.data.getVar("MULTILIB_VARIANTS") or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500146
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 Bishop6e60e8b2018-02-01 10:27:11 -0500153 origprovs = provs = e.data.getVar("PROVIDES") or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500154 for clsextend in clsextends:
155 provs = provs + " " + clsextend.map_variable("PROVIDES", setvar=False)
156 e.data.setVar("PROVIDES", provs)
157
158 # Process RPROVIDES
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500159 origrprovs = rprovs = e.data.getVar("RPROVIDES") or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500160 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 Bishop6e60e8b2018-02-01 10:27:11 -0500166 for pkg in (e.data.getVar("PACKAGES") or "").split():
167 origrprovs = rprovs = e.data.getVar("RPROVIDES_%s" % pkg) or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500168 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
174addhandler multilib_virtclass_handler_global
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500175multilib_virtclass_handler_global[eventmask] = "bb.event.RecipeParsed"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500176