1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-30 12:29:55 +00:00

bitbake: user-manual: Added "Hello World" Appendix.

I took Bill's chapter and made it into an appendix.  I did some
re-writing to make it not so much like a getting-started feel,
although it still leans way that way for an appendix.  The content
is not complete.

Had to add in a line to the user-manual.xml file so that the
new appendix would be part of the book.

Had to use a different form of the command in the
user-manual-cusomization.xsl file in order to not through a bunch
of errors for an unrecognized parameter value.  I commented out
the existing one.

(Bitbake rev: 80e9306c288ca2ab42585f99fb0f396253cb8253)

Signed-off-by: Scott Rifenbark <scott.m.rifenbark@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Scott Rifenbark
2014-02-19 16:15:38 -06:00
committed by Richard Purdie
parent 9b3e31e5e1
commit 4cd882b9d0
3 changed files with 117 additions and 101 deletions
@@ -5,9 +5,10 @@
<xsl:param name="html.stylesheet" select="'user-manual-style.css'" /> <xsl:param name="html.stylesheet" select="'user-manual-style.css'" />
<xsl:param name="chapter.autolabel" select="1" /> <xsl:param name="chapter.autolabel" select="1" />
<xsl:param name="appendix.autolabel" select="A" /> <!-- <xsl:param name="appendix.autolabel" select="A" /> -->
<xsl:param name="section.autolabel" select="1" /> <xsl:param name="section.autolabel" select="1" />
<xsl:param name="section.label.includes.component.label" select="1" /> <xsl:param name="section.label.includes.component.label" select="1" />
<xsl:param name="appendix.autolabel">A</xsl:param>
<!-- <xsl:param name="generate.toc" select="'article nop'"></xsl:param> --> <!-- <xsl:param name="generate.toc" select="'article nop'"></xsl:param> -->
+113 -100
View File
@@ -1,8 +1,8 @@
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<chapter id='hello'> <appendix id='hello-world-example'>
<title>A BitBake Hello World</title> <title>Hello World Example</title>
<section id='bitbake-hello-world'> <section id='bitbake-hello-world'>
<title>BitBake Hello World</title> <title>BitBake Hello World</title>
@@ -12,22 +12,23 @@
programming language or tool is the programming language or tool is the
<ulink url="http://en.wikipedia.org/wiki/Hello_world_program">Hello World</ulink> <ulink url="http://en.wikipedia.org/wiki/Hello_world_program">Hello World</ulink>
example. example.
This chapter demonstrates, in tutorial form, Hello This appendix demonstrates, in tutorial form, Hello
World within the context of BitBake. World within the context of BitBake.
This tutorial describes how to create a new Project The tutorial describes how to create a new Project
and the applicable metadata files necessary to allow and the applicable metadata files necessary to allow
BitBake to build it. BitBake to build it.
</para> </para>
</section> </section>
<section id='obtaining-bitbake'> <section id='example-obtaining-bitbake'>
<title>Obtaining BitBake</title> <title>Obtaining BitBake</title>
<para> <para>
Please refer to Chapter 1 Section 1.7 for the various methods to See the
obtain BitBake. "<link linkend='obtaining-bitbake'>Obtaining BitBake</link>"
Once the source code is on your machine the BitBake directory will section for information on how to obtain BitBake.
appear as follows: Once you have the source code on your machine, the BitBake directory
appears as follows:
<literallayout class='monospaced'> <literallayout class='monospaced'>
$ ls -al $ ls -al
total 100 total 100
@@ -52,10 +53,9 @@
</para> </para>
<para> <para>
At this point you should have BitBake extracted or cloned to At this point, you should have BitBake cloned to
a directory and it should match the directory tree above. a directory that matches the previous listing except for
Please note that you'll see your username wherever dates and user names.
"wmat" appears above.
</para> </para>
</section> </section>
@@ -68,62 +68,56 @@
The directory can be within your home directory or in The directory can be within your home directory or in
<filename>/usr/local</filename>, <filename>/usr/local</filename>,
depending on your preference. depending on your preference.
Let's run BitBake now to make sure it's working.
</para> </para>
<para> <para>
First, run BitBake to make sure it's working.
From the BitBake source code directory, issue the following command: From the BitBake source code directory, issue the following command:
<literallayout class='monospaced'> <literallayout class='monospaced'>
$ ./bin/bitbake --version $ ./bin/bitbake --version
BitBake Build Tool Core version 1.19.0, bitbake version BitBake Build Tool Core version 1.19.0, bitbake version
1.19.0 1.19.0
</literallayout> </literallayout>
You're now ready to use BitBake. You are now ready to use BitBake.
</para> </para>
<para> <para>
A final step to make development easier is to add the executable A final step to make development easier is to add the executable
binary to your environment <filename>PATH</filename>. binary to your environment <filename>PATH</filename>.
First, have a look at your current <filename>PATH</filename> variable. First, look at your current <filename>PATH</filename> variable
If I check mine, I get: by entering the following:
<literallayout class='monospaced'> <literallayout class='monospaced'>
$ echo $PATH $ echo $PATH
/home/wmat/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:
/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
</literallayout> </literallayout>
Now add the directory location for the BitBake binary to the <filename>PATH</filename> Next, add the directory location for the BitBake binary to the
with: <filename>PATH</filename> using this form:
<literallayout class='monospaced'> <literallayout class='monospaced'>
$ export PATH={path to the bitbake executable}:$PATH $ export PATH=&lt;path-to-bitbake-executable&gt;:$PATH
</literallayout> </literallayout>
This will add the directory to the beginning of your PATH environment This will add the directory to the beginning of your
variable. <filename>PATH</filename> environment variable.
For example, on my machine: You should now be able to enter the <filename>bitbake</filename>
<literallayout class='monospaced'> command at the command line to run BitBake.
$ export PATH=/media/wmat/Backups/dev/bitbake/bin:$PATH </para>
/media/wmat/Backups/dev/bitbake/bin:/home/wmat/bin:
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin: <para>
/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games For a more permanent solution assuming you are running the BASH
</literallayout>
Now, you should be able to simply enter the
<filename>bitbake</filename>
command at the command line to run bitbake.
For a more permanent solution and assuming you are running the BASH
shell, edit <filename>~/.bashrc</filename> and add the following to the end shell, edit <filename>~/.bashrc</filename> and add the following to the end
of that file: of that file:
<literallayout class='monospaced'> <literallayout class='monospaced'>
PATH={path to the bitbake executable}:$PATH PATH=&lt;path-to-bitbake-executable&gt;:$PATH
</literallayout> </literallayout>
</para> </para>
<para> <para>
Note that if you're a Vim user, you will find useful If you're a Vim user, you will find useful
Vim configuration contributions in the Vim configuration contributions in the
<filename>contrib/vim</filename> directory. <filename>contrib/vim</filename> directory.
Copy the files from that directory to your Copy the files from that directory to your
<filename>/home/yourusername/.vim</filename> <filename>/home/yourusername/.vim</filename>
directory. directory.
If it doesn't exist, create it, and restart Vim. If that directory does not exist, create it, and then
restart Vim.
</para> </para>
</section> </section>
@@ -133,16 +127,17 @@
<para> <para>
The following example leaps directly into how BitBake The following example leaps directly into how BitBake
works. works.
Every attempt is made to explain what is happening, While every attempt is made to explain what is happening,
however, further information can be found in the not everything can be covered.
Metadata chapter. You can find further information in the
"<link linkend='user-manual-metadata'>Syntax and Operators</link>"
chapter.
</para> </para>
<para> <para>
The overall goal of this exercise is to create a Hello The overall goal of this exercise is to build a
World example utilizing concepts used to complete "Hello World" example utilizing task and layer
build and construct a complete example application concepts.
including Tasks and Layers.
This is how modern projects such as OpenEmbedded and This is how modern projects such as OpenEmbedded and
the Yocto Project utilize BitBake, therefore it the Yocto Project utilize BitBake, therefore it
provides an excellent starting point for understanding provides an excellent starting point for understanding
@@ -162,34 +157,39 @@
</itemizedlist> </itemizedlist>
</para> </para>
<section id='a-reverse-walkthrough'> <section id='a-reverse-walk-through'>
<title>A Reverse Walkthrough</title> <title>A Reverse Walk-Through</title>
<para> <para>
One of the best means to understand anything is to walk A good way to understand anything is to walk through the steps
through the steps to where we want to be by observing first that take you to where you want to be and observe first
principles. principles.
BitBake allows us to do this through the -D or Debug command BitBake allows us to do this through the
line parameter. <filename>-D</filename> or <filename>Debug</filename>
We know we want to eventually compile a HelloWorld example, but command-line parameter.
we don't know what we need to do that.
Remember that BitBake utilizes three types of metadata files:
Configuration Files, Classes, and Recipes.
But where do they go, how does BitBake find them, etc. etc.?
Hopefully we can use BitBake's error messaging to figure this
out and better understand exactly what's going on.
</para> </para>
<para> <para>
First, let's begin by setting up a directory for our HelloWorld The goal is to eventually compile a "Hello World" example.
project. However, it is unknown what is needed to achieve that goal.
I'll do this in my home directory and change into that Recall that BitBake utilizes three types of metadata files:
directory: <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.
Here is how you can do so in your home directory:
<literallayout class='monospaced'> <literallayout class='monospaced'>
$ mkdir ~/dev/hello &amp;&amp; cd ~/dev/hello $ mkdir ~/dev/hello &amp;&amp; cd ~/dev/hello
</literallayout> </literallayout>
Within this new, empty directory, let's run BitBake with Within this new, empty directory, run BitBake with
Debugging output and see what happens: debugging output and see what happens:
<literallayout class='monospaced'> <literallayout class='monospaced'>
$ bitbake -DDD $ bitbake -DDD
The BBPATH variable is not set The BBPATH variable is not set
@@ -208,38 +208,44 @@
</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 However, the very first message
first message <filename>The BBPATH variable is not set</filename> "<filename>The BBPATH variable is not set</filename>"
is and needs to be rectified. is relevant and you need to rectify it by setting
So how do we set the BBPATH <link linkend='var-BBPATH'><filename>BBPATH</filename></link>.
variable?
</para> </para>
<para> <para>
When BitBake is run it begins looking for metadata files. When you run BitBake, it begins looking for metadata files.
The BBPATH variable is what tells BitBake where to look. The <filename>BBPATH</filename> variable is what tells
It is possible to set BBPATH as an environment variable as you BitBake where to look.
did above for the BitBake exexcutable's PATH. You could set <filename>BBPATH</filename> in the same manner
However, it's much more flexible to set the BBPATH variable for that you set <filename>PATH</filename> as shown earlier.
each project, as this allows for greater flexibility. However, it is much more flexible to set the
<link linkend='var-BBPATH'><filename>BBPATH</filename></link>
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>
<para> <para>
Without BBPATH Bitbake will not find any <filename>.conf</filename>
files or recipe files at all.
It will also not find <filename>bitbake.conf</filename>.
Note the reference to <filename>conf/</filename>.
It is standard practice to organize the project's directory tree It is standard practice to organize the project's directory tree
to include a <filename>conf/</filename> and a to include both a <filename>conf/</filename> and
<filename>classes/</filename> directory. <filename>classes/</filename> directory.
Add those now to your project directory: You need to add those directories to your project:
<literallayout class='monospaced'> <literallayout class='monospaced'>
$ mkdir conf classes $ mkdir conf classes
</literallayout> </literallayout>
Now let's copy the sample configuration files provided in the Once those directories are in place, you can copy the
BitBake source tree to their appropriate conf and classes sample configuration files provided in the
directory. BitBake source tree to their appropriate directories.
Change to the BitBake source tree directory and: 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/ cp conf/bitbake.conf ~/dev/hello/conf/
cp classes/base.bbclass ~/dev/hello/classes/ cp classes/base.bbclass ~/dev/hello/classes/
@@ -249,36 +255,43 @@
<literallayout class='monospaced'> <literallayout class='monospaced'>
~/dev/hello$ tree ~/dev/hello$ tree
. .
├── classes |-- classes
   └── base.bbclass |   +-- base.bbclass
