aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/classes
diff options
context:
space:
mode:
authorMartin Jansa <Martin.Jansa@gmail.com>2011-04-10 13:24:47 +0200
committerMartin Jansa <Martin.Jansa@gmail.com>2011-04-10 14:43:41 +0200
commit89500c583e0f1dc1b4ffdf72914e08e505e427e0 (patch)
treeb073036cc61aa34ca5ac9eec4d617366e0dcb3d5 /meta-oe/classes
parente66079da37992abd54486488aa06a99bf7a4198c (diff)
downloadmeta-openembedded-89500c583e0f1dc1b4ffdf72914e08e505e427e0.tar.gz
recipes,classes: import a lot of recipes from meta-shr
* tested on shr-lite-image for om-gta02 and nokia900 (with meta-shr layer)
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 0000000000..bedceb9d6e
--- /dev/null
+++ b/meta-oe/classes/gitpkgv.bbclass
@@ -0,0 +1,84 @@
+# gitpkgv.bbclass provides a GITPKGV and GITPKGVTAG variables to be
+# used in PKGV, as described bellow:
+#
+# - GITPKGV which is a sortable version with the format NN+GITHASH, to
+# be used in PKGV, where
+#
+# NN equals the total number of revs up to SRCREV
+# GITHASH is SRCREV's (full) hash
+#
+# - GITPKGVTAG which is the output of 'git describe' allowing for
+# automatic versioning
+#
+# gitpkgv.bbclass assumes the git repository has been cloned, and
+# contains SRCREV. So ${GITPKGV} and ${GITPKGVTAG} should never be
+# used in PV, only in PKGV. It can handle SRCREV = ${AUTOREV}, as
+# well as SRCREV = "<some fixed git hash>".
+#
+# WARNING: if upstream repository is always using consistent and
+# sortable tag name scheme you can get sortable version including tag
+# name with ${GITPKGVTAG}, but be aware that ie tag sequence "v1.0,
+# v1.2, xtest, v2.0" will force you to increment PE to get upgradeable
+# path to v2.0 revisions
+#
+# use example:
+#
+# inherit gitpkgv
+#
+# PV = "1.0+gitr${SRCPV}" # expands to something like 1.0+gitr3+4c1c21d7dbbf93b0df336994524313dfe0d4963b
+# PKGV = "1.0+gitr${GITPKGV}" # expands also to something like 1.0+gitr31337+4c1c21d7d
+#
+# or
+#
+# inherit gitpkgv
+#
+# PV = "1.0+gitr${SRCPV}" # expands to something like 1.0+gitr3+4c1c21d7dbbf93b0df336994524313dfe0d4963b
+# PKGV = "${GITPKGVTAG}" # expands to something like 1.0-31337+g4c1c21d
+# if there is tag v1.0 before this revision or
+# ver1.0-31337+g4c1c21d if there is tag ver1.0
+
+GITPKGV = "${@get_git_pkgv(d, False)}"
+GITPKGVTAG = "${@get_git_pkgv(d, True)}"
+
+def gitpkgv_drop_tag_prefix(version):
+ import re
+ if re.match("v\d", version):
+ return version[1:]
+ else:
+ return version
+
+def get_git_pkgv(d, use_tags):
+ import os
+ import bb
+
+ urls = bb.data.getVar('SRC_URI', d, 1).split()
+
+ for url in urls:
+ (type, host, path, user, pswd, parm) = bb.decodeurl(bb.data.expand(url, d))
+ if type in ['git']:
+
+ gitsrcname = '%s%s' % (host, path.replace('/', '.'))
+ repodir = os.path.join(bb.data.expand('${GITDIR}', d), gitsrcname)
+ if not os.path.exists(repodir):
+ return None
+
+ rev = bb.fetch.get_srcrev(d).split('+')[1]
+
+ cwd = os.getcwd()
+ os.chdir(repodir)
+
+ commits = bb.fetch.runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % rev, d, quiet=True).strip()
+
+ if use_tags:
+ try:
+ ver = gitpkgv_drop_tag_prefix(bb.fetch.runfetchcmd("git describe %s 2>/dev/null" % rev, d, quiet=True).strip())
+ except Exception:
+ ver = "0.0-%s-g%s" % (commits, rev[:7])
+ else:
+ ver = "%s+%s" % (commits, rev[:7])
+
+ os.chdir(cwd)
+
+ return ver
+
+ return "0+0"
diff --git a/meta-oe/classes/gitver.bbclass b/meta-oe/classes/gitver.bbclass
new file mode 100644
index 0000000000..ee8323d6f4
--- /dev/null
+++ b/meta-oe/classes/gitver.bbclass
@@ -0,0 +1,80 @@
+# Copyright (C) 2009 Chris Larson <clarson@kergoth.com>
+# Released under the MIT license (see COPYING.MIT for the terms)
+#
+# gitver.bbclass provides a GITVER variable which is a (fairly) sane version,
+# for use in ${PV}, extracted from the ${S} git checkout, assuming it is one.
+# This is most useful in concert with srctree.bbclass.
+
+def git_drop_tag_prefix(version):
+ import re
+ if re.match("v\d", version):
+ return version[1:]
+ else:
+ return version
+
+GIT_TAGADJUST = "git_drop_tag_prefix(version)"
+GITVER = "${@get_git_pv('${S}', d, tagadjust=lambda version:${GIT_TAGADJUST})}"
+GITSHA = "${@get_git_hash('${S}', d)}"
+
+def get_git_hash(path, d):
+ return oe_run(d, ["git", "rev-parse", "--short", "HEAD"], cwd=path).rstrip()
+
+def get_git_pv(path, d, tagadjust=None):
+ import os
+ import oe.process
+
+ gitdir = os.path.abspath(os.path.join(d.getVar("S", True), ".git"))
+ def git(cmd):
+ try:
+ return oe_run(d, ["git"] + cmd, cwd=gitdir).rstrip()
+ except oe.process.CmdError, exc:
+ bb.fatal(str(exc))
+
+ try:
+ ver = oe_run(d, ["git", "describe", "--tags"], cwd=gitdir).rstrip()
+ except Exception, exc:
+ bb.fatal(str(exc))
+
+ if not ver:
+ try:
+ ver = get_git_hash(gitdir, d)
+ except Exception, exc:
+ bb.fatal(str(exc))
+
+ if ver:
+ return "0.0+%s" % ver
+ else:
+ return "0.0"
+ else:
+ if tagadjust:
+ ver = tagadjust(ver)
+ return ver
+
+def mark_recipe_dependencies(path, d):
+ from bb.parse import mark_dependency
+
+ gitdir = os.path.join(path, ".git")
+
+ # Force the recipe to be reparsed so the version gets bumped
+ # if the active branch is switched, or if the branch changes.
+ mark_dependency(d, os.path.join(gitdir, "HEAD"))
+
+ # Force a reparse if anything in the index changes.
+ mark_dependency(d, os.path.join(gitdir, "index"))
+
+ try:
+ ref = oe_run(d, ["git", "symbolic-ref", "-q", "HEAD"], cwd=gitdir).rstrip()
+ except oe.process.CmdError:
+ pass
+ else:
+ if ref:
+ mark_dependency(d, os.path.join(gitdir, ref))
+
+ # Catch new tags.
+ tagdir = os.path.join(gitdir, "refs", "tags")
+ if os.path.exists(tagdir):
+ mark_dependency(d, tagdir)
+
+python () {
+ mark_recipe_dependencies(d.getVar("S", True), d)
+}
diff --git a/meta-oe/classes/glx-use-tls.bbclass b/meta-oe/classes/glx-use-tls.bbclass
new file mode 100644
index 0000000000..7530872fa4
--- /dev/null
+++ b/meta-oe/classes/glx-use-tls.bbclass
@@ -0,0 +1,7 @@
+def get_tls_setting(bb, d):
+ # until we have no prober TLS support in uclibc disable it
+ if bb.data.getVar('TARGET_OS', d, 1).find('uclibc') >= 0 :
+ return ""
+ return "--enable-glx-tls"
+
+EXTRA_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 0000000000..7e042ee930
--- /dev/null
+++ b/meta-oe/classes/gpe.bbclass
@@ -0,0 +1,17 @@
+DEPENDS_prepend = "virtual/libintl intltool-native "
+GPE_TARBALL_SUFFIX ?= "gz"
+SRC_URI = "${GPE_MIRROR}/${PN}-${PV}.tar.${GPE_TARBALL_SUFFIX}"
+FILES_${PN} += "${datadir}/gpe ${datadir}/application-registry"
+SECTION ?= "gpe"
+
+inherit gettext
+
+gpe_do_compile() {
+ oe_runmake PREFIX=${prefix}
+}
+
+gpe_do_install() {
+ oe_runmake PREFIX=${prefix} DESTDIR=${D} install
+}
+
+EXPORT_FUNCTIONS do_compile do_install
diff --git a/meta-oe/classes/srctree.bbclass b/meta-oe/classes/srctree.bbclass
new file mode 100644
index 0000000000..1457e5618d
--- /dev/null
+++ b/meta-oe/classes/srctree.bbclass
@@ -0,0 +1,123 @@
+# Copyright (C) 2009 Chris Larson <clarson@kergoth.com>
+# Released under the MIT license (see COPYING.MIT for the terms)
+#
+# srctree.bbclass enables operation inside of an existing source tree for a
+# project, rather than using the fetch/unpack/patch idiom.
+#
+# By default, it expects that you're keeping the recipe(s) inside the
+# aforementioned source tree, but you could override S to point at an external
+# directory and place the recipes in a normal collection/overlay, if you so
+# chose.
+#
+# It also provides some convenience python functions for assembling your
+# do_clean, if you want to leverage things like 'git clean' to simplify the
+# operation.
+
+
+# Grab convenience methods & sane default for do_clean
+inherit clean
+
+# Build here
+S = "${FILE_DIRNAME}"
+SRC_URI = ""
+
+def remove_tasks(deltasks, d):
+ for task in filter(lambda k: d.getVarFlag(k, "task"), d.keys()):
+ deps = d.getVarFlag(task, "deps")
+ for preptask in deltasks:
+ if preptask in deps:
+ deps.remove(preptask)
+ d.setVarFlag(task, "deps", deps)
+
+addtask configure after do_setscene
+
+def merge_tasks(d):
+ """
+ Merges all of the operations that occur prior to do_populate_sysroot
+ into do_populate_sysroot.
+
+ This is necessary because of recipe variants (normal, native, cross,
+ sdk). If a bitbake run happens to want to build more than one of
+ these variants in a single run, it's possible for them to step on one
+ another's toes, due to the shared ${S}. Interleaved
+ configure/compile/install amongst variants will break things badly.
+ """
+ from itertools import chain
+ from bb import note
+
+ def __gather_taskdeps(task, seen):
+ for dep in d.getVarFlag(task, "deps"):
+ if not dep in seen:
+ __gather_taskdeps(dep, seen)
+ if not task in seen:
+ seen.append(task)
+
+ def gather_taskdeps(task):
+ items = []
+ __gather_taskdeps(task, items)
+ return items
+
+ newtask = "do_populate_sysroot_post"
+ mergedtasks = gather_taskdeps(newtask)
+ mergedtasks.pop()
+
+ for task in (key for key in d.keys()
+ if d.getVarFlag(key, "task") and
+ not key in mergedtasks):
+ deps = d.getVarFlag(task, "deps")
+ for mergetask in mergedtasks:
+ if mergetask in (d.getVarFlag(task, "recrdeptask"),
+ d.getVarFlag(task, "recdeptask"),
+ d.getVarFlag(task, "deptask")):
+ continue
+
+ if mergetask in deps:
+ deps.remove(mergetask)
+ #note("removing dep on %s from %s" % (mergetask, task))
+
+ if not newtask in deps:
+ #note("adding dep on %s to %s" % (newtask, task))
+ deps.append(newtask)
+ d.setVarFlag(task, "deps", deps)
+
+ # Pull cross recipe task deps over
+ depends = []
+ deptask = []
+ for task in mergedtasks[:-1]:
+ depends.append(d.getVarFlag(task, "depends") or "")
+ deptask.append(d.getVarFlag(task, "deptask") or "")
+
+ d.setVarFlag("do_populate_sysroot_post", "depends", " ".join(depends))
+ d.setVarFlag("do_populate_sysroot_post", "deptask", " ".join(deptask))
+
+python () {
+ remove_tasks(["do_patch", "do_unpack", "do_fetch"], d)
+ b = d.getVar("B", True)
+ if not b or b == d.getVar("S", True):
+ merge_tasks(d)
+}
+
+# Manually run do_install & all of its deps
+python do_populate_sysroot_post () {
+ from os.path import exists
+ from bb.build import exec_func, make_stamp
+ from bb import note
+
+ stamp = d.getVar("STAMP", True)
+
+ def rec_exec_task(task, seen):
+ for dep in d.getVarFlag(task, "deps"):
+ if not dep in seen:
+ rec_exec_task(dep, seen)
+ seen.add(task)
+ if not exists("%s.%s" % (stamp, task)):
+ note("%s: executing task %s" % (d.getVar("PF", True), task))
+ exec_func(task, d)
+ flags = d.getVarFlags(task)
+ if not flags.get('nostamp') and not flags.get('selfstamp'):
+ make_stamp(task, d)
+
+ rec_exec_task("do_populate_sysroot", set())
+}
+addtask populate_sysroot_post after do_populate_sysroot
+do_populate_sysroot_post[lockfiles] += "${S}/.lock"