mirror of
https://git.yoctoproject.org/poky
synced 2026-06-02 13:29:49 +00:00
bitbake: bitbake-user-manual-hello.xml: First draft of "Hello World" appendix
Fixes [YOCTO #1973] Added the complete "Hello World" appendix first draft beyond what Bill Traynor had supplied. (Bitbake rev: 176baaf3d0f033091f5ab9d9cfb2cec3d25a5442) Signed-off-by: Scott Rifenbark <scott.m.rifenbark@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
4687351d16
commit
61a680fb5d
@@ -120,16 +120,6 @@
|
|||||||
<section id='the-hello-world-example'>
|
<section id='the-hello-world-example'>
|
||||||
<title>The Hello World Example</title>
|
<title>The Hello World Example</title>
|
||||||
|
|
||||||
<para>
|
|
||||||
The following example leaps directly into how BitBake
|
|
||||||
works.
|
|
||||||
While every attempt is made to explain what is happening,
|
|
||||||
not everything can be covered.
|
|
||||||
You can find further information in the
|
|
||||||
"<link linkend='bitbake-user-manual-metadata'>Syntax and Operators</link>"
|
|
||||||
chapter.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The overall goal of this exercise is to build a
|
The overall goal of this exercise is to build a
|
||||||
complete "Hello World" example utilizing task and layer
|
complete "Hello World" example utilizing task and layer
|
||||||
@@ -141,8 +131,25 @@
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
It should be noted that this chapter was inspired by
|
To help you understand how to use BitBake to build targets,
|
||||||
and draws heavily from several sources:
|
the example starts with nothing but the <filename>bitbake</filename>
|
||||||
|
command, which causes BitBake to fail and report problems.
|
||||||
|
The example progresses by adding pieces to the build to
|
||||||
|
eventually conclude with a working, minimal "Hello World"
|
||||||
|
example.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
While every attempt is made to explain what is happening during
|
||||||
|
the example, the descriptions cannot cover everything.
|
||||||
|
You can find further information throughout this manual.
|
||||||
|
Also, you can actively participate in the
|
||||||
|
<ulink url='http://lists.openembedded.org/mailman/listinfo/bitbake-devel'></ulink>
|
||||||
|
discussion mailing list about the BitBake build tool.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<note>
|
||||||
|
This example was inspired by and drew heavily from these sources:
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
<ulink url="http://www.mail-archive.com/yocto@yoctoproject.org/msg09379.html">Mailing List post - The BitBake equivalent of "Hello, World!"</ulink>
|
<ulink url="http://www.mail-archive.com/yocto@yoctoproject.org/msg09379.html">Mailing List post - The BitBake equivalent of "Hello, World!"</ulink>
|
||||||
@@ -151,114 +158,177 @@
|
|||||||
<ulink url="http://hambedded.org/blog/2012/11/24/from-bitbake-hello-world-to-an-image/">Hambedded Linux blog post - From Bitbake Hello World to an Image</ulink>
|
<ulink url="http://hambedded.org/blog/2012/11/24/from-bitbake-hello-world-to-an-image/">Hambedded Linux blog post - From Bitbake Hello World to an Image</ulink>
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
</note>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
As stated earlier, the goal of this example
|
||||||
|
is to eventually compile "Hello World".
|
||||||
|
However, it is unknown what BitBake needs and what you have
|
||||||
|
to provide in order to achieve that goal.
|
||||||
|
Recall that BitBake utilizes three types of metadata files:
|
||||||
|
<link linkend='configuration-files'>Configuration Files</link>,
|
||||||
|
<link linkend='classes'>Classes</link>, and
|
||||||
|
<link linkend='recipes'>Recipes</link>.
|
||||||
|
But where do they go?
|
||||||
|
How does BitBake find them?
|
||||||
|
BitBake's error messaging helps you answer these types of questions
|
||||||
|
and helps you better understand exactly what is going on.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<section id='a-reverse-walk-through'>
|
<para>
|
||||||
<title>A Reverse Walk-Through</title>
|
Following is the complete "Hello World" example.
|
||||||
|
</para>
|
||||||
|
|
||||||
<para>
|
<orderedlist>
|
||||||
A good way to understand anything is to walk through the steps
|
<listitem><para><emphasis>Create a Project Directory:</emphasis>
|
||||||
that take you to where you want to be and observe first
|
|
||||||
principles.
|
|
||||||
BitBake allows us to do this through the
|
|
||||||
<filename>-D</filename> or <filename>Debug</filename>
|
|
||||||
command-line parameter.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The goal is to eventually compile a "Hello World" example.
|
|
||||||
However, it is unknown what is needed to achieve that goal.
|
|
||||||
Recall that BitBake utilizes three types of metadata files:
|
|
||||||
<link linkend='configuration-files'>Configuration Files</link>,
|
|
||||||
<link linkend='classes'>Classes</link>, and
|
|
||||||
<link linkend='recipes'>Recipes</link>.
|
|
||||||
But where do they go?
|
|
||||||
How does BitBake find them?
|
|
||||||
BitBake's error messaging helps you answer these types of questions
|
|
||||||
and helps you better understand exactly what is going on.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
First, set up a directory for the "Hello World" project.
|
First, set up a directory for the "Hello World" project.
|
||||||
Here is how you can do so in your home directory:
|
Here is how you can do so in your home directory:
|
||||||
<literallayout class='monospaced'>
|
<literallayout class='monospaced'>
|
||||||
$ mkdir ~/hello
|
$ mkdir ~/hello
|
||||||
$ cd ~/hello
|
$ cd ~/hello
|
||||||
</literallayout>
|
</literallayout>
|
||||||
Within this new, empty directory, run BitBake with
|
This is the directory that BitBake will use to do all of
|
||||||
debugging output and see what happens:
|
its work.
|
||||||
|
You can use this directory to keep all the metafiles needed
|
||||||
|
by BitBake.
|
||||||
|
Having a project directory is a good way to isolate your
|
||||||
|
project.
|
||||||
|
</para></listitem>
|
||||||
|
<listitem><para><emphasis>Run Bitbake:</emphasis>
|
||||||
|
At this point, you have nothing but a project directory.
|
||||||
|
Run the <filename>bitbake</filename> command and see what
|
||||||
|
it does:
|
||||||
<literallayout class='monospaced'>
|
<literallayout class='monospaced'>
|
||||||
$ bitbake -DDD
|
$ bitbake
|
||||||
The BBPATH variable is not set and bitbake did not find
|
The BBPATH variable is not set and bitbake did not
|
||||||
a conf/bblayers.conf file in the expected location.
|
find a conf/bblayers.conf file in the expected location.
|
||||||
Maybe you accidentally invoked bitbake from the wrong
|
Maybe you accidentally invoked bitbake from the wrong directory?
|
||||||
directory?
|
|
||||||
DEBUG: Removed the following variables from the environment:
|
DEBUG: Removed the following variables from the environment:
|
||||||
GNOME_DESKTOP_SESSION_ID, XDG_CURRENT_DESKTOP,
|
GNOME_DESKTOP_SESSION_ID, XDG_CURRENT_DESKTOP,
|
||||||
GNOME_KEYRING_CONTROL, DISPLAY, SSH_AGENT_PID, LANG,
|
GNOME_KEYRING_CONTROL, DISPLAY, SSH_AGENT_PID, LANG, no_proxy,
|
||||||
no_proxy, XDG_SESSION_PATH, XAUTHORITY, SESSION_MANAGER,
|
XDG_SESSION_PATH, XAUTHORITY, SESSION_MANAGER, SHLVL,
|
||||||
SHLVL, MANDATORY_PATH, COMPIZ_CONFIG_PROFILE, WINDOWID,
|
MANDATORY_PATH, COMPIZ_CONFIG_PROFILE, WINDOWID, EDITOR,
|
||||||
EDITOR, GPG_AGENT_INFO, SSH_AUTH_SOCK, GDMSESSION,
|
GPG_AGENT_INFO, SSH_AUTH_SOCK, GDMSESSION, GNOME_KEYRING_PID,
|
||||||
DEFAULTS_PATH, XDG_SEAT_PATH, XDG_CONFIG_DIRS, LESSOPEN,
|
XDG_SEAT_PATH, XDG_CONFIG_DIRS, LESSOPEN, DBUS_SESSION_BUS_ADDRESS,
|
||||||
DBUS_SESSION_BUS_ADDRESS, _, XDG_SESSION_COOKIE,
|
_, XDG_SESSION_COOKIE, DESKTOP_SESSION, LESSCLOSE, DEFAULTS_PATH,
|
||||||
DESKTOP_SESSION, LESSCLOSE, GNOME_KEYRING_PID,
|
UBUNTU_MENUPROXY, OLDPWD, XDG_DATA_DIRS, COLORTERM, LS_COLORS
|
||||||
UBUNTU_MENUPROXY, OLDPWD, XDG_DATA_DIRS, COLORTERM,
|
|
||||||
LS_COLORS
|
|
||||||
</literallayout>
|
</literallayout>
|
||||||
The majority of this output is specific to environment variables
|
The majority of this output is specific to environment variables
|
||||||
that are not directly relevant to BitBake.
|
that are not directly relevant to BitBake.
|
||||||
However, the very first message regarding the
|
However, the very first message regarding the
|
||||||
<filename>BBPATH</filename> variable and the
|
<filename>BBPATH</filename> variable and the
|
||||||
<filename>conf/bblayers.conf</filename> file
|
<filename>conf/bblayers.conf</filename> file
|
||||||
is relevant.
|
is relevant.</para>
|
||||||
</para>
|
<para>
|
||||||
|
When you run BitBake, it begins looking for metadata files.
|
||||||
<para>
|
The
|
||||||
|
<link linkend='var-BBPATH'><filename>BBPATH</filename></link>
|
||||||
|
variable is what tells BitBake where to look for those files.
|
||||||
|
<filename>BBPATH</filename> is not set and you need to set it.
|
||||||
|
Without <filename>BBPATH</filename>, Bitbake cannot
|
||||||
|
find any configuration files (<filename>.conf</filename>)
|
||||||
|
or recipe files (<filename>.bb</filename>) at all.
|
||||||
|
BitBake also cannot find the <filename>bitbake.conf</filename>
|
||||||
|
file.
|
||||||
|
</para></listitem>
|
||||||
|
<listitem><para><emphasis>Setting <filename>BBPATH</filename>:</emphasis>
|
||||||
|
For this example, you can set <filename>BBPATH</filename>
|
||||||
|
in the same manner that you set <filename>PATH</filename>
|
||||||
|
earlier in the appendix.
|
||||||
|
You should realize, though, that it is much more flexible to set the
|
||||||
|
<filename>BBPATH</filename> variable up in a configuration
|
||||||
|
file for each project.</para>
|
||||||
|
<para>From your shell, enter the following commands to set and
|
||||||
|
export the <filename>BBPATH</filename> variable:
|
||||||
<literallayout class='monospaced'>
|
<literallayout class='monospaced'>
|
||||||
1. Once you have PATH set up to actually run BB, and then you run it
|
$ BBPATH="<projectdirectory>"
|
||||||
using:
|
$ export BBPATH
|
||||||
|
</literallayout>
|
||||||
|
Use your actual project directory in the command.
|
||||||
|
BitBake uses that directory to find the metadata it needs for
|
||||||
|
your project.
|
||||||
|
<note>
|
||||||
|
When specifying your project directory, do not use the
|
||||||
|
tilde ("~") character as BitBake does not expand that character
|
||||||
|
as the shell would.
|
||||||
|
</note>
|
||||||
|
</para></listitem>
|
||||||
|
<listitem><para><emphasis>Run Bitbake:</emphasis>
|
||||||
|
Now that you have <filename>BBPATH</filename> defined, run
|
||||||
|
the <filename>bitbake</filename> command again:
|
||||||
|
<literallayout class='monospaced'>
|
||||||
|
$ bitbake
|
||||||
|
ERROR: Traceback (most recent call last):
|
||||||
|
File "/home/scott-lenovo/bitbake/lib/bb/cookerdata.py", line 163, in wrapped
|
||||||
|
return func(fn, *args)
|
||||||
|
File "/home/scott-lenovo/bitbake/lib/bb/cookerdata.py", line 173, in parse_config_file
|
||||||
|
return bb.parse.handle(fn, data, include)
|
||||||
|
File "/home/scott-lenovo/bitbake/lib/bb/parse/__init__.py", line 99, in handle
|
||||||
|
return h['handle'](fn, data, include)
|
||||||
|
File "/home/scott-lenovo/bitbake/lib/bb/parse/parse_py/ConfHandler.py", line 120, in handle
|
||||||
|
abs_fn = resolve_file(fn, data)
|
||||||
|
File "/home/scott-lenovo/bitbake/lib/bb/parse/__init__.py", line 117, in resolve_file
|
||||||
|
raise IOError("file %s not found in %s" % (fn, bbpath))
|
||||||
|
IOError: file conf/bitbake.conf not found in /home/scott-lenovo/hello
|
||||||
|
|
||||||
bitbake -DDD
|
ERROR: Unable to parse conf/bitbake.conf: file conf/bitbake.conf not found in /home/scott-lenovo/hello
|
||||||
|
</literallayout>
|
||||||
You get these complaints:
|
This sample output shows that BitBake could not find the
|
||||||
|
<filename>conf/bitbake.conf</filename> file in the project
|
||||||
The BBPATH variable is not set and bitbake did not find a conf/bblayers.conf file in the expected location.
|
directory.
|
||||||
Maybe you accidentally invoked bitbake from the wrong directory?
|
This file is the first thing BitBake must find in order
|
||||||
|
to build a target.
|
||||||
2. If you export BBPATH to point to your build directory and do nothing
|
And, since the project directory for this example is
|
||||||
else, BB will look for the <buildir>/conf/bitbake.conf file. It will
|
empty, you need to provide a <filename>conf/bitbake.conf</filename>
|
||||||
throw and error with a bunch of traceback stuff and say:
|
file.
|
||||||
|
</para></listitem>
|
||||||
scott-lenovo@scott-lenovo:~ [master #]
|
<listitem><para><emphasis>Creating <filename>conf/bitbake.conf</filename>:</emphasis>
|
||||||
$ mkdir junk
|
The <filename>conf/bitbake.conf</filename> includes a number of
|
||||||
scott-lenovo@scott-lenovo:~ [master #]
|
configuration variables BitBake uses for metadata and recipe
|
||||||
$ BBPATH="/home/scott-lenovo/junk"
|
files.
|
||||||
scott-lenovo@scott-lenovo:~ [master #]
|
For this example, you need to create the file in your project directory
|
||||||
$ export BBPATH
|
and define some key BitBake variables.
|
||||||
scott-lenovo@scott-lenovo:~ [master #]
|
For more information on the <filename>bitbake.conf</filename>,
|
||||||
$ bitbake -DDD
|
see
|
||||||
ERROR: Traceback (most recent call last):
|
<ulink url='http://hambedded.org/blog/2012/11/24/from-bitbake-hello-world-to-an-image/#an-overview-of-bitbakeconf'></ulink>
|
||||||
File "/home/scott-lenovo/bitbake/lib/bb/cookerdata.py", line 163, in wrapped
|
</para>
|
||||||
return func(fn, *args)
|
<para>Use the following commands to create the <filename>conf</filename>
|
||||||
File "/home/scott-lenovo/bitbake/lib/bb/cookerdata.py", line 173, in parse_config_file
|
directory in the project directory:
|
||||||
return bb.parse.handle(fn, data, include)
|
<literallayout class='monospaced'>
|
||||||
File "/home/scott-lenovo/bitbake/lib/bb/parse/__init__.py", line 99, in handle
|
$ mkdir conf
|
||||||
return h['handle'](fn, data, include)
|
</literallayout>
|
||||||
File "/home/scott-lenovo/bitbake/lib/bb/parse/parse_py/ConfHandler.py", line 120, in handle
|
From within the <filename>conf</filename> directory, use
|
||||||
abs_fn = resolve_file(fn, data)
|
some editor to create the <filename>bitbake.conf</filename>
|
||||||
File "/home/scott-lenovo/bitbake/lib/bb/parse/__init__.py", line 117, in resolve_file
|
so that it contains the following:
|
||||||
raise IOError("file %s not found in %s" % (fn, bbpath))
|
<literallayout class='monospaced'>
|
||||||
IOError: file conf/bitbake.conf not found in /home/scott-lenovo/junk
|
TMPDIR = "${<link linkend='var-TOPDIR'>TOPDIR</link>}/tmp"
|
||||||
|
<link linkend='var-CACHE'>CACHE</link> = "${TMPDIR}/cache"
|
||||||
ERROR: Unable to parse conf/bitbake.conf: file conf/bitbake.conf not found in /home/scott-lenovo/junk
|
<link linkend='var-STAMP'>STAMP</link> = "${TMPDIR}/stamps"
|
||||||
scott-lenovo@scott-lenovo:~ [master #]
|
<link linkend='var-T'>T</link> = "${TMPDIR}/work"
|
||||||
|
<link linkend='var-B'>B</link> = "${TMPDIR}"
|
||||||
3. Now I am going to create the conf/bitbake.conf file I need for the hello
|
</literallayout>
|
||||||
world example. Then run it again. Time it complains about not finding
|
The <filename>TMPDIR</filename> variable establishes a directory
|
||||||
classes/base.bbclass.
|
that BitBake uses for build output and intermediate files (other
|
||||||
|
than the cached information used by the
|
||||||
scott-lenovo@scott-lenovo:~/junk [master #]
|
<link linkend='setscene'>Setscene</link> process.
|
||||||
$ bitbake -DDD
|
Here, the <filename>TMPDIR</filename> directory is set to
|
||||||
|
<filename>hello/tmp</filename>.
|
||||||
|
<note><title>Tip</title>
|
||||||
|
You can always safely delete the <filename>tmp</filename>
|
||||||
|
directory in order to rebuild a BitBake target.
|
||||||
|
The build process creates the directory for you
|
||||||
|
when you run BitBake.
|
||||||
|
</note></para>
|
||||||
|
<para>For information about each of the other variables defined in this
|
||||||
|
example, click on the links to take you to the definitions in
|
||||||
|
the glossary.
|
||||||
|
</para></listitem>
|
||||||
|
<listitem><para><emphasis>Run Bitbake:</emphasis>
|
||||||
|
After making sure that the <filename>conf/bitbake.conf</filename>
|
||||||
|
file exists, you can run the <filename>bitbake</filename>
|
||||||
|
command again:
|
||||||
|
<literallayout class='monospaced'>
|
||||||
|
$ bitbake
|
||||||
ERROR: Traceback (most recent call last):
|
ERROR: Traceback (most recent call last):
|
||||||
File "/home/scott-lenovo/bitbake/lib/bb/cookerdata.py", line 163, in wrapped
|
File "/home/scott-lenovo/bitbake/lib/bb/cookerdata.py", line 163, in wrapped
|
||||||
return func(fn, *args)
|
return func(fn, *args)
|
||||||
@@ -271,241 +341,178 @@ ERROR: Traceback (most recent call last):
|
|||||||
ParseError: ParseError in configuration INHERITs: Could not inherit file classes/base.bbclass
|
ParseError: ParseError in configuration INHERITs: Could not inherit file classes/base.bbclass
|
||||||
|
|
||||||
ERROR: Unable to parse base: ParseError in configuration INHERITs: Could not inherit file classes/base.bbclass
|
ERROR: Unable to parse base: ParseError in configuration INHERITs: Could not inherit file classes/base.bbclass
|
||||||
scott-lenovo@scott-lenovo:~/junk [master #]
|
|
||||||
|
|
||||||
4. So now we add that classes/base.bbclass file and put in one line that says
|
|
||||||
"addtask build", which is the minimum task you need. We run it again and
|
|
||||||
things work but there is nothing to do. That stands to reason since I gave it
|
|
||||||
no target.
|
|
||||||
|
|
||||||
scott-lenovo@scott-lenovo:~/junk [master #]
|
|
||||||
$ bitbake -DDD
|
|
||||||
Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.
|
|
||||||
DEBUG: Removed the following variables from the environment: GNOME_DESKTOP_SESSION_ID, XDG_CURRENT_DESKTOP, GNOME_KEYRING_CONTROL, DISPLAY, SSH_AGENT_PID, LANG, no_proxy, XDG_SESSION_PATH, XAUTHORITY, SESSION_MANAGER, SHLVL, MANDATORY_PATH, COMPIZ_CONFIG_PROFILE, WINDOWID, EDITOR, GPG_AGENT_INFO, SSH_AUTH_SOCK, GDMSESSION, GNOME_KEYRING_PID, XDG_SEAT_PATH, XDG_CONFIG_DIRS, LESSOPEN, DBUS_SESSION_BUS_ADDRESS, _, XDG_SESSION_COOKIE, DESKTOP_SESSION, LESSCLOSE, DEFAULTS_PATH, UBUNTU_MENUPROXY, OLDPWD, XDG_DATA_DIRS, COLORTERM, LS_COLORS
|
|
||||||
DEBUG: LOAD /home/scott-lenovo/junk/conf/bitbake.conf
|
|
||||||
DEBUG: BB configuration INHERITs:0: inheriting /home/scott-lenovo/junk/classes/base.bbclass
|
|
||||||
DEBUG: BB /home/scott-lenovo/junk/classes/base.bbclass: handle(data, include)
|
|
||||||
DEBUG: LOAD /home/scott-lenovo/junk/classes/base.bbclass
|
|
||||||
DEBUG: Clearing SRCREV cache due to cache policy of: clear
|
|
||||||
DEBUG: Using cache in '/home/scott-lenovo/junk/tmp/cache/local_file_checksum_cache.dat'
|
|
||||||
DEBUG: Using cache in '/home/scott-lenovo/junk/tmp/cache/bb_codeparser.dat'
|
|
||||||
DEBUG: Features set [3] (was [3])
|
|
||||||
scott-lenovo@scott-lenovo:~/junk [master #]
|
|
||||||
|
|
||||||
5. Here is what happens when you do provide a target but the target doesn't
|
|
||||||
exist yet.
|
|
||||||
|
|
||||||
scott-lenovo@scott-lenovo:~/junk [master #]
|
|
||||||
$ bitbake a
|
|
||||||
ERROR: no recipe files to build, check your BBPATH and BBFILES?
|
|
||||||
|
|
||||||
Summary: There was 1 ERROR message shown, returning a non-zero exit code.
|
|
||||||
scott-lenovo@scott-lenovo:~/junk [master #]
|
|
||||||
|
|
||||||
6. Create a layer that has your metadata in it. You need your recipe file
|
|
||||||
and your layer.conf file. That is all good but you still need to
|
|
||||||
tell BB where your layers are. You do that through a bblayers.conf file.
|
|
||||||
We will use this one:
|
|
||||||
|
|
||||||
BBLAYERS ?=" \
|
|
||||||
/home/scott-lenovo/LayerA \
|
|
||||||
"
|
|
||||||
|
|
||||||
Now when you run it, you get this:
|
|
||||||
|
|
||||||
$ bitbake -DDD a
|
|
||||||
DEBUG: Removed the following variables from the environment: GNOME_DESKTOP_SESSION_ID, XDG_CURRENT_DESKTOP, GNOME_KEYRING_CONTROL, DISPLAY, SSH_AGENT_PID, LANG, no_proxy, XDG_SESSION_PATH, XAUTHORITY, SESSION_MANAGER, SHLVL, MANDATORY_PATH, COMPIZ_CONFIG_PROFILE, WINDOWID, EDITOR, GPG_AGENT_INFO, SSH_AUTH_SOCK, GDMSESSION, GNOME_KEYRING_PID, XDG_SEAT_PATH, XDG_CONFIG_DIRS, LESSOPEN, DBUS_SESSION_BUS_ADDRESS, _, XDG_SESSION_COOKIE, DESKTOP_SESSION, LESSCLOSE, DEFAULTS_PATH, UBUNTU_MENUPROXY, OLDPWD, XDG_DATA_DIRS, COLORTERM, LS_COLORS
|
|
||||||
DEBUG: Found bblayers.conf (/home/scott-lenovo/junk/conf/bblayers.conf)
|
|
||||||
DEBUG: LOAD /home/scott-lenovo/junk/conf/bblayers.conf
|
|
||||||
DEBUG: Adding layer /home/scott-lenovo/LayerA
|
|
||||||
DEBUG: LOAD /home/scott-lenovo/LayerA/conf/layer.conf
|
|
||||||
DEBUG: LOAD /home/scott-lenovo/junk/conf/bitbake.conf
|
|
||||||
DEBUG: BB configuration INHERITs:0: inheriting /home/scott-lenovo/junk/classes/base.bbclass
|
|
||||||
DEBUG: BB /home/scott-lenovo/junk/classes/base.bbclass: handle(data, include)
|
|
||||||
DEBUG: LOAD /home/scott-lenovo/junk/classes/base.bbclass
|
|
||||||
DEBUG: Clearing SRCREV cache due to cache policy of: clear
|
|
||||||
DEBUG: Using cache in '/home/scott-lenovo/junk/tmp/cache/local_file_checksum_cache.dat'
|
|
||||||
DEBUG: Using cache in '/home/scott-lenovo/junk/tmp/cache/bb_codeparser.dat'
|
|
||||||
DEBUG: Features set [3] (was [3])
|
|
||||||
DEBUG: Calculated priority of layer A as 1
|
|
||||||
DEBUG: collecting .bb files
|
|
||||||
DEBUG: Using cache in '/home/scott-lenovo/junk/tmp/cache'
|
|
||||||
DEBUG: Cache: /home/scott-lenovo/LayerA/a.bb is not cached
|
|
||||||
DEBUG: BB /home/scott-lenovo/LayerA/a.bb: handle(data) | ETA: --:--:--
|
|
||||||
DEBUG: LOAD /home/scott-lenovo/LayerA/a.bb
|
|
||||||
Parsing recipes: 100% |##########################################################################################| Time: 00:00:00
|
|
||||||
Parsing of 1 .bb files complete (0 cached, 1 parsed). 1 targets, 0 skipped, 0 masked, 0 errors.
|
|
||||||
DEBUG: parsing complete
|
|
||||||
DEBUG: providers for a are: ['a']
|
|
||||||
DEBUG: sorted providers for a are: ['/home/scott-lenovo/LayerA/a.bb']
|
|
||||||
DEBUG: adding /home/scott-lenovo/LayerA/a.bb to satisfy a
|
|
||||||
DEBUG: Added dependencies [] for /home/scott-lenovo/LayerA/a.bb
|
|
||||||
NOTE: Resolving any missing task queue dependencies
|
|
||||||
DEBUG: Resolved 0 extra dependencies
|
|
||||||
NOTE: Preparing runqueue
|
|
||||||
NOTE: Marking Active Tasks
|
|
||||||
NOTE: Pruned 0 inactive tasks, 1 left
|
|
||||||
NOTE: Assign Weightings
|
|
||||||
NOTE: Compute totals (have 1 endpoint(s))
|
|
||||||
DEBUG: Starting bitbake-worker
|
|
||||||
NOTE: Executing RunQueue Tasks
|
|
||||||
DEBUG: Considering 0 (/home/scott-lenovo/LayerA/a.bb, do_build): set([])
|
|
||||||
DEBUG: Skip list (pre setsceneverify) []
|
|
||||||
DEBUG: Full skip list set([])
|
|
||||||
DEBUG: Using runqueue scheduler 'speed'
|
|
||||||
DEBUG: Stampfile /home/scott-lenovo/junk/tmp/stamps.do_build not available
|
|
||||||
DEBUG: Found bblayers.conf (/home/scott-lenovo/junk/conf/bblayers.conf)
|
|
||||||
DEBUG: LOAD /home/scott-lenovo/junk/conf/bblayers.conf
|
|
||||||
DEBUG: Adding layer /home/scott-lenovo/LayerA
|
|
||||||
DEBUG: LOAD /home/scott-lenovo/LayerA/conf/layer.conf
|
|
||||||
DEBUG: LOAD /home/scott-lenovo/junk/conf/bitbake.conf
|
|
||||||
DEBUG: BB configuration INHERITs:0: inheriting /home/scott-lenovo/junk/classes/base.bbclass
|
|
||||||
DEBUG: BB /home/scott-lenovo/junk/classes/base.bbclass: handle(data, include)
|
|
||||||
DEBUG: LOAD /home/scott-lenovo/junk/classes/base.bbclass
|
|
||||||
DEBUG: Using cache in '/home/scott-lenovo/junk/tmp/cache/bb_codeparser.dat'
|
|
||||||
************************
|
|
||||||
* *
|
|
||||||
* Hello, World! *
|
|
||||||
* *
|
|
||||||
************************
|
|
||||||
DEBUG: Teardown for bitbake-worker
|
|
||||||
NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be rerun and all succeeded.
|
|
||||||
scott-lenovo@scott-lenovo:~/junk/conf [master #]
|
|
||||||
|
|
||||||
7. If you run it without the "-DDD" option, the output is cleaner.
|
|
||||||
|
|
||||||
scott-lenovo@scott-lenovo:~/junk [master #]
|
|
||||||
$ bitbake a
|
|
||||||
Parsing recipes: 100% |##########################################################################################| Time: 00:00:00
|
|
||||||
Parsing of 1 .bb files complete (0 cached, 1 parsed). 1 targets, 0 skipped, 0 masked, 0 errors.
|
|
||||||
NOTE: Resolving any missing task queue dependencies
|
|
||||||
NOTE: Preparing runqueue
|
|
||||||
NOTE: Executing RunQueue Tasks
|
|
||||||
************************
|
|
||||||
* *
|
|
||||||
* Hello, World! *
|
|
||||||
* *
|
|
||||||
************************
|
|
||||||
NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be rerun and all succeeded.
|
|
||||||
scott-lenovo@scott-lenovo:~/junk [master #]
|
|
||||||
</literallayout>
|
</literallayout>
|
||||||
</para>
|
In the sample output, BitBake could not find the
|
||||||
|
<filename>classes/base.bbclass</filename> file.
|
||||||
<para>
|
You need to create that file next.
|
||||||
You need to set
|
</para></listitem>
|
||||||
<link linkend='var-BBPATH'><filename>BBPATH</filename></link>.
|
<listitem><para><emphasis>Creating <filename>classes/base.bbclass</filename>:</emphasis>
|
||||||
</para>
|
BitBake uses class files to provide common code and functionality.
|
||||||
|
The minimally required class for BitBake is the
|
||||||
<para>
|
<filename>classes/base.bbclass</filename> file.
|
||||||
When you run BitBake, it begins looking for metadata files.
|
The <filename>base</filename> class is implicitly inherited by
|
||||||
The <filename>BBPATH</filename> variable is what tells
|
every recipe.
|
||||||
BitBake where to look.
|
BitBake looks for the class in the <filename>classes</filename>
|
||||||
You could set <filename>BBPATH</filename> in the same manner
|
directory of the project (i.e <filename>hello/classes</filename>
|
||||||
that you set <filename>PATH</filename> as shown earlier.
|
in this example).
|
||||||
However, it is much more flexible to set the
|
</para>
|
||||||
<link linkend='var-BBPATH'><filename>BBPATH</filename></link>
|
<para>Create the <filename>classes</filename> directory as follows:
|
||||||
variable for each project.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Without <filename>BBPATH</filename>, Bitbake cannot
|
|
||||||
find any configuration files (<filename>.conf</filename>)
|
|
||||||
or recipe files (<filename>.bb</filename>) at all.
|
|
||||||
BitBake also cannot find the <filename>bitbake.conf</filename>
|
|
||||||
file.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
It is standard practice to organize the project's directory tree
|
|
||||||
to include both a <filename>conf/</filename> and
|
|
||||||
<filename>classes/</filename> directory.
|
|
||||||
You need to add those directories to your project:
|
|
||||||
<literallayout class='monospaced'>
|
<literallayout class='monospaced'>
|
||||||
$ mkdir conf classes
|
$ cd $HOME/hello
|
||||||
|
$ mkdir classes
|
||||||
</literallayout>
|
</literallayout>
|
||||||
Once those directories are in place, you can copy the
|
Move to the <filename>classes</filename> directory and then
|
||||||
sample configuration files provided in the
|
create the <filename>base.bbclass</filename> file by inserting
|
||||||
BitBake source tree to their appropriate directories.
|
this single line:
|
||||||
First, change to the BitBake source tree directory and
|
|
||||||
then copy the directories:
|
|
||||||
<literallayout class='monospaced'>
|
<literallayout class='monospaced'>
|
||||||
cp conf/bitbake.conf ~/dev/hello/conf/
|
addtask build
|
||||||
cp classes/base.bbclass ~/dev/hello/classes/
|
|
||||||
</literallayout>
|
</literallayout>
|
||||||
At this point your project directory structure should look like
|
The minimal task that BitBake runs is the
|
||||||
the following:
|
<filename>do_build</filename> task.
|
||||||
<literallayout class='monospaced'>
|
This is all the example needs in order to build the project.
|
||||||
~/dev/hello$ tree
|
Of course, the <filename>base.bbclass</filename> can have much
|
||||||
.
|
more depending on which build environments BitBake is
|
||||||
|-- classes
|
supporting.
|
||||||
| +-- base.bbclass
|
For more information on the <filename>base.bbclass</filename> file,
|
||||||
+-- conf
|
you can look at
|
||||||
+-- bitbake.conf
|
<ulink url='http://hambedded.org/blog/2012/11/24/from-bitbake-hello-world-to-an-image/#tasks'></ulink>.
|
||||||
</literallayout>
|
</para></listitem>
|
||||||
</para>
|
<listitem><para><emphasis>Run Bitbake:</emphasis>
|
||||||
|
After making sure that the <filename>classes/base.bbclass</filename>
|
||||||
<para>
|
file exists, you can run the <filename>bitbake</filename>
|
||||||
Once you have copied these files into your project, you
|
command again:
|
||||||
can now get back to resolving the <filename>BBPATH</filename>
|
|
||||||
issue.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The first configuration file that BitBake looks for is always
|
|
||||||
<filename>bblayers.conf</filename>.
|
|
||||||
With this knowledge, you know that to resolve your
|
|
||||||
<filename>BBPATH</filename> error you can add a
|
|
||||||
<filename>conf/bblayers.conf</filename> file to the
|
|
||||||
project source tree and populate it with the
|
|
||||||
<filename>BBPATH</filename> variable declaration.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
From your project source tree:
|
|
||||||
<literallayout class='monospaced'>
|
<literallayout class='monospaced'>
|
||||||
$ vim conf/bblayers.conf
|
$ bitbake
|
||||||
</literallayout>
|
Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.
|
||||||
Now add the following to the empty
|
|
||||||
<filename>bblayers.conf</filename> file:
|
|
||||||
<literallayout class='monospaced'>
|
|
||||||
BBPATH := "${TOPDIR}"
|
|
||||||
</literallayout>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Now, from the root of your project directory, run BitBake
|
|
||||||
again and see what happens:
|
|
||||||
<literallayout class='monospaced'>
|
|
||||||
$ bitbake -DDD
|
|
||||||
Nothing to do. Use 'bitbake world' to build everything, or
|
|
||||||
run 'bitbake --help' for usage information.
|
|
||||||
DEBUG: Removed the following variables from the environment:
|
|
||||||
GNOME_DESKTOP_SESSION_ID, XDG_CURRENT_DESKTOP,
|
|
||||||
GNOME_KEYRING_CONTROL, DISPLAY, SSH_AGENT_PID, LANG, no_proxy,
|
|
||||||
XDG_SESSION_PATH, XAUTHORITY, SESSION_MANAGER, SHLVL,
|
|
||||||
MANDATORY_PATH, COMPIZ_CONFIG_PROFILE, WINDOWID, EDITOR,
|
|
||||||
GPG_AGENT_INFO, SSH_AUTH_SOCK, GDMSESSION, DEFAULTS_PATH,
|
|
||||||
XDG_SEAT_PATH, XDG_CONFIG_DIRS, LESSOPEN,
|
|
||||||
DBUS_SESSION_BUS_ADDRESS, _, XDG_SESSION_COOKIE,
|
|
||||||
DESKTOP_SESSION, LESSCLOSE, GNOME_KEYRING_PID, UBUNTU_MENUPROXY,
|
|
||||||
OLDPWD, XDG_DATA_DIRS, COLORTERM, LS_COLORS
|
|
||||||
DEBUG: Found bblayers.conf (/home/scott-lenovo/dev/hello/conf/bblayers.conf)
|
|
||||||
DEBUG: LOAD /home/scott-lenovo/dev/hello/conf/bblayers.conf
|
|
||||||
DEBUG: LOAD /home/scott-lenovo/dev/hello/conf/bitbake.conf
|
|
||||||
DEBUG: BB configuration INHERITs:0: inheriting /home/scott-lenovo/dev/hello/classes/base.bbclass
|
|
||||||
DEBUG: BB /home/scott-lenovo/dev/hello/classes/base.bbclass: handle(data, include)
|
|
||||||
DEBUG: LOAD /home/scott-lenovo/dev/hello/classes/base.bbclass
|
|
||||||
DEBUG: Clearing SRCREV cache due to cache policy of: clear
|
|
||||||
DEBUG: Using cache in '/home/scott-lenovo/dev/hello/tmp/cache/local_file_checksum_cache.dat'
|
|
||||||
DEBUG: Using cache in '/home/scott-lenovo/dev/hello/tmp/cache/bb_codeparser.dat'
|
|
||||||
DEBUG: Features set [3] (was [3])
|
|
||||||
</literallayout>
|
</literallayout>
|
||||||
|
BitBake is finally reporting no errors.
|
||||||
|
However, you can see that it really does not have anything
|
||||||
|
to do.
|
||||||
|
You need to create a recipe that gives BitBake something to do.
|
||||||
|
</para></listitem>
|
||||||
|
<listitem><para><emphasis>Creating a Layer:</emphasis>
|
||||||
|
While it is not really necessary for such a small example,
|
||||||
|
it is good practice to create a layer in which to keep your
|
||||||
|
code separate from the general metadata used by BitBake.
|
||||||
|
Thus, this example creates and uses a layer called "mylayer".
|
||||||
<note>
|
<note>
|
||||||
From this point forward in the example, the environment
|
You can find additional information on adding a layer at
|
||||||
variable removal messages are ignored and omitted.
|
<ulink url='http://hambedded.org/blog/2012/11/24/from-bitbake-hello-world-to-an-image/#adding-an-example-layer'></ulink>.
|
||||||
Examine the relevant DEBUG messages:
|
|
||||||
</note>
|
</note>
|
||||||
</para>
|
</para>
|
||||||
</section>
|
<para>Minimally, you need a recipe file and a layer configuration
|
||||||
|
file in your layer.
|
||||||
|
The configuration file needs to be in the <filename>conf</filename>
|
||||||
|
directory inside the layer.
|
||||||
|
Use these commands to set up the layer and the <filename>conf</filename>
|
||||||
|
directory:
|
||||||
|
<literallayout class='monospaced'>
|
||||||
|
$ cd $HOME
|
||||||
|
$ mkdir mylayer
|
||||||
|
$ cd mylayer
|
||||||
|
$ mkdir conf
|
||||||
|
</literallayout>
|
||||||
|
Move to the <filename>conf</filename> directory and create a
|
||||||
|
<filename>layer.conf</filename> file that has the following:
|
||||||
|
<literallayout class='monospaced'>
|
||||||
|
BBPATH .= ":${<link linkend='var-LAYERDIR'>LAYERDIR</link>}"
|
||||||
|
|
||||||
|
<link linkend='var-BBFILES'>BBFILES</link> += "${LAYERDIR}/*.bb"
|
||||||
|
|
||||||
|
<link linkend='var-BBFILE_COLLECTIONS'>BBFILE_COLLECTIONS</link> += "mylayer"
|
||||||
|
<link linkend='var-BBFILE_PATTERN'>BBFILE_PATTERN_mylayer</link> := "^${LAYERDIR}/"
|
||||||
|
</literallayout>
|
||||||
|
For information on these variables, click the links
|
||||||
|
to go to the definitions in the glossary.</para>
|
||||||
|
<para>You need to create the recipe file next.
|
||||||
|
Inside your layer at the top-level, use an editor and create
|
||||||
|
a recipe file named <filename>printhello.bb</filename> that
|
||||||
|
has the following:
|
||||||
|
<literallayout class='monospaced'>
|
||||||
|
<link linkend='var-DESCRIPTION'>DESCRIPTION</link> = "Prints Hello World"
|
||||||
|
<link linkend='var-PN'>PN</link> = 'printhello'
|
||||||
|
<link linkend='var-PV'>PV</link> = '1'
|
||||||
|
|
||||||
|
python do_build() {
|
||||||
|
bb.plain("********************");
|
||||||
|
bb.plain("* *");
|
||||||
|
bb.plain("* Hello, World! *");
|
||||||
|
bb.plain("* *");
|
||||||
|
bb.plain("********************");
|
||||||
|
}
|
||||||
|
</literallayout>
|
||||||
|
The recipe file simply provides a description of the
|
||||||
|
recipe, the name, version, and the <filename>do_build</filename>
|
||||||
|
task, which prints out "Hello World" to the console.
|
||||||
|
For more information on these variables, follow the links
|
||||||
|
to the glossary.
|
||||||
|
</para></listitem>
|
||||||
|
<listitem><para><emphasis>Run Bitbake With a Target:</emphasis>
|
||||||
|
Now that a BitBake target exists, run the command and provide
|
||||||
|
that target:
|
||||||
|
<literallayout class='monospaced'>
|
||||||
|
$ cd $HOME/hello
|
||||||
|
$ bitbake printhello
|
||||||
|
ERROR: no recipe files to build, check your BBPATH and BBFILES?
|
||||||
|
|
||||||
|
Summary: There was 1 ERROR message shown, returning a non-zero exit code.
|
||||||
|
</literallayout>
|
||||||
|
We have created the layer with the recipe and the layer
|
||||||
|
configuration file but it still seems that BitBake cannot
|
||||||
|
find the recipe.
|
||||||
|
BitBake needs a <filename>conf/bblayers.conf</filename> that
|
||||||
|
lists the layers for the project.
|
||||||
|
Without this file, BitBake cannot find the recipe.
|
||||||
|
</para></listitem>
|
||||||
|
<listitem><para><emphasis>Creating <filename>conf/bblayers.conf</filename>:</emphasis>
|
||||||
|
BitBake uses the <filename>conf/bblayers.conf</filename> file
|
||||||
|
to locate layers needed for the project.
|
||||||
|
This file must reside in the <filename>conf</filename> directory
|
||||||
|
of the project (i.e. <filename>hello/conf</filename> for this
|
||||||
|
example).</para>
|
||||||
|
<para>Set your working directory to the <filename>hello/conf</filename>
|
||||||
|
directory and then create the <filename>bblayers.conf</filename>
|
||||||
|
file so that it contains the following:
|
||||||
|
<literallayout class='monospaced'>
|
||||||
|
BBLAYERS ?= " \
|
||||||
|
/home/<you>/mylayer \
|
||||||
|
"
|
||||||
|
</literallayout>
|
||||||
|
You need to provide your own information for
|
||||||
|
<filename>you</filename> in the file.
|
||||||
|
</para></listitem>
|
||||||
|
<listitem><para><emphasis>Run Bitbake With a Target:</emphasis>
|
||||||
|
Now that you have supplied the <filename>bblayers.conf</filename>
|
||||||
|
file, run the <filename>bitbake</filename> command and provide
|
||||||
|
the target:
|
||||||
|
<literallayout class='monospaced'>
|
||||||
|
$ bitbake printhello
|
||||||
|
Parsing recipes: 100% |##################################################################################|
|
||||||
|
Time: 00:00:00
|
||||||
|
Parsing of 1 .bb files complete (0 cached, 1 parsed). 1 targets, 0 skipped, 0 masked, 0 errors.
|
||||||
|
NOTE: Resolving any missing task queue dependencies
|
||||||
|
NOTE: Preparing runqueue
|
||||||
|
NOTE: Executing RunQueue Tasks
|
||||||
|
********************
|
||||||
|
* *
|
||||||
|
* Hello, World! *
|
||||||
|
* *
|
||||||
|
********************
|
||||||
|
NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be rerun and all succeeded.
|
||||||
|
</literallayout>
|
||||||
|
BitBake finds the <filename>printhello</filename> recipe and
|
||||||
|
successfully runs the task.
|
||||||
|
<note>
|
||||||
|
Rerunning the task without removing the <filename>tmp</filename>
|
||||||
|
directory will not result in a BitBake run that prints the
|
||||||
|
same console output.
|
||||||
|
BitBake uses its Setscene process and determines that
|
||||||
|
nothing needs to be re-run.
|
||||||
|
If you delete the <filename>tmp</filename> directory and
|
||||||
|
then re-run the build, the printed output appears
|
||||||
|
at the console.
|
||||||
|
</note>
|
||||||
|
</para></listitem>
|
||||||
|
</orderedlist>
|
||||||
</section>
|
</section>
|
||||||
</appendix>
|
</appendix>
|
||||||
|
|||||||
Reference in New Issue
Block a user