└── conf +-- conf
└── bitbake.conf +-- bitbake.conf
</literallayout> </literallayout>
</para> </para>
<para> <para>
But what about BBPATH, we still haven't set it? Once you have copied these files into your project, you
can now get back to resolving the <filename>BBPATH</filename>
issue.
</para> </para>
<para> <para>
The first configuration file that BitBake looks for is always The first configuration file that BitBake looks for is always
<filename>bblayers.conf</filename>. <filename>bblayers.conf</filename>.
With this knowledge we know that to resolve our BBPATH error we With this knowledge, you know that to resolve your
can add a <filename>conf/bblayers.conf</filename> file to our <filename>BBPATH</filename> error you can add a
project source tree and populate it with the BBPATH variable <filename>conf/bblayers.conf</filename> file to the
declaration. project source tree and populate it with the
<filename>BBPATH</filename> variable declaration.
</para>
<para>
From your project source tree: From your project source tree:
<literallayout class='monospaced'> <literallayout class='monospaced'>
$ vim conf/bblayers.conf $ vim conf/bblayers.conf
</literallayout> </literallayout>
Add the following to the empty bblayers.conf file: Now add the following to the empty
<filename>bblayers.conf</filename> file:
<literallayout class='monospaced'> <literallayout class='monospaced'>
BBPATH := "${TOPDIR}" BBPATH := "${TOPDIR}"
</literallayout> </literallayout>
</para> </para>
<para> <para>
Now from the root of our project directory, let's run BitBake Now, from the root of your project directory, run BitBake
again and see what happens: again and see what happens:
<literallayout class='monospaced'> <literallayout class='monospaced'>
$ bitbake -DDD $ bitbake -DDD
@@ -311,11 +324,11 @@
bb_codeparser.dat' bb_codeparser.dat'
</literallayout> </literallayout>
<note> <note>
From this point forward, the environment variable From this point forward in the example, the environment
removal messages will be ignored and omitted. variable removal messages are ignored and omitted.
Let's examine the relevant DEBUG messages: Examine the relevant DEBUG messages:
</note> </note>
</para> </para>
</section> </section>
</section> </section>
</chapter> </appendix>
+2
View File
@@ -85,4 +85,6 @@
<xi:include href="user-manual-ref-variables.xml"/> <xi:include href="user-manual-ref-variables.xml"/>
<xi:include href="user-manual-hello.xml"/>
</book> </book>