diff options
author | Scott Rifenbark <scott.m.rifenbark@intel.com> | 2014-04-15 14:06:21 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-04-21 23:03:19 +0100 |
commit | 61a680fb5d0c5ebac552645b0d99e90e9ddb628a (patch) | |
tree | 5ea6a5824d8261c00bf4a12d49058c098d6076f3 /bitbake/doc/bitbake-user-manual | |
parent | 4687351d165fe2a7218a920c2aaca5d0e27af1bb (diff) | |
download | poky-61a680fb5d0c5ebac552645b0d99e90e9ddb628a.tar.gz |
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>
Diffstat (limited to 'bitbake/doc/bitbake-user-manual')
-rw-r--r-- | bitbake/doc/bitbake-user-manual/bitbake-user-manual-hello.xml | 649 |
1 files changed, 328 insertions, 321 deletions
diff --git a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-hello.xml b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-hello.xml index 95a6804a19..2d67ff77da 100644 --- a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-hello.xml +++ b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-hello.xml | |||
@@ -121,16 +121,6 @@ | |||
121 | <title>The Hello World Example</title> | 121 | <title>The Hello World Example</title> |
122 | 122 | ||
123 | <para> | 123 | <para> |
124 | The following example leaps directly into how BitBake | ||
125 | works. | ||
126 | While every attempt is made to explain what is happening, | ||
127 | not everything can be covered. | ||
128 | You can find further information in the | ||
129 | "<link linkend='bitbake-user-manual-metadata'>Syntax and Operators</link>" | ||
130 | chapter. | ||
131 | </para> | ||
132 | |||
133 | <para> | ||
134 | The overall goal of this exercise is to build a | 124 | The overall goal of this exercise is to build a |
135 | complete "Hello World" example utilizing task and layer | 125 | complete "Hello World" example utilizing task and layer |
136 | concepts. | 126 | concepts. |
@@ -141,8 +131,25 @@ | |||
141 | </para> | 131 | </para> |
142 | 132 | ||
143 | <para> | 133 | <para> |
144 | It should be noted that this chapter was inspired by | 134 | To help you understand how to use BitBake to build targets, |
145 | and draws heavily from several sources: | 135 | the example starts with nothing but the <filename>bitbake</filename> |
136 | command, which causes BitBake to fail and report problems. | ||
137 | The example progresses by adding pieces to the build to | ||
138 | eventually conclude with a working, minimal "Hello World" | ||
139 | example. | ||
140 | </para> | ||
141 | |||
142 | <para> | ||
143 | While every attempt is made to explain what is happening during | ||
144 | the example, the descriptions cannot cover everything. | ||
145 | You can find further information throughout this manual. | ||
146 | Also, you can actively participate in the | ||
147 | <ulink url='http://lists.openembedded.org/mailman/listinfo/bitbake-devel'></ulink> | ||
148 | discussion mailing list about the BitBake build tool. | ||
149 | </para> | ||
150 | |||
151 | <note> | ||
152 | This example was inspired by and drew heavily from these sources: | ||
146 | <itemizedlist> | 153 | <itemizedlist> |
147 | <listitem><para> | 154 | <listitem><para> |
148 | <ulink url="http://www.mail-archive.com/yocto@yoctoproject.org/msg09379.html">Mailing List post - The BitBake equivalent of "Hello, World!"</ulink> | 155 | <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 @@ | |||
151 | <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> | 158 | <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> |
152 | </para></listitem> | 159 | </para></listitem> |
153 | </itemizedlist> | 160 | </itemizedlist> |
154 | </para> | 161 | </note> |
155 | |||
156 | <section id='a-reverse-walk-through'> | ||
157 | <title>A Reverse Walk-Through</title> | ||
158 | 162 | ||
159 | <para> | 163 | <para> |
160 | A good way to understand anything is to walk through the steps | 164 | As stated earlier, the goal of this example |
161 | that take you to where you want to be and observe first | 165 | is to eventually compile "Hello World". |
162 | principles. | 166 | However, it is unknown what BitBake needs and what you have |
163 | BitBake allows us to do this through the | 167 | to provide in order to achieve that goal. |
164 | <filename>-D</filename> or <filename>Debug</filename> | 168 | Recall that BitBake utilizes three types of metadata files: |
165 | command-line parameter. | 169 | <link linkend='configuration-files'>Configuration Files</link>, |
166 | </para> | 170 | <link linkend='classes'>Classes</link>, and |
171 | <link linkend='recipes'>Recipes</link>. | ||
172 | But where do they go? | ||
173 | How does BitBake find them? | ||
174 | BitBake's error messaging helps you answer these types of questions | ||
175 | and helps you better understand exactly what is going on. | ||
176 | </para> | ||
167 | 177 | ||
168 | <para> | 178 | <para> |
169 | The goal is to eventually compile a "Hello World" example. | 179 | Following is the complete "Hello World" example. |
170 | However, it is unknown what is needed to achieve that goal. | 180 | </para> |
171 | Recall that BitBake utilizes three types of metadata files: | ||
172 | <link linkend='configuration-files'>Configuration Files</link>, | ||
173 | <link linkend='classes'>Classes</link>, and | ||
174 | <link linkend='recipes'>Recipes</link>. | ||
175 | But where do they go? | ||
176 | How does BitBake find them? | ||
177 | BitBake's error messaging helps you answer these types of questions | ||
178 | and helps you better understand exactly what is going on. | ||
179 | </para> | ||
180 | 181 | ||
181 | <para> | 182 | <orderedlist> |
183 | <listitem><para><emphasis>Create a Project Directory:</emphasis> | ||
182 | First, set up a directory for the "Hello World" project. | 184 | First, set up a directory for the "Hello World" project. |
183 | Here is how you can do so in your home directory: | 185 | Here is how you can do so in your home directory: |
184 | <literallayout class='monospaced'> | 186 | <literallayout class='monospaced'> |
185 | $ mkdir ~/hello | 187 | $ mkdir ~/hello |
186 | $ cd ~/hello | 188 | $ cd ~/hello |
187 | </literallayout> | 189 | </literallayout> |
188 | Within this new, empty directory, run BitBake with | 190 | This is the directory that BitBake will use to do all of |
189 | debugging output and see what happens: | 191 | its work. |
192 | You can use this directory to keep all the metafiles needed | ||
193 | by BitBake. | ||
194 | Having a project directory is a good way to isolate your | ||
195 | project. | ||
196 | </para></listitem> | ||
197 | <listitem><para><emphasis>Run Bitbake:</emphasis> | ||
198 | At this point, you have nothing but a project directory. | ||
199 | Run the <filename>bitbake</filename> command and see what | ||
200 | it does: | ||
190 | <literallayout class='monospaced'> | 201 | <literallayout class='monospaced'> |
191 | $ bitbake -DDD | 202 | $ bitbake |
192 | The BBPATH variable is not set and bitbake did not find | 203 | The BBPATH variable is not set and bitbake did not |
193 | a conf/bblayers.conf file in the expected location. | 204 | find a conf/bblayers.conf file in the expected location. |
194 | Maybe you accidentally invoked bitbake from the wrong | 205 | Maybe you accidentally invoked bitbake from the wrong directory? |
195 | directory? | ||
196 | DEBUG: Removed the following variables from the environment: | 206 | DEBUG: Removed the following variables from the environment: |
197 | GNOME_DESKTOP_SESSION_ID, XDG_CURRENT_DESKTOP, | 207 | GNOME_DESKTOP_SESSION_ID, XDG_CURRENT_DESKTOP, |
198 | GNOME_KEYRING_CONTROL, DISPLAY, SSH_AGENT_PID, LANG, | 208 | GNOME_KEYRING_CONTROL, DISPLAY, SSH_AGENT_PID, LANG, no_proxy, |
199 | no_proxy, XDG_SESSION_PATH, XAUTHORITY, SESSION_MANAGER, | 209 | XDG_SESSION_PATH, XAUTHORITY, SESSION_MANAGER, SHLVL, |
200 | SHLVL, MANDATORY_PATH, COMPIZ_CONFIG_PROFILE, WINDOWID, | 210 | MANDATORY_PATH, COMPIZ_CONFIG_PROFILE, WINDOWID, EDITOR, |
201 | EDITOR, GPG_AGENT_INFO, SSH_AUTH_SOCK, GDMSESSION, | 211 | GPG_AGENT_INFO, SSH_AUTH_SOCK, GDMSESSION, GNOME_KEYRING_PID, |
202 | DEFAULTS_PATH, XDG_SEAT_PATH, XDG_CONFIG_DIRS, LESSOPEN, | 212 | XDG_SEAT_PATH, XDG_CONFIG_DIRS, LESSOPEN, DBUS_SESSION_BUS_ADDRESS, |
203 | DBUS_SESSION_BUS_ADDRESS, _, XDG_SESSION_COOKIE, | 213 | _, XDG_SESSION_COOKIE, DESKTOP_SESSION, LESSCLOSE, DEFAULTS_PATH, |
204 | DESKTOP_SESSION, LESSCLOSE, GNOME_KEYRING_PID, | 214 | UBUNTU_MENUPROXY, OLDPWD, XDG_DATA_DIRS, COLORTERM, LS_COLORS |
205 | UBUNTU_MENUPROXY, OLDPWD, XDG_DATA_DIRS, COLORTERM, | ||
206 | LS_COLORS | ||
207 | </literallayout> | 215 | </literallayout> |
208 | The majority of this output is specific to environment variables | 216 | The majority of this output is specific to environment variables |
209 | that are not directly relevant to BitBake. | 217 | that are not directly relevant to BitBake. |
210 | However, the very first message regarding the | 218 | However, the very first message regarding the |
211 | <filename>BBPATH</filename> variable and the | 219 | <filename>BBPATH</filename> variable and the |
212 | <filename>conf/bblayers.conf</filename> file | 220 | <filename>conf/bblayers.conf</filename> file |
213 | is relevant. | 221 | is relevant.</para> |
214 | </para> | 222 | <para> |
215 | 223 | When you run BitBake, it begins looking for metadata files. | |
216 | <para> | 224 | The |
225 | <link linkend='var-BBPATH'><filename>BBPATH</filename></link> | ||
226 | variable is what tells BitBake where to look for those files. | ||
227 | <filename>BBPATH</filename> is not set and you need to set it. | ||
228 | Without <filename>BBPATH</filename>, Bitbake cannot | ||
229 | find any configuration files (<filename>.conf</filename>) | ||
230 | or recipe files (<filename>.bb</filename>) at all. | ||
231 | BitBake also cannot find the <filename>bitbake.conf</filename> | ||
232 | file. | ||
233 | </para></listitem> | ||
234 | <listitem><para><emphasis>Setting <filename>BBPATH</filename>:</emphasis> | ||
235 | For this example, you can set <filename>BBPATH</filename> | ||
236 | in the same manner that you set <filename>PATH</filename> | ||
237 | earlier in the appendix. | ||
238 | You should realize, though, that it is much more flexible to set the | ||
239 | <filename>BBPATH</filename> variable up in a configuration | ||
240 | file for each project.</para> | ||
241 | <para>From your shell, enter the following commands to set and | ||
242 | export the <filename>BBPATH</filename> variable: | ||
217 | <literallayout class='monospaced'> | 243 | <literallayout class='monospaced'> |
218 | 1. Once you have PATH set up to actually run BB, and then you run it | 244 | $ BBPATH="<projectdirectory>" |
219 | using: | 245 | $ export BBPATH |
220 | 246 | </literallayout> | |
221 | bitbake -DDD | 247 | Use your actual project directory in the command. |
222 | 248 | BitBake uses that directory to find the metadata it needs for | |
223 | You get these complaints: | 249 | your project. |
224 | 250 | <note> | |
225 | The BBPATH variable is not set and bitbake did not find a conf/bblayers.conf file in the expected location. | 251 | When specifying your project directory, do not use the |
226 | Maybe you accidentally invoked bitbake from the wrong directory? | 252 | tilde ("~") character as BitBake does not expand that character |
227 | 253 | as the shell would. | |
228 | 2. If you export BBPATH to point to your build directory and do nothing | 254 | </note> |
229 | else, BB will look for the <buildir>/conf/bitbake.conf file. It will | 255 | </para></listitem> |
230 | throw and error with a bunch of traceback stuff and say: | 256 | <listitem><para><emphasis>Run Bitbake:</emphasis> |
231 | 257 | Now that you have <filename>BBPATH</filename> defined, run | |
232 | scott-lenovo@scott-lenovo:~ [master #] | 258 | the <filename>bitbake</filename> command again: |
233 | $ mkdir junk | 259 | <literallayout class='monospaced'> |
234 | scott-lenovo@scott-lenovo:~ [master #] | 260 | $ bitbake |
235 | $ BBPATH="/home/scott-lenovo/junk" | 261 | ERROR: Traceback (most recent call last): |
236 | scott-lenovo@scott-lenovo:~ [master #] | 262 | File "/home/scott-lenovo/bitbake/lib/bb/cookerdata.py", line 163, in wrapped |
237 | $ export BBPATH | 263 | return func(fn, *args) |
238 | scott-lenovo@scott-lenovo:~ [master #] | 264 | File "/home/scott-lenovo/bitbake/lib/bb/cookerdata.py", line 173, in parse_config_file |
239 | $ bitbake -DDD | 265 | return bb.parse.handle(fn, data, include) |
240 | ERROR: Traceback (most recent call last): | 266 | File "/home/scott-lenovo/bitbake/lib/bb/parse/__init__.py", line 99, in handle |
241 | File "/home/scott-lenovo/bitbake/lib/bb/cookerdata.py", line 163, in wrapped | 267 | return h['handle'](fn, data, include) |
242 | return func(fn, *args) | 268 | File "/home/scott-lenovo/bitbake/lib/bb/parse/parse_py/ConfHandler.py", line 120, in handle |
243 | File "/home/scott-lenovo/bitbake/lib/bb/cookerdata.py", line 173, in parse_config_file | 269 | abs_fn = resolve_file(fn, data) |
244 | return bb.parse.handle(fn, data, include) | 270 | File "/home/scott-lenovo/bitbake/lib/bb/parse/__init__.py", line 117, in resolve_file |
245 | File "/home/scott-lenovo/bitbake/lib/bb/parse/__init__.py", line 99, in handle | 271 | raise IOError("file %s not found in %s" % (fn, bbpath)) |
246 | return h['handle'](fn, data, include) | 272 | IOError: file conf/bitbake.conf not found in /home/scott-lenovo/hello |
247 | File "/home/scott-lenovo/bitbake/lib/bb/parse/parse_py/ConfHandler.py", line 120, in handle | 273 | |
248 | abs_fn = resolve_file(fn, data) | 274 | ERROR: Unable to parse conf/bitbake.conf: file conf/bitbake.conf not found in /home/scott-lenovo/hello |
249 | File "/home/scott-lenovo/bitbake/lib/bb/parse/__init__.py", line 117, in resolve_file | 275 | </literallayout> |
250 | raise IOError("file %s not found in %s" % (fn, bbpath)) | 276 | This sample output shows that BitBake could not find the |
251 | IOError: file conf/bitbake.conf not found in /home/scott-lenovo/junk | 277 | <filename>conf/bitbake.conf</filename> file in the project |
252 | 278 | directory. | |
253 | ERROR: Unable to parse conf/bitbake.conf: file conf/bitbake.conf not found in /home/scott-lenovo/junk | 279 | This file is the first thing BitBake must find in order |
254 | scott-lenovo@scott-lenovo:~ [master #] | 280 | to build a target. |
255 | 281 | And, since the project directory for this example is | |
256 | 3. Now I am going to create the conf/bitbake.conf file I need for the hello | 282 | empty, you need to provide a <filename>conf/bitbake.conf</filename> |
257 | world example. Then run it again. Time it complains about not finding | 283 | file. |
258 | classes/base.bbclass. | 284 | </para></listitem> |
259 | 285 | <listitem><para><emphasis>Creating <filename>conf/bitbake.conf</filename>:</emphasis> | |
260 | scott-lenovo@scott-lenovo:~/junk [master #] | 286 | The <filename>conf/bitbake.conf</filename> includes a number of |
261 | $ bitbake -DDD | 287 | configuration variables BitBake uses for metadata and recipe |
288 | files. | ||
289 | For this example, you need to create the file in your project directory | ||
290 | and define some key BitBake variables. | ||
291 | For more information on the <filename>bitbake.conf</filename>, | ||
292 | see | ||
293 | <ulink url='http://hambedded.org/blog/2012/11/24/from-bitbake-hello-world-to-an-image/#an-overview-of-bitbakeconf'></ulink> | ||
294 | </para> | ||
295 | <para>Use the following commands to create the <filename>conf</filename> | ||
296 | directory in the project directory: | ||
297 | <literallayout class='monospaced'> | ||
298 | $ mkdir conf | ||
299 | </literallayout> | ||
300 | From within the <filename>conf</filename> directory, use | ||
301 | some editor to create the <filename>bitbake.conf</filename> | ||
302 | so that it contains the following: | ||
303 | <literallayout class='monospaced'> | ||
304 | TMPDIR = "${<link linkend='var-TOPDIR'>TOPDIR</link>}/tmp" | ||
305 | <link linkend='var-CACHE'>CACHE</link> = "${TMPDIR}/cache" | ||
306 | <link linkend='var-STAMP'>STAMP</link> = "${TMPDIR}/stamps" | ||
307 | <link linkend='var-T'>T</link> = "${TMPDIR}/work" | ||
308 | <link linkend='var-B'>B</link> = "${TMPDIR}" | ||
309 | </literallayout> | ||
310 | The <filename>TMPDIR</filename> variable establishes a directory | ||
311 | that BitBake uses for build output and intermediate files (other | ||
312 | than the cached information used by the | ||
313 | <link linkend='setscene'>Setscene</link> process. | ||
314 | Here, the <filename>TMPDIR</filename> directory is set to | ||
315 | <filename>hello/tmp</filename>. | ||
316 | <note><title>Tip</title> | ||
317 | You can always safely delete the <filename>tmp</filename> | ||
318 | directory in order to rebuild a BitBake target. | ||
319 | The build process creates the directory for you | ||
320 | when you run BitBake. | ||
321 | </note></para> | ||
322 | <para>For information about each of the other variables defined in this | ||
323 | example, click on the links to take you to the definitions in | ||
324 | the glossary. | ||
325 | </para></listitem> | ||
326 | <listitem><para><emphasis>Run Bitbake:</emphasis> | ||
327 | After making sure that the <filename>conf/bitbake.conf</filename> | ||
328 | file exists, you can run the <filename>bitbake</filename> | ||
329 | command again: | ||
330 | <literallayout class='monospaced'> | ||
331 | $ bitbake | ||
262 | ERROR: Traceback (most recent call last): | 332 | ERROR: Traceback (most recent call last): |
263 | File "/home/scott-lenovo/bitbake/lib/bb/cookerdata.py", line 163, in wrapped | 333 | File "/home/scott-lenovo/bitbake/lib/bb/cookerdata.py", line 163, in wrapped |
264 | return func(fn, *args) | 334 | return func(fn, *args) |
@@ -271,241 +341,178 @@ ERROR: Traceback (most recent call last): | |||
271 | ParseError: ParseError in configuration INHERITs: Could not inherit file classes/base.bbclass | 341 | ParseError: ParseError in configuration INHERITs: Could not inherit file classes/base.bbclass |
272 | 342 | ||
273 | ERROR: Unable to parse base: ParseError in configuration INHERITs: Could not inherit file classes/base.bbclass | 343 | ERROR: Unable to parse base: ParseError in configuration INHERITs: Could not inherit file classes/base.bbclass |
274 | scott-lenovo@scott-lenovo:~/junk [master #] | ||
275 | |||
276 | 4. So now we add that classes/base.bbclass file and put in one line that says | ||
277 | "addtask build", which is the minimum task you need. We run it again and | ||
278 | things work but there is nothing to do. That stands to reason since I gave it | ||
279 | no target. | ||
280 | |||
281 | scott-lenovo@scott-lenovo:~/junk [master #] | ||
282 | $ bitbake -DDD | ||
283 | Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information. | ||
284 | 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 | ||
285 | DEBUG: LOAD /home/scott-lenovo/junk/conf/bitbake.conf | ||
286 | DEBUG: BB configuration INHERITs:0: inheriting /home/scott-lenovo/junk/classes/base.bbclass | ||
287 | DEBUG: BB /home/scott-lenovo/junk/classes/base.bbclass: handle(data, include) | ||
288 | DEBUG: LOAD /home/scott-lenovo/junk/classes/base.bbclass | ||
289 | DEBUG: Clearing SRCREV cache due to cache policy of: clear | ||
290 | DEBUG: Using cache in '/home/scott-lenovo/junk/tmp/cache/local_file_checksum_cache.dat' | ||
291 | DEBUG: Using cache in '/home/scott-lenovo/junk/tmp/cache/bb_codeparser.dat' | ||
292 | DEBUG: Features set [3] (was [3]) | ||
293 | scott-lenovo@scott-lenovo:~/junk [master #] | ||
294 | |||
295 | 5. Here is what happens when you do provide a target but the target doesn't | ||
296 | exist yet. | ||
297 | |||
298 | scott-lenovo@scott-lenovo:~/junk [master #] | ||
299 | $ bitbake a | ||
300 | ERROR: no recipe files to build, check your BBPATH and BBFILES? | ||
301 | |||
302 | Summary: There was 1 ERROR message shown, returning a non-zero exit code. | ||
303 | scott-lenovo@scott-lenovo:~/junk [master #] | ||
304 | |||
305 | 6. Create a layer that has your metadata in it. You need your recipe file | ||
306 | and your layer.conf file. That is all good but you still need to | ||
307 | tell BB where your layers are. You do that through a bblayers.conf file. | ||
308 | We will use this one: | ||
309 | |||
310 | BBLAYERS ?=" \ | ||
311 | /home/scott-lenovo/LayerA \ | ||
312 | " | ||
313 | |||
314 | Now when you run it, you get this: | ||
315 | |||
316 | $ bitbake -DDD a | ||
317 | 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 | ||
318 | DEBUG: Found bblayers.conf (/home/scott-lenovo/junk/conf/bblayers.conf) | ||
319 | DEBUG: LOAD /home/scott-lenovo/junk/conf/bblayers.conf | ||
320 | DEBUG: Adding layer /home/scott-lenovo/LayerA | ||
321 | DEBUG: LOAD /home/scott-lenovo/LayerA/conf/layer.conf | ||
322 | DEBUG: LOAD /home/scott-lenovo/junk/conf/bitbake.conf | ||
323 | DEBUG: BB configuration INHERITs:0: inheriting /home/scott-lenovo/junk/classes/base.bbclass | ||
324 | DEBUG: BB /home/scott-lenovo/junk/classes/base.bbclass: handle(data, include) | ||
325 | DEBUG: LOAD /home/scott-lenovo/junk/classes/base.bbclass | ||
326 | DEBUG: Clearing SRCREV cache due to cache policy of: clear | ||
327 | DEBUG: Using cache in '/home/scott-lenovo/junk/tmp/cache/local_file_checksum_cache.dat' | ||
328 | DEBUG: Using cache in '/home/scott-lenovo/junk/tmp/cache/bb_codeparser.dat' | ||
329 | DEBUG: Features set [3] (was [3]) | ||
330 | DEBUG: Calculated priority of layer A as 1 | ||
331 | DEBUG: collecting .bb files | ||
332 | DEBUG: Using cache in '/home/scott-lenovo/junk/tmp/cache' | ||
333 | DEBUG: Cache: /home/scott-lenovo/LayerA/a.bb is not cached | ||
334 | DEBUG: BB /home/scott-lenovo/LayerA/a.bb: handle(data) | ETA: --:--:-- | ||
335 | DEBUG: LOAD /home/scott-lenovo/LayerA/a.bb | ||
336 | Parsing recipes: 100% |##########################################################################################| Time: 00:00:00 | ||
337 | Parsing of 1 .bb files complete (0 cached, 1 parsed). 1 targets, 0 skipped, 0 masked, 0 errors. | ||
338 | DEBUG: parsing complete | ||
339 | DEBUG: providers for a are: ['a'] | ||
340 | DEBUG: sorted providers for a are: ['/home/scott-lenovo/LayerA/a.bb'] | ||
341 | DEBUG: adding /home/scott-lenovo/LayerA/a.bb to satisfy a | ||
342 | DEBUG: Added dependencies [] for /home/scott-lenovo/LayerA/a.bb | ||
343 | NOTE: Resolving any missing task queue dependencies | ||
344 | DEBUG: Resolved 0 extra dependencies | ||
345 | NOTE: Preparing runqueue | ||
346 | NOTE: Marking Active Tasks | ||
347 | NOTE: Pruned 0 inactive tasks, 1 left | ||
348 | NOTE: Assign Weightings | ||
349 | NOTE: Compute totals (have 1 endpoint(s)) | ||
350 | DEBUG: Starting bitbake-worker | ||
351 | NOTE: Executing RunQueue Tasks | ||
352 | DEBUG: Considering 0 (/home/scott-lenovo/LayerA/a.bb, do_build): set([]) | ||
353 | DEBUG: Skip list (pre setsceneverify) [] | ||
354 | DEBUG: Full skip list set([]) | ||
355 | DEBUG: Using runqueue scheduler 'speed' | ||
356 | DEBUG: Stampfile /home/scott-lenovo/junk/tmp/stamps.do_build not available | ||
357 | DEBUG: Found bblayers.conf (/home/scott-lenovo/junk/conf/bblayers.conf) | ||
358 | DEBUG: LOAD /home/scott-lenovo/junk/conf/bblayers.conf | ||
359 | DEBUG: Adding layer /home/scott-lenovo/LayerA | ||
360 | DEBUG: LOAD /home/scott-lenovo/LayerA/conf/layer.conf | ||
361 | DEBUG: LOAD /home/scott-lenovo/junk/conf/bitbake.conf | ||
362 | DEBUG: BB configuration INHERITs:0: inheriting /home/scott-lenovo/junk/classes/base.bbclass | ||
363 | DEBUG: BB /home/scott-lenovo/junk/classes/base.bbclass: handle(data, include) | ||
364 | DEBUG: LOAD /home/scott-lenovo/junk/classes/base.bbclass | ||
365 | DEBUG: Using cache in '/home/scott-lenovo/junk/tmp/cache/bb_codeparser.dat' | ||
366 | ************************ | ||
367 | * * | ||
368 | * Hello, World! * | ||
369 | * * | ||
370 | ************************ | ||
371 | DEBUG: Teardown for bitbake-worker | ||
372 | NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be rerun and all succeeded. | ||
373 | scott-lenovo@scott-lenovo:~/junk/conf [master #] | ||
374 | |||
375 | 7. If you run it without the "-DDD" option, the output is cleaner. | ||
376 | |||
377 | scott-lenovo@scott-lenovo:~/junk [master #] | ||
378 | $ bitbake a | ||
379 | Parsing recipes: 100% |##########################################################################################| Time: 00:00:00 | ||
380 | Parsing of 1 .bb files complete (0 cached, 1 parsed). 1 targets, 0 skipped, 0 masked, 0 errors. | ||
381 | NOTE: Resolving any missing task queue dependencies | ||
382 | NOTE: Preparing runqueue | ||
383 | NOTE: Executing RunQueue Tasks | ||
384 | ************************ | ||
385 | * * | ||
386 | * Hello, World! * | ||
387 | * * | ||
388 | ************************ | ||
389 | NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be rerun and all succeeded. | ||
390 | scott-lenovo@scott-lenovo:~/junk [master #] | ||
391 | </literallayout> | 344 | </literallayout> |
392 | </para> | 345 | In the sample output, BitBake could not find the |
393 | 346 | <filename>classes/base.bbclass</filename> file. | |
394 | <para> | 347 | You need to create that file next. |
395 | You need to set | 348 | </para></listitem> |
396 | <link linkend='var-BBPATH'><filename>BBPATH</filename></link>. | 349 | <listitem><para><emphasis>Creating <filename>classes/base.bbclass</filename>:</emphasis> |
397 | </para> | 350 | BitBake uses class files to provide common code and functionality. |
398 | 351 | The minimally required class for BitBake is the | |
399 | <para> | 352 | <filename>classes/base.bbclass</filename> file. |
400 | When you run BitBake, it begins looking for metadata files. | 353 | The <filename>base</filename> class is implicitly inherited by |
401 | The <filename>BBPATH</filename> variable is what tells | 354 | every recipe. |
402 | BitBake where to look. | 355 | BitBake looks for the class in the <filename>classes</filename> |
403 | You could set <filename>BBPATH</filename> in the same manner | 356 | directory of the project (i.e <filename>hello/classes</filename> |
404 | that you set <filename>PATH</filename> as shown earlier. | 357 | in this example). |
405 | However, it is much more flexible to set the | 358 | </para> |
406 | <link linkend='var-BBPATH'><filename>BBPATH</filename></link> | 359 | <para>Create the <filename>classes</filename> directory as follows: |
407 | variable for each project. | ||
408 | </para> | ||
409 | |||
410 | <para> | ||
411 | Without <filename>BBPATH</filename>, Bitbake cannot | ||
412 | find any configuration files (<filename>.conf</filename>) | ||
413 | or recipe files (<filename>.bb</filename>) at all. | ||
414 | BitBake also cannot find the <filename>bitbake.conf</filename> | ||
415 | file. | ||
416 | </para> | ||
417 | |||
418 | <para> | ||
419 | It is standard practice to organize the project's directory tree | ||
420 | to include both a <filename>conf/</filename> and | ||
421 | <filename>classes/</filename> directory. | ||
422 | You need to add those directories to your project: | ||
423 | <literallayout class='monospaced'> | 360 | <literallayout class='monospaced'> |
424 | $ mkdir conf classes | 361 | $ cd $HOME/hello |
362 | $ mkdir classes | ||
425 | </literallayout> | 363 | </literallayout> |
426 | Once those directories are in place, you can copy the | 364 | Move to the <filename>classes</filename> directory and then |
427 | sample configuration files provided in the | 365 | create the <filename>base.bbclass</filename> file by inserting |
428 | BitBake source tree to their appropriate directories. | 366 | this single line: |
429 | First, change to the BitBake source tree directory and | ||
430 | then copy the directories: | ||
431 | <literallayout class='monospaced'> | 367 | <literallayout class='monospaced'> |
432 | cp conf/bitbake.conf ~/dev/hello/conf/ | 368 | addtask build |
433 | cp classes/base.bbclass ~/dev/hello/classes/ | ||
434 | </literallayout> | 369 | </literallayout> |
435 | At this point your project directory structure should look like | 370 | The minimal task that BitBake runs is the |
436 | the following: | 371 | <filename>do_build</filename> task. |
437 | <literallayout class='monospaced'> | 372 | This is all the example needs in order to build the project. |
438 | ~/dev/hello$ tree | 373 | Of course, the <filename>base.bbclass</filename> can have much |
439 | . | 374 | more depending on which build environments BitBake is |
440 | |-- classes | 375 | supporting. |
441 | | +-- base.bbclass | 376 | For more information on the <filename>base.bbclass</filename> file, |
442 | +-- conf | 377 | you can look at |
443 | +-- bitbake.conf | 378 | <ulink url='http://hambedded.org/blog/2012/11/24/from-bitbake-hello-world-to-an-image/#tasks'></ulink>. |
379 | </para></listitem> | ||
380 | <listitem><para><emphasis>Run Bitbake:</emphasis> | ||
381 | After making sure that the <filename>classes/base.bbclass</filename> | ||
382 | file exists, you can run the <filename>bitbake</filename> | ||
383 | command again: | ||
384 | <literallayout class='monospaced'> | ||
385 | $ bitbake | ||
386 | Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information. | ||
444 | </literallayout> | 387 | </literallayout> |
445 | </para> | 388 | BitBake is finally reporting no errors. |
446 | 389 | However, you can see that it really does not have anything | |
447 | <para> | 390 | to do. |
448 | Once you have copied these files into your project, you | 391 | You need to create a recipe that gives BitBake something to do. |
449 | can now get back to resolving the <filename>BBPATH</filename> | 392 | </para></listitem> |
450 | issue. | 393 | <listitem><para><emphasis>Creating a Layer:</emphasis> |
451 | </para> | 394 | While it is not really necessary for such a small example, |
395 | it is good practice to create a layer in which to keep your | ||
396 | code separate from the general metadata used by BitBake. | ||
397 | Thus, this example creates and uses a layer called "mylayer". | ||
398 | <note> | ||
399 | You can find additional information on adding a layer at | ||
400 | <ulink url='http://hambedded.org/blog/2012/11/24/from-bitbake-hello-world-to-an-image/#adding-an-example-layer'></ulink>. | ||
401 | </note> | ||
402 | </para> | ||
403 | <para>Minimally, you need a recipe file and a layer configuration | ||
404 | file in your layer. | ||
405 | The configuration file needs to be in the <filename>conf</filename> | ||
406 | directory inside the layer. | ||
407 | Use these commands to set up the layer and the <filename>conf</filename> | ||
408 | directory: | ||
409 | <literallayout class='monospaced'> | ||
410 | $ cd $HOME | ||
411 | $ mkdir mylayer | ||
412 | $ cd mylayer | ||
413 | $ mkdir conf | ||
414 | </literallayout> | ||
415 | Move to the <filename>conf</filename> directory and create a | ||
416 | <filename>layer.conf</filename> file that has the following: | ||
417 | <literallayout class='monospaced'> | ||
418 | BBPATH .= ":${<link linkend='var-LAYERDIR'>LAYERDIR</link>}" | ||
452 | 419 | ||
453 | <para> | 420 | <link linkend='var-BBFILES'>BBFILES</link> += "${LAYERDIR}/*.bb" |
454 | The first configuration file that BitBake looks for is always | ||
455 | <filename>bblayers.conf</filename>. | ||
456 | With this knowledge, you know that to resolve your | ||
457 | <filename>BBPATH</filename> error you can add a | ||
458 | <filename>conf/bblayers.conf</filename> file to the | ||
459 | project source tree and populate it with the | ||
460 | <filename>BBPATH</filename> variable declaration. | ||
461 | </para> | ||
462 | 421 | ||
463 | <para> | 422 | <link linkend='var-BBFILE_COLLECTIONS'>BBFILE_COLLECTIONS</link> += "mylayer" |
464 | From your project source tree: | 423 | <link linkend='var-BBFILE_PATTERN'>BBFILE_PATTERN_mylayer</link> := "^${LAYERDIR}/" |
465 | <literallayout class='monospaced'> | ||
466 | $ vim conf/bblayers.conf | ||
467 | </literallayout> | 424 | </literallayout> |
468 | Now add the following to the empty | 425 | For information on these variables, click the links |
469 | <filename>bblayers.conf</filename> file: | 426 | to go to the definitions in the glossary.</para> |
427 | <para>You need to create the recipe file next. | ||
428 | Inside your layer at the top-level, use an editor and create | ||
429 | a recipe file named <filename>printhello.bb</filename> that | ||
430 | has the following: | ||
470 | <literallayout class='monospaced'> | 431 | <literallayout class='monospaced'> |
471 | BBPATH := "${TOPDIR}" | 432 | <link linkend='var-DESCRIPTION'>DESCRIPTION</link> = "Prints Hello World" |
433 | <link linkend='var-PN'>PN</link> = 'printhello' | ||
434 | <link linkend='var-PV'>PV</link> = '1' | ||
435 | |||
436 | python do_build() { | ||
437 | bb.plain("********************"); | ||
438 | bb.plain("* *"); | ||
439 | bb.plain("* Hello, World! *"); | ||
440 | bb.plain("* *"); | ||
441 | bb.plain("********************"); | ||
442 | } | ||
472 | </literallayout> | 443 | </literallayout> |
473 | </para> | 444 | The recipe file simply provides a description of the |
445 | recipe, the name, version, and the <filename>do_build</filename> | ||
446 | task, which prints out "Hello World" to the console. | ||
447 | For more information on these variables, follow the links | ||
448 | to the glossary. | ||
449 | </para></listitem> | ||
450 | <listitem><para><emphasis>Run Bitbake With a Target:</emphasis> | ||
451 | Now that a BitBake target exists, run the command and provide | ||
452 | that target: | ||
453 | <literallayout class='monospaced'> | ||
454 | $ cd $HOME/hello | ||
455 | $ bitbake printhello | ||
456 | ERROR: no recipe files to build, check your BBPATH and BBFILES? | ||
474 | 457 | ||
475 | <para> | 458 | Summary: There was 1 ERROR message shown, returning a non-zero exit code. |
476 | Now, from the root of your project directory, run BitBake | 459 | </literallayout> |
477 | again and see what happens: | 460 | We have created the layer with the recipe and the layer |
461 | configuration file but it still seems that BitBake cannot | ||
462 | find the recipe. | ||
463 | BitBake needs a <filename>conf/bblayers.conf</filename> that | ||
464 | lists the layers for the project. | ||
465 | Without this file, BitBake cannot find the recipe. | ||
466 | </para></listitem> | ||
467 | <listitem><para><emphasis>Creating <filename>conf/bblayers.conf</filename>:</emphasis> | ||
468 | BitBake uses the <filename>conf/bblayers.conf</filename> file | ||
469 | to locate layers needed for the project. | ||
470 | This file must reside in the <filename>conf</filename> directory | ||
471 | of the project (i.e. <filename>hello/conf</filename> for this | ||
472 | example).</para> | ||
473 | <para>Set your working directory to the <filename>hello/conf</filename> | ||
474 | directory and then create the <filename>bblayers.conf</filename> | ||
475 | file so that it contains the following: | ||
478 | <literallayout class='monospaced'> | 476 | <literallayout class='monospaced'> |
479 | $ bitbake -DDD | 477 | BBLAYERS ?= " \ |
480 | Nothing to do. Use 'bitbake world' to build everything, or | 478 | /home/<you>/mylayer \ |
481 | run 'bitbake --help' for usage information. | 479 | " |
482 | DEBUG: Removed the following variables from the environment: | 480 | </literallayout> |
483 | GNOME_DESKTOP_SESSION_ID, XDG_CURRENT_DESKTOP, | 481 | You need to provide your own information for |
484 | GNOME_KEYRING_CONTROL, DISPLAY, SSH_AGENT_PID, LANG, no_proxy, | 482 | <filename>you</filename> in the file. |
485 | XDG_SESSION_PATH, XAUTHORITY, SESSION_MANAGER, SHLVL, | 483 | </para></listitem> |
486 | MANDATORY_PATH, COMPIZ_CONFIG_PROFILE, WINDOWID, EDITOR, | 484 | <listitem><para><emphasis>Run Bitbake With a Target:</emphasis> |
487 | GPG_AGENT_INFO, SSH_AUTH_SOCK, GDMSESSION, DEFAULTS_PATH, | 485 | Now that you have supplied the <filename>bblayers.conf</filename> |
488 | XDG_SEAT_PATH, XDG_CONFIG_DIRS, LESSOPEN, | 486 | file, run the <filename>bitbake</filename> command and provide |
489 | DBUS_SESSION_BUS_ADDRESS, _, XDG_SESSION_COOKIE, | 487 | the target: |
490 | DESKTOP_SESSION, LESSCLOSE, GNOME_KEYRING_PID, UBUNTU_MENUPROXY, | 488 | <literallayout class='monospaced'> |
491 | OLDPWD, XDG_DATA_DIRS, COLORTERM, LS_COLORS | 489 | $ bitbake printhello |
492 | DEBUG: Found bblayers.conf (/home/scott-lenovo/dev/hello/conf/bblayers.conf) | 490 | Parsing recipes: 100% |##################################################################################| |
493 | DEBUG: LOAD /home/scott-lenovo/dev/hello/conf/bblayers.conf | 491 | Time: 00:00:00 |
494 | DEBUG: LOAD /home/scott-lenovo/dev/hello/conf/bitbake.conf | 492 | Parsing of 1 .bb files complete (0 cached, 1 parsed). 1 targets, 0 skipped, 0 masked, 0 errors. |
495 | DEBUG: BB configuration INHERITs:0: inheriting /home/scott-lenovo/dev/hello/classes/base.bbclass | 493 | NOTE: Resolving any missing task queue dependencies |
496 | DEBUG: BB /home/scott-lenovo/dev/hello/classes/base.bbclass: handle(data, include) | 494 | NOTE: Preparing runqueue |
497 | DEBUG: LOAD /home/scott-lenovo/dev/hello/classes/base.bbclass | 495 | NOTE: Executing RunQueue Tasks |
498 | DEBUG: Clearing SRCREV cache due to cache policy of: clear | 496 | ******************** |
499 | DEBUG: Using cache in '/home/scott-lenovo/dev/hello/tmp/cache/local_file_checksum_cache.dat' | 497 | * * |
500 | DEBUG: Using cache in '/home/scott-lenovo/dev/hello/tmp/cache/bb_codeparser.dat' | 498 | * Hello, World! * |
501 | DEBUG: Features set [3] (was [3]) | 499 | * * |
500 | ******************** | ||
501 | NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be rerun and all succeeded. | ||
502 | </literallayout> | 502 | </literallayout> |
503 | BitBake finds the <filename>printhello</filename> recipe and | ||
504 | successfully runs the task. | ||
503 | <note> | 505 | <note> |
504 | From this point forward in the example, the environment | 506 | Rerunning the task without removing the <filename>tmp</filename> |
505 | variable removal messages are ignored and omitted. | 507 | directory will not result in a BitBake run that prints the |
506 | Examine the relevant DEBUG messages: | 508 | same console output. |
509 | BitBake uses its Setscene process and determines that | ||
510 | nothing needs to be re-run. | ||
511 | If you delete the <filename>tmp</filename> directory and | ||
512 | then re-run the build, the printed output appears | ||
513 | at the console. | ||
507 | </note> | 514 | </note> |
508 | </para> | 515 | </para></listitem> |
509 | </section> | 516 | </orderedlist> |
510 | </section> | 517 | </section> |
511 | </appendix> | 518 | </appendix> |