blob: 649cc096b76a2dbbbb2cea4f7363d1ccb7fe1b06 [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 = []
Brad Bishop316dfdd2018-06-25 12:45:53 -040016 rproviders = []
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017 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 Bishop316dfdd2018-06-25 12:45:53 -040022 if v.startswith("PREFERRED_RPROVIDER_"):
23 rproviders.append(v)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024
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 Williamsc124f4f2015-09-15 14:41:29 -050035 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 Williamsc124f4f2015-09-15 14:41:29 -050062 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 Williamsc0f7c042017-02-23 20:41:17 -060076 newval = None
Patrick Williamsc124f4f2015-09-15 14:41:29 -050077 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 Williamsc124f4f2015-09-15 14:41:29 -050084 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 Williamsc0f7c042017-02-23 20:41:17 -060090 if not d.getVar(newname, False) and newval != None:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050091 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 Bishop316dfdd2018-06-25 12:45:53 -040097 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 Williamsf1e5d692016-03-30 15:21:19 -0500120 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 Williamsc124f4f2015-09-15 14:41:29 -0500127
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500128 mp = (d.getVar("MULTI_PROVIDER_WHITELIST") or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500129 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 Williamsc124f4f2015-09-15 14:41:29 -0500133 for pref in prefixes:
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500134 extramp.append(translate_provide(pref, p))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500135 d.setVar("MULTI_PROVIDER_WHITELIST", " ".join(mp + extramp))
136
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500137 abisafe = (d.getVar("SIGGEN_EXCLUDERECIPES_ABISAFE") or "").split()
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500138 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 Bishop6e60e8b2018-02-01 10:27:11 -0500144 siggen_exclude = (d.getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS") or "").split()
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500145 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 Williamsc124f4f2015-09-15 14:41:29 -0500152python multilib_virtclass_handler_vendor () {
153 if isinstance(e, bb.event.ConfigParsed):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500154 for v in e.data.getVar("MULTILIB_VARIANTS").split():
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500155 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}
159addhandler multilib_virtclass_handler_vendor
160multilib_virtclass_handler_vendor[eventmask] = "bb.event.ConfigParsed"
161
162python multilib_virtclass_handler_global () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500163 variant = e.data.getVar("BBEXTENDVARIANT")
164 if variant:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500165 return
166
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800167 non_ml_recipes = d.getVar('NON_MULTILIB_RECIPES').split()
168
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500169 if bb.data.inherits_class('kernel', e.data) or \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500170 bb.data.inherits_class('module-base', e.data) or \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800171 d.getVar('BPN') in non_ml_recipes:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500172 variants = (e.data.getVar("MULTILIB_VARIANTS") or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500173
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 Bishop6e60e8b2018-02-01 10:27:11 -0500180 origprovs = provs = e.data.getVar("PROVIDES") or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500181 for clsextend in clsextends:
182 provs = provs + " " + clsextend.map_variable("PROVIDES", setvar=False)
183 e.data.setVar("PROVIDES", provs)
184
185 # Process RPROVIDES
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500186 origrprovs = rprovs = e.data.getVar("RPROVIDES") or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500187 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 Bishop316dfdd2018-06-25 12:45:53 -0400192 # Process RPROVIDES_${PN}...
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500193 for pkg in (e.data.getVar("PACKAGES") or "").split():
194 origrprovs = rprovs = e.data.getVar("RPROVIDES_%s" % pkg) or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500195 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
201addhandler multilib_virtclass_handler_global
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500202multilib_virtclass_handler_global[eventmask] = "bb.event.RecipeParsed"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500203