summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/classextend.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oe/classextend.py')
-rw-r--r--meta/lib/oe/classextend.py104
1 files changed, 104 insertions, 0 deletions
diff --git a/meta/lib/oe/classextend.py b/meta/lib/oe/classextend.py
new file mode 100644
index 0000000..e2ae7e9
--- /dev/null
+++ b/meta/lib/oe/classextend.py
@@ -0,0 +1,104 @@
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-") or name == "virtual/kernel":
9 return name
10 if name.startswith("rtld"):
11 return name
12 if name.endswith("-" + self.extname):
13 name = name.replace("-" + self.extname, "")
14 if name.startswith("virtual/"):
15 subs = name.split("/", 1)[1]
16 if not subs.startswith(self.extname):
17 return "virtual/" + self.extname + "-" + subs
18 return name
19 if not name.startswith(self.extname):
20 return self.extname + "-" + name
21 return name
22
23 def map_variable(self, varname, setvar = True):
24 var = self.d.getVar(varname, True)
25 if not var:
26 return ""
27 var = var.split()
28 newvar = []
29 for v in var:
30 newvar.append(self.extend_name(v))
31 newdata = " ".join(newvar)
32 if setvar:
33 self.d.setVar(varname, newdata)
34 return newdata
35
36 def map_regexp_variable(self, varname, setvar = True):
37 var = self.d.getVar(varname, True)
38 if not var:
39 return ""
40 var = var.split()
41 newvar = []
42 for v in var:
43 if v.startswith("^" + self.extname):
44 newvar.append(v)
45 elif v.startswith("^"):
46 newvar.append("^" + self.extname + "-" + v[1:])
47 else:
48 newvar.append(self.extend_name(v))
49 newdata = " ".join(newvar)
50 if setvar:
51 self.d.setVar(varname, newdata)
52 return newdata
53
54 def map_depends(self, dep):
55 if dep.endswith(("-native", "-native-runtime", "-crosssdk")) or ('nativesdk-' in dep) or ('cross-canadian' in dep):
56 return dep
57 else:
58 return self.extend_name(dep)
59
60 def map_depends_variable(self, varname, suffix = ""):
61 if suffix:
62 varname = varname + "_" + suffix
63 deps = self.d.getVar(varname, True)
64 if not deps:
65 return
66 deps = bb.utils.explode_dep_versions2(deps)
67 newdeps = {}
68 for dep in deps:
69 newdeps[self.map_depends(dep)] = deps[dep]
70
71 self.d.setVar(varname, bb.utils.join_deps(newdeps, False))
72
73 def map_packagevars(self):
74 for pkg in (self.d.getVar("PACKAGES", True).split() + [""]):
75 self.map_depends_variable("RDEPENDS", pkg)
76 self.map_depends_variable("RRECOMMENDS", pkg)
77 self.map_depends_variable("RSUGGESTS", pkg)
78 self.map_depends_variable("RPROVIDES", pkg)
79 self.map_depends_variable("RREPLACES", pkg)
80 self.map_depends_variable("RCONFLICTS", pkg)
81 self.map_depends_variable("PKG", pkg)
82
83 def rename_packages(self):
84 for pkg in (self.d.getVar("PACKAGES", True) or "").split():
85 if pkg.startswith(self.extname):
86 self.pkgs_mapping.append([pkg.split(self.extname + "-")[1], pkg])
87 continue
88 self.pkgs_mapping.append([pkg, self.extend_name(pkg)])
89
90 self.d.setVar("PACKAGES", " ".join([row[1] for row in self.pkgs_mapping]))
91
92 def rename_package_variables(self, variables):
93 for pkg_mapping in self.pkgs_mapping:
94 for subs in variables:
95 self.d.renameVar("%s_%s" % (subs, pkg_mapping[0]), "%s_%s" % (subs, pkg_mapping[1]))
96
97class NativesdkClassExtender(ClassExtender):
98 def map_depends(self, dep):
99 if dep.endswith(("-native", "-native-runtime", "-cross", "-crosssdk")) or ('nativesdk-' in dep):
100 return dep
101 elif dep.endswith(("-gcc-intermediate", "-gcc-initial", "-gcc", "-g++")):
102 return dep + "-crosssdk"
103 else:
104 return self.extend_name(dep)