[oe] srctree & gitver

Chris Larson clarson at kergoth.com
Thu Aug 27 02:05:33 UTC 2009


I'm going to summarize the features of the two classes I've created
over the past couple days.  I believe that they will make the lives of
app & kernel developers much easier when dealing with bitbake/OE/MVL6.

srctree facilitates bitbake builds in existing source trees, bypassing
the fetch/unpack/patch idiom.  It's easy to allow the user to put the
recipe in their source tree, if they want to store it in their scm
repository with their app/kernel code, or you can point the recipe at
external trees.  This works for app and kernel development.

gitver facilitates extraction of version information from git.  By
default, it runs 'git describe' to get the version.  If that fails, it
will set the version to 0.0-<sha1 hash>.  This version is stored in
the ${GITVER} variable, and can be used in the recipe's PV variable.
When using this, it will automatically detect changes to .git/HEAD
(i.e. commit your local changes, check out a different branch, ..) and
invalidate the bitbake cache, pick up the new PV, and know that it
needs to re-run the build steps.

Examples:
Common steps:

$ cd myproject
~/oe/projects/myproject
$ . ./setup.sh


Example of a user who wants bitbake to build their existing source
tree outside the project:
Userland:

$ cd myproject
~/oe/projects/myproject
$ . ./setup.sh
$ cat <<END >collections/custom/hello.bb
inherit srctree

# Pointing to the external source tree
S = "${HOME}/code/hello"
DESCRIPTION = "Hello, World"

do_install () {
   install -D -m 0755 hello ${D}${bindir}/hello
}
END
$ bitbake hello

Kernel:

$ cat <<END >collections/custom/linux.bb
inherit kernel srctree gitver

# Strip off the leading 'v' from the Linux kernel git tags
PV = "${@'${GITVER}'[1:]}"

# Point to my existing kernel development tree
S = "${HOME}/code/linux-2.6"
END
$ bitbake linux


Example of a user who wants their source tree to live in their project:
Userland:

$ mkdir collections/hello
$ cd collections/hello
~/oe/projects/myproject/collections/hello
$ cat <<END >hello.c
heredoc> #include <stdio.h>
heredoc>
heredoc> int main(int argc, char **argv)
heredoc> {
heredoc>     printf("Hello, World!\n");
heredoc> }
heredoc> END
$ cat <<END >Makefile
heredoc> all: hello
heredoc> hello: hello.c
heredoc>        \$(CC) \$(CFLAGS) \$(LDFLAGS) hello.c -o hello
heredoc> clean:
heredoc>        rm -f hello
heredoc> END
$ cat <<END >hello.bb
heredoc> inherit srctree
heredoc>
heredoc> DESCRIPTION = "Hello, World."
heredoc>
heredoc> do_install () {
heredoc>     install -D -m 0755 hello \${D}\${bindir}/hello
heredoc> }
heredoc> END
$ bitbake hello
NOTE: Handling BitBake files: \ (0010/0010) [100%%]
NOTE: Parsing finished. 0 cached, 10 parsed, 0 skipped, 0 masked.
NOTE: Resolving any missing task queue dependencies
NOTE: Preparing runqueue
NOTE: Executing runqueue
NOTE: Running task 1 of 2 (ID: 1,
/home/clarson/oe/projects/myproject/collections/hello/hello.bb,
do_populate_staging)
NOTE: Running task 2 of 2 (ID: 0,
/home/clarson/oe/projects/myproject/collections/hello/hello.bb,
do_build)
NOTE: Tasks Summary: Attempted 2 tasks of which 0 didn't need to be
rerun and 0 failed.
$ ls
hello  hello.bb  hello.c  Makefile
$ ./hello
Hello, World!
$ bitbake -c clean hello
NOTE: Handling BitBake files: \ (0010/0010) [100%%]
NOTE: Parsing finished. 10 cached, 0 parsed, 0 skipped, 0 masked.
NOTE: Cache is clean, not saving.
NOTE: Resolving any missing task queue dependencies
NOTE: Preparing runqueue
NOTE: Executing runqueue
NOTE: Running task 1 of 1 (ID: 0,
/home/clarson/oe/projects/myproject/collections/hello/hello.bb,
do_clean)
NOTE: Removing stamps
NOTE: Removing /home/clarson/oe/projects/myproject/tmp/work/i486-linux/hello-1.0-r0
NOTE: Running make clean
NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be
rerun and 0 failed.
$ ls
hello.bb  hello.c  Makefile
$ sed -i -e 's,World,Country,' hello.c
$ bitbake hello
NOTE: Handling BitBake files: \ (0010/0010) [100%%]
NOTE: Parsing finished. 10 cached, 0 parsed, 0 skipped, 0 masked.
NOTE: Cache is clean, not saving.
NOTE: Resolving any missing task queue dependencies
NOTE: Preparing runqueue
NOTE: Executing runqueue
NOTE: Running task 1 of 2 (ID: 1,
/home/clarson/oe/projects/myproject/collections/hello/hello.bb,
do_populate_staging)
NOTE: Running task 2 of 2 (ID: 0,
/home/clarson/oe/projects/myproject/collections/hello/hello.bb,
do_build)
NOTE: Tasks Summary: Attempted 2 tasks of which 0 didn't need to be
rerun and 0 failed.
$ ./hello
Hello, Country!
$

Kernel:
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
collections/linux-2.6
[... git output ...]
$ cat <<END >collections/linux-2.6/linux.bb
inherit kernel srctree gitver

# Strip off the leading 'v' from the Linux kernel git tags
PV = "${@'${GITVER}'[1:]}"
END
$ bitbake linux
-- 
Chris Larson
clarson at kergoth dot com
clarson at mvista dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Software Engineer
MontaVista Software, Inc.




More information about the Openembedded-devel mailing list