summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-12-21 13:52:46 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-01-05 12:36:29 +0000
commit8e43f9a751f1637d483d48aa9a9a647d1e3d2003 (patch)
tree77eb98fbd61bf59f66c02089c74661353254d01a
parent0fa52f70789afe5a53384ba20249af34c16a8568 (diff)
downloadpoky-8e43f9a751f1637d483d48aa9a9a647d1e3d2003.tar.gz
multilib: Abstract class extension code into classextend.py
(From OE-Core rev: 563828bad19a242bba9ce3db461bb5807037dfdf) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/multilib.bbclass58
-rw-r--r--meta/classes/multilib_global.bbclass48
-rw-r--r--meta/lib/oe/classextend.py81
3 files changed, 107 insertions, 80 deletions
diff --git a/meta/classes/multilib.bbclass b/meta/classes/multilib.bbclass
index 6eb3bc3756..87d0cd4f5e 100644
--- a/meta/classes/multilib.bbclass
+++ b/meta/classes/multilib.bbclass
@@ -37,25 +37,14 @@ STAGINGCC_prepend = "${BBEXTENDVARIANT}-"
37python __anonymous () { 37python __anonymous () {
38 variant = d.getVar("BBEXTENDVARIANT", True) 38 variant = d.getVar("BBEXTENDVARIANT", True)
39 39
40 def map_dependencies(varname, d, suffix = ""): 40 import oe.classextend
41 if suffix: 41
42 varname = varname + "_" + suffix 42 clsextend = oe.classextend.ClassExtender(variant, d)
43 deps = d.getVar(varname, True)
44 if not deps:
45 return
46 deps = bb.utils.explode_deps(deps)
47 newdeps = []
48 for dep in deps:
49 if dep.endswith(("-native", "-native-runtime")):
50 newdeps.append(dep)
51 else:
52 newdeps.append(multilib_extend_name(variant, dep))
53 d.setVar(varname, " ".join(newdeps))
54 43
55 if bb.data.inherits_class('image', d): 44 if bb.data.inherits_class('image', d):
56 map_dependencies("PACKAGE_INSTALL", d) 45 clsextend.map_depends_variable("PACKAGE_INSTALL")
57 map_dependencies("LINGUAS_INSTALL", d) 46 clsextend.map_depends_variable("LINGUAS_INSTALL")
58 map_dependencies("RDEPENDS", d) 47 clsextend.map_depends_variable("RDEPENDS")
59 pinstall = d.getVar("LINGUAS_INSTALL", True) + " " + d.getVar("PACKAGE_INSTALL", True) 48 pinstall = d.getVar("LINGUAS_INSTALL", True) + " " + d.getVar("PACKAGE_INSTALL", True)
60 d.setVar("PACKAGE_INSTALL", pinstall) 49 d.setVar("PACKAGE_INSTALL", pinstall)
61 d.setVar("LINGUAS_INSTALL", "") 50 d.setVar("LINGUAS_INSTALL", "")
@@ -63,32 +52,13 @@ python __anonymous () {
63 d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", "") 52 d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", "")
64 return 53 return
65 54
66 pkgs_mapping = [] 55 clsextend.rename_packages()
67 for pkg in (d.getVar("PACKAGES", True) or "").split(): 56 clsextend.rename_package_variables((d.getVar("PACKAGEVARS", True) or "").split())
68 if pkg.startswith(variant):
69 pkgs_mapping.append([pkg.split(variant + "-")[1], pkg])
70 continue
71 pkgs_mapping.append([pkg, multilib_extend_name(variant, pkg)])
72
73 d.setVar("PACKAGES", " ".join([row[1] for row in pkgs_mapping]))
74
75 vars = (d.getVar("PACKAGEVARS", True) or "").split()
76 for pkg_mapping in pkgs_mapping:
77 for subs in vars:
78 d.renameVar("%s_%s" % (subs, pkg_mapping[0]), "%s_%s" % (subs, pkg_mapping[1]))
79
80 map_dependencies("DEPENDS", d)
81 for pkg in (d.getVar("PACKAGES", True).split() + [""]):
82 map_dependencies("RDEPENDS", d, pkg)
83 map_dependencies("RRECOMMENDS", d, pkg)
84 map_dependencies("RSUGGESTS", d, pkg)
85 map_dependencies("RPROVIDES", d, pkg)
86 map_dependencies("RREPLACES", d, pkg)
87 map_dependencies("RCONFLICTS", d, pkg)
88 map_dependencies("PKG", d, pkg)
89 57
90 multilib_map_variable("PROVIDES", variant, d) 58 clsextend.map_depends_variable("DEPENDS")
91 multilib_map_variable("PACKAGES_DYNAMIC", variant, d) 59 clsextend.map_packagevars()
92 multilib_map_variable("PACKAGE_INSTALL", variant, d) 60 clsextend.map_variable("PROVIDES")
93 multilib_map_variable("INITSCRIPT_PACKAGES", variant, d) 61 clsextend.map_variable("PACKAGES_DYNAMIC")
62 clsextend.map_variable("PACKAGE_INSTALL")
63 clsextend.map_variable("INITSCRIPT_PACKAGES")
94} 64}
diff --git a/meta/classes/multilib_global.bbclass b/meta/classes/multilib_global.bbclass
index 2da66a5e6e..b76fd94162 100644
--- a/meta/classes/multilib_global.bbclass
+++ b/meta/classes/multilib_global.bbclass
@@ -8,55 +8,31 @@ python multilib_virtclass_handler_global () {
8 if bb.data.inherits_class('kernel', e.data) or bb.data.inherits_class('module-base', e.data): 8 if bb.data.inherits_class('kernel', e.data) or bb.data.inherits_class('module-base', e.data):
9 variants = (e.data.getVar("MULTILIB_VARIANTS", True) or "").split() 9 variants = (e.data.getVar("MULTILIB_VARIANTS", True) or "").split()
10 10
11 import oe.classextend
12 clsextends = []
13 for variant in variants:
14 clsextends.append(oe.classextend.ClassExtender(variant, e.data))
15
11 # Process PROVIDES 16 # Process PROVIDES
12 origprovs = provs = e.data.getVar("PROVIDES", True) or "" 17 origprovs = provs = e.data.getVar("PROVIDES", True) or ""
13 for variant in variants: 18 for clsextend in clsextends:
14 provs = provs + " " + multilib_map_variable("PROVIDES", variant, e.data) 19 provs = provs + " " + clsextend.map_variable("PROVIDES", setvar=False)
15 # Reset to original value so next time around multilib_map_variable works properly
16 e.data.setVar("PROVIDES", origprovs)
17 e.data.setVar("PROVIDES", provs) 20 e.data.setVar("PROVIDES", provs)
18 21
19 # Process RPROVIDES 22 # Process RPROVIDES
20 origrprovs = rprovs = e.data.getVar("RPROVIDES", True) or "" 23 origrprovs = rprovs = e.data.getVar("RPROVIDES", True) or ""
21 for variant in variants: 24 for clsextend in clsextends:
22 rprovs = rprovs + " " + multilib_map_variable("RPROVIDES", variant, e.data) 25 rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES", setvar=False)
23 # Reset to original value so next time around multilib_map_variable works properly
24 e.data.setVar("RPROVIDES", origrprovs)
25 e.data.setVar("RPROVIDES", rprovs) 26 e.data.setVar("RPROVIDES", rprovs)
26 27
27 # Process RPROVIDES_${PN}... 28 # Process RPROVIDES_${PN}...
28 for pkg in (e.data.getVar("PACKAGES", True) or "").split(): 29 for pkg in (e.data.getVar("PACKAGES", True) or "").split():
29 origrprovs = rprovs = e.data.getVar("RPROVIDES_%s" % pkg, True) or "" 30 origrprovs = rprovs = e.data.getVar("RPROVIDES_%s" % pkg, True) or ""
30 for variant in variants: 31 for clsextend in clsextends:
31 rprovs = rprovs + " " + multilib_map_variable("RPROVIDES_%s" % pkg, variant, e.data) 32 rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES_%s" % pkg, setvar=False)
32 rprovs = rprovs + " " + variant + "-" + pkg 33 rprovs = rprovs + " " + clsextend.extname + "-" + pkg
33 # Reset to original value so next time around multilib_map_variable works properly
34 e.data.setVar("RPROVIDES_%s" % pkg, origrprovs)
35 e.data.setVar("RPROVIDES_%s" % pkg, rprovs) 34 e.data.setVar("RPROVIDES_%s" % pkg, rprovs)
36} 35}
37 36
38addhandler multilib_virtclass_handler_global 37addhandler multilib_virtclass_handler_global
39 38
40def multilib_extend_name(variant, name):
41 if name.startswith("kernel-module"):
42 return name
43 if name.startswith("virtual/"):
44 subs = name.split("/", 1)[1]
45 if not subs.startswith(variant):
46 return "virtual/" + variant + "-" + subs
47 return name
48 if not name.startswith(variant):
49 return variant + "-" + name
50 return name
51
52def multilib_map_variable(varname, variant, d):
53 var = d.getVar(varname, True)
54 if not var:
55 return ""
56 var = var.split()
57 newvar = []
58 for v in var:
59 newvar.append(multilib_extend_name(variant, v))
60 newdata = " ".join(newvar)
61 d.setVar(varname, newdata)
62 return newdata
diff --git a/meta/lib/oe/classextend.py b/meta/lib/oe/classextend.py
new file mode 100644
index 0000000000..fb0d967372
--- /dev/null
+++ b/meta/lib/oe/classextend.py
@@ -0,0 +1,81 @@
1class ClassExtender(object):
2 def __init__(self, extname, d):
3 self.extname = extname
4 self.d = d
5 self.pkgs_mapping = []
6
7 def extend_name(self, name):
8 if name.startswith("kernel-module"):
9 return name
10 if name.startswith("virtual/"):
11 subs = name.split("/", 1)[1]
12 if not subs.startswith(self.extname):
13 return "virtual/" + self.extname + "-" + subs
14 return name
15 if not name.startswith(self.extname):
16 return self.extname + "-" + name
17 return name
18
19 def map_variable(self, varname, setvar = True):
20 var = self.d.getVar(varname, True)
21 if not var:
22 return ""
23 var = var.split()
24 newvar = []
25 for v in var:
26 newvar.append(self.extend_name(v))
27 newdata = " ".join(newvar)
28 if setvar:
29 self.d.setVar(varname, newdata)
30 return newdata
31
32 def map_depends(self, dep):
33 if dep.endswith(("-native", "-native-runtime")):
34 return dep
35 else:
36 return self.extend_name(dep)
37
38 def map_depends_variable(self, varname, suffix = ""):
39 if suffix:
40 varname = varname + "_" + suffix
41 deps = self.d.getVar(varname, True)
42 if not deps:
43 return
44 deps = bb.utils.explode_deps(deps)
45 newdeps = []
46 for dep in deps:
47 newdeps.append(self.map_depends(dep))
48 self.d.setVar(varname, " ".join(newdeps))
49
50 def map_packagevars(self):
51 for pkg in (self.d.getVar("PACKAGES", True).split() + [""]):
52 self.map_depends_variable("RDEPENDS", pkg)
53 self.map_depends_variable("RRECOMMENDS", pkg)
54 self.map_depends_variable("RSUGGESTS", pkg)
55 self.map_depends_variable("RPROVIDES", pkg)
56 self.map_depends_variable("RREPLACES", pkg)
57 self.map_depends_variable("RCONFLICTS", pkg)
58 self.map_depends_variable("PKG", pkg)
59
60 def rename_packages(self):
61 for pkg in (self.d.getVar("PACKAGES", True) or "").split():
62 if pkg.startswith(self.extname):
63 self.pkgs_mapping.append([pkg.split(self.extname + "-")[1], pkg])
64 continue
65 self.pkgs_mapping.append([pkg, self.extend_name(pkg)])
66
67 self.d.setVar("PACKAGES", " ".join([row[1] for row in self.pkgs_mapping]))
68
69 def rename_package_variables(self, variables):
70 for pkg_mapping in self.pkgs_mapping:
71 for subs in variables:
72 self.d.renameVar("%s_%s" % (subs, pkg_mapping[0]), "%s_%s" % (subs, pkg_mapping[1]))
73
74class NativesdkClassExtender(ClassExtender):
75 def map_depends(self, dep):
76 if dep.endswith(("-native", "-native-runtime", "-cross")):
77 return dep
78 elif dep.endswith(("-gcc-intermediate", "-gcc-initial", "-gcc", "-g++")):
79 return dep + "-crosssdk"
80 else:
81 return self.extend_name(dep)