diff options
Diffstat (limited to 'bitbake/doc/user-manual/user-manual-hello.xml')
-rw-r--r-- | bitbake/doc/user-manual/user-manual-hello.xml | 334 |
1 files changed, 0 insertions, 334 deletions
diff --git a/bitbake/doc/user-manual/user-manual-hello.xml b/bitbake/doc/user-manual/user-manual-hello.xml deleted file mode 100644 index 5a616e07b3..0000000000 --- a/bitbake/doc/user-manual/user-manual-hello.xml +++ /dev/null | |||
@@ -1,334 +0,0 @@ | |||
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 | <appendix id='hello-world-example'> | ||
5 | <title>Hello World Example</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 appendix demonstrates, in tutorial form, Hello | ||
16 | World within the context of BitBake. | ||
17 | The 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='example-obtaining-bitbake'> | ||
24 | <title>Obtaining BitBake</title> | ||
25 | |||
26 | <para> | ||
27 | See the | ||
28 | "<link linkend='obtaining-bitbake'>Obtaining BitBake</link>" | ||
29 | section for information on how to obtain BitBake. | ||
30 | Once you have the source code on your machine, the BitBake directory | ||
31 | appears as follows: | ||
32 | <literallayout class='monospaced'> | ||
33 | $ ls -al | ||
34 | total 100 | ||
35 | drwxrwxr-x. 9 wmat wmat 4096 Jan 31 13:44 . | ||
36 | drwxrwxr-x. 3 wmat wmat 4096 Feb 4 10:45 .. | ||
37 | -rw-rw-r--. 1 wmat wmat 365 Nov 26 04:55 AUTHORS | ||
38 | drwxrwxr-x. 2 wmat wmat 4096 Nov 26 04:55 bin | ||
39 | drwxrwxr-x. 4 wmat wmat 4096 Jan 31 13:44 build | ||
40 | -rw-rw-r--. 1 wmat wmat 16501 Nov 26 04:55 ChangeLog | ||
41 | drwxrwxr-x. 2 wmat wmat 4096 Nov 26 04:55 classes | ||
42 | drwxrwxr-x. 2 wmat wmat 4096 Nov 26 04:55 conf | ||
43 | drwxrwxr-x. 3 wmat wmat 4096 Nov 26 04:55 contrib | ||
44 | -rw-rw-r--. 1 wmat wmat 17987 Nov 26 04:55 COPYING | ||
45 | drwxrwxr-x. 3 wmat wmat 4096 Nov 26 04:55 doc | ||
46 | -rw-rw-r--. 1 wmat wmat 69 Nov 26 04:55 .gitignore | ||
47 | -rw-rw-r--. 1 wmat wmat 849 Nov 26 04:55 HEADER | ||
48 | drwxrwxr-x. 5 wmat wmat 4096 Jan 31 13:44 lib | ||
49 | -rw-rw-r--. 1 wmat wmat 195 Nov 26 04:55 MANIFEST.in | ||
50 | -rwxrwxr-x. 1 wmat wmat 3195 Jan 31 11:57 setup.py | ||
51 | -rw-rw-r--. 1 wmat wmat 2887 Nov 26 04:55 TODO | ||
52 | </literallayout> | ||
53 | </para> | ||
54 | |||
55 | <para> | ||
56 | At this point, you should have BitBake cloned to | ||
57 | a directory that matches the previous listing except for | ||
58 | dates and user names. | ||
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 | </para> | ||
72 | |||
73 | <para> | ||
74 | First, run BitBake to make sure it's working. | ||
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 are 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, look at your current <filename>PATH</filename> variable | ||
88 | by entering the following: | ||
89 | <literallayout class='monospaced'> | ||
90 | $ echo $PATH | ||
91 | </literallayout> | ||
92 | Next, add the directory location for the BitBake binary to the | ||
93 | <filename>PATH</filename> using this form: | ||
94 | <literallayout class='monospaced'> | ||
95 | $ export PATH=<path-to-bitbake-executable>:$PATH | ||
96 | </literallayout> | ||
97 | This will add the directory to the beginning of your | ||
98 | <filename>PATH</filename> environment variable. | ||
99 | You should now be able to enter the <filename>bitbake</filename> | ||
100 | command at the command line to run BitBake. | ||
101 | </para> | ||
102 | |||
103 | <para> | ||
104 | For a more permanent solution assuming you are running the BASH | ||
105 | shell, edit <filename>~/.bashrc</filename> and add the following to the end | ||
106 | of that file: | ||
107 | <literallayout class='monospaced'> | ||
108 | PATH=<path-to-bitbake-executable>:$PATH | ||
109 | </literallayout> | ||
110 | </para> | ||
111 | |||
112 | <para> | ||
113 | If you're a Vim user, you will find useful | ||
114 | Vim configuration contributions in the | ||
115 | <filename>contrib/vim</filename> directory. | ||
116 | Copy the files from that directory to your | ||
117 | <filename>/home/yourusername/.vim</filename> | ||
118 | directory. | ||
119 | If that directory does not exist, create it, and then | ||
120 | restart Vim. | ||
121 | </para> | ||
122 | </section> | ||
123 | |||
124 | <section id='the-hello-world-example'> | ||
125 | <title>The Hello World Example</title> | ||
126 | |||
127 | <para> | ||
128 | The following example leaps directly into how BitBake | ||
129 | works. | ||
130 | While every attempt is made to explain what is happening, | ||
131 | not everything can be covered. | ||
132 | You can find further information in the | ||
133 | "<link linkend='user-manual-metadata'>Syntax and Operators</link>" | ||
134 | chapter. | ||
135 | </para> | ||
136 | |||
137 | <para> | ||
138 | The overall goal of this exercise is to build a | ||
139 | complete "Hello World" example utilizing task and layer | ||
140 | concepts. | ||
141 | This is how modern projects such as OpenEmbedded and | ||
142 | the Yocto Project utilize BitBake, therefore it | ||
143 | provides an excellent starting point for understanding | ||
144 | BitBake. | ||
145 | </para> | ||
146 | |||
147 | <para> | ||
148 | It should be noted that this chapter was inspired by | ||
149 | and draws heavily from several sources: | ||
150 | <itemizedlist> | ||
151 | <listitem><para> | ||
152 | <ulink href="http://www.mail-archive.com/yocto@yoctoproject.org/msg09379.html">Mailing List post - The BitBake equivalent of "Hello, World!"</ulink> | ||
153 | </para></listitem> | ||
154 | <listitem><para> | ||
155 | <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> | ||
156 | </para></listitem> | ||
157 | </itemizedlist> | ||
158 | </para> | ||
159 | |||
160 | <section id='a-reverse-walk-through'> | ||
161 | <title>A Reverse Walk-Through</title> | ||
162 | |||
163 | <para> | ||
164 | A good way to understand anything is to walk through the steps | ||
165 | that take you to where you want to be and observe first | ||
166 | principles. | ||
167 | BitBake allows us to do this through the | ||
168 | <filename>-D</filename> or <filename>Debug</filename> | ||
169 | command-line parameter. | ||
170 | </para> | ||
171 | |||
172 | <para> | ||
173 | The goal is to eventually compile a "Hello World" example. | ||
174 | However, it is unknown what is needed to achieve that goal. | ||
175 | Recall that BitBake utilizes three types of metadata files: | ||
176 | <link linkend='configuration-files'>Configuration Files</link>, | ||
177 | <link linkend='classes'>Classes</link>, and | ||
178 | <link linkend='recipes'>Recipes</link>. | ||
179 | But where do they go? | ||
180 | How does BitBake find them? | ||
181 | BitBake's error messaging helps you answer these types of questions | ||
182 | and helps you better understand exactly what is going on. | ||
183 | </para> | ||
184 | |||
185 | <para> | ||
186 | First, set up a directory for the "Hello World" project. | ||
187 | Here is how you can do so in your home directory: | ||
188 | <literallayout class='monospaced'> | ||
189 | $ mkdir ~/dev/hello && cd ~/dev/hello | ||
190 | </literallayout> | ||
191 | Within this new, empty directory, 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 first message | ||
212 | "<filename>The BBPATH variable is not set</filename>" | ||
213 | is relevant and you need to rectify it by setting | ||
214 | <link linkend='var-BBPATH'><filename>BBPATH</filename></link>. | ||
215 | </para> | ||
216 | |||
217 | <para> | ||
218 | When you run BitBake, it begins looking for metadata files. | ||
219 | The <filename>BBPATH</filename> variable is what tells | ||
220 | BitBake where to look. | ||
221 | You could set <filename>BBPATH</filename> in the same manner | ||
222 | that you set <filename>PATH</filename> as shown earlier. | ||
223 | However, it is much more flexible to set the | ||
224 | <link linkend='var-BBPATH'><filename>BBPATH</filename></link> | ||
225 | variable for each project. | ||
226 | </para> | ||
227 | |||
228 | <para> | ||
229 | Without <filename>BBPATH</filename>, Bitbake cannot | ||
230 | find any configuration files (<filename>.conf</filename>) | ||
231 | or recipe files (<filename>.bb</filename>) at all. | ||
232 | BitBake also cannot find the <filename>bitbake.conf</filename> | ||
233 | file. | ||
234 | </para> | ||
235 | |||
236 | <para> | ||
237 | It is standard practice to organize the project's directory tree | ||
238 | to include both a <filename>conf/</filename> and | ||
239 | <filename>classes/</filename> directory. | ||
240 | You need to add those directories to your project: | ||
241 | <literallayout class='monospaced'> | ||
242 | $ mkdir conf classes | ||
243 | </literallayout> | ||
244 | Once those directories are in place, you can copy the | ||
245 | sample configuration files provided in the | ||
246 | BitBake source tree to their appropriate directories. | ||
247 | First, change to the BitBake source tree directory and | ||
248 | then copy the directories: | ||
249 | <literallayout class='monospaced'> | ||
250 | cp conf/bitbake.conf ~/dev/hello/conf/ | ||
251 | cp classes/base.bbclass ~/dev/hello/classes/ | ||
252 | </literallayout> | ||
253 | At this point your project directory structure should look like | ||
254 | the following: | ||
255 | <literallayout class='monospaced'> | ||
256 | ~/dev/hello$ tree | ||
257 | . | ||
258 | |-- classes | ||
259 | | +-- base.bbclass | ||
260 | +-- conf | ||
261 | +-- bitbake.conf | ||
262 | </literallayout> | ||
263 | </para> | ||
264 | |||
265 | <para> | ||
266 | Once you have copied these files into your project, you | ||
267 | can now get back to resolving the <filename>BBPATH</filename> | ||
268 | issue. | ||
269 | </para> | ||
270 | |||
271 | <para> | ||
272 | The first configuration file that BitBake looks for is always | ||
273 | <filename>bblayers.conf</filename>. | ||
274 | With this knowledge, you know that to resolve your | ||
275 | <filename>BBPATH</filename> error you can add a | ||
276 | <filename>conf/bblayers.conf</filename> file to the | ||
277 | project source tree and populate it with the | ||
278 | <filename>BBPATH</filename> variable declaration. | ||
279 | </para> | ||
280 | |||
281 | <para> | ||
282 | From your project source tree: | ||
283 | <literallayout class='monospaced'> | ||
284 | $ vim conf/bblayers.conf | ||
285 | </literallayout> | ||
286 | Now add the following to the empty | ||
287 | <filename>bblayers.conf</filename> file: | ||
288 | <literallayout class='monospaced'> | ||
289 | BBPATH := "${TOPDIR}" | ||
290 | </literallayout> | ||
291 | </para> | ||
292 | |||
293 | <para> | ||
294 | Now, from the root of your project directory, run BitBake | ||
295 | again and see what happens: | ||
296 | <literallayout class='monospaced'> | ||
297 | $ bitbake -DDD | ||
298 | Nothing to do. Use 'bitbake world' to build everything, or run | ||
299 | 'bitbake --help' for usage information. | ||
300 | DEBUG: Removed the following variables from the environment: | ||
301 | GNOME_DESKTOP_SESSION_ID, LESSOPEN, WINDOWID, | ||
302 | GNOME_KEYRING_CONTROL, DISPLAY, SSH_AGENT_PID, LANG, | ||
303 | XDG_SESSION_PATH, XAUTHORITY, LANGUAGE, SESSION_MANAGER, | ||
304 | SHLVL, MANDATORY_PATH, COMPIZ_CONFIG_PROFILE, TEXTDOMAIN, | ||
305 | GPG_AGENT_INFO, SSH_AUTH_SOCK, XDG_RUNTIME_DIR, | ||
306 | COMPIZ_BIN_PATH, GDMSESSION, DEFAULTS_PATH, TEXTDOMAINDIR, | ||
307 | XDG_SEAT_PATH, XDG_CONFIG_DIRS, XDG_CURRENT_DESKTOP, | ||
308 | DBUS_SESSION_BUS_ADDRESS, _, XDG_SESSION_COOKIE, | ||
309 | DESKTOP_SESSION, LESSCLOSE, GNOME_KEYRING_PID, UBUNTU_MENUPROXY, | ||
310 | OLDPWD, GTK_MODULES, XDG_DATA_DIRS, COLORTERM, LS_COLORS | ||
311 | DEBUG: Found bblayers.conf (/home/wmat/dev/hello/conf/ | ||
312 | bblayers.conf) | ||
313 | DEBUG: LOAD /home/wmat/dev/hello/conf/bblayers.conf | ||
314 | DEBUG: LOAD /home/wmat/dev/hello/conf/bitbake.conf | ||
315 | DEBUG: BB configuration INHERITs:0: inheriting /home/wmat/dev/ | ||
316 | hello/classes/base.bbclass | ||
317 | DEBUG: BB /home/wmat/dev/hello/classes/base.bbclass: handle | ||
318 | (data, include) | ||
319 | DEBUG: LOAD /home/wmat/dev/hello/classes/base.bbclass | ||
320 | DEBUG: Clearing SRCREV cache due to cache policy of: clear | ||
321 | DEBUG: Using cache in '/home/wmat/dev/hello/tmp/cache/ | ||
322 | local_file_checksum_cache.dat' | ||
323 | DEBUG: Using cache in '/home/wmat/dev/hello/tmp/cache/ | ||
324 | bb_codeparser.dat' | ||
325 | </literallayout> | ||
326 | <note> | ||
327 | From this point forward in the example, the environment | ||
328 | variable removal messages are ignored and omitted. | ||
329 | Examine the relevant DEBUG messages: | ||
330 | </note> | ||
331 | </para> | ||
332 | </section> | ||
333 | </section> | ||
334 | </appendix> | ||