diff options
author | Scott Rifenbark <scott.m.rifenbark@intel.com> | 2014-01-14 07:27:59 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-01-27 21:03:19 +0000 |
commit | 437791a23d7b82e23f63956857deb3ed5c4e3a21 (patch) | |
tree | 39dd7106446c15514e62e9d1aa280834f69eb482 /bitbake | |
parent | 1b08402519696de33d2a7e345191ccd39101dc54 (diff) | |
download | poky-437791a23d7b82e23f63956857deb3ed5c4e3a21.tar.gz |
bitbake: user-manual-hello.xml: Added new chapter for "Hello World Example"
This file was evidently a "working" file and not included in the
manual at the point Bill left off. The wmat branch, however, had
a load of commits dedicated to this file. Rather than attempt to
replay them all one-by-one, I simply copied the file from the
wmat branch and hand-inserted the changes to make it equal to what
was there. Note also that I re-formatted the file to have the
same formatting standards I use in the YP manuals.
(Bitbake rev: 9ddbf31ba7d05a596ca53b8ed78d94221850894b)
Signed-off-by: Scott Rifenbark <scott.m.rifenbark@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/doc/user-manual/user-manual-hello.xml | 321 |
1 files changed, 321 insertions, 0 deletions
diff --git a/bitbake/doc/user-manual/user-manual-hello.xml b/bitbake/doc/user-manual/user-manual-hello.xml new file mode 100644 index 0000000000..77869f80dd --- /dev/null +++ b/bitbake/doc/user-manual/user-manual-hello.xml | |||
@@ -0,0 +1,321 @@ | |||
1 | <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" | ||
2 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | ||
3 | |||
4 | <chapter id='hello'> | ||
5 | <title>A BitBake Hello World</title> | ||
6 | |||
7 | <section id='bitbake-hello-world'> | ||
8 | <title>BitBake Hello World</title> | ||
9 | |||
10 | <para> | ||
11 | The simplest example commonly used to demonstrate any new | ||
12 | programming language or tool is the | ||
13 | <ulink url="http://en.wikipedia.org/wiki/Hello_world_program">Hello World</ulink> | ||
14 | example. | ||
15 | This chapter demonstrates, in tutorial form, Hello | ||
16 | World within the context of BitBake. | ||
17 | This tutorial describes how to create a new Project | ||
18 | and the applicable metadata files necessary to allow | ||
19 | BitBake to build it. | ||
20 | </para> | ||
21 | </section> | ||
22 | |||
23 | <section id='obtaining-bitbake'> | ||
24 | <title>Obtaining BitBake</title> | ||
25 | |||
26 | <para> | ||
27 | Please refer to Chapter 1 Section 1.7 for the various methods to | ||
28 | obtain BitBake. | ||
29 | Once the source code is on your machine the BitBake directory will | ||
30 | appear as follows: | ||
31 | <literallayout class='monospaced'> | ||
32 | $ ls -al | ||
33 | total 100 | ||
34 | drwxrwxr-x. 9 wmat wmat 4096 Jan 31 13:44 . | ||
35 | drwxrwxr-x. 3 wmat wmat 4096 Feb 4 10:45 .. | ||
36 | -rw-rw-r--. 1 wmat wmat 365 Nov 26 04:55 AUTHORS | ||
37 | drwxrwxr-x. 2 wmat wmat 4096 Nov 26 04:55 bin | ||
38 | drwxrwxr-x. 4 wmat wmat 4096 Jan 31 13:44 build | ||
39 | -rw-rw-r--. 1 wmat wmat 16501 Nov 26 04:55 ChangeLog | ||
40 | drwxrwxr-x. 2 wmat wmat 4096 Nov 26 04:55 classes | ||
41 | drwxrwxr-x. 2 wmat wmat 4096 Nov 26 04:55 conf | ||
42 | drwxrwxr-x. 3 wmat wmat 4096 Nov 26 04:55 contrib | ||
43 | -rw-rw-r--. 1 wmat wmat 17987 Nov 26 04:55 COPYING | ||
44 | drwxrwxr-x. 3 wmat wmat 4096 Nov 26 04:55 doc | ||
45 | -rw-rw-r--. 1 wmat wmat 69 Nov 26 04:55 .gitignore | ||
46 | -rw-rw-r--. 1 wmat wmat 849 Nov 26 04:55 HEADER | ||
47 | drwxrwxr-x. 5 wmat wmat 4096 Jan 31 13:44 lib | ||
48 | -rw-rw-r--. 1 wmat wmat 195 Nov 26 04:55 MANIFEST.in | ||
49 | -rwxrwxr-x. 1 wmat wmat 3195 Jan 31 11:57 setup.py | ||
50 | -rw-rw-r--. 1 wmat wmat 2887 Nov 26 04:55 TODO | ||
51 | </literallayout> | ||
52 | </para> | ||
53 | |||
54 | <para> | ||
55 | At this point you should have BitBake extracted or cloned to | ||
56 | a directory and it should match the directory tree above. | ||
57 | Please note that you'll see your username wherever | ||
58 | "wmat" appears above. | ||
59 | </para> | ||
60 | </section> | ||
61 | |||
62 | <section id='setting-up-the-bitbake-environment'> | ||
63 | <title>Setting Up the BitBake Environment</title> | ||
64 | |||
65 | <para> | ||
66 | The recommended method to run BitBake is from a directory of your | ||
67 | choice. | ||
68 | The directory can be within your home directory or in | ||
69 | <filename>/usr/local</filename>, | ||
70 | depending on your preference. | ||
71 | Let's run BitBake now to make sure it's working. | ||
72 | </para> | ||
73 | |||
74 | <para> | ||
75 | From the BitBake source code directory, issue the following command: | ||
76 | <literallayout class='monospaced'> | ||
77 | $ ./bin/bitbake --version | ||
78 | BitBake Build Tool Core version 1.19.0, bitbake version | ||
79 | 1.19.0 | ||
80 | </literallayout> | ||
81 | You're now ready to use BitBake. | ||
82 | </para> | ||
83 | |||
84 | <para> | ||
85 | A final step to make development easier is to add the executable | ||
86 | binary to your environment <filename>PATH</filename>. | ||
87 | First, have a look at your current <filename>PATH</filename> variable. | ||
88 | If I check mine, I get: | ||
89 | <literallayout class='monospaced'> | ||
90 | $ echo $PATH | ||
91 | /home/wmat/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin: | ||
92 | /usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games | ||
93 | </literallayout> | ||
94 | Now add the directory location for the BitBake binary to the <filename>PATH</filename> | ||
95 | with: | ||
96 | <literallayout class='monospaced'> | ||
97 | $ export PATH={path to the bitbake executable}:$PATH | ||
98 | </literallayout> | ||
99 | This will add the directory to the beginning of your PATH environment | ||
100 | variable. | ||
101 | For example, on my machine: | ||
102 | <literallayout class='monospaced'> | ||
103 | $ export PATH=/media/wmat/Backups/dev/bitbake/bin:$PATH | ||
104 | /media/wmat/Backups/dev/bitbake/bin:/home/wmat/bin: | ||
105 | /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin: | ||
106 | /usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games | ||
107 | </literallayout> | ||
108 | Now, you should be able to simply enter the | ||
109 | <filename>bitbake</filename> | ||
110 | command at the command line to run bitbake. | ||
111 | For a more permanent solution and assuming you are running the BASH | ||
112 | shell, edit <filename>~/.bashrc</filename> and add the following to the end | ||
113 | of that file: | ||
114 | <literallayout class='monospaced'> | ||
115 | PATH={path to the bitbake executable}:$PATH | ||
116 | </literallayout> | ||
117 | </para> | ||
118 | |||
119 | <para> | ||
120 | Note that if you're a Vim user, you will find useful | ||
121 | Vim configuration contributions in the | ||
122 | <filename>contrib/vim</filename> directory. | ||
123 | Copy the files from that directory to your | ||
124 | <filename>/home/yourusername/.vim</filename> | ||
125 | directory. | ||
126 | If it doesn't exist, create it, and restart Vim. | ||
127 | </para> | ||
128 | </section> | ||
129 | |||
130 | <section id='the-hello-world-example'> | ||
131 | <title>The Hello World Example</title> | ||
132 | |||
133 | <para> | ||
134 | The following example leaps directly into how BitBake | ||
135 | works. | ||
136 | Every attempt is made to explain what is happening, | ||
137 | however, further information can be found in the | ||
138 | Metadata chapter. | ||
139 | </para> | ||
140 | |||
141 | <para> | ||
142 | The overall goal of this exercise is to create a Hello | ||
143 | World example utilizing concepts used to | ||
144 | build and construct a complete example application | ||
145 | including Tasks and Layers. | ||
146 | This is how modern projects such as OpenEmbedded and | ||
147 | the Yocto Project utilize BitBake, therefore it | ||
148 | provides an excellent starting point for understanding | ||
149 | BitBake. | ||
150 | </para> | ||
151 | |||
152 | <para> | ||
153 | It should be noted that this chapter was inspired by | ||
154 | and draws heavily from several sources: | ||
155 | <itemizedlist> | ||
156 | <listitem><para> | ||
157 | <ulink href="http://www.mail-archive.com/yocto@yoctoproject.org/msg09379.html">Mailing List post - The BitBake equivalent of "Hello, World!"</ulink> | ||
158 | </para></listitem> | ||
159 | <listitem><para> | ||
160 | <ulink href="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> | ||
161 | </para></listitem> | ||
162 | </itemizedlist> | ||
163 | </para> | ||
164 | |||
165 | <section id='a-reverse-walkthrough'> | ||
166 | <title>A Reverse Walkthrough</title> | ||
167 | |||
168 | <para> | ||
169 | One of the best means to understand anything is to walk | ||
170 | through the steps to where we want to be by observing first | ||
171 | principles. | ||
172 | BitBake allows us to do this through the -D or Debug command | ||
173 | line parameter. | ||
174 | We know we want to eventually compile a HelloWorld example, but | ||
175 | we don't know what we need to do that. | ||
176 | Remember that BitBake utilizes three types of metadata files: | ||
177 | Configuration Files, Classes, and Recipes. | ||
178 | But where do they go, how does BitBake find them, etc. etc.? | ||
179 | Hopefully we can use BitBake's error messaging to figure this | ||
180 | out and better understand exactly what's going on. | ||
181 | </para> | ||
182 | |||
183 | <para> | ||
184 | First, let's begin by setting up a directory for our HelloWorld | ||
185 | project. | ||
186 | I'll do this in my home directory and change into that | ||
187 | directory: | ||
188 | <literallayout class='monospaced'> | ||
189 | $ mkdir ~/dev/hello && cd ~/dev/hello | ||
190 | </literallayout> | ||
191 | Within this new, empty directory, let's run BitBake with | ||
192 | Debugging output and see what happens: | ||
193 | <literallayout class='monospaced'> | ||
194 | $ bitbake -DDD | ||
195 | The BBPATH variable is not set | ||
196 | DEBUG: Removed the following variables from the environment: | ||
197 | GNOME_DESKTOP_SESSION_ID, LESSOPEN, WINDOWID, | ||
198 | GNOME_KEYRING_CONTROL, DISPLAY, SSH_AGENT_PID, LANG, | ||
199 | XDG_SESSION_PATH, XAUTHORITY, LANGUAGE, SESSION_MANAGER, | ||
200 | SHLVL, MANDATORY_PATH, COMPIZ_CONFIG_PROFILE, TEXTDOMAIN, | ||
201 | GPG_AGENT_INFO, SSH_AUTH_SOCK, XDG_RUNTIME_DIR, | ||
202 | COMPIZ_BIN_PATH, GDMSESSION, DEFAULTS_PATH, TEXTDOMAINDIR, | ||
203 | XDG_SEAT_PATH, XDG_CONFIG_DIRS, XDG_CURRENT_DESKTOP, | ||
204 | DBUS_SESSION_BUS_ADDRESS, _, XDG_SESSION_COOKIE, | ||
205 | DESKTOP_SESSION, LESSCLOSE, GNOME_KEYRING_PID, | ||
206 | UBUNTU_MENUPROXY, OLDPWD, GTK_MODULES, XDG_DATA_DIRS, | ||
207 | COLORTERM, LS_COLORS | ||
208 | </literallayout> | ||
209 | The majority of this output is specific to environment variables | ||
210 | that are not directly relevant to BitBake. | ||
211 | However, the very | ||
212 | first message <filename>The BBPATH variable is not set</filename> | ||
213 | is and needs to be rectified. | ||
214 | So how do we set the BBPATH | ||
215 | variable? | ||
216 | </para> | ||
217 | |||
218 | <para> | ||
219 | When BitBake is run it begins looking for metadata files. | ||
220 | The BBPATH variable is what tells BitBake where to look. | ||
221 | It is possible to set BBPATH as an environment variable as you | ||
222 | did above for the BitBake exexcutable's PATH. | ||
223 | However, it's much more flexible to set the BBPATH variable for | ||
224 | each project, as this allows for greater flexibility. | ||
225 | </para> | ||
226 | |||
227 | <para> | ||
228 | Without BBPATH Bitbake will not find any <filename>.conf</filename> | ||
229 | files or recipe files at all. | ||
230 | It will also not find <filename>bitbake.conf</filename>. | ||
231 | Note the reference to <filename>conf/</filename>. | ||
232 | It is standard practice to organize the project's directory tree | ||
233 | to include a <filename>conf/</filename> and a | ||
234 | <filename>classes/</filename> directory. | ||
235 | Add those now to your project directory: | ||
236 | <literallayout class='monospaced'> | ||
237 | $ mkdir conf classes | ||
238 | </literallayout> | ||
239 | Now let's copy the sample configuration files provided in the | ||
240 | BitBake source tree to their appropriate conf and classes | ||
241 | directory. | ||
242 | Change to the BitBake source tree directory and: | ||
243 | <literallayout class='monospaced'> | ||
244 | cp conf/bitbake.conf ~/dev/hello/conf/ | ||
245 | cp classes/base.bbclass ~/dev/hello/classes/ | ||
246 | </literallayout> | ||
247 | At this point your project directory structure should look like | ||
248 | the following: | ||
249 | <literallayout class='monospaced'> | ||
250 | ~/dev/hello$ tree | ||
251 | . | ||
252 | ├── classes | ||
253 | │ └── base.bbclass | ||
254 | └── conf | ||
255 | └── bitbake.conf | ||
256 | </literallayout> | ||
257 | </para> | ||
258 | |||
259 | <para> | ||
260 | But what about BBPATH, we still haven't set it? | ||
261 | </para> | ||
262 | |||
263 | <para> | ||
264 | The first configuration file that BitBake looks for is always | ||
265 | <filename>bblayers.conf</filename>. | ||
266 | With this knowledge we know that to resolve our BBPATH error we | ||
267 | can add a <filename>conf/bblayers.conf</filename> file to our | ||
268 | project source tree and populate it with the BBPATH variable | ||
269 | declaration. | ||
270 | From your project source tree: | ||
271 | <literallayout class='monospaced'> | ||
272 | $ vim conf/bblayers.conf | ||
273 | </literallayout> | ||
274 | Add the following to the empty bblayers.conf file: | ||
275 | <literallayout class='monospaced'> | ||
276 | BBPATH := "${TOPDIR}" | ||
277 | </literallayout> | ||
278 | </para> | ||
279 | |||
280 | <para> | ||
281 | Now from the root of our project directory, let's run BitBake | ||
282 | again and see what happens: | ||
283 | <literallayout class='monospaced'> | ||
284 | $ bitbake -DDD | ||
285 | Nothing to do. Use 'bitbake world' to build everything, or run | ||
286 | 'bitbake --help' for usage information. | ||
287 | DEBUG: Removed the following variables from the environment: | ||
288 | GNOME_DESKTOP_SESSION_ID, LESSOPEN, WINDOWID, | ||
289 | GNOME_KEYRING_CONTROL, DISPLAY, SSH_AGENT_PID, LANG, | ||
290 | XDG_SESSION_PATH, XAUTHORITY, LANGUAGE, SESSION_MANAGER, | ||
291 | SHLVL, MANDATORY_PATH, COMPIZ_CONFIG_PROFILE, TEXTDOMAIN, | ||
292 | GPG_AGENT_INFO, SSH_AUTH_SOCK, XDG_RUNTIME_DIR, | ||
293 | COMPIZ_BIN_PATH, GDMSESSION, DEFAULTS_PATH, TEXTDOMAINDIR, | ||
294 | XDG_SEAT_PATH, XDG_CONFIG_DIRS, XDG_CURRENT_DESKTOP, | ||
295 | DBUS_SESSION_BUS_ADDRESS, _, XDG_SESSION_COOKIE, | ||
296 | DESKTOP_SESSION, LESSCLOSE, GNOME_KEYRING_PID, UBUNTU_MENUPROXY, | ||
297 | OLDPWD, GTK_MODULES, XDG_DATA_DIRS, COLORTERM, LS_COLORS | ||
298 | DEBUG: Found bblayers.conf (/home/wmat/dev/hello/conf/ | ||
299 | bblayers.conf) | ||
300 | DEBUG: LOAD /home/wmat/dev/hello/conf/bblayers.conf | ||
301 | DEBUG: LOAD /home/wmat/dev/hello/conf/bitbake.conf | ||
302 | DEBUG: BB configuration INHERITs:0: inheriting /home/wmat/dev/ | ||
303 | hello/classes/base.bbclass | ||
304 | DEBUG: BB /home/wmat/dev/hello/classes/base.bbclass: handle | ||
305 | (data, include) | ||
306 | DEBUG: LOAD /home/wmat/dev/hello/classes/base.bbclass | ||
307 | DEBUG: Clearing SRCREV cache due to cache policy of: clear | ||
308 | DEBUG: Using cache in '/home/wmat/dev/hello/tmp/cache/ | ||
309 | local_file_checksum_cache.dat' | ||
310 | DEBUG: Using cache in '/home/wmat/dev/hello/tmp/cache/ | ||
311 | bb_codeparser.dat' | ||
312 | </literallayout> | ||
313 | <note> | ||
314 | From this point forward, the environment variable | ||
315 | removal messages will be ignored and omitted. | ||
316 | Let's examine the relevant DEBUG messages: | ||
317 | </note> | ||
318 | </para> | ||
319 | </section> | ||
320 | </section> | ||
321 | </chapter> | ||