blob: 11ae2681f004edc2c0dbcc2c48d6a1b4b05a4c28 [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;
4 multilibs = d.getVar('MULTILIBS', True) or ""
5 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)
32 bb.data.update_data(localdata)
33 if "-canadian-" in pkg:
34 newname = localdata.expand(v)
35 else:
36 newname = localdata.expand(v).replace("PREFERRED_VERSION_", "PREFERRED_VERSION_" + p + '-')
37 if newname != v:
38 newval = localdata.expand(val)
39 d.setVar(newname, newval)
40 # Avoid future variable key expansion
41 vexp = d.expand(v)
42 if v != vexp and d.getVar(v, False):
43 d.renameVar(v, vexp)
44 continue
45 for p in prefixes:
46 newname = "PREFERRED_VERSION_" + p + "-" + pkg
47 if not d.getVar(newname, False):
48 d.setVar(newname, val)
49
50 for prov in providers:
51 val = d.getVar(prov, False)
52 pkg = prov.replace("PREFERRED_PROVIDER_", "")
53 if pkg.endswith("-native") or "-crosssdk-" in pkg or pkg.startswith(("nativesdk-", "virtual/nativesdk-")):
54 continue
55 if 'cross-canadian' in pkg:
56 for p in prefixes:
57 localdata = bb.data.createCopy(d)
58 override = ":virtclass-multilib-" + p
59 localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override)
60 bb.data.update_data(localdata)
61 newname = localdata.expand(prov)
62 if newname != prov:
63 newval = localdata.expand(val)
64 d.setVar(newname, newval)
65 # Avoid future variable key expansion
66 provexp = d.expand(prov)
67 if prov != provexp and d.getVar(prov, False):
68 d.renameVar(prov, provexp)
69 continue
70 virt = ""
71 if pkg.startswith("virtual/"):
72 pkg = pkg.replace("virtual/", "")
73 virt = "virtual/"
74 for p in prefixes:
Patrick Williamsc0f7c042017-02-23 20:41:17 -060075 newval = None
Patrick Williamsc124f4f2015-09-15 14:41:29 -050076 if pkg != "kernel":
77 newval = p + "-" + val
78
79 # implement variable keys
80 localdata = bb.data.createCopy(d)
81 override = ":virtclass-multilib-" + p
82 localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override)
83 bb.data.update_data(localdata)
84 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
Patrick Williamsf1e5d692016-03-30 15:21:19 -050097 def translate_provide(prefix, prov):
98 if not prov.startswith("virtual/"):
99 return prefix + "-" + prov
100 if prov == "virtual/kernel":
101 return prov
102 prov = prov.replace("virtual/", "")
103 return "virtual/" + prefix + "-" + prov
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104
105 mp = (d.getVar("MULTI_PROVIDER_WHITELIST", True) or "").split()
106 extramp = []
107 for p in mp:
108 if p.endswith("-native") or "-crosssdk-" in p or p.startswith(("nativesdk-", "virtual/nativesdk-")) or 'cross-canadian' in p:
109 continue
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500110 for pref in prefixes:
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500111 extramp.append(translate_provide(pref, p))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500112 d.setVar("MULTI_PROVIDER_WHITELIST", " ".join(mp + extramp))
113
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500114 abisafe = (d.getVar("SIGGEN_EXCLUDERECIPES_ABISAFE", True) or "").split()
115 extras = []
116 for p in prefixes:
117 for a in abisafe:
118 extras.append(p + "-" + a)
119 d.appendVar("SIGGEN_EXCLUDERECIPES_ABISAFE", " " + " ".join(extras))
120
121 siggen_exclude = (d.getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS", True) or "").split()
122 extras = []
123 for p in prefixes:
124 for a in siggen_exclude:
125 a1, a2 = a.split("->")
126 extras.append(translate_provide(p, a1) + "->" + translate_provide(p, a2))
127 d.appendVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS", " " + " ".join(extras))
128
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500129python multilib_virtclass_handler_vendor () {
130 if isinstance(e, bb.event.ConfigParsed):
131 for v in e.data.getVar("MULTILIB_VARIANTS", True).split():
132 if e.data.getVar("TARGET_VENDOR_virtclass-multilib-" + v, False) is None:
133 e.data.setVar("TARGET_VENDOR_virtclass-multilib-" + v, e.data.getVar("TARGET_VENDOR", False) + "ml" + v)
134 preferred_ml_updates(e.data)
135}
136addhandler multilib_virtclass_handler_vendor
137multilib_virtclass_handler_vendor[eventmask] = "bb.event.ConfigParsed"
138
139python multilib_virtclass_handler_global () {
140 if not e.data:
141 return
142
143 variant = e.data.getVar("BBEXTENDVARIANT", True)
144
145 if isinstance(e, bb.event.RecipeParsed) and not variant:
146 if bb.data.inherits_class('kernel', e.data) or \
147 bb.data.inherits_class('module-base', e.data) or \
148 (bb.data.inherits_class('allarch', e.data) and\
149 not bb.data.inherits_class('packagegroup', e.data)):
150 variants = (e.data.getVar("MULTILIB_VARIANTS", True) or "").split()
151
152 import oe.classextend
153 clsextends = []
154 for variant in variants:
155 clsextends.append(oe.classextend.ClassExtender(variant, e.data))
156
157 # Process PROVIDES
158 origprovs = provs = e.data.getVar("PROVIDES", True) or ""
159 for clsextend in clsextends:
160 provs = provs + " " + clsextend.map_variable("PROVIDES", setvar=False)
161 e.data.setVar("PROVIDES", provs)
162
163 # Process RPROVIDES
164 origrprovs = rprovs = e.data.getVar("RPROVIDES", True) or ""
165 for clsextend in clsextends:
166 rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES", setvar=False)
167 if rprovs.strip():
168 e.data.setVar("RPROVIDES", rprovs)
169
170 # Process RPROVIDES_${PN}...
171 for pkg in (e.data.getVar("PACKAGES", True) or "").split():
172 origrprovs = rprovs = e.data.getVar("RPROVIDES_%s" % pkg, True) or ""
173 for clsextend in clsextends:
174 rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES_%s" % pkg, setvar=False)
175 rprovs = rprovs + " " + clsextend.extname + "-" + pkg
176 e.data.setVar("RPROVIDES_%s" % pkg, rprovs)
177}
178
179addhandler multilib_virtclass_handler_global
180multilib_virtclass_handler_global[eventmask] = "bb.event.RecipePreFinalise bb.event.RecipeParsed"
181