summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/classextend.py81
1 files changed, 81 insertions, 0 deletions
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)