summaryrefslogtreecommitdiffstats
path: root/meta-oe/classes
diff options
context:
space:
mode:
Diffstat (limited to 'meta-oe/classes')
-rw-r--r--meta-oe/classes/gitpkgv.bbclass84
-rw-r--r--meta-oe/classes/gitver.bbclass80
-rw-r--r--meta-oe/classes/glx-use-tls.bbclass7
-rw-r--r--meta-oe/classes/gpe.bbclass17
-rw-r--r--meta-oe/classes/srctree.bbclass123
5 files changed, 311 insertions, 0 deletions
diff --git a/meta-oe/classes/gitpkgv.bbclass b/meta-oe/classes/gitpkgv.bbclass
new file mode 100644
index 000000000..bedceb9d6
--- /dev/null
+++ b/meta-oe/classes/gitpkgv.bbclass
@@ -0,0 +1,84 @@
1# gitpkgv.bbclass provides a GITPKGV and GITPKGVTAG variables to be
2# used in PKGV, as described bellow:
3#
4# - GITPKGV which is a sortable version with the format NN+GITHASH, to
5# be used in PKGV, where
6#
7# NN equals the total number of revs up to SRCREV
8# GITHASH is SRCREV's (full) hash
9#
10# - GITPKGVTAG which is the output of 'git describe' allowing for
11# automatic versioning
12#
13# gitpkgv.bbclass assumes the git repository has been cloned, and
14# contains SRCREV. So ${GITPKGV} and ${GITPKGVTAG} should never be
15# used in PV, only in PKGV. It can handle SRCREV = ${AUTOREV}, as
16# well as SRCREV = "<some fixed git hash>".
17#
18# WARNING: if upstream repository is always using consistent and
19# sortable tag name scheme you can get sortable version including tag
20# name with ${GITPKGVTAG}, but be aware that ie tag sequence "v1.0,
21# v1.2, xtest, v2.0" will force you to increment PE to get upgradeable
22# path to v2.0 revisions
23#
24# use example:
25#
26# inherit gitpkgv
27#
28# PV = "1.0+gitr${SRCPV}" # expands to something like 1.0+gitr3+4c1c21d7dbbf93b0df336994524313dfe0d4963b
29# PKGV = "1.0+gitr${GITPKGV}" # expands also to something like 1.0+gitr31337+4c1c21d7d
30#
31# or
32#
33# inherit gitpkgv
34#
35# PV = "1.0+gitr${SRCPV}" # expands to something like 1.0+gitr3+4c1c21d7dbbf93b0df336994524313dfe0d4963b
36# PKGV = "${GITPKGVTAG}" # expands to something like 1.0-31337+g4c1c21d
37# if there is tag v1.0 before this revision or
38# ver1.0-31337+g4c1c21d if there is tag ver1.0
39
40GITPKGV = "${@get_git_pkgv(d, False)}"
41GITPKGVTAG = "${@get_git_pkgv(d, True)}"
42
43def gitpkgv_drop_tag_prefix(version):
44 import re
45 if re.match("v\d", version):
46 return version[1:]
47 else:
48 return version
49
50def get_git_pkgv(d, use_tags):
51 import os
52 import bb
53
54 urls = bb.data.getVar('SRC_URI', d, 1).split()
55
56 for url in urls:
57 (type, host, path, user, pswd, parm) = bb.decodeurl(bb.data.expand(url, d))
58 if type in ['git']:
59
60 gitsrcname = '%s%s' % (host, path.replace('/', '.'))
61 repodir = os.path.join(bb.data.expand('${GITDIR}', d), gitsrcname)
62 if not os.path.exists(repodir):
63 return None
64
65 rev = bb.fetch.get_srcrev(d).split('+')[1]
66
67 cwd = os.getcwd()
68 os.chdir(repodir)
69
70 commits = bb.fetch.runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % rev, d, quiet=True).strip()
71
72 if use_tags:
73 try:
74 ver = gitpkgv_drop_tag_prefix(bb.fetch.runfetchcmd("git describe %s 2>/dev/null" % rev, d, quiet=True).strip())
75 except Exception:
76 ver = "0.0-%s-g%s" % (commits, rev[:7])
77 else:
78 ver = "%s+%s" % (commits, rev[:7])
79
80 os.chdir(cwd)
81
82 return ver
83
84 return "0+0"
diff --git a/meta-oe/classes/gitver.bbclass b/meta-oe/classes/gitver.bbclass
new file mode 100644
index 000000000..ee8323d6f
--- /dev/null
+++ b/meta-oe/classes/gitver.bbclass
@@ -0,0 +1,80 @@
1# Copyright (C) 2009 Chris Larson <clarson@kergoth.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3#
4# gitver.bbclass provides a GITVER variable which is a (fairly) sane version,
5# for use in ${PV}, extracted from the ${S} git checkout, assuming it is one.
6# This is most useful in concert with srctree.bbclass.
7
8def git_drop_tag_prefix(version):
9 import re
10 if re.match("v\d", version):
11 return version[1:]
12 else:
13 return version
14
15GIT_TAGADJUST = "git_drop_tag_prefix(version)"
16GITVER = "${@get_git_pv('${S}', d, tagadjust=lambda version:${GIT_TAGADJUST})}"
17GITSHA = "${@get_git_hash('${S}', d)}"
18
19def get_git_hash(path, d):
20 return oe_run(d, ["git", "rev-parse", "--short", "HEAD"], cwd=path).rstrip()
21
22def get_git_pv(path, d, tagadjust=None):
23 import os
24 import oe.process
25
26 gitdir = os.path.abspath(os.path.join(d.getVar("S", True), ".git"))
27 def git(cmd):
28 try:
29 return oe_run(d, ["git"] + cmd, cwd=gitdir).rstrip()
30 except oe.process.CmdError, exc:
31 bb.fatal(str(exc))
32
33 try:
34 ver = oe_run(d, ["git", "describe", "--tags"], cwd=gitdir).rstrip()
35 except Exception, exc:
36 bb.fatal(str(exc))
37
38 if not ver:
39 try:
40 ver = get_git_hash(gitdir, d)
41 except Exception, exc:
42 bb.fatal(str(exc))
43
44 if ver:
45 return "0.0+%s" % ver
46 else:
47 return "0.0"
48 else:
49 if tagadjust:
50 ver = tagadjust(ver)
51 return ver
52
53def mark_recipe_dependencies(path, d):
54 from bb.parse import mark_dependency
55
56 gitdir = os.path.join(path, ".git")
57
58 # Force the recipe to be reparsed so the version gets bumped
59 # if the active branch is switched, or if the branch changes.
60 mark_dependency(d, os.path.join(gitdir, "HEAD"))
61
62 # Force a reparse if anything in the index changes.
63 mark_dependency(d, os.path.join(gitdir, "index"))
64
65 try:
66 ref = oe_run(d, ["git", "symbolic-ref", "-q", "HEAD"], cwd=gitdir).rstrip()
67 except oe.process.CmdError:
68 pass
69 else:
70 if ref:
71 mark_dependency(d, os.path.join(gitdir, ref))
72
73 # Catch new tags.
74 tagdir = os.path.join(gitdir, "refs", "tags")
75 if os.path.exists(tagdir):
76 mark_dependency(d, tagdir)
77
78python () {
79 mark_recipe_dependencies(d.getVar("S", True), d)
80}
diff --git a/meta-oe/classes/glx-use-tls.bbclass b/meta-oe/classes/glx-use-tls.bbclass
new file mode 100644
index 000000000..7530872fa
--- /dev/null
+++ b/meta-oe/classes/glx-use-tls.bbclass
@@ -0,0 +1,7 @@
1def get_tls_setting(bb, d):
2 # until we have no prober TLS support in uclibc disable it
3 if bb.data.getVar('TARGET_OS', d, 1).find('uclibc') >= 0 :
4 return ""
5 return "--enable-glx-tls"
6
7EXTRA_OECONF += "${@get_tls_setting(bb, d)}"
diff --git a/meta-oe/classes/gpe.bbclass b/meta-oe/classes/gpe.bbclass
new file mode 100644
index 000000000..7e042ee93
--- /dev/null
+++ b/meta-oe/classes/gpe.bbclass
@@ -0,0 +1,17 @@
1DEPENDS_prepend = "virtual/libintl intltool-native "
2GPE_TARBALL_SUFFIX ?= "gz"
3SRC_URI = "${GPE_MIRROR}/${PN}-${PV}.tar.${GPE_TARBALL_SUFFIX}"
4FILES_${PN} += "${datadir}/gpe ${datadir}/application-registry"
5SECTION ?= "gpe"
6
7inherit gettext
8
9gpe_do_compile() {
10 oe_runmake PREFIX=${prefix}
11}
12
13gpe_do_install() {
14 oe_runmake PREFIX=${prefix} DESTDIR=${D} install
15}
16
17EXPORT_FUNCTIONS do_compile do_install
diff --git a/meta-oe/classes/srctree.bbclass b/meta-oe/classes/srctree.bbclass
new file mode 100644
index 000000000..1457e5618
--- /dev/null
+++ b/meta-oe/classes/srctree.bbclass
@@ -0,0 +1,123 @@
1# Copyright (C) 2009 Chris Larson <clarson@kergoth.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3#
4# srctree.bbclass enables operation inside of an existing source tree for a
5# project, rather than using the fetch/unpack/patch idiom.
6#
7# By default, it expects that you're keeping the recipe(s) inside the
8# aforementioned source tree, but you could override S to point at an external
9# directory and place the recipes in a normal collection/overlay, if you so
10# chose.
11#
12# It also provides some convenience python functions for assembling your
13# do_clean, if you want to leverage things like 'git clean' to simplify the
14# operation.
15
16
17# Grab convenience methods & sane default for do_clean
18inherit clean
19
20# Build here
21S = "${FILE_DIRNAME}"
22SRC_URI = ""
23
24def remove_tasks(deltasks, d):
25 for task in filter(lambda k: d.getVarFlag(k, "task"), d.keys()):
26 deps = d.getVarFlag(task, "deps")
27 for preptask in deltasks:
28 if preptask in deps:
29 deps.remove(preptask)
30 d.setVarFlag(task, "deps", deps)
31
32addtask configure after do_setscene
33
34def merge_tasks(d):
35 """
36 Merges all of the operations that occur prior to do_populate_sysroot
37 into do_populate_sysroot.
38
39 This is necessary because of recipe variants (normal, native, cross,
40 sdk). If a bitbake run happens to want to build more than one of
41 these variants in a single run, it's possible for them to step on one
42 another's toes, due to the shared ${S}. Interleaved
43 configure/compile/install amongst variants will break things badly.
44 """
45 from itertools import chain
46 from bb import note
47
48 def __gather_taskdeps(task, seen):
49 for dep in d.getVarFlag(task, "deps"):
50 if not dep in seen:
51 __gather_taskdeps(dep, seen)
52 if not task in seen:
53 seen.append(task)
54
55 def gather_taskdeps(task):
56 items = []
57 __gather_taskdeps(task, items)
58 return items
59
60 newtask = "do_populate_sysroot_post"
61 mergedtasks = gather_taskdeps(newtask)
62 mergedtasks.pop()
63
64 for task in (key for key in d.keys()
65 if d.getVarFlag(key, "task") and
66 not key in mergedtasks):
67 deps = d.getVarFlag(task, "deps")
68 for mergetask in mergedtasks:
69 if mergetask in (d.getVarFlag(task, "recrdeptask"),
70 d.getVarFlag(task, "recdeptask"),
71 d.getVarFlag(task, "deptask")):
72 continue
73
74 if mergetask in deps:
75 deps.remove(mergetask)
76 #note("removing dep on %s from %s" % (mergetask, task))
77
78 if not newtask in deps:
79 #note("adding dep on %s to %s" % (newtask, task))
80 deps.append(newtask)
81 d.setVarFlag(task, "deps", deps)
82
83 # Pull cross recipe task deps over
84 depends = []
85 deptask = []
86 for task in mergedtasks[:-1]:
87 depends.append(d.getVarFlag(task, "depends") or "")
88 deptask.append(d.getVarFlag(task, "deptask") or "")
89
90 d.setVarFlag("do_populate_sysroot_post", "depends", " ".join(depends))
91 d.setVarFlag("do_populate_sysroot_post", "deptask", " ".join(deptask))
92
93python () {
94 remove_tasks(["do_patch", "do_unpack", "do_fetch"], d)
95 b = d.getVar("B", True)
96 if not b or b == d.getVar("S", True):
97 merge_tasks(d)
98}
99
100# Manually run do_install & all of its deps
101python do_populate_sysroot_post () {
102 from os.path import exists
103 from bb.build import exec_func, make_stamp
104 from bb import note
105
106 stamp = d.getVar("STAMP", True)
107
108 def rec_exec_task(task, seen):
109 for dep in d.getVarFlag(task, "deps"):
110 if not dep in seen:
111 rec_exec_task(dep, seen)
112 seen.add(task)
113 if not exists("%s.%s" % (stamp, task)):
114 note("%s: executing task %s" % (d.getVar("PF", True), task))
115 exec_func(task, d)
116 flags = d.getVarFlags(task)
117 if not flags.get('nostamp') and not flags.get('selfstamp'):
118 make_stamp(task, d)
119
120 rec_exec_task("do_populate_sysroot", set())
121}
122addtask populate_sysroot_post after do_populate_sysroot
123do_populate_sysroot_post[lockfiles] += "${S}/.lock"