blob: 19ce1a50915981d0e8aaa64108505590bf9c0897 [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):
Brad Bishop15ae2502019-06-18 21:44:24 -0400121 # Really need to know if kernel modules class is inherited somehow
122 if prov == "lttng-modules":
123 return prov
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500124 if not prov.startswith("virtual/"):
125 return prefix + "-" + prov
126 if prov == "virtual/kernel":
127 return prov
128 prov = prov.replace("virtual/", "")
129 return "virtual/" + prefix + "-" + prov
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500130
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500131 mp = (d.getVar("MULTI_PROVIDER_WHITELIST") or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500132 extramp = []
133 for p in mp:
134 if p.endswith("-native") or "-crosssdk-" in p or p.startswith(("nativesdk-", "virtual/nativesdk-")) or 'cross-canadian' in p:
135 continue
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500136 for pref in prefixes:
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500137 extramp.append(translate_provide(pref, p))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500138 d.setVar("MULTI_PROVIDER_WHITELIST", " ".join(mp + extramp))
139
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500140 abisafe = (d.getVar("SIGGEN_EXCLUDERECIPES_ABISAFE") or "").split()
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500141 extras = []
142 for p in prefixes:
143 for a in abisafe:
144 extras.append(p + "-" + a)
145 d.appendVar("SIGGEN_EXCLUDERECIPES_ABISAFE", " " + " ".join(extras))
146
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500147 siggen_exclude = (d.getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS") or "").split()
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500148 extras = []
149 for p in prefixes:
150 for a in siggen_exclude:
151 a1, a2 = a.split("->")
152 extras.append(translate_provide(p, a1) + "->" + translate_provide(p, a2))
153 d.appendVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS", " " + " ".join(extras))
154
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500155python multilib_virtclass_handler_vendor () {
156 if isinstance(e, bb.event.ConfigParsed):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500157 for v in e.data.getVar("MULTILIB_VARIANTS").split():
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500158 if e.data.getVar("TARGET_VENDOR_virtclass-multilib-" + v, False) is None:
159 e.data.setVar("TARGET_VENDOR_virtclass-multilib-" + v, e.data.getVar("TARGET_VENDOR", False) + "ml" + v)
160 preferred_ml_updates(e.data)
161}
162addhandler multilib_virtclass_handler_vendor
163multilib_virtclass_handler_vendor[eventmask] = "bb.event.ConfigParsed"
164
165python multilib_virtclass_handler_global () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500166 variant = e.data.getVar("BBEXTENDVARIANT")
167 if variant:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500168 return
169
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800170 non_ml_recipes = d.getVar('NON_MULTILIB_RECIPES').split()
171
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500172 if bb.data.inherits_class('kernel', e.data) or \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500173 bb.data.inherits_class('module-base', e.data) or \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800174 d.getVar('BPN') in non_ml_recipes:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500175 variants = (e.data.getVar("MULTILIB_VARIANTS") or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500176
177 import oe.classextend
178 clsextends = []
179 for variant in variants:
180 clsextends.append(oe.classextend.ClassExtender(variant, e.data))
181
182 # Process PROVIDES
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500183 origprovs = provs = e.data.getVar("PROVIDES") or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500184 for clsextend in clsextends:
185 provs = provs + " " + clsextend.map_variable("PROVIDES", setvar=False)
186 e.data.setVar("PROVIDES", provs)
187
188 # Process RPROVIDES
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500189 origrprovs = rprovs = e.data.getVar("RPROVIDES") or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500190 for clsextend in clsextends:
191 rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES", setvar=False)
192 if rprovs.strip():
193 e.data.setVar("RPROVIDES", rprovs)
194
Brad Bishop316dfdd2018-06-25 12:45:53 -0400195 # Process RPROVIDES_${PN}...
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500196 for pkg in (e.data.getVar("PACKAGES") or "").split():
197 origrprovs = rprovs = e.data.getVar("RPROVIDES_%s" % pkg) or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500198 for clsextend in clsextends:
199 rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES_%s" % pkg, setvar=False)
200 rprovs = rprovs + " " + clsextend.extname + "-" + pkg
201 e.data.setVar("RPROVIDES_%s" % pkg, rprovs)
202}
203
204addhandler multilib_virtclass_handler_global
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500205multilib_virtclass_handler_global[eventmask] = "bb.event.RecipeParsed"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500206