blob: 612cfb6919407a71114f15c2398ccd0d1a601c87 [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:
75 if pkg != "kernel":
76 newval = p + "-" + val
77
78 # implement variable keys
79 localdata = bb.data.createCopy(d)
80 override = ":virtclass-multilib-" + p
81 localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override)
82 bb.data.update_data(localdata)
83 newname = localdata.expand(prov)
84 if newname != prov and not d.getVar(newname, False):
85 d.setVar(newname, localdata.expand(newval))
86
87 # implement alternative multilib name
88 newname = localdata.expand("PREFERRED_PROVIDER_" + virt + p + "-" + pkg)
89 if not d.getVar(newname, False):
90 d.setVar(newname, localdata.expand(newval))
91 # Avoid future variable key expansion
92 provexp = d.expand(prov)
93 if prov != provexp and d.getVar(prov, False):
94 d.renameVar(prov, provexp)
95
96
97 mp = (d.getVar("MULTI_PROVIDER_WHITELIST", True) or "").split()
98 extramp = []
99 for p in mp:
100 if p.endswith("-native") or "-crosssdk-" in p or p.startswith(("nativesdk-", "virtual/nativesdk-")) or 'cross-canadian' in p:
101 continue
102 virt = ""
103 if p.startswith("virtual/"):
104 p = p.replace("virtual/", "")
105 virt = "virtual/"
106 for pref in prefixes:
107 extramp.append(virt + pref + "-" + p)
108 d.setVar("MULTI_PROVIDER_WHITELIST", " ".join(mp + extramp))
109
110python multilib_virtclass_handler_vendor () {
111 if isinstance(e, bb.event.ConfigParsed):
112 for v in e.data.getVar("MULTILIB_VARIANTS", True).split():
113 if e.data.getVar("TARGET_VENDOR_virtclass-multilib-" + v, False) is None:
114 e.data.setVar("TARGET_VENDOR_virtclass-multilib-" + v, e.data.getVar("TARGET_VENDOR", False) + "ml" + v)
115 preferred_ml_updates(e.data)
116}
117addhandler multilib_virtclass_handler_vendor
118multilib_virtclass_handler_vendor[eventmask] = "bb.event.ConfigParsed"
119
120python multilib_virtclass_handler_global () {
121 if not e.data:
122 return
123
124 variant = e.data.getVar("BBEXTENDVARIANT", True)
125
126 if isinstance(e, bb.event.RecipeParsed) and not variant:
127 if bb.data.inherits_class('kernel', e.data) or \
128 bb.data.inherits_class('module-base', e.data) or \
129 (bb.data.inherits_class('allarch', e.data) and\
130 not bb.data.inherits_class('packagegroup', e.data)):
131 variants = (e.data.getVar("MULTILIB_VARIANTS", True) or "").split()
132
133 import oe.classextend
134 clsextends = []
135 for variant in variants:
136 clsextends.append(oe.classextend.ClassExtender(variant, e.data))
137
138 # Process PROVIDES
139 origprovs = provs = e.data.getVar("PROVIDES", True) or ""
140 for clsextend in clsextends:
141 provs = provs + " " + clsextend.map_variable("PROVIDES", setvar=False)
142 e.data.setVar("PROVIDES", provs)
143
144 # Process RPROVIDES
145 origrprovs = rprovs = e.data.getVar("RPROVIDES", True) or ""
146 for clsextend in clsextends:
147 rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES", setvar=False)
148 if rprovs.strip():
149 e.data.setVar("RPROVIDES", rprovs)
150
151 # Process RPROVIDES_${PN}...
152 for pkg in (e.data.getVar("PACKAGES", True) or "").split():
153 origrprovs = rprovs = e.data.getVar("RPROVIDES_%s" % pkg, True) or ""
154 for clsextend in clsextends:
155 rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES_%s" % pkg, setvar=False)
156 rprovs = rprovs + " " + clsextend.extname + "-" + pkg
157 e.data.setVar("RPROVIDES_%s" % pkg, rprovs)
158}
159
160addhandler multilib_virtclass_handler_global
161multilib_virtclass_handler_global[eventmask] = "bb.event.RecipePreFinalise bb.event.RecipeParsed"
162