Refactoring of stage and *DEPENDS handling and add fstage/FDEPENDS
[oe-lite:cbss-base.git] / classes / library.oeclass
1 # -*- mode:python; -*-
2 #
3 # inherit this for (single) library recipes
4 #
5
6 DEPENDS_${PN}           = "${PN}-dev_${PV}"
7 DEPENDS_${PN}-dev       = ""
8
9 FILES_${PN}             = "${base_libdir}/lib*${SOLIBS} ${libdir}/lib*${SOLIBS}"
10 ALLOW_EMPTY_${PN}-dev   = "0"
11
12 addhook library_depends to post_recipe_parse after fixup_package_type before blacklist
13
14 def library_depends(d):
15     pkg = d.get("PN")
16     pkg_type = d.get("PACKAGE_TYPE_" + pkg) or d.get("RECIPE_TYPE")
17     pv = d.get("PV")
18     devpkg = pkg + "-dev"
19     pkg_depends = (d.get("DEPENDS_" + pkg) or "").split()
20
21     if not pkg.startswith("lib"):
22         library_name = d.get("LIBRARY_NAME")
23         if not library_name:
24             library_name = "lib" + pkg
25         provides = (d.get("PROVIDES_" + pkg) or "").split()
26         if not library_name in provides:
27             provides.append(library_name)
28             d.set("PROVIDES_" + pkg, " ".join(provides))
29         provides = (d.get("PROVIDES_" + devpkg) or "").split()
30         if not library_name + "-dev" in provides:
31             provides.append(library_name + "-dev")
32             d.set("PROVIDES_" + devpkg, " ".join(provides))
33
34     if not pkg_type in ("machine", "sdk", "canadian-cross"):
35         return
36
37     pkg_rdepends = d.get("RDEPENDS_" + pkg)
38     if pkg_rdepends is None:
39         pkg_rdepends = []
40         for dep in pkg_depends:
41             item = oelite.item.OEliteItem(dep, ("DEPENDS", pkg_type))
42             if item.type != pkg_type:
43                 continue
44             if dep == (devpkg + "_" + pv):
45                 continue
46             if item.name.startswith("lib"):
47                 pkg_rdepends.append(dep)
48         if pkg_rdepends:
49             d.set("RDEPENDS_" + pkg, " ".join(pkg_rdepends))
50     else:
51         pkg_rdepends = pkg_rdepends.split()
52
53     devpkg_rdepends = (d.get("RDEPENDS_" + devpkg) or "").split()
54     for dep in pkg_rdepends:
55         item = oelite.item.OEliteItem(dep, ("RDEPENDS", pkg_type))
56         if item.name.startswith("lib") and not item.name.endswith("-dev"):
57             if item.version:
58                 devdep = "%s:%s_%s"%(item.type, item.name + "-dev", item.type)
59             else:
60                 devdep = "%s:%s"%(item.type, item.name + "-dev")
61             devpkg_rdepends.append(dep + "-dev")
62     d.set("RDEPENDS_" + devpkg, " ".join(devpkg_rdepends))