blob: e06307d057a323aa5e48185e9b9504280ee5d337 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001def preferred_ml_updates(d):
Andrew Geissler95ac1b82021-03-31 14:34:31 -05002 # If any of PREFERRED_PROVIDER, PREFERRED_RPROVIDER, REQUIRED_VERSION
3 # or PREFERRED_VERSION are set, we need to mirror these variables in
4 # the multilib case;
Brad Bishop6e60e8b2018-02-01 10:27:11 -05005 multilibs = d.getVar('MULTILIBS') or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006 if not multilibs:
7 return
8
9 prefixes = []
10 for ext in multilibs.split():
11 eext = ext.split(':')
12 if len(eext) > 1 and eext[0] == 'multilib':
13 prefixes.append(eext[1])
14
Andrew Geissler95ac1b82021-03-31 14:34:31 -050015 required_versions = []
16 preferred_versions = []
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017 providers = []
Brad Bishop316dfdd2018-06-25 12:45:53 -040018 rproviders = []
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019 for v in d.keys():
Andrew Geissler95ac1b82021-03-31 14:34:31 -050020 if v.startswith("REQUIRED_VERSION_"):
21 required_versions.append(v)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022 if v.startswith("PREFERRED_VERSION_"):
Andrew Geissler95ac1b82021-03-31 14:34:31 -050023 preferred_versions.append(v)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024 if v.startswith("PREFERRED_PROVIDER_"):
25 providers.append(v)
Brad Bishop316dfdd2018-06-25 12:45:53 -040026 if v.startswith("PREFERRED_RPROVIDER_"):
27 rproviders.append(v)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028
Andrew Geissler95ac1b82021-03-31 14:34:31 -050029 def sort_versions(versions, keyword):
30 version_str = "_".join([keyword, "VERSION", ""])
31 for v in versions:
32 val = d.getVar(v, False)
33 pkg = v.replace(version_str, "")
34 if pkg.endswith("-native") or "-crosssdk-" in pkg or pkg.startswith(("nativesdk-", "virtual/nativesdk-")):
35 continue
36 if '-cross-' in pkg and '${' in pkg:
37 for p in prefixes:
38 localdata = bb.data.createCopy(d)
39 override = ":virtclass-multilib-" + p
40 localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override)
41 if "-canadian-" in pkg:
Andrew Geissler9aee5002022-03-30 16:27:02 +000042 newtune = localdata.getVar("DEFAULTTUNE:" + "virtclass-multilib-" + p, False)
43 if newtune:
44 localdata.setVar("DEFAULTTUNE", newtune)
Andrew Geissler95ac1b82021-03-31 14:34:31 -050045 newname = localdata.expand(v)
46 else:
47 newname = localdata.expand(v).replace(version_str, version_str + p + '-')
48 if newname != v:
49 newval = localdata.expand(val)
50 d.setVar(newname, newval)
51 # Avoid future variable key expansion
52 vexp = d.expand(v)
53 if v != vexp and d.getVar(v, False):
54 d.renameVar(v, vexp)
55 continue
Patrick Williamsc124f4f2015-09-15 14:41:29 -050056 for p in prefixes:
Andrew Geissler95ac1b82021-03-31 14:34:31 -050057 newname = version_str + p + "-" + pkg
58 if not d.getVar(newname, False):
59 d.setVar(newname, val)
60
61 sort_versions(required_versions, "REQUIRED")
62 sort_versions(preferred_versions, "PREFERRED")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063
64 for prov in providers:
65 val = d.getVar(prov, False)
66 pkg = prov.replace("PREFERRED_PROVIDER_", "")
67 if pkg.endswith("-native") or "-crosssdk-" in pkg or pkg.startswith(("nativesdk-", "virtual/nativesdk-")):
68 continue
69 if 'cross-canadian' in pkg:
70 for p in prefixes:
71 localdata = bb.data.createCopy(d)
72 override = ":virtclass-multilib-" + p
73 localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074 newname = localdata.expand(prov)
75 if newname != prov:
76 newval = localdata.expand(val)
77 d.setVar(newname, newval)
78 # Avoid future variable key expansion
79 provexp = d.expand(prov)
80 if prov != provexp and d.getVar(prov, False):
81 d.renameVar(prov, provexp)
82 continue
83 virt = ""
84 if pkg.startswith("virtual/"):
85 pkg = pkg.replace("virtual/", "")
86 virt = "virtual/"
87 for p in prefixes:
Patrick Williamsc0f7c042017-02-23 20:41:17 -060088 newval = None
Patrick Williamsc124f4f2015-09-15 14:41:29 -050089 if pkg != "kernel":
90 newval = p + "-" + val
91
92 # implement variable keys
93 localdata = bb.data.createCopy(d)
94 override = ":virtclass-multilib-" + p
95 localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050096 newname = localdata.expand(prov)
97 if newname != prov and not d.getVar(newname, False):
98 d.setVar(newname, localdata.expand(newval))
99
100 # implement alternative multilib name
101 newname = localdata.expand("PREFERRED_PROVIDER_" + virt + p + "-" + pkg)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600102 if not d.getVar(newname, False) and newval != None:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500103 d.setVar(newname, localdata.expand(newval))
104 # Avoid future variable key expansion
105 provexp = d.expand(prov)
106 if prov != provexp and d.getVar(prov, False):
107 d.renameVar(prov, provexp)
108
Brad Bishop316dfdd2018-06-25 12:45:53 -0400109 for prov in rproviders:
110 val = d.getVar(prov, False)
111 pkg = prov.replace("PREFERRED_RPROVIDER_", "")
112 for p in prefixes:
113 newval = p + "-" + val
114
115 # implement variable keys
116 localdata = bb.data.createCopy(d)
117 override = ":virtclass-multilib-" + p
118 localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override)
119 newname = localdata.expand(prov)
120 if newname != prov and not d.getVar(newname, False):
121 d.setVar(newname, localdata.expand(newval))
122
123 # implement alternative multilib name
124 newname = localdata.expand("PREFERRED_RPROVIDER_" + p + "-" + pkg)
125 if not d.getVar(newname, False) and newval != None:
126 d.setVar(newname, localdata.expand(newval))
127 # Avoid future variable key expansion
128 provexp = d.expand(prov)
129 if prov != provexp and d.getVar(prov, False):
130 d.renameVar(prov, provexp)
131
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500132 def translate_provide(prefix, prov):
Brad Bishop15ae2502019-06-18 21:44:24 -0400133 # Really need to know if kernel modules class is inherited somehow
134 if prov == "lttng-modules":
135 return prov
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500136 if not prov.startswith("virtual/"):
137 return prefix + "-" + prov
138 if prov == "virtual/kernel":
139 return prov
140 prov = prov.replace("virtual/", "")
141 return "virtual/" + prefix + "-" + prov
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500142
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000143 mp = (d.getVar("BB_MULTI_PROVIDER_ALLOWED") or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500144 extramp = []
145 for p in mp:
146 if p.endswith("-native") or "-crosssdk-" in p or p.startswith(("nativesdk-", "virtual/nativesdk-")) or 'cross-canadian' in p:
147 continue
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500148 for pref in prefixes:
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500149 extramp.append(translate_provide(pref, p))
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000150 d.setVar("BB_MULTI_PROVIDER_ALLOWED", " ".join(mp + extramp))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500151
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500152 abisafe = (d.getVar("SIGGEN_EXCLUDERECIPES_ABISAFE") or "").split()
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500153 extras = []
154 for p in prefixes:
155 for a in abisafe:
156 extras.append(p + "-" + a)
157 d.appendVar("SIGGEN_EXCLUDERECIPES_ABISAFE", " " + " ".join(extras))
158
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500159 siggen_exclude = (d.getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS") or "").split()
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500160 extras = []
161 for p in prefixes:
162 for a in siggen_exclude:
163 a1, a2 = a.split("->")
164 extras.append(translate_provide(p, a1) + "->" + translate_provide(p, a2))
165 d.appendVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS", " " + " ".join(extras))
166
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500167python multilib_virtclass_handler_vendor () {
168 if isinstance(e, bb.event.ConfigParsed):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500169 for v in e.data.getVar("MULTILIB_VARIANTS").split():
Patrick Williams213cb262021-08-07 19:21:33 -0500170 if e.data.getVar("TARGET_VENDOR:virtclass-multilib-" + v, False) is None:
171 e.data.setVar("TARGET_VENDOR:virtclass-multilib-" + v, e.data.getVar("TARGET_VENDOR", False) + "ml" + v)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500172 preferred_ml_updates(e.data)
173}
174addhandler multilib_virtclass_handler_vendor
175multilib_virtclass_handler_vendor[eventmask] = "bb.event.ConfigParsed"
176
177python multilib_virtclass_handler_global () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500178 variant = e.data.getVar("BBEXTENDVARIANT")
179 if variant:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500180 return
181
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800182 non_ml_recipes = d.getVar('NON_MULTILIB_RECIPES').split()
183
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500184 if bb.data.inherits_class('kernel', e.data) or \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500185 bb.data.inherits_class('module-base', e.data) or \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800186 d.getVar('BPN') in non_ml_recipes:
Brad Bishop96ff1982019-08-19 13:50:42 -0400187
188 # We need to avoid expanding KERNEL_VERSION which we can do by deleting it
189 # from a copy of the datastore
190 localdata = bb.data.createCopy(d)
191 localdata.delVar("KERNEL_VERSION")
192
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500193 variants = (e.data.getVar("MULTILIB_VARIANTS") or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500194
195 import oe.classextend
196 clsextends = []
197 for variant in variants:
Brad Bishop96ff1982019-08-19 13:50:42 -0400198 clsextends.append(oe.classextend.ClassExtender(variant, localdata))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500199
200 # Process PROVIDES
Brad Bishop96ff1982019-08-19 13:50:42 -0400201 origprovs = provs = localdata.getVar("PROVIDES") or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500202 for clsextend in clsextends:
203 provs = provs + " " + clsextend.map_variable("PROVIDES", setvar=False)
204 e.data.setVar("PROVIDES", provs)
205
206 # Process RPROVIDES
Brad Bishop96ff1982019-08-19 13:50:42 -0400207 origrprovs = rprovs = localdata.getVar("RPROVIDES") or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500208 for clsextend in clsextends:
209 rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES", setvar=False)
210 if rprovs.strip():
211 e.data.setVar("RPROVIDES", rprovs)
212
Patrick Williams213cb262021-08-07 19:21:33 -0500213 # Process RPROVIDES:${PN}...
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500214 for pkg in (e.data.getVar("PACKAGES") or "").split():
Patrick Williams213cb262021-08-07 19:21:33 -0500215 origrprovs = rprovs = localdata.getVar("RPROVIDES:%s" % pkg) or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500216 for clsextend in clsextends:
Patrick Williams213cb262021-08-07 19:21:33 -0500217 rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES:%s" % pkg, setvar=False)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500218 rprovs = rprovs + " " + clsextend.extname + "-" + pkg
Patrick Williams213cb262021-08-07 19:21:33 -0500219 e.data.setVar("RPROVIDES:%s" % pkg, rprovs)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500220}
221
222addhandler multilib_virtclass_handler_global
Brad Bishop96ff1982019-08-19 13:50:42 -0400223multilib_virtclass_handler_global[eventmask] = "bb.event.RecipeTaskPreProcess"