blob: 6c6499a23e6d0da1c8e12a1d6461f3cef4034f38 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001python multilib_virtclass_handler () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -05002 cls = e.data.getVar("BBEXTENDCURR")
3 variant = e.data.getVar("BBEXTENDVARIANT")
Patrick Williamsc124f4f2015-09-15 14:41:29 -05004 if cls != "multilib" or not variant:
5 return
6
Brad Bishopd7bf8c12018-02-25 22:55:05 -05007 localdata = bb.data.createCopy(e.data)
8 localdata.delVar('TMPDIR')
9 e.data.setVar('STAGING_KERNEL_DIR', localdata.getVar('STAGING_KERNEL_DIR'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050010
11 # There should only be one kernel in multilib configs
12 # We also skip multilib setup for module packages.
Brad Bishop6e60e8b2018-02-01 10:27:11 -050013 provides = (e.data.getVar("PROVIDES") or "").split()
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080014 non_ml_recipes = d.getVar('NON_MULTILIB_RECIPES').split()
15 bpn = e.data.getVar("BPN")
16 if "virtual/kernel" in provides or \
17 bb.data.inherits_class('module-base', e.data) or \
18 bpn in non_ml_recipes:
19 raise bb.parse.SkipRecipe("We shouldn't have multilib variants for %s" % bpn)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021 save_var_name=e.data.getVar("MULTILIB_SAVE_VARNAME") or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022 for name in save_var_name.split():
Brad Bishop6e60e8b2018-02-01 10:27:11 -050023 val=e.data.getVar(name)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024 if val:
25 e.data.setVar(name + "_MULTILIB_ORIGINAL", val)
26
27 overrides = e.data.getVar("OVERRIDES", False)
28 pn = e.data.getVar("PN", False)
29 overrides = overrides.replace("pn-${PN}", "pn-${PN}:pn-" + pn)
30 e.data.setVar("OVERRIDES", overrides)
31
32 if bb.data.inherits_class('image', e.data):
33 e.data.setVar("MLPREFIX", variant + "-")
34 e.data.setVar("PN", variant + "-" + e.data.getVar("PN", False))
Brad Bishop6e60e8b2018-02-01 10:27:11 -050035 e.data.setVar('SDKTARGETSYSROOT', e.data.getVar('SDKTARGETSYSROOT'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036 target_vendor = e.data.getVar("TARGET_VENDOR_" + "virtclass-multilib-" + variant, False)
37 if target_vendor:
38 e.data.setVar("TARGET_VENDOR", target_vendor)
39 return
40
41 if bb.data.inherits_class('cross-canadian', e.data):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080042 # Multilib cross-candian should use the same nativesdk sysroot without MLPREFIX
43 e.data.setVar("RECIPE_SYSROOT", "${WORKDIR}/recipe-sysroot")
44 e.data.setVar("STAGING_DIR_TARGET", "${WORKDIR}/recipe-sysroot")
45 e.data.setVar("STAGING_DIR_HOST", "${WORKDIR}/recipe-sysroot")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046 e.data.setVar("MLPREFIX", variant + "-")
47 override = ":virtclass-multilib-" + variant
48 e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050049 return
50
51 if bb.data.inherits_class('native', e.data):
Brad Bishop316dfdd2018-06-25 12:45:53 -040052 raise bb.parse.SkipRecipe("We can't extend native recipes")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050053
54 if bb.data.inherits_class('nativesdk', e.data) or bb.data.inherits_class('crosssdk', e.data):
Brad Bishop316dfdd2018-06-25 12:45:53 -040055 raise bb.parse.SkipRecipe("We can't extend nativesdk recipes")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050056
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080057 if bb.data.inherits_class('allarch', e.data) and not d.getVar('MULTILIB_VARIANTS') \
58 and not bb.data.inherits_class('packagegroup', e.data):
Brad Bishop316dfdd2018-06-25 12:45:53 -040059 raise bb.parse.SkipRecipe("Don't extend allarch recipes which are not packagegroups")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060
Patrick Williamsc124f4f2015-09-15 14:41:29 -050061 # Expand this since this won't work correctly once we set a multilib into place
Brad Bishop6e60e8b2018-02-01 10:27:11 -050062 e.data.setVar("ALL_MULTILIB_PACKAGE_ARCHS", e.data.getVar("ALL_MULTILIB_PACKAGE_ARCHS"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063
64 override = ":virtclass-multilib-" + variant
65
Brad Bishop6e60e8b2018-02-01 10:27:11 -050066 blacklist = e.data.getVarFlag('PNBLACKLIST', e.data.getVar('PN'))
67 if blacklist:
68 pn_new = variant + "-" + e.data.getVar('PN')
69 if not e.data.getVarFlag('PNBLACKLIST', pn_new):
70 e.data.setVarFlag('PNBLACKLIST', pn_new, blacklist)
71
Patrick Williamsc124f4f2015-09-15 14:41:29 -050072 e.data.setVar("MLPREFIX", variant + "-")
73 e.data.setVar("PN", variant + "-" + e.data.getVar("PN", False))
74 e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override)
75
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080076 # Expand WHITELIST_GPL-3.0 with multilib prefix
77 pkgs = e.data.getVar("WHITELIST_GPL-3.0")
78 for pkg in pkgs.split():
79 pkgs += " " + variant + "-" + pkg
80 e.data.setVar("WHITELIST_GPL-3.0", pkgs)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050081
82 # DEFAULTTUNE can change TARGET_ARCH override so expand this now before update_data
83 newtune = e.data.getVar("DEFAULTTUNE_" + "virtclass-multilib-" + variant, False)
84 if newtune:
85 e.data.setVar("DEFAULTTUNE", newtune)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086}
87
88addhandler multilib_virtclass_handler
89multilib_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
90
91STAGINGCC_prepend = "${BBEXTENDVARIANT}-"
92
93python __anonymous () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -050094 variant = d.getVar("BBEXTENDVARIANT")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050095
96 import oe.classextend
97
98 clsextend = oe.classextend.ClassExtender(variant, d)
99
100 if bb.data.inherits_class('image', d):
101 clsextend.map_depends_variable("PACKAGE_INSTALL")
102 clsextend.map_depends_variable("LINGUAS_INSTALL")
103 clsextend.map_depends_variable("RDEPENDS")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500104 pinstall = d.getVar("LINGUAS_INSTALL") + " " + d.getVar("PACKAGE_INSTALL")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500105 d.setVar("PACKAGE_INSTALL", pinstall)
106 d.setVar("LINGUAS_INSTALL", "")
107 # FIXME, we need to map this to something, not delete it!
108 d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", "")
Brad Bishop316dfdd2018-06-25 12:45:53 -0400109 bb.build.deltask('do_populate_sdk', d)
110 bb.build.deltask('do_populate_sdk_ext', d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500111 return
112
113 clsextend.map_depends_variable("DEPENDS")
114 clsextend.map_variable("PROVIDES")
115
116 if bb.data.inherits_class('cross-canadian', d):
117 return
118
119 clsextend.rename_packages()
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500120 clsextend.rename_package_variables((d.getVar("PACKAGEVARS") or "").split())
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500121
122 clsextend.map_packagevars()
123 clsextend.map_regexp_variable("PACKAGES_DYNAMIC")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500124 clsextend.map_variable("INITSCRIPT_PACKAGES")
125 clsextend.map_variable("USERADD_PACKAGES")
126 clsextend.map_variable("SYSTEMD_PACKAGES")
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800127 clsextend.map_variable("UPDATERCPN")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500128}
129
130PACKAGEFUNCS_append = " do_package_qa_multilib"
131
132python do_package_qa_multilib() {
133
134 def check_mlprefix(pkg, var, mlprefix):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500135 values = bb.utils.explode_deps(d.getVar('%s_%s' % (var, pkg)) or d.getVar(var) or "")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500136 candidates = []
137 for i in values:
138 if i.startswith('virtual/'):
139 i = i[len('virtual/'):]
140 if (not i.startswith('kernel-module')) and (not i.startswith(mlprefix)) and \
141 (not 'cross-canadian' in i) and (not i.startswith("nativesdk-")) and \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800142 (not i.startswith("rtld")) and (not i.startswith('kernel-vmlinux')) \
143 and (not i.startswith("kernel-image")):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500144 candidates.append(i)
145 if len(candidates) > 0:
146 msg = "%s package %s - suspicious values '%s' in %s" \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500147 % (d.getVar('PN'), pkg, ' '.join(candidates), var)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500148 package_qa_handle_error("multilib", msg, d)
149
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500150 ml = d.getVar('MLPREFIX')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500151 if not ml:
152 return
153
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800154 # exception for ${MLPREFIX}target-sdk-provides-dummy
155 if 'target-sdk-provides-dummy' in d.getVar('PN'):
156 return
157
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500158 packages = d.getVar('PACKAGES')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500159 for pkg in packages.split():
160 check_mlprefix(pkg, 'RDEPENDS', ml)
161 check_mlprefix(pkg, 'RPROVIDES', ml)
162 check_mlprefix(pkg, 'RRECOMMENDS', ml)
163 check_mlprefix(pkg, 'RSUGGESTS', ml)
164 check_mlprefix(pkg, 'RREPLACES', ml)
165 check_mlprefix(pkg, 'RCONFLICTS', ml)
166}