summaryrefslogtreecommitdiff
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:08 +0000
commit563828bad19a242bba9ce3db461bb5807037dfdf (patch)
treef070e047f30de99d93364f04c1fd9c254ba5273c
parent0f485bfd6fc82a109b9da629e464fca1e90faec3 (diff)
downloadopenembedded-core-563828bad19a242bba9ce3db461bb5807037dfdf.tar.gz
openembedded-core-563828bad19a242bba9ce3db461bb5807037dfdf.tar.bz2
openembedded-core-563828bad19a242bba9ce3db461bb5807037dfdf.tar.xz
openembedded-core-563828bad19a242bba9ce3db461bb5807037dfdf.zip
multilib: Abstract class extension code into classextend.py
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 6eb3bc375..87d0cd4f5 100644
--- a/meta/classes/multilib.bbclass
+++ b/meta/classes/multilib.bbclass
@@ -37,25 +37,14 @@ STAGINGCC_prepend = "${BBEXTENDVARIANT}-"
python __anonymous () {
variant = d.getVar("BBEXTENDVARIANT", True)
- def map_dependencies(varname, d, suffix = ""):
- if suffix:
- varname = varname + "_" + suffix
- deps = d.getVar(varname, True)
- if not deps:
- return
- deps = bb.utils.explode_deps(deps)
- newdeps = []
- for dep in deps:
- if dep.endswith(("-native", "-native-runtime")):
- newdeps.append(dep)
- else:
- newdeps.append(multilib_extend_name(variant, dep))
- d.setVar(varname, " ".join(newdeps))
+ import oe.classextend
+
+ clsextend = oe.classextend.ClassExtender(variant, d)
if bb.data.inherits_class('image', d):
- map_dependencies("PACKAGE_INSTALL", d)
- map_dependencies("LINGUAS_INSTALL", d)
- map_dependencies("RDEPENDS", d)
+ clsextend.map_depends_variable("PACKAGE_INSTALL")
+ clsextend.map_depends_variable("LINGUAS_INSTALL")
+ clsextend.map_depends_variable("RDEPENDS")
pinstall = d.getVar("LINGUAS_INSTALL", True) + " " + d.getVar("PACKAGE_INSTALL", True)
d.setVar("PACKAGE_INSTALL", pinstall)
d.setVar("LINGUAS_INSTALL", "")
@@ -63,32 +52,13 @@ python __anonymous () {
d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", "")
return
- pkgs_mapping = []
- for pkg in (d.getVar("PACKAGES", True) or "").split():
- if pkg.startswith(variant):
- pkgs_mapping.append([pkg.split(variant + "-")[1], pkg])
- continue
- pkgs_mapping.append([pkg, multilib_extend_name(variant, pkg)])
-
- d.setVar("PACKAGES", " ".join([row[1] for row in pkgs_mapping]))
-
- vars = (d.getVar("PACKAGEVARS", True) or "").split()
- for pkg_mapping in pkgs_mapping:
- for subs in vars:
- d.renameVar("%s_%s" % (subs, pkg_mapping[0]), "%s_%s" % (subs, pkg_mapping[1]))
-
- map_dependencies("DEPENDS", d)
- for pkg in (d.getVar("PACKAGES", True).split() + [""]):
- map_dependencies("RDEPENDS", d, pkg)
- map_dependencies("RRECOMMENDS", d, pkg)
- map_dependencies("RSUGGESTS", d, pkg)
- map_dependencies("RPROVIDES", d, pkg)
- map_dependencies("RREPLACES", d, pkg)
- map_dependencies("RCONFLICTS", d, pkg)
- map_dependencies("PKG", d, pkg)
+ clsextend.rename_packages()
+ clsextend.rename_package_variables((d.getVar("PACKAGEVARS", True) or "").split())
- multilib_map_variable("PROVIDES", variant, d)
- multilib_map_variable("PACKAGES_DYNAMIC", variant, d)
- multilib_map_variable("PACKAGE_INSTALL", variant, d)
- multilib_map_variable("INITSCRIPT_PACKAGES", variant, d)
+ clsextend.map_depends_variable("DEPENDS")
+ clsextend.map_packagevars()
+ clsextend.map_variable("PROVIDES")
+ clsextend.map_variable("PACKAGES_DYNAMIC")
+ clsextend.map_variable("PACKAGE_INSTALL")
+ clsextend.map_variable("INITSCRIPT_PACKAGES")
}
diff --git a/meta/classes/multilib_global.bbclass b/meta/classes/multilib_global.bbclass
index 2da66a5e6..b76fd9416 100644
--- a/meta/classes/multilib_global.bbclass
+++ b/meta/classes/multilib_global.bbclass
@@ -8,55 +8,31 @@ python multilib_virtclass_handler_global () {
if bb.data.inherits_class('kernel', e.data) or bb.data.inherits_class('module-base', e.data):
variants = (e.data.getVar("MULTILIB_VARIANTS", True) or "").split()
+ import oe.classextend
+ clsextends = []
+ for variant in variants:
+ clsextends.append(oe.classextend.ClassExtender(variant, e.data))
+
# Process PROVIDES
origprovs = provs = e.data.getVar("PROVIDES", True) or ""
- for variant in variants:
- provs = provs + " " + multilib_map_variable("PROVIDES", variant, e.data)
- # Reset to original value so next time around multilib_map_variable works properly
- e.data.setVar("PROVIDES", origprovs)
+ for clsextend in clsextends:
+ provs = provs + " " + clsextend.map_variable("PROVIDES", setvar=False)
e.data.setVar("PROVIDES", provs)
# Process RPROVIDES
origrprovs = rprovs = e.data.getVar("RPROVIDES", True) or ""
- for variant in variants:
- rprovs = rprovs + " " + multilib_map_variable("RPROVIDES", variant, e.data)
- # Reset to original value so next time around multilib_map_variable works properly
- e.data.setVar("RPROVIDES", origrprovs)
+ for clsextend in clsextends:
+ rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES", setvar=False)
e.data.setVar("RPROVIDES", rprovs)
# Process RPROVIDES_${PN}...
for pkg in (e.data.getVar("PACKAGES", True) or "").split():
origrprovs = rprovs = e.data.getVar("RPROVIDES_%s" % pkg, True) or ""
- for variant in variants:
- rprovs = rprovs + " " + multilib_map_variable("RPROVIDES_%s" % pkg, variant, e.data)
- rprovs = rprovs + " " + variant + "-" + pkg
- # Reset to original value so next time around multilib_map_variable works properly
- e.data.setVar("RPROVIDES_%s" % pkg, origrprovs)
+ for clsextend in clsextends:
+ rprovs = rprovs + " " + clsextend.map_variable("RPROVIDES_%s" % pkg, setvar=False)
+ rprovs = rprovs + " " + clsextend.extname + "-" + pkg
e.data.setVar("RPROVIDES_%s" % pkg, rprovs)
}
addhandler multilib_virtclass_handler_global
-def multilib_extend_name(variant, name):
- if name.startswith("kernel-module"):
- return name
- if name.startswith("virtual/"):
- subs = name.split("/", 1)[1]
- if not subs.startswith(variant):
- return "virtual/" + variant + "-" + subs
- return name
- if not name.startswith(variant):
- return variant + "-" + name
- return name
-
-def multilib_map_variable(varname, variant, d):
- var = d.getVar(varname, True)
- if not var:
- return ""
- var = var.split()
- newvar = []
- for v in var:
- newvar.append(multilib_extend_name(variant, v))
- newdata = " ".join(newvar)
- d.setVar(varname, newdata)
- return newdata
diff --git a/meta/lib/oe/classextend.py b/meta/lib/oe/classextend.py
new file mode 100644
index 000000000..fb0d96737
--- /dev/null
+++ b/meta/lib/oe/classextend.py
@@ -0,0 +1,81 @@
+class ClassExtender(object):
+ def __init__(self, extname, d):
+ self.extname = extname
+ self.d = d
+ self.pkgs_mapping = []
+
+ def extend_name(self, name):
+ if name.startswith("kernel-module"):
+ return name
+ if name.startswith("virtual/"):
+ subs = name.split("/", 1)[1]
+ if not subs.startswith(self.extname):
+ return "virtual/" + self.extname + "-" + subs
+ return name
+ if not name.startswith(self.extname):
+ return self.extname + "-" + name
+ return name
+
+ def map_variable(self, varname, setvar = True):
+ var = self.d.getVar(varname, True)
+ if not var:
+ return ""
+ var = var.split()
+ newvar = []
+ for v in var:
+ newvar.append(self.extend_name(v))
+ newdata = " ".join(newvar)
+ if setvar:
+ self.d.setVar(varname, newdata)
+ return newdata
+
+ def map_depends(self, dep):
+ if dep.endswith(("-native", "-native-runtime")):
+ return dep
+ else:
+ return self.extend_name(dep)
+
+ def map_depends_variable(self, varname, suffix = ""):
+ if suffix:
+ varname = varname + "_" + suffix
+ deps = self.d.getVar(varname, True)
+ if not deps:
+ return
+ deps = bb.utils.explode_deps(deps)
+ newdeps = []
+ for dep in deps:
+ newdeps.append(self.map_depends(dep))
+ self.d.setVar(varname, " ".join(newdeps))
+
+ def map_packagevars(self):
+ for pkg in (self.d.getVar("PACKAGES", True).split() + [""]):
+ self.map_depends_variable("RDEPENDS", pkg)
+ self.map_depends_variable("RRECOMMENDS", pkg)
+ self.map_depends_variable("RSUGGESTS", pkg)
+ self.map_depends_variable("RPROVIDES", pkg)
+ self.map_depends_variable("RREPLACES", pkg)
+ self.map_depends_variable("RCONFLICTS", pkg)
+ self.map_depends_variable("PKG", pkg)
+
+ def rename_packages(self):
+ for pkg in (self.d.getVar("PACKAGES", True) or "").split():
+ if pkg.startswith(self.extname):
+ self.pkgs_mapping.append([pkg.split(self.extname + "-")[1], pkg])
+ continue
+ self.pkgs_mapping.append([pkg, self.extend_name(pkg)])
+
+ self.d.setVar("PACKAGES", " ".join([row[1] for row in self.pkgs_mapping]))
+
+ def rename_package_variables(self, variables):
+ for pkg_mapping in self.pkgs_mapping:
+ for subs in variables:
+ self.d.renameVar("%s_%s" % (subs, pkg_mapping[0]), "%s_%s" % (subs, pkg_mapping[1]))
+
+class NativesdkClassExtender(ClassExtender):
+ def map_depends(self, dep):
+ if dep.endswith(("-native", "-native-runtime", "-cross")):
+ return dep
+ elif dep.endswith(("-gcc-intermediate", "-gcc-initial", "-gcc", "-g++")):
+ return dep + "-crosssdk"
+ else:
+ return self.extend_name(dep)