blob: 96257de5ca0e2db3479088427ca22ed3b1946785 [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:
42 newname = localdata.expand(v)
43 else:
44 newname = localdata.expand(v).replace(version_str, version_str + p + '-')
45 if newname != v:
46 newval = localdata.expand(val)
47 d.setVar(newname, newval)
48 # Avoid future variable key expansion
49 vexp = d.expand(v)
50 if v != vexp and d.getVar(v, False):
51 d.renameVar(v, vexp)
52 continue
Patrick Williamsc124f4f2015-09-15 14:41:29 -050053 for p in prefixes:
Andrew Geissler95ac1b82021-03-31 14:34:31 -050054 newname = version_str + p + "-" + pkg
55 if not d.getVar(newname, False):
56 d.setVar(newname, val)
57
58 sort_versions(required_versions, "REQUIRED")
59 sort_versions(preferred_versions, "PREFERRED")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060
61 for prov in providers:
62 val = d.getVar(prov, False)
63 pkg = prov.replace("PREFERRED_PROVIDER_", "")
64 if pkg.endswith("-native") or "-crosssdk-" in pkg or pkg.startswith(("nativesdk-", "virtual/nativesdk-")):
65 continue
66 if 'cross-canadian' in pkg:
67 for p in prefixes:
68 localdata = bb.data.createCopy(d)
69 override = ":virtclass-multilib-" + p
70 localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050071 newname = localdata.expand(prov)
72 if newname != prov:
73 newval = localdata.expand(val)
74 d.setVar(newname, newval)
75 # Avoid future variable key expansion
76 provexp = d.expand(prov)
77 if prov != provexp and d.getVar(prov, False):
78 d.renameVar(prov, provexp)
79 continue
80 virt = ""
81 if pkg.startswith("virtual/"):
82 pkg = pkg.replace("virtual/", "")
83 virt = "virtual/"
84 for p in prefixes:
Patrick Williamsc0f7c042017-02-23 20:41:17 -060085 newval = None
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086 if pkg != "kernel":
87 newval = p + "-" + val
88
89 # implement variable keys
90 localdata = bb.data.createCopy(d)
91 override = ":virtclass-multilib-" + p
92 localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050093 newname = localdata.expand(prov)
94 if newname != prov and not d.getVar(newname, False):
95 d.setVar(newname, localdata.expand(newval))
96
97 # implement alternative multilib name
98 newname = localdata.expand("PREFERRED_PROVIDER_" + virt + p + "-" + pkg)
Patrick Williamsc0f7c042017-02-23 20:41:17 -060099 if not d.getVar(newname, False) and newval != None:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500100 d.setVar(newname, localdata.expand(newval))
101 # Avoid future variable key expansion
102 provexp = d.expand(prov)
103 if prov != provexp and d.getVar(prov, False):
104 d.renameVar(prov, provexp)
105
Brad Bishop316dfdd2018-06-25 12:45:53 -0400106 for prov in rproviders:
107 val = d.getVar(prov, False)
108 pkg = prov.replace("PREFERRED_RPROVIDER_", "")
109 for p in prefixes:
110 newval = p + "-" + val
111
112 # implement variable keys
113 localdata = bb.data.createCopy(d)
114 override = ":virtclass-multilib-" + p
115 localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override)
116 newname = localdata.expand(prov)
117 if newname != prov and not d.getVar(newname, False):
118 d.setVar(newname, localdata.expand(newval))
119
120 # implement alternative multilib name
121 newname = localdata.expand("PREFERRED_RPROVIDER_" + p + "-" + pkg)
122 if not d.getVar(newname, False) and newval != None:
123 d.setVar(newname, localdata.expand(newval))
124 # Avoid future variable key expansion
125 provexp = d.expand(prov)
126 if prov != provexp and d.getVar(prov, False):
127 d.renameVar(prov, provexp)
128
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500129 def translate_provide(prefix, prov):
Brad Bishop15ae2502019-06-18 21:44:24 -0400130 # Really need to know if kernel modules class is inherited somehow
131 if prov == "lttng-modules":
132 return prov
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500133 if not prov.startswith("virtual/"):
134 return prefix + "-" + prov
135 if prov == "virtual/kernel":
136 return prov
137 prov = prov.replace("virtual/", "")
138 return "virtual/" + prefix + "-" + prov
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500139
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500140 mp = (d.getVar("MULTI_PROVIDER_WHITELIST") or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500141 extramp = []
142 for p in mp:
143 if p.endswith("-native") or "-crosssdk-" in p or p.startswith(("nativesdk-", "virtual/nativesdk-")) or 'cross-canadian' in p:
144 continue
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500145 for pref in prefixes:
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500146 extramp.append(translate_provide(pref, p))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500147 d.setVar("MULTI_PROVIDER_WHITELIST", " ".join(mp + extramp))
148
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500149 abisafe = (d.getVar("SIGGEN_EXCLUDERECIPES_ABISAFE") or "").split()
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500150 extras = []
151 for p in prefixes:
152 for a in abisafe:
153 extras.append(p + "-" + a)
154 d.appendVar("SIGGEN_EXCLUDERECIPES_ABISAFE", " " + " ".join(extras))
155
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500156 siggen_exclude = (d.getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS") or "").split()
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500157 extras = []
158 for p in prefixes:
159 for a in siggen_exclude:
160 a1, a2 = a.split("->")
161 extras.append(translate_provide(p, a1) + "->" + translate_provide(p, a2))
162 d.appendVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS", " " + " ".join(extras))
163
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500164python multilib_virtclass_handler_vendor () {
165 if isinstance(e, bb.event.ConfigParsed):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500166 for v in e.data.getVar("MULTILIB_VARIANTS").split():
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500167 if e.data.getVar("TARGET_VENDOR_virtclass-multilib-" + v, False) is None:
168 e.data.setVar("TARGET_VENDOR_virtclass-multilib-" + v, e.data.getVar("TARGET_VENDOR", False) + "ml" + v)
169 preferred_ml_updates(e.data)
170}
171addhandler multilib_virtclass_handler_vendor
172multilib_virtclass_handler_vendor[eventmask] = "bb.event.ConfigParsed"
173
174python multilib_virtclass_handler_global () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500175 variant = e.data.getVar("BBEXTENDVARIANT")
176 if variant:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500177 return
178
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800179 non_ml_recipes = d.getVar('NON_MULTILIB_RECIPES').split()
180
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500181 if bb.data.inherits_class('kernel', e.data) or \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500182 bb.data.inherits_class('module-base', e.data) or \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800183 d.getVar('BPN') in non_ml_recipes:
Brad Bishop96ff1982019-08-19 13:50:42 -0400184
185 # We need to avoid expanding KERNEL_VERSION which we can do by deleting it
186 # from a copy of the datastore
187 localdata = bb.data.createCopy(d)
188 localdata.delVar("KERNEL_VERSION")
189
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500190 variants = (e.data.getVar("MULTILIB_VARIANTS") or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500191
192 import oe.classextend
193 clsextends = []
194 for variant in variants:
Brad Bishop96ff1982019-08-19 13:50:42 -0400195 clsextends.append(oe.classextend.ClassExtender(variant, localdata))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500196
197 # Process PROVIDES
Brad Bishop96ff1982019-08-19 13:50:42 -0400198 origprovs = provs = localdata.getVar("PROVIDES") or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500199 for clsextend in clsextends:
200 provs = provs + " " + clsextend.map_variable("PROVIDES", setvar=False)
201 e.data.setVar("PROVIDES", provs)
202
203 # Process RPROVIDES
Brad Bishop96ff1982019-08-19 13:50:42 -0400204 origrprovs = rprovs = localdata.getVar("RPROVIDES") or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500205 for clsextend in clsextends:
206 rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES", setvar=False)
207 if rprovs.strip():
208 e.data.setVar("RPROVIDES", rprovs)
209
Brad Bishop316dfdd2018-06-25 12:45:53 -0400210 # Process RPROVIDES_${PN}...
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500211 for pkg in (e.data.getVar("PACKAGES") or "").split():
Brad Bishop96ff1982019-08-19 13:50:42 -0400212 origrprovs = rprovs = localdata.getVar("RPROVIDES_%s" % pkg) or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500213 for clsextend in clsextends:
214 rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES_%s" % pkg, setvar=False)
215 rprovs = rprovs + " " + clsextend.extname + "-" + pkg
216 e.data.setVar("RPROVIDES_%s" % pkg, rprovs)
217}
218
219addhandler multilib_virtclass_handler_global
Brad Bishop96ff1982019-08-19 13:50:42 -0400220multilib_virtclass_handler_global[eventmask] = "bb.event.RecipeTaskPreProcess"