diff options
Diffstat (limited to 'meta/classes/multilib.bbclass')
-rw-r--r-- | meta/classes/multilib.bbclass | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/meta/classes/multilib.bbclass b/meta/classes/multilib.bbclass new file mode 100644 index 0000000000..6e1669fb7f --- /dev/null +++ b/meta/classes/multilib.bbclass | |||
@@ -0,0 +1,89 @@ | |||
1 | python multilib_virtclass_handler () { | ||
2 | if not isinstance(e, bb.event.RecipePreFinalise): | ||
3 | return | ||
4 | |||
5 | cls = e.data.getVar("BBEXTENDCURR", True) | ||
6 | variant = e.data.getVar("BBEXTENDVARIANT", True) | ||
7 | if cls != "multilib" or not variant: | ||
8 | return | ||
9 | |||
10 | override = ":virtclass-multilib-" + variant | ||
11 | |||
12 | e.data.setVar("MLPREFIX", variant + "-") | ||
13 | e.data.setVar("PN", variant + "-" + e.data.getVar("PN", False)) | ||
14 | e.data.setVar("SHLIBSDIR_virtclass-multilib-" + variant ,e.data.getVar("SHLIBSDIR", False) + "/" + variant) | ||
15 | e.data.setVar("TARGET_VENDOR_virtclass-multilib-" + variant, e.data.getVar("TARGET_VENDOR", False) + "ml" + variant) | ||
16 | e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + override) | ||
17 | } | ||
18 | |||
19 | addhandler multilib_virtclass_handler | ||
20 | |||
21 | STAGINGCC_prepend = "${BBEXTENDVARIANT}-" | ||
22 | |||
23 | python __anonymous () { | ||
24 | variant = d.getVar("BBEXTENDVARIANT", True) | ||
25 | |||
26 | def extend_name(name): | ||
27 | if name.startswith("virtual/"): | ||
28 | subs = name.split("/", 1)[1] | ||
29 | if not subs.startswith(variant): | ||
30 | return "virtual/" + variant + "-" + subs | ||
31 | return name | ||
32 | if not name.startswith(variant): | ||
33 | return variant + "-" + name | ||
34 | return name | ||
35 | |||
36 | def map_dependencies(varname, d, suffix = ""): | ||
37 | if suffix: | ||
38 | varname = varname + "_" + suffix | ||
39 | deps = d.getVar(varname, True) | ||
40 | if not deps: | ||
41 | return | ||
42 | deps = bb.utils.explode_deps(deps) | ||
43 | newdeps = [] | ||
44 | for dep in deps: | ||
45 | if dep.endswith(("-native", "-native-runtime")): | ||
46 | newdeps.append(dep) | ||
47 | else: | ||
48 | newdeps.append(extend_name(dep)) | ||
49 | d.setVar(varname, " ".join(newdeps)) | ||
50 | |||
51 | def map_variable(varname, d): | ||
52 | var = d.getVar(varname, True) | ||
53 | if not var: | ||
54 | return | ||
55 | var = var.split() | ||
56 | newvar = [] | ||
57 | for v in var: | ||
58 | newvar.append(extend_name(v)) | ||
59 | d.setVar(varname, " ".join(newvar)) | ||
60 | |||
61 | pkgs = [] | ||
62 | pkgrename = {} | ||
63 | for pkg in (d.getVar("PACKAGES", True) or "").split(): | ||
64 | if pkg.startswith(variant): | ||
65 | pkgs.append(pkg) | ||
66 | continue | ||
67 | pkgrename[pkg] = extend_name(pkg) | ||
68 | pkgs.append(pkgrename[pkg]) | ||
69 | |||
70 | if pkgrename: | ||
71 | d.setVar("PACKAGES", " ".join(pkgs)) | ||
72 | for pkg in pkgrename: | ||
73 | for subs in ["FILES", "RDEPENDS", "RRECOMMENDS", "SUMMARY", "DESCRIPTION", "RSUGGESTS", "RPROVIDES", "RCONFLICTS", "PKG", "ALLOW_EMPTY"]: | ||
74 | d.renameVar("%s_%s" % (subs, pkg), "%s_%s" % (subs, pkgrename[pkg])) | ||
75 | |||
76 | map_dependencies("DEPENDS", d) | ||
77 | for pkg in (d.getVar("PACKAGES", True).split() + [""]): | ||
78 | map_dependencies("RDEPENDS", d, pkg) | ||
79 | map_dependencies("RRECOMMENDS", d, pkg) | ||
80 | map_dependencies("RSUGGESTS", d, pkg) | ||
81 | map_dependencies("RPROVIDES", d, pkg) | ||
82 | map_dependencies("RREPLACES", d, pkg) | ||
83 | map_dependencies("RCONFLICTS", d, pkg) | ||
84 | map_dependencies("PKG", d, pkg) | ||
85 | |||
86 | map_variable("PROVIDES", d) | ||
87 | map_variable("PACKAGES_DYNAMIC", d) | ||
88 | map_variable("PACKAGE_INSTALL", d) | ||
89 | } | ||