ref-development-environment.xml 124 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443
  1. <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  2. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
  3. [<!ENTITY % poky SYSTEM "../poky.ent"> %poky; ] >
  4. <chapter id='ref-development-environment'>
  5. <title>The Yocto Project Development Environment</title>
  6. <para>
  7. This chapter takes a look at the Yocto Project development
  8. environment and also provides a detailed look at what goes on during
  9. development in that environment.
  10. The chapter provides Yocto Project Development environment concepts that
  11. help you understand how work is accomplished in an open source environment,
  12. which is very different as compared to work accomplished in a closed,
  13. proprietary environment.
  14. This chapter specifically addresses open source philosophy, using the
  15. Yocto Project in a team environment, source repositories, Yocto Project
  16. terms, licensing, the open source distributed version control system Git,
  17. workflows, bug tracking, and how to submit changes.
  18. </para>
  19. <section id='open-source-philosophy'>
  20. <title>Open Source Philosophy</title>
  21. <para>
  22. Open source philosophy is characterized by software development
  23. directed by peer production and collaboration through an active
  24. community of developers.
  25. Contrast this to the more standard centralized development models
  26. used by commercial software companies where a finite set of developers
  27. produces a product for sale using a defined set of procedures that
  28. ultimately result in an end product whose architecture and source
  29. material are closed to the public.
  30. </para>
  31. <para>
  32. Open source projects conceptually have differing concurrent agendas,
  33. approaches, and production.
  34. These facets of the development process can come from anyone in the
  35. public (community) that has a stake in the software project.
  36. The open source environment contains new copyright, licensing, domain,
  37. and consumer issues that differ from the more traditional development
  38. environment.
  39. In an open source environment, the end product, source material,
  40. and documentation are all available to the public at no cost.
  41. </para>
  42. <para>
  43. A benchmark example of an open source project is the Linux kernel,
  44. which was initially conceived and created by Finnish computer science
  45. student Linus Torvalds in 1991.
  46. Conversely, a good example of a non-open source project is the
  47. <trademark class='registered'>Windows</trademark> family of operating
  48. systems developed by
  49. <trademark class='registered'>Microsoft</trademark> Corporation.
  50. </para>
  51. <para>
  52. Wikipedia has a good historical description of the Open Source
  53. Philosophy
  54. <ulink url='http://en.wikipedia.org/wiki/Open_source'>here</ulink>.
  55. You can also find helpful information on how to participate in the
  56. Linux Community
  57. <ulink url='http://ldn.linuxfoundation.org/book/how-participate-linux-community'>here</ulink>.
  58. </para>
  59. </section>
  60. <section id='workflows'>
  61. <title>Workflows</title>
  62. <para>
  63. This section provides workflow concepts using the Yocto Project and
  64. Git.
  65. In particular, the information covers basic practices that describe
  66. roles and actions in a collaborative development environment.
  67. <note>
  68. If you are familiar with this type of development environment, you
  69. might not want to read this section.
  70. </note>
  71. </para>
  72. <para>
  73. The Yocto Project files are maintained using Git in "master"
  74. branches whose Git histories track every change and whose structures
  75. provides branches for all diverging functionality.
  76. Although there is no need to use Git, many open source projects do so.
  77. <para>
  78. </para>
  79. For the Yocto Project, a key individual called the "maintainer" is
  80. responsible for the "master" branch of a given Git repository.
  81. The "master" branch is the “upstream” repository from which final or
  82. most recent builds of the project occur.
  83. The maintainer is responsible for accepting changes from other
  84. developers and for organizing the underlying branch structure to
  85. reflect release strategies and so forth.
  86. <note>For information on finding out who is responsible for (maintains)
  87. a particular area of code, see the
  88. "<ulink url='&YOCTO_DOCS_DEV_URL;#how-to-submit-a-change'>Submitting a Change to the Yocto Project</ulink>"
  89. section of the Yocto Project Development Manual.
  90. </note>
  91. </para>
  92. <para>
  93. The Yocto Project <filename>poky</filename> Git repository also has an
  94. upstream contribution Git repository named
  95. <filename>poky-contrib</filename>.
  96. You can see all the branches in this repository using the web interface
  97. of the
  98. <ulink url='&YOCTO_GIT_URL;'>Source Repositories</ulink> organized
  99. within the "Poky Support" area.
  100. These branches temporarily hold changes to the project that have been
  101. submitted or committed by the Yocto Project development team and by
  102. community members who contribute to the project.
  103. The maintainer determines if the changes are qualified to be moved
  104. from the "contrib" branches into the "master" branch of the Git
  105. repository.
  106. </para>
  107. <para>
  108. Developers (including contributing community members) create and
  109. maintain cloned repositories of the upstream "master" branch.
  110. The cloned repositories are local to their development platforms and
  111. are used to develop changes.
  112. When a developer is satisfied with a particular feature or change,
  113. they "push" the changes to the appropriate "contrib" repository.
  114. </para>
  115. <para>
  116. Developers are responsible for keeping their local repository
  117. up-to-date with "master".
  118. They are also responsible for straightening out any conflicts that
  119. might arise within files that are being worked on simultaneously by
  120. more than one person.
  121. All this work is done locally on the developer’s machine before
  122. anything is pushed to a "contrib" area and examined at the maintainer’s
  123. level.
  124. </para>
  125. <para>
  126. A somewhat formal method exists by which developers commit changes
  127. and push them into the "contrib" area and subsequently request that
  128. the maintainer include them into "master".
  129. This process is called “submitting a patch” or "submitting a change."
  130. For information on submitting patches and changes, see the
  131. "<ulink url='&YOCTO_DOCS_DEV_URL;#how-to-submit-a-change'>Submitting a Change to the Yocto Project</ulink>"
  132. section in the Yocto Project Development Manual.
  133. </para>
  134. <para>
  135. To summarize the development workflow: a single point of entry
  136. exists for changes into the project’s "master" branch of the
  137. Git repository, which is controlled by the project’s maintainer.
  138. And, a set of developers exist who independently develop, test, and
  139. submit changes to "contrib" areas for the maintainer to examine.
  140. The maintainer then chooses which changes are going to become a
  141. permanent part of the project.
  142. </para>
  143. <para>
  144. <imagedata fileref="figures/git-workflow.png" width="6in" depth="3in" align="left" scalefit="1" />
  145. </para>
  146. <para>
  147. While each development environment is unique, there are some best
  148. practices or methods that help development run smoothly.
  149. The following list describes some of these practices.
  150. For more information about Git workflows, see the workflow topics in
  151. the
  152. <ulink url='http://book.git-scm.com'>Git Community Book</ulink>.
  153. <itemizedlist>
  154. <listitem><para>
  155. <emphasis>Make Small Changes:</emphasis>
  156. It is best to keep the changes you commit small as compared to
  157. bundling many disparate changes into a single commit.
  158. This practice not only keeps things manageable but also allows
  159. the maintainer to more easily include or refuse changes.</para>
  160. <para>It is also good practice to leave the repository in a
  161. state that allows you to still successfully build your project.
  162. In other words, do not commit half of a feature,
  163. then add the other half as a separate, later commit.
  164. Each commit should take you from one buildable project state
  165. to another buildable state.
  166. </para></listitem>
  167. <listitem><para>
  168. <emphasis>Use Branches Liberally:</emphasis>
  169. It is very easy to create, use, and delete local branches in
  170. your working Git repository.
  171. You can name these branches anything you like.
  172. It is helpful to give them names associated with the particular
  173. feature or change on which you are working.
  174. Once you are done with a feature or change and have merged it
  175. into your local master branch, simply discard the temporary
  176. branch.
  177. </para></listitem>
  178. <listitem><para>
  179. <emphasis>Merge Changes:</emphasis>
  180. The <filename>git merge</filename> command allows you to take
  181. the changes from one branch and fold them into another branch.
  182. This process is especially helpful when more than a single
  183. developer might be working on different parts of the same
  184. feature.
  185. Merging changes also automatically identifies any collisions
  186. or "conflicts" that might happen as a result of the same lines
  187. of code being altered by two different developers.
  188. </para></listitem>
  189. <listitem><para>
  190. <emphasis>Manage Branches:</emphasis>
  191. Because branches are easy to use, you should use a system
  192. where branches indicate varying levels of code readiness.
  193. For example, you can have a "work" branch to develop in, a
  194. "test" branch where the code or change is tested, a "stage"
  195. branch where changes are ready to be committed, and so forth.
  196. As your project develops, you can merge code across the
  197. branches to reflect ever-increasing stable states of the
  198. development.
  199. </para></listitem>
  200. <listitem><para>
  201. <emphasis>Use Push and Pull:</emphasis>
  202. The push-pull workflow is based on the concept of developers
  203. "pushing" local commits to a remote repository, which is
  204. usually a contribution repository.
  205. This workflow is also based on developers "pulling" known
  206. states of the project down into their local development
  207. repositories.
  208. The workflow easily allows you to pull changes submitted by
  209. other developers from the upstream repository into your
  210. work area ensuring that you have the most recent software
  211. on which to develop.
  212. The Yocto Project has two scripts named
  213. <filename>create-pull-request</filename> and
  214. <filename>send-pull-request</filename> that ship with the
  215. release to facilitate this workflow.
  216. You can find these scripts in the <filename>scripts</filename>
  217. folder of the
  218. <link linkend='source-directory'>Source Directory</link>.
  219. For information on how to use these scripts, see the
  220. "<ulink url='&YOCTO_DOCS_DEV_URL;#pushing-a-change-upstream'>Using Scripts to Push a Change Upstream and Request a Pull</ulink>"
  221. section in the Yocto Project Development Manual.
  222. </para></listitem>
  223. <listitem><para>
  224. <emphasis>Patch Workflow:</emphasis>
  225. This workflow allows you to notify the maintainer through an
  226. email that you have a change (or patch) you would like
  227. considered for the "master" branch of the Git repository.
  228. To send this type of change, you format the patch and then
  229. send the email using the Git commands
  230. <filename>git format-patch</filename> and
  231. <filename>git send-email</filename>.
  232. For information on how to use these scripts, see the
  233. "<ulink url='&YOCTO_DOCS_DEV_URL;#how-to-submit-a-change'>Submitting a Change to the Yocto Project</ulink>"
  234. section in the Yocto Project Development Manual.
  235. </para></listitem>
  236. </itemizedlist>
  237. </para>
  238. </section>
  239. <section id='git'>
  240. <title>Git</title>
  241. <para>
  242. The Yocto Project makes extensive use of Git, which is a
  243. free, open source distributed version control system.
  244. Git supports distributed development, non-linear development,
  245. and can handle large projects.
  246. It is best that you have some fundamental understanding
  247. of how Git tracks projects and how to work with Git if
  248. you are going to use the Yocto Project for development.
  249. This section provides a quick overview of how Git works and
  250. provides you with a summary of some essential Git commands.
  251. <note><title>Notes</title>
  252. <itemizedlist>
  253. <listitem><para>
  254. For more information on Git, see
  255. <ulink url='http://git-scm.com/documentation'></ulink>.
  256. </para></listitem>
  257. <listitem><para>
  258. If you need to download Git, it is recommended that you add
  259. Git to your system through your distribution's "software
  260. store" (e.g. for Ubuntu, use the Ubuntu Software feature).
  261. For the Git download page, see
  262. <ulink url='http://git-scm.com/download'></ulink>.
  263. </para></listitem>
  264. <listitem><para>
  265. For examples beyond the limited few in this section on how
  266. to use Git with the Yocto Project, see the
  267. "<ulink url='&YOCTO_DOCS_DEV_URL;#working-with-yocto-project-source-files'>Working With Yocto Project Source Files</ulink>"
  268. section in the Yocto Project Development Manual.
  269. </para></listitem>
  270. </itemizedlist>
  271. </note>
  272. </para>
  273. <section id='repositories-tags-and-branches'>
  274. <title>Repositories, Tags, and Branches</title>
  275. <para>
  276. As mentioned briefly in the previous section and also in the
  277. "<link linkend='workflows'>Workflows</link>" section,
  278. the Yocto Project maintains source repositories at
  279. <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>.
  280. If you look at this web-interface of the repositories, each item
  281. is a separate Git repository.
  282. </para>
  283. <para>
  284. Git repositories use branching techniques that track content
  285. change (not files) within a project (e.g. a new feature or updated
  286. documentation).
  287. Creating a tree-like structure based on project divergence allows
  288. for excellent historical information over the life of a project.
  289. This methodology also allows for an environment from which you can
  290. do lots of local experimentation on projects as you develop
  291. changes or new features.
  292. </para>
  293. <para>
  294. A Git repository represents all development efforts for a given
  295. project.
  296. For example, the Git repository <filename>poky</filename> contains
  297. all changes and developments for Poky over the course of its
  298. entire life.
  299. That means that all changes that make up all releases are captured.
  300. The repository maintains a complete history of changes.
  301. </para>
  302. <para>
  303. You can create a local copy of any repository by "cloning" it
  304. with the <filename>git clone</filename> command.
  305. When you clone a Git repository, you end up with an identical
  306. copy of the repository on your development system.
  307. Once you have a local copy of a repository, you can take steps to
  308. develop locally.
  309. For examples on how to clone Git repositories, see the
  310. "<ulink url='&YOCTO_DOCS_DEV_URL;#working-with-yocto-project-source-files'>Working With Yocto Project Source Files</ulink>"
  311. section in the Yocto Project Development Manual.
  312. </para>
  313. <para>
  314. It is important to understand that Git tracks content change and
  315. not files.
  316. Git uses "branches" to organize different development efforts.
  317. For example, the <filename>poky</filename> repository has
  318. several branches that include the current "&DISTRO_NAME_NO_CAP;"
  319. branch, the "master" branch, and many branches for past
  320. Yocto Project releases.
  321. You can see all the branches by going to
  322. <ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/'></ulink> and
  323. clicking on the
  324. <filename><ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/refs/heads'>[...]</ulink></filename>
  325. link beneath the "Branch" heading.
  326. </para>
  327. <para>
  328. Each of these branches represents a specific area of development.
  329. The "master" branch represents the current or most recent
  330. development.
  331. All other branches represent offshoots of the "master" branch.
  332. </para>
  333. <para>
  334. When you create a local copy of a Git repository, the copy has
  335. the same set of branches as the original.
  336. This means you can use Git to create a local working area
  337. (also called a branch) that tracks a specific development branch
  338. from the upstream source Git repository.
  339. in other words, you can define your local Git environment to
  340. work on any development branch in the repository.
  341. To help illustrate, consider the following example Git commands:
  342. <literallayout class='monospaced'>
  343. $ cd ~
  344. $ git clone git://git.yoctoproject.org/poky
  345. $ cd poky
  346. $ git checkout -b &DISTRO_NAME_NO_CAP; origin/&DISTRO_NAME_NO_CAP;
  347. </literallayout>
  348. In the previous example after moving to the home directory, the
  349. <filename>git clone</filename> command creates a
  350. local copy of the upstream <filename>poky</filename> Git repository.
  351. By default, Git checks out the "master" branch for your work.
  352. After changing the working directory to the new local repository
  353. (i.e. <filename>poky</filename>), the
  354. <filename>git checkout</filename> command creates
  355. and checks out a local branch named "&DISTRO_NAME_NO_CAP;", which
  356. tracks the upstream "origin/&DISTRO_NAME_NO_CAP;" branch.
  357. Changes you make while in this branch would ultimately affect
  358. the upstream "&DISTRO_NAME_NO_CAP;" branch of the
  359. <filename>poky</filename> repository.
  360. </para>
  361. <para>
  362. It is important to understand that when you create and checkout a
  363. local working branch based on a branch name,
  364. your local environment matches the "tip" of that particular
  365. development branch at the time you created your local branch,
  366. which could be different from the files in the "master" branch
  367. of the upstream repository.
  368. In other words, creating and checking out a local branch based on
  369. the "&DISTRO_NAME_NO_CAP;" branch name is not the same as
  370. cloning and checking out the "master" branch if the repository.
  371. Keep reading to see how you create a local snapshot of a Yocto
  372. Project Release.
  373. </para>
  374. <para>
  375. Git uses "tags" to mark specific changes in a repository.
  376. Typically, a tag is used to mark a special point such as the final
  377. change before a project is released.
  378. You can see the tags used with the <filename>poky</filename> Git
  379. repository by going to
  380. <ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/'></ulink> and
  381. clicking on the
  382. <filename><ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/refs/tags'>[...]</ulink></filename>
  383. link beneath the "Tag" heading.
  384. </para>
  385. <para>
  386. Some key tags for the <filename>poky</filename> are
  387. <filename>jethro-14.0.3</filename>,
  388. <filename>morty-16.0.1</filename>,
  389. <filename>pyro-17.0.0</filename>, and
  390. <filename>&DISTRO_NAME_NO_CAP;-&POKYVERSION;</filename>.
  391. These tags represent Yocto Project releases.
  392. </para>
  393. <para>
  394. When you create a local copy of the Git repository, you also
  395. have access to all the tags in the upstream repository.
  396. Similar to branches, you can create and checkout a local working
  397. Git branch based on a tag name.
  398. When you do this, you get a snapshot of the Git repository that
  399. reflects the state of the files when the change was made associated
  400. with that tag.
  401. The most common use is to checkout a working branch that matches
  402. a specific Yocto Project release.
  403. Here is an example:
  404. <literallayout class='monospaced'>
  405. $ cd ~
  406. $ git clone git://git.yoctoproject.org/poky
  407. $ cd poky
  408. $ git fetch --all --tags --prune
  409. $ git checkout tags/pyro-17.0.0 -b my-pyro-17.0.0
  410. </literallayout>
  411. In this example, the name of the top-level directory of your
  412. local Yocto Project repository is <filename>poky</filename>.
  413. After moving to the <filename>poky</filename> directory, the
  414. <filename>git fetch</filename> command makes all the upstream
  415. tags available locally in your repository.
  416. Finally, the <filename>git checkout</filename> command
  417. creates and checks out a branch named "my-pyro-17.0.0" that is
  418. based on the specific change upstream in the repository
  419. associated with the "pyro-17.0.0" tag.
  420. The files in your repository now exactly match that particular
  421. Yocto Project release as it is tagged in the upstream Git
  422. repository.
  423. It is important to understand that when you create and
  424. checkout a local working branch based on a tag, your environment
  425. matches a specific point in time and not the entire development
  426. branch (i.e. the "tip" of the branch).
  427. </para>
  428. </section>
  429. <section id='basic-commands'>
  430. <title>Basic Commands</title>
  431. <para>
  432. Git has an extensive set of commands that lets you manage changes
  433. and perform collaboration over the life of a project.
  434. Conveniently though, you can manage with a small set of basic
  435. operations and workflows once you understand the basic
  436. philosophy behind Git.
  437. You do not have to be an expert in Git to be functional.
  438. A good place to look for instruction on a minimal set of Git
  439. commands is
  440. <ulink url='http://git-scm.com/documentation'>here</ulink>.
  441. </para>
  442. <para>
  443. If you do not know much about Git, you should educate
  444. yourself by visiting the links previously mentioned.
  445. </para>
  446. <para>
  447. The following list of Git commands briefly describes some basic
  448. Git operations as a way to get started.
  449. As with any set of commands, this list (in most cases) simply shows
  450. the base command and omits the many arguments they support.
  451. See the Git documentation for complete descriptions and strategies
  452. on how to use these commands:
  453. <itemizedlist>
  454. <listitem><para>
  455. <emphasis><filename>git init</filename>:</emphasis>
  456. Initializes an empty Git repository.
  457. You cannot use Git commands unless you have a
  458. <filename>.git</filename> repository.
  459. </para></listitem>
  460. <listitem><para id='git-commands-clone'>
  461. <emphasis><filename>git clone</filename>:</emphasis>
  462. Creates a local clone of a Git repository that is on
  463. equal footing with a fellow developer’s Git repository
  464. or an upstream repository.
  465. </para></listitem>
  466. <listitem><para>
  467. <emphasis><filename>git add</filename>:</emphasis>
  468. Locally stages updated file contents to the index that
  469. Git uses to track changes.
  470. You must stage all files that have changed before you
  471. can commit them.
  472. </para></listitem>
  473. <listitem><para>
  474. <emphasis><filename>git commit</filename>:</emphasis>
  475. Creates a local "commit" that documents the changes you
  476. made.
  477. Only changes that have been staged can be committed.
  478. Commits are used for historical purposes, for determining
  479. if a maintainer of a project will allow the change,
  480. and for ultimately pushing the change from your local
  481. Git repository into the project’s upstream repository.
  482. </para></listitem>
  483. <listitem><para>
  484. <emphasis><filename>git status</filename>:</emphasis>
  485. Reports any modified files that possibly need to be
  486. staged and gives you a status of where you stand regarding
  487. local commits as compared to the upstream repository.
  488. </para></listitem>
  489. <listitem><para>
  490. <emphasis><filename>git checkout</filename> <replaceable>branch-name</replaceable>:</emphasis>
  491. Changes your working branch.
  492. This command is analogous to "cd".
  493. </para></listitem>
  494. <listitem><para><emphasis><filename>git checkout –b</filename> <replaceable>working-branch</replaceable>:</emphasis>
  495. Creates and checks out a working branch on your local
  496. machine that you can use to isolate your work.
  497. It is a good idea to use local branches when adding
  498. specific features or changes.
  499. Using isolated branches facilitates easy removal of
  500. changes if they do not work out.
  501. </para></listitem>
  502. <listitem><para><emphasis><filename>git branch</filename>:</emphasis>
  503. Displays the existing local branches associated with your
  504. local repository.
  505. The branch that you have currently checked out is noted
  506. with an asterisk character.
  507. </para></listitem>
  508. <listitem><para>
  509. <emphasis><filename>git branch -D</filename> <replaceable>branch-name</replaceable>:</emphasis>
  510. Deletes an existing local branch.
  511. You need to be in a local branch other than the one you
  512. are deleting in order to delete
  513. <replaceable>branch-name</replaceable>.
  514. </para></listitem>
  515. <listitem><para>
  516. <emphasis><filename>git pull</filename>:</emphasis>
  517. Retrieves information from an upstream Git repository
  518. and places it in your local Git repository.
  519. You use this command to make sure you are synchronized with
  520. the repository from which you are basing changes
  521. (.e.g. the "master" branch).
  522. </para></listitem>
  523. <listitem><para>
  524. <emphasis><filename>git push</filename>:</emphasis>
  525. Sends all your committed local changes to the upstream Git
  526. repository that your local repository is tracking
  527. (e.g. a contribution repository).
  528. The maintainer of the project draws from these repositories
  529. to merge changes (commits) into the appropriate branch
  530. of project's upstream repository.
  531. </para></listitem>
  532. <listitem><para>
  533. <emphasis><filename>git merge</filename>:</emphasis>
  534. Combines or adds changes from one
  535. local branch of your repository with another branch.
  536. When you create a local Git repository, the default branch
  537. is named "master".
  538. A typical workflow is to create a temporary branch that is
  539. based off "master" that you would use for isolated work.
  540. You would make your changes in that isolated branch,
  541. stage and commit them locally, switch to the "master"
  542. branch, and then use the <filename>git merge</filename>
  543. command to apply the changes from your isolated branch
  544. into the currently checked out branch (e.g. "master").
  545. After the merge is complete and if you are done with
  546. working in that isolated branch, you can safely delete
  547. the isolated branch.
  548. </para></listitem>
  549. <listitem><para>
  550. <emphasis><filename>git cherry-pick</filename>:</emphasis>
  551. Choose and apply specific commits from one branch
  552. into another branch.
  553. There are times when you might not be able to merge
  554. all the changes in one branch with
  555. another but need to pick out certain ones.
  556. </para></listitem>
  557. <listitem><para>
  558. <emphasis><filename>gitk</filename>:</emphasis>
  559. Provides a GUI view of the branches and changes in your
  560. local Git repository.
  561. This command is a good way to graphically see where things
  562. have diverged in your local repository.
  563. <note>
  564. You need to install the <filename>gitk</filename>
  565. package on your development system to use this
  566. command.
  567. </note>
  568. </para></listitem>
  569. <listitem><para>
  570. <emphasis><filename>git log</filename>:</emphasis>
  571. Reports a history of your commits to the repository.
  572. This report lists all commits regardless of whether you
  573. have pushed them upstream or not.
  574. </para></listitem>
  575. <listitem><para>
  576. <emphasis><filename>git diff</filename>:</emphasis>
  577. Displays line-by-line differences between a local
  578. working file and the same file as understood by Git.
  579. This command is useful to see what you have changed
  580. in any given file.
  581. </para></listitem>
  582. </itemizedlist>
  583. </para>
  584. </section>
  585. </section>
  586. <section id='yocto-project-repositories'>
  587. <title>Yocto Project Source Repositories</title>
  588. <para>
  589. The Yocto Project team maintains complete source repositories for all
  590. Yocto Project files at
  591. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi'></ulink>.
  592. This web-based source code browser is organized into categories by
  593. function such as IDE Plugins, Matchbox, Poky, Yocto Linux Kernel, and
  594. so forth.
  595. From the interface, you can click on any particular item in the "Name"
  596. column and see the URL at the bottom of the page that you need to clone
  597. a Git repository for that particular item.
  598. Having a local Git repository of the
  599. <link linkend='source-directory'>Source Directory</link>, which is
  600. usually named "poky", allows
  601. you to make changes, contribute to the history, and ultimately enhance
  602. the Yocto Project's tools, Board Support Packages, and so forth.
  603. </para>
  604. <para>
  605. For any supported release of Yocto Project, you can also go to the
  606. <ulink url='&YOCTO_HOME_URL;'>Yocto Project Website</ulink> and
  607. select the "Downloads" tab and get a released tarball of the
  608. <filename>poky</filename> repository or any supported BSP tarballs.
  609. Unpacking these tarballs gives you a snapshot of the released
  610. files.
  611. <note><title>Notes</title>
  612. <itemizedlist>
  613. <listitem><para>
  614. The recommended method for setting up the Yocto Project
  615. <link linkend='source-directory'>Source Directory</link>
  616. and the files for supported BSPs
  617. (e.g., <filename>meta-intel</filename>) is to use
  618. <link linkend='git'>Git</link> to create a local copy of
  619. the upstream repositories.
  620. </para></listitem>
  621. <listitem><para>
  622. Be sure to always work in matching branches for both
  623. the selected BSP repository and the
  624. <link linkend='source-directory'>Source Directory</link>
  625. (i.e. <filename>poky</filename>) repository.
  626. For example, if you have checked out the "master" branch
  627. of <filename>poky</filename> and you are going to use
  628. <filename>meta-intel</filename>, be sure to checkout the
  629. "master" branch of <filename>meta-intel</filename>.
  630. </para></listitem>
  631. </itemizedlist>
  632. </note>
  633. </para>
  634. <para>
  635. In summary, here is where you can get the project files needed for
  636. development:
  637. <itemizedlist>
  638. <listitem><para id='source-repositories'>
  639. <emphasis>
  640. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi'>Source Repositories:</ulink>
  641. </emphasis>
  642. This area contains IDE Plugins, Matchbox, Poky, Poky Support,
  643. Tools, Yocto Linux Kernel, and Yocto Metadata Layers.
  644. You can create local copies of Git repositories for each of
  645. these areas.</para>
  646. <para>
  647. <imagedata fileref="figures/source-repos.png" align="center" width="6in" depth="4in" />
  648. For steps on how to view and access these upstream Git
  649. repositories, see the
  650. "<ulink url='&YOCTO_DOCS_DEV_URL;#accessing-source-repositories'>Accessing Source Repositories</ulink>"
  651. Section in the Yocto Project Development Manual.
  652. </para></listitem>
  653. <listitem><para><anchor id='index-downloads' />
  654. <emphasis>
  655. <ulink url='&YOCTO_DL_URL;/releases/'>Index of /releases:</ulink>
  656. </emphasis>
  657. This is an index of releases such as
  658. the <trademark class='trade'>Eclipse</trademark>
  659. Yocto Plug-in, miscellaneous support, Poky, Pseudo, installers
  660. for cross-development toolchains, and all released versions of
  661. Yocto Project in the form of images or tarballs.
  662. Downloading and extracting these files does not produce a local
  663. copy of the Git repository but rather a snapshot of a
  664. particular release or image.</para>
  665. <para>
  666. <imagedata fileref="figures/index-downloads.png" align="center" width="6in" depth="3.5in" />
  667. For steps on how to view and access these files, see the
  668. "<ulink url='&YOCTO_DOCS_DEV_URL;#accessing-index-of-releases'>Accessing Index of Releases</ulink>"
  669. section in the Yocto Project Development Manual.
  670. </para></listitem>
  671. <listitem><para id='downloads-page'>
  672. <emphasis>"Downloads" page for the
  673. <ulink url='&YOCTO_HOME_URL;'>Yocto Project Website</ulink>:
  674. </emphasis></para>
  675. <para role="writernotes">This section will change due to
  676. reworking of the YP Website.</para>
  677. <para>The Yocto Project website includes a "Downloads" tab
  678. that allows you to download any Yocto Project
  679. release and Board Support Package (BSP) in tarball form.
  680. The tarballs are similar to those found in the
  681. <ulink url='&YOCTO_DL_URL;/releases/'>Index of /releases:</ulink> area.</para>
  682. <para>
  683. <imagedata fileref="figures/yp-download.png" align="center" width="6in" depth="4in" />
  684. For steps on how to use the "Downloads" page, see the
  685. "<ulink url='&YOCTO_DOCS_DEV_URL;#using-the-downloads-page'>Using the Downloads Page</ulink>"
  686. section in the Yocto Project Development Manual.
  687. </para></listitem>
  688. </itemizedlist>
  689. </para>
  690. </section>
  691. <section id='licensing'>
  692. <title>Licensing</title>
  693. <para>
  694. Because open source projects are open to the public, they have
  695. different licensing structures in place.
  696. License evolution for both Open Source and Free Software has an
  697. interesting history.
  698. If you are interested in this history, you can find basic information
  699. here:
  700. <itemizedlist>
  701. <listitem><para>
  702. <ulink url='http://en.wikipedia.org/wiki/Open-source_license'>Open source license history</ulink>
  703. </para></listitem>
  704. <listitem><para>
  705. <ulink url='http://en.wikipedia.org/wiki/Free_software_license'>Free software license history</ulink>
  706. </para></listitem>
  707. </itemizedlist>
  708. </para>
  709. <para>
  710. In general, the Yocto Project is broadly licensed under the
  711. Massachusetts Institute of Technology (MIT) License.
  712. MIT licensing permits the reuse of software within proprietary
  713. software as long as the license is distributed with that software.
  714. MIT is also compatible with the GNU General Public License (GPL).
  715. Patches to the Yocto Project follow the upstream licensing scheme.
  716. You can find information on the MIT license
  717. <ulink url='http://www.opensource.org/licenses/mit-license.php'>here</ulink>.
  718. You can find information on the GNU GPL
  719. <ulink url='http://www.opensource.org/licenses/LGPL-3.0'>here</ulink>.
  720. </para>
  721. <para>
  722. When you build an image using the Yocto Project, the build process
  723. uses a known list of licenses to ensure compliance.
  724. You can find this list in the
  725. <link linkend='source-directory'>Source Directory</link> at
  726. <filename>meta/files/common-licenses</filename>.
  727. Once the build completes, the list of all licenses found and used
  728. during that build are kept in the
  729. <link linkend='build-directory'>Build Directory</link>
  730. at <filename>tmp/deploy/licenses</filename>.
  731. </para>
  732. <para>
  733. If a module requires a license that is not in the base list, the
  734. build process generates a warning during the build.
  735. These tools make it easier for a developer to be certain of the
  736. licenses with which their shipped products must comply.
  737. However, even with these tools it is still up to the developer to
  738. resolve potential licensing issues.
  739. </para>
  740. <para>
  741. The base list of licenses used by the build process is a combination
  742. of the Software Package Data Exchange (SPDX) list and the Open
  743. Source Initiative (OSI) projects.
  744. <ulink url='http://spdx.org'>SPDX Group</ulink> is a working group of
  745. the Linux Foundation that maintains a specification for a standard
  746. format for communicating the components, licenses, and copyrights
  747. associated with a software package.
  748. <ulink url='http://opensource.org'>OSI</ulink> is a corporation
  749. dedicated to the Open Source Definition and the effort for reviewing
  750. and approving licenses that conform to the Open Source Definition
  751. (OSD).
  752. </para>
  753. <para>
  754. You can find a list of the combined SPDX and OSI licenses that the
  755. Yocto Project uses in the
  756. <filename>meta/files/common-licenses</filename> directory in your
  757. <link linkend='source-directory'>Source Directory</link>.
  758. </para>
  759. <para>
  760. For information that can help you maintain compliance with various
  761. open source licensing during the lifecycle of a product created using
  762. the Yocto Project, see the
  763. "<ulink url='&YOCTO_DOCS_DEV_URL;#maintaining-open-source-license-compliance-during-your-products-lifecycle'>Maintaining Open Source License Compliance During Your Product's Lifecycle</ulink>"
  764. section.
  765. </para>
  766. </section>
  767. <section id="development-concepts">
  768. <title>Development Concepts</title>
  769. <para>
  770. This section takes a more detailed look inside the development
  771. process.
  772. The following diagram represents development at a high level.
  773. The remainder of this chapter expands on the fundamental input, output,
  774. process, and
  775. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>) blocks
  776. that make up development in the Yocto Project environment.
  777. </para>
  778. <para id='general-yocto-environment-figure'>
  779. <imagedata fileref="figures/yocto-environment-ref.png" align="center" width="8in" depth="4.25in" />
  780. </para>
  781. <para>
  782. In general, development consists of several functional areas:
  783. <itemizedlist>
  784. <listitem><para><emphasis>User Configuration:</emphasis>
  785. Metadata you can use to control the build process.
  786. </para></listitem>
  787. <listitem><para><emphasis>Metadata Layers:</emphasis>
  788. Various layers that provide software, machine, and
  789. distro Metadata.</para></listitem>
  790. <listitem><para><emphasis>Source Files:</emphasis>
  791. Upstream releases, local projects, and SCMs.</para></listitem>
  792. <listitem><para><emphasis>Build System:</emphasis>
  793. Processes under the control of
  794. <link linkend='bitbake-term'>BitBake</link>.
  795. This block expands on how BitBake fetches source, applies
  796. patches, completes compilation, analyzes output for package
  797. generation, creates and tests packages, generates images, and
  798. generates cross-development tools.</para></listitem>
  799. <listitem><para><emphasis>Package Feeds:</emphasis>
  800. Directories containing output packages (RPM, DEB or IPK),
  801. which are subsequently used in the construction of an image or
  802. SDK, produced by the build system.
  803. These feeds can also be copied and shared using a web server or
  804. other means to facilitate extending or updating existing
  805. images on devices at runtime if runtime package management is
  806. enabled.</para></listitem>
  807. <listitem><para><emphasis>Images:</emphasis>
  808. Images produced by the development process.
  809. </para></listitem>
  810. <listitem><para><emphasis>Application Development SDK:</emphasis>
  811. Cross-development tools that are produced along with an image
  812. or separately with BitBake.</para></listitem>
  813. </itemizedlist>
  814. </para>
  815. <section id="user-configuration">
  816. <title>User Configuration</title>
  817. <para>
  818. User configuration helps define the build.
  819. Through user configuration, you can tell BitBake the
  820. target architecture for which you are building the image,
  821. where to store downloaded source, and other build properties.
  822. </para>
  823. <para>
  824. The following figure shows an expanded representation of the
  825. "User Configuration" box of the
  826. <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>:
  827. </para>
  828. <para>
  829. <imagedata fileref="figures/user-configuration.png" align="center" />
  830. </para>
  831. <para>
  832. BitBake needs some basic configuration files in order to complete
  833. a build.
  834. These files are <filename>*.conf</filename> files.
  835. The minimally necessary ones reside as example files in the
  836. <ulink url='&YOCTO_DOCS_DEV_URL;#source-directory'>Source Directory</ulink>.
  837. For simplicity, this section refers to the Source Directory as
  838. the "Poky Directory."
  839. </para>
  840. <para>
  841. When you clone the <filename>poky</filename> Git repository or you
  842. download and unpack a Yocto Project release, you can set up the
  843. Source Directory to be named anything you want.
  844. For this discussion, the cloned repository uses the default
  845. name <filename>poky</filename>.
  846. <note>
  847. The Poky repository is primarily an aggregation of existing
  848. repositories.
  849. It is not a canonical upstream source.
  850. </note>
  851. </para>
  852. <para>
  853. The <filename>meta-poky</filename> layer inside Poky contains
  854. a <filename>conf</filename> directory that has example
  855. configuration files.
  856. These example files are used as a basis for creating actual
  857. configuration files when you source the build environment
  858. script
  859. (i.e.
  860. <link linkend='structure-core-script'><filename>&OE_INIT_FILE;</filename></link>
  861. or
  862. <link linkend='structure-memres-core-script'><filename>oe-init-build-env-memres</filename></link>).
  863. </para>
  864. <para>
  865. Sourcing the build environment script creates a
  866. <link linkend='build-directory'>Build Directory</link>
  867. if one does not already exist.
  868. BitBake uses the Build Directory for all its work during builds.
  869. The Build Directory has a <filename>conf</filename> directory that
  870. contains default versions of your <filename>local.conf</filename>
  871. and <filename>bblayers.conf</filename> configuration files.
  872. These default configuration files are created only if versions
  873. do not already exist in the Build Directory at the time you
  874. source the build environment setup script.
  875. </para>
  876. <para>
  877. Because the Poky repository is fundamentally an aggregation of
  878. existing repositories, some users might be familiar with running
  879. the <filename>&OE_INIT_FILE;</filename> or
  880. <filename>oe-init-build-env-memres</filename> script in the context
  881. of separate OpenEmbedded-Core and BitBake repositories rather than a
  882. single Poky repository.
  883. This discussion assumes the script is executed from within a cloned
  884. or unpacked version of Poky.
  885. </para>
  886. <para>
  887. Depending on where the script is sourced, different sub-scripts
  888. are called to set up the Build Directory (Yocto or OpenEmbedded).
  889. Specifically, the script
  890. <filename>scripts/oe-setup-builddir</filename> inside the
  891. poky directory sets up the Build Directory and seeds the directory
  892. (if necessary) with configuration files appropriate for the
  893. Yocto Project development environment.
  894. <note>
  895. The <filename>scripts/oe-setup-builddir</filename> script
  896. uses the <filename>$TEMPLATECONF</filename> variable to
  897. determine which sample configuration files to locate.
  898. </note>
  899. </para>
  900. <para>
  901. The <filename>local.conf</filename> file provides many
  902. basic variables that define a build environment.
  903. Here is a list of a few.
  904. To see the default configurations in a <filename>local.conf</filename>
  905. file created by the build environment script, see the
  906. <filename>local.conf.sample</filename> in the
  907. <filename>meta-poky</filename> layer:
  908. <itemizedlist>
  909. <listitem><para><emphasis>Parallelism Options:</emphasis>
  910. Controlled by the
  911. <link linkend='var-BB_NUMBER_THREADS'><filename>BB_NUMBER_THREADS</filename></link>,
  912. <link linkend='var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></link>,
  913. and
  914. <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_NUMBER_PARSE_THREADS'><filename>BB_NUMBER_PARSE_THREADS</filename></ulink>
  915. variables.</para></listitem>
  916. <listitem><para><emphasis>Target Machine Selection:</emphasis>
  917. Controlled by the
  918. <link linkend='var-MACHINE'><filename>MACHINE</filename></link>
  919. variable.</para></listitem>
  920. <listitem><para><emphasis>Download Directory:</emphasis>
  921. Controlled by the
  922. <link linkend='var-DL_DIR'><filename>DL_DIR</filename></link>
  923. variable.</para></listitem>
  924. <listitem><para><emphasis>Shared State Directory:</emphasis>
  925. Controlled by the
  926. <link linkend='var-SSTATE_DIR'><filename>SSTATE_DIR</filename></link>
  927. variable.</para></listitem>
  928. <listitem><para><emphasis>Build Output:</emphasis>
  929. Controlled by the
  930. <link linkend='var-TMPDIR'><filename>TMPDIR</filename></link>
  931. variable.</para></listitem>
  932. </itemizedlist>
  933. <note>
  934. Configurations set in the <filename>conf/local.conf</filename>
  935. file can also be set in the
  936. <filename>conf/site.conf</filename> and
  937. <filename>conf/auto.conf</filename> configuration files.
  938. </note>
  939. </para>
  940. <para>
  941. The <filename>bblayers.conf</filename> file tells BitBake what
  942. layers you want considered during the build.
  943. By default, the layers listed in this file include layers
  944. minimally needed by the build system.
  945. However, you must manually add any custom layers you have created.
  946. You can find more information on working with the
  947. <filename>bblayers.conf</filename> file in the
  948. "<ulink url='&YOCTO_DOCS_DEV_URL;#enabling-your-layer'>Enabling Your Layer</ulink>"
  949. section in the Yocto Project Development Manual.
  950. </para>
  951. <para>
  952. The files <filename>site.conf</filename> and
  953. <filename>auto.conf</filename> are not created by the environment
  954. initialization script.
  955. If you want the <filename>site.conf</filename> file, you need to
  956. create that yourself.
  957. The <filename>auto.conf</filename> file is typically created by
  958. an autobuilder:
  959. <itemizedlist>
  960. <listitem><para><emphasis><filename>site.conf</filename>:</emphasis>
  961. You can use the <filename>conf/site.conf</filename>
  962. configuration file to configure multiple build directories.
  963. For example, suppose you had several build environments and
  964. they shared some common features.
  965. You can set these default build properties here.
  966. A good example is perhaps the packaging format to use
  967. through the
  968. <link linkend='var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></link>
  969. variable.</para>
  970. <para>One useful scenario for using the
  971. <filename>conf/site.conf</filename> file is to extend your
  972. <link linkend='var-BBPATH'><filename>BBPATH</filename></link>
  973. variable to include the path to a
  974. <filename>conf/site.conf</filename>.
  975. Then, when BitBake looks for Metadata using
  976. <filename>BBPATH</filename>, it finds the
  977. <filename>conf/site.conf</filename> file and applies your
  978. common configurations found in the file.
  979. To override configurations in a particular build directory,
  980. alter the similar configurations within that build
  981. directory's <filename>conf/local.conf</filename> file.
  982. </para></listitem>
  983. <listitem><para><emphasis><filename>auto.conf</filename>:</emphasis>
  984. The file is usually created and written to by
  985. an autobuilder.
  986. The settings put into the file are typically the same as
  987. you would find in the <filename>conf/local.conf</filename>
  988. or the <filename>conf/site.conf</filename> files.
  989. </para></listitem>
  990. </itemizedlist>
  991. </para>
  992. <para>
  993. You can edit all configuration files to further define
  994. any particular build environment.
  995. This process is represented by the "User Configuration Edits"
  996. box in the figure.
  997. </para>
  998. <para>
  999. When you launch your build with the
  1000. <filename>bitbake <replaceable>target</replaceable></filename>
  1001. command, BitBake sorts out the configurations to ultimately
  1002. define your build environment.
  1003. It is important to understand that the OpenEmbedded build system
  1004. reads the configuration files in a specific order:
  1005. <filename>site.conf</filename>, <filename>auto.conf</filename>,
  1006. and <filename>local.conf</filename>.
  1007. And, the build system applies the normal assignment statement
  1008. rules.
  1009. Because the files are parsed in a specific order, variable
  1010. assignments for the same variable could be affected.
  1011. For example, if the <filename>auto.conf</filename> file and
  1012. the <filename>local.conf</filename> set
  1013. <replaceable>variable1</replaceable> to different values, because
  1014. the build system parses <filename>local.conf</filename> after
  1015. <filename>auto.conf</filename>,
  1016. <replaceable>variable1</replaceable> is assigned the value from
  1017. the <filename>local.conf</filename> file.
  1018. </para>
  1019. </section>
  1020. <section id="metadata-machine-configuration-and-policy-configuration">
  1021. <title>Metadata, Machine Configuration, and Policy Configuration</title>
  1022. <para>
  1023. The previous section described the user configurations that
  1024. define BitBake's global behavior.
  1025. This section takes a closer look at the layers the build system
  1026. uses to further control the build.
  1027. These layers provide Metadata for the software, machine, and
  1028. policy.
  1029. </para>
  1030. <para>
  1031. In general, three types of layer input exist:
  1032. <itemizedlist>
  1033. <listitem><para><emphasis>Policy Configuration:</emphasis>
  1034. Distribution Layers provide top-level or general
  1035. policies for the image or SDK being built.
  1036. For example, this layer would dictate whether BitBake
  1037. produces RPM or IPK packages.</para></listitem>
  1038. <listitem><para><emphasis>Machine Configuration:</emphasis>
  1039. Board Support Package (BSP) layers provide machine
  1040. configurations.
  1041. This type of information is specific to a particular
  1042. target architecture.</para></listitem>
  1043. <listitem><para><emphasis>Metadata:</emphasis>
  1044. Software layers contain user-supplied recipe files,
  1045. patches, and append files.
  1046. </para></listitem>
  1047. </itemizedlist>
  1048. </para>
  1049. <para>
  1050. The following figure shows an expanded representation of the
  1051. Metadata, Machine Configuration, and Policy Configuration input
  1052. (layers) boxes of the
  1053. <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>:
  1054. </para>
  1055. <para>
  1056. <imagedata fileref="figures/layer-input.png" align="center" width="8in" depth="7.5in" />
  1057. </para>
  1058. <para>
  1059. In general, all layers have a similar structure.
  1060. They all contain a licensing file
  1061. (e.g. <filename>COPYING</filename>) if the layer is to be
  1062. distributed, a <filename>README</filename> file as good practice
  1063. and especially if the layer is to be distributed, a
  1064. configuration directory, and recipe directories.
  1065. </para>
  1066. <para>
  1067. The Yocto Project has many layers that can be used.
  1068. You can see a web-interface listing of them on the
  1069. <ulink url="http://git.yoctoproject.org/">Source Repositories</ulink>
  1070. page.
  1071. The layers are shown at the bottom categorized under
  1072. "Yocto Metadata Layers."
  1073. These layers are fundamentally a subset of the
  1074. <ulink url="http://layers.openembedded.org/layerindex/layers/">OpenEmbedded Metadata Index</ulink>,
  1075. which lists all layers provided by the OpenEmbedded community.
  1076. <note>
  1077. Layers exist in the Yocto Project Source Repositories that
  1078. cannot be found in the OpenEmbedded Metadata Index.
  1079. These layers are either deprecated or experimental in nature.
  1080. </note>
  1081. </para>
  1082. <para>
  1083. BitBake uses the <filename>conf/bblayers.conf</filename> file,
  1084. which is part of the user configuration, to find what layers it
  1085. should be using as part of the build.
  1086. </para>
  1087. <para>
  1088. For more information on layers, see the
  1089. "<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>"
  1090. section in the Yocto Project Development Manual.
  1091. </para>
  1092. <section id="distro-layer">
  1093. <title>Distro Layer</title>
  1094. <para>
  1095. The distribution layer provides policy configurations for your
  1096. distribution.
  1097. Best practices dictate that you isolate these types of
  1098. configurations into their own layer.
  1099. Settings you provide in
  1100. <filename>conf/distro/<replaceable>distro</replaceable>.conf</filename> override
  1101. similar
  1102. settings that BitBake finds in your
  1103. <filename>conf/local.conf</filename> file in the Build
  1104. Directory.
  1105. </para>
  1106. <para>
  1107. The following list provides some explanation and references
  1108. for what you typically find in the distribution layer:
  1109. <itemizedlist>
  1110. <listitem><para><emphasis>classes:</emphasis>
  1111. Class files (<filename>.bbclass</filename>) hold
  1112. common functionality that can be shared among
  1113. recipes in the distribution.
  1114. When your recipes inherit a class, they take on the
  1115. settings and functions for that class.
  1116. You can read more about class files in the
  1117. "<link linkend='ref-classes'>Classes</link>" section.
  1118. </para></listitem>
  1119. <listitem><para><emphasis>conf:</emphasis>
  1120. This area holds configuration files for the
  1121. layer (<filename>conf/layer.conf</filename>),
  1122. the distribution
  1123. (<filename>conf/distro/<replaceable>distro</replaceable>.conf</filename>),
  1124. and any distribution-wide include files.
  1125. </para></listitem>
  1126. <listitem><para><emphasis>recipes-*:</emphasis>
  1127. Recipes and append files that affect common
  1128. functionality across the distribution.
  1129. This area could include recipes and append files
  1130. to add distribution-specific configuration,
  1131. initialization scripts, custom image recipes,
  1132. and so forth.</para></listitem>
  1133. </itemizedlist>
  1134. </para>
  1135. </section>
  1136. <section id="bsp-layer">
  1137. <title>BSP Layer</title>
  1138. <para>
  1139. The BSP Layer provides machine configurations.
  1140. Everything in this layer is specific to the machine for which
  1141. you are building the image or the SDK.
  1142. A common structure or form is defined for BSP layers.
  1143. You can learn more about this structure in the
  1144. <ulink url='&YOCTO_DOCS_BSP_URL;'>Yocto Project Board Support Package (BSP) Developer's Guide</ulink>.
  1145. <note>
  1146. In order for a BSP layer to be considered compliant with the
  1147. Yocto Project, it must meet some structural requirements.
  1148. </note>
  1149. </para>
  1150. <para>
  1151. The BSP Layer's configuration directory contains
  1152. configuration files for the machine
  1153. (<filename>conf/machine/<replaceable>machine</replaceable>.conf</filename>) and,
  1154. of course, the layer (<filename>conf/layer.conf</filename>).
  1155. </para>
  1156. <para>
  1157. The remainder of the layer is dedicated to specific recipes
  1158. by function: <filename>recipes-bsp</filename>,
  1159. <filename>recipes-core</filename>,
  1160. <filename>recipes-graphics</filename>, and
  1161. <filename>recipes-kernel</filename>.
  1162. Metadata can exist for multiple formfactors, graphics
  1163. support systems, and so forth.
  1164. <note>
  1165. While the figure shows several <filename>recipes-*</filename>
  1166. directories, not all these directories appear in all
  1167. BSP layers.
  1168. </note>
  1169. </para>
  1170. </section>
  1171. <section id="software-layer">
  1172. <title>Software Layer</title>
  1173. <para>
  1174. The software layer provides the Metadata for additional
  1175. software packages used during the build.
  1176. This layer does not include Metadata that is specific to the
  1177. distribution or the machine, which are found in their
  1178. respective layers.
  1179. </para>
  1180. <para>
  1181. This layer contains any new recipes that your project needs
  1182. in the form of recipe files.
  1183. </para>
  1184. </section>
  1185. </section>
  1186. <section id="sources-dev-environment">
  1187. <title>Sources</title>
  1188. <para>
  1189. In order for the OpenEmbedded build system to create an image or
  1190. any target, it must be able to access source files.
  1191. The
  1192. <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>
  1193. represents source files using the "Upstream Project Releases",
  1194. "Local Projects", and "SCMs (optional)" boxes.
  1195. The figure represents mirrors, which also play a role in locating
  1196. source files, with the "Source Mirror(s)" box.
  1197. </para>
  1198. <para>
  1199. The method by which source files are ultimately organized is
  1200. a function of the project.
  1201. For example, for released software, projects tend to use tarballs
  1202. or other archived files that can capture the state of a release
  1203. guaranteeing that it is statically represented.
  1204. On the other hand, for a project that is more dynamic or
  1205. experimental in nature, a project might keep source files in a
  1206. repository controlled by a Source Control Manager (SCM) such as
  1207. Git.
  1208. Pulling source from a repository allows you to control
  1209. the point in the repository (the revision) from which you want to
  1210. build software.
  1211. Finally, a combination of the two might exist, which would give the
  1212. consumer a choice when deciding where to get source files.
  1213. </para>
  1214. <para>
  1215. BitBake uses the
  1216. <link linkend='var-SRC_URI'><filename>SRC_URI</filename></link>
  1217. variable to point to source files regardless of their location.
  1218. Each recipe must have a <filename>SRC_URI</filename> variable
  1219. that points to the source.
  1220. </para>
  1221. <para>
  1222. Another area that plays a significant role in where source files
  1223. come from is pointed to by the
  1224. <link linkend='var-DL_DIR'><filename>DL_DIR</filename></link>
  1225. variable.
  1226. This area is a cache that can hold previously downloaded source.
  1227. You can also instruct the OpenEmbedded build system to create
  1228. tarballs from Git repositories, which is not the default behavior,
  1229. and store them in the <filename>DL_DIR</filename> by using the
  1230. <link linkend='var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></link>
  1231. variable.
  1232. </para>
  1233. <para>
  1234. Judicious use of a <filename>DL_DIR</filename> directory can
  1235. save the build system a trip across the Internet when looking
  1236. for files.
  1237. A good method for using a download directory is to have
  1238. <filename>DL_DIR</filename> point to an area outside of your
  1239. Build Directory.
  1240. Doing so allows you to safely delete the Build Directory
  1241. if needed without fear of removing any downloaded source file.
  1242. </para>
  1243. <para>
  1244. The remainder of this section provides a deeper look into the
  1245. source files and the mirrors.
  1246. Here is a more detailed look at the source file area of the
  1247. base figure:
  1248. <imagedata fileref="figures/source-input.png" align="center" width="7in" depth="7.5in" />
  1249. </para>
  1250. <section id='upstream-project-releases'>
  1251. <title>Upstream Project Releases</title>
  1252. <para>
  1253. Upstream project releases exist anywhere in the form of an
  1254. archived file (e.g. tarball or zip file).
  1255. These files correspond to individual recipes.
  1256. For example, the figure uses specific releases each for
  1257. BusyBox, Qt, and Dbus.
  1258. An archive file can be for any released product that can be
  1259. built using a recipe.
  1260. </para>
  1261. </section>
  1262. <section id='local-projects'>
  1263. <title>Local Projects</title>
  1264. <para>
  1265. Local projects are custom bits of software the user provides.
  1266. These bits reside somewhere local to a project - perhaps
  1267. a directory into which the user checks in items (e.g.
  1268. a local directory containing a development source tree
  1269. used by the group).
  1270. </para>
  1271. <para>
  1272. The canonical method through which to include a local project
  1273. is to use the
  1274. <link linkend='ref-classes-externalsrc'><filename>externalsrc</filename></link>
  1275. class to include that local project.
  1276. You use either the <filename>local.conf</filename> or a
  1277. recipe's append file to override or set the
  1278. recipe to point to the local directory on your disk to pull
  1279. in the whole source tree.
  1280. </para>
  1281. <para>
  1282. For information on how to use the
  1283. <filename>externalsrc</filename> class, see the
  1284. "<link linkend='ref-classes-externalsrc'><filename>externalsrc.bbclass</filename></link>"
  1285. section.
  1286. </para>
  1287. </section>
  1288. <section id='scms'>
  1289. <title>Source Control Managers (Optional)</title>
  1290. <para>
  1291. Another place the build system can get source files from is
  1292. through an SCM such as Git or Subversion.
  1293. In this case, a repository is cloned or checked out.
  1294. The
  1295. <link linkend='ref-tasks-fetch'><filename>do_fetch</filename></link>
  1296. task inside BitBake uses
  1297. the <link linkend='var-SRC_URI'><filename>SRC_URI</filename></link>
  1298. variable and the argument's prefix to determine the correct
  1299. fetcher module.
  1300. </para>
  1301. <note>
  1302. For information on how to have the OpenEmbedded build system
  1303. generate tarballs for Git repositories and place them in the
  1304. <link linkend='var-DL_DIR'><filename>DL_DIR</filename></link>
  1305. directory, see the
  1306. <link linkend='var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></link>
  1307. variable.
  1308. </note>
  1309. <para>
  1310. When fetching a repository, BitBake uses the
  1311. <link linkend='var-SRCREV'><filename>SRCREV</filename></link>
  1312. variable to determine the specific revision from which to
  1313. build.
  1314. </para>
  1315. </section>
  1316. <section id='source-mirrors'>
  1317. <title>Source Mirror(s)</title>
  1318. <para>
  1319. Two kinds of mirrors exist: pre-mirrors and regular mirrors.
  1320. The <link linkend='var-PREMIRRORS'><filename>PREMIRRORS</filename></link>
  1321. and
  1322. <link linkend='var-MIRRORS'><filename>MIRRORS</filename></link>
  1323. variables point to these, respectively.
  1324. BitBake checks pre-mirrors before looking upstream for any
  1325. source files.
  1326. Pre-mirrors are appropriate when you have a shared directory
  1327. that is not a directory defined by the
  1328. <link linkend='var-DL_DIR'><filename>DL_DIR</filename></link>
  1329. variable.
  1330. A Pre-mirror typically points to a shared directory that is
  1331. local to your organization.
  1332. </para>
  1333. <para>
  1334. Regular mirrors can be any site across the Internet that is
  1335. used as an alternative location for source code should the
  1336. primary site not be functioning for some reason or another.
  1337. </para>
  1338. </section>
  1339. </section>
  1340. <section id="package-feeds-dev-environment">
  1341. <title>Package Feeds</title>
  1342. <para>
  1343. When the OpenEmbedded build system generates an image or an SDK,
  1344. it gets the packages from a package feed area located in the
  1345. <link linkend='build-directory'>Build Directory</link>.
  1346. The
  1347. <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>
  1348. shows this package feeds area in the upper-right corner.
  1349. </para>
  1350. <para>
  1351. This section looks a little closer into the package feeds area used
  1352. by the build system.
  1353. Here is a more detailed look at the area:
  1354. <imagedata fileref="figures/package-feeds.png" align="center" width="7in" depth="6in" />
  1355. </para>
  1356. <para>
  1357. Package feeds are an intermediary step in the build process.
  1358. The OpenEmbedded build system provides classes to generate
  1359. different package types, and you specify which classes to enable
  1360. through the
  1361. <link linkend='var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></link>
  1362. variable.
  1363. Before placing the packages into package feeds,
  1364. the build process validates them with generated output quality
  1365. assurance checks through the
  1366. <link linkend='ref-classes-insane'><filename>insane</filename></link>
  1367. class.
  1368. </para>
  1369. <para>
  1370. The package feed area resides in the Build Directory.
  1371. The directory the build system uses to temporarily store packages
  1372. is determined by a combination of variables and the particular
  1373. package manager in use.
  1374. See the "Package Feeds" box in the illustration and note the
  1375. information to the right of that area.
  1376. In particular, the following defines where package files are
  1377. kept:
  1378. <itemizedlist>
  1379. <listitem><para><link linkend='var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></link>:
  1380. Defined as <filename>tmp/deploy</filename> in the Build
  1381. Directory.
  1382. </para></listitem>
  1383. <listitem><para><filename>DEPLOY_DIR_*</filename>:
  1384. Depending on the package manager used, the package type
  1385. sub-folder.
  1386. Given RPM, IPK, or DEB packaging and tarball creation, the
  1387. <link linkend='var-DEPLOY_DIR_RPM'><filename>DEPLOY_DIR_RPM</filename></link>,
  1388. <link linkend='var-DEPLOY_DIR_IPK'><filename>DEPLOY_DIR_IPK</filename></link>,
  1389. <link linkend='var-DEPLOY_DIR_DEB'><filename>DEPLOY_DIR_DEB</filename></link>,
  1390. or
  1391. <link linkend='var-DEPLOY_DIR_TAR'><filename>DEPLOY_DIR_TAR</filename></link>,
  1392. variables are used, respectively.
  1393. </para></listitem>
  1394. <listitem><para><link linkend='var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></link>:
  1395. Defines architecture-specific sub-folders.
  1396. For example, packages could exist for the i586 or qemux86
  1397. architectures.
  1398. </para></listitem>
  1399. </itemizedlist>
  1400. </para>
  1401. <para>
  1402. BitBake uses the <filename>do_package_write_*</filename> tasks to
  1403. generate packages and place them into the package holding area (e.g.
  1404. <filename>do_package_write_ipk</filename> for IPK packages).
  1405. See the
  1406. "<link linkend='ref-tasks-package_write_deb'><filename>do_package_write_deb</filename></link>",
  1407. "<link linkend='ref-tasks-package_write_ipk'><filename>do_package_write_ipk</filename></link>",
  1408. "<link linkend='ref-tasks-package_write_rpm'><filename>do_package_write_rpm</filename></link>",
  1409. and
  1410. "<link linkend='ref-tasks-package_write_tar'><filename>do_package_write_tar</filename></link>"
  1411. sections for additional information.
  1412. As an example, consider a scenario where an IPK packaging manager
  1413. is being used and package architecture support for both i586
  1414. and qemux86 exist.
  1415. Packages for the i586 architecture are placed in
  1416. <filename>build/tmp/deploy/ipk/i586</filename>, while packages for
  1417. the qemux86 architecture are placed in
  1418. <filename>build/tmp/deploy/ipk/qemux86</filename>.
  1419. </para>
  1420. </section>
  1421. <section id='bitbake-dev-environment'>
  1422. <title>BitBake</title>
  1423. <para>
  1424. The OpenEmbedded build system uses
  1425. <link linkend='bitbake-term'>BitBake</link>
  1426. to produce images.
  1427. You can see from the
  1428. <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>,
  1429. the BitBake area consists of several functional areas.
  1430. This section takes a closer look at each of those areas.
  1431. </para>
  1432. <para>
  1433. Separate documentation exists for the BitBake tool.
  1434. See the
  1435. <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual'>BitBake User Manual</ulink>
  1436. for reference material on BitBake.
  1437. </para>
  1438. <section id='source-fetching-dev-environment'>
  1439. <title>Source Fetching</title>
  1440. <para>
  1441. The first stages of building a recipe are to fetch and unpack
  1442. the source code:
  1443. <imagedata fileref="figures/source-fetching.png" align="center" width="6.5in" depth="5in" />
  1444. </para>
  1445. <para>
  1446. The
  1447. <link linkend='ref-tasks-fetch'><filename>do_fetch</filename></link>
  1448. and
  1449. <link linkend='ref-tasks-unpack'><filename>do_unpack</filename></link>
  1450. tasks fetch the source files and unpack them into the work
  1451. directory.
  1452. <note>
  1453. For every local file (e.g. <filename>file://</filename>)
  1454. that is part of a recipe's
  1455. <link linkend='var-SRC_URI'><filename>SRC_URI</filename></link>
  1456. statement, the OpenEmbedded build system takes a checksum
  1457. of the file for the recipe and inserts the checksum into
  1458. the signature for the <filename>do_fetch</filename>.
  1459. If any local file has been modified, the
  1460. <filename>do_fetch</filename> task and all tasks that
  1461. depend on it are re-executed.
  1462. </note>
  1463. By default, everything is accomplished in the
  1464. <link linkend='build-directory'>Build Directory</link>,
  1465. which has a defined structure.
  1466. For additional general information on the Build Directory,
  1467. see the
  1468. "<link linkend='structure-core-build'><filename>build/</filename></link>"
  1469. section.
  1470. </para>
  1471. <para>
  1472. Unpacked source files are pointed to by the
  1473. <link linkend='var-S'><filename>S</filename></link> variable.
  1474. Each recipe has an area in the Build Directory where the
  1475. unpacked source code resides.
  1476. The name of that directory for any given recipe is defined from
  1477. several different variables.
  1478. You can see the variables that define these directories
  1479. by looking at the figure:
  1480. <itemizedlist>
  1481. <listitem><para><link linkend='var-TMPDIR'><filename>TMPDIR</filename></link> -
  1482. The base directory where the OpenEmbedded build system
  1483. performs all its work during the build.
  1484. </para></listitem>
  1485. <listitem><para><link linkend='var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></link> -
  1486. The architecture of the built package or packages.
  1487. </para></listitem>
  1488. <listitem><para><link linkend='var-TARGET_OS'><filename>TARGET_OS</filename></link> -
  1489. The operating system of the target device.
  1490. </para></listitem>
  1491. <listitem><para><link linkend='var-PN'><filename>PN</filename></link> -
  1492. The name of the built package.
  1493. </para></listitem>
  1494. <listitem><para><link linkend='var-PV'><filename>PV</filename></link> -
  1495. The version of the recipe used to build the package.
  1496. </para></listitem>
  1497. <listitem><para><link linkend='var-PR'><filename>PR</filename></link> -
  1498. The revision of the recipe used to build the package.
  1499. </para></listitem>
  1500. <listitem><para><link linkend='var-WORKDIR'><filename>WORKDIR</filename></link> -
  1501. The location within <filename>TMPDIR</filename> where
  1502. a specific package is built.
  1503. </para></listitem>
  1504. <listitem><para><link linkend='var-S'><filename>S</filename></link> -
  1505. Contains the unpacked source files for a given recipe.
  1506. </para></listitem>
  1507. </itemizedlist>
  1508. </para>
  1509. </section>
  1510. <section id='patching-dev-environment'>
  1511. <title>Patching</title>
  1512. <para>
  1513. Once source code is fetched and unpacked, BitBake locates
  1514. patch files and applies them to the source files:
  1515. <imagedata fileref="figures/patching.png" align="center" width="6in" depth="5in" />
  1516. </para>
  1517. <para>
  1518. The
  1519. <link linkend='ref-tasks-patch'><filename>do_patch</filename></link>
  1520. task processes recipes by
  1521. using the
  1522. <link linkend='var-SRC_URI'><filename>SRC_URI</filename></link>
  1523. variable to locate applicable patch files, which by default
  1524. are <filename>*.patch</filename> or
  1525. <filename>*.diff</filename> files, or any file if
  1526. "apply=yes" is specified for the file in
  1527. <filename>SRC_URI</filename>.
  1528. </para>
  1529. <para>
  1530. BitBake finds and applies multiple patches for a single recipe
  1531. in the order in which it finds the patches.
  1532. Patches are applied to the recipe's source files located in the
  1533. <link linkend='var-S'><filename>S</filename></link> directory.
  1534. </para>
  1535. <para>
  1536. For more information on how the source directories are
  1537. created, see the
  1538. "<link linkend='source-fetching-dev-environment'>Source Fetching</link>"
  1539. section.
  1540. </para>
  1541. </section>
  1542. <section id='configuration-and-compilation-dev-environment'>
  1543. <title>Configuration and Compilation</title>
  1544. <para>
  1545. After source code is patched, BitBake executes tasks that
  1546. configure and compile the source code:
  1547. <imagedata fileref="figures/configuration-compile-autoreconf.png" align="center" width="7in" depth="5in" />
  1548. </para>
  1549. <para>
  1550. This step in the build process consists of three tasks:
  1551. <itemizedlist>
  1552. <listitem><para>
  1553. <emphasis><link linkend='ref-tasks-prepare_recipe_sysroot'><filename>do_prepare_recipe_sysroot</filename></link>:</emphasis>
  1554. This task sets up the two sysroots in
  1555. <filename>${</filename><link linkend='var-WORKDIR'><filename>WORKDIR</filename></link><filename>}</filename>
  1556. (i.e. <filename>recipe-sysroot</filename> and
  1557. <filename>recipe-sysroot-native</filename>) so that
  1558. the sysroots contain the contents of the
  1559. <link linkend='ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></link>
  1560. tasks of the recipes on which the recipe
  1561. containing the tasks depends.
  1562. A sysroot exists for both the target and for the native
  1563. binaries, which run on the host system.
  1564. </para></listitem>
  1565. <listitem><para><emphasis><filename>do_configure</filename>:</emphasis>
  1566. This task configures the source by enabling and
  1567. disabling any build-time and configuration options for
  1568. the software being built.
  1569. Configurations can come from the recipe itself as well
  1570. as from an inherited class.
  1571. Additionally, the software itself might configure itself
  1572. depending on the target for which it is being built.
  1573. </para>
  1574. <para>The configurations handled by the
  1575. <link linkend='ref-tasks-configure'><filename>do_configure</filename></link>
  1576. task are specific
  1577. to source code configuration for the source code
  1578. being built by the recipe.</para>
  1579. <para>If you are using the
  1580. <link linkend='ref-classes-autotools'><filename>autotools</filename></link>
  1581. class,
  1582. you can add additional configuration options by using
  1583. the <link linkend='var-EXTRA_OECONF'><filename>EXTRA_OECONF</filename></link>
  1584. or
  1585. <link linkend='var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></link>
  1586. variables.
  1587. For information on how this variable works within
  1588. that class, see the
  1589. <filename>meta/classes/autotools.bbclass</filename> file.
  1590. </para></listitem>
  1591. <listitem><para><emphasis><filename>do_compile</filename>:</emphasis>
  1592. Once a configuration task has been satisfied, BitBake
  1593. compiles the source using the
  1594. <link linkend='ref-tasks-compile'><filename>do_compile</filename></link>
  1595. task.
  1596. Compilation occurs in the directory pointed to by the
  1597. <link linkend='var-B'><filename>B</filename></link>
  1598. variable.
  1599. Realize that the <filename>B</filename> directory is, by
  1600. default, the same as the
  1601. <link linkend='var-S'><filename>S</filename></link>
  1602. directory.</para></listitem>
  1603. <listitem><para><emphasis><filename>do_install</filename>:</emphasis>
  1604. Once compilation is done, BitBake executes the
  1605. <link linkend='ref-tasks-install'><filename>do_install</filename></link>
  1606. task.
  1607. This task copies files from the <filename>B</filename>
  1608. directory and places them in a holding area pointed to
  1609. by the
  1610. <link linkend='var-D'><filename>D</filename></link>
  1611. variable.</para></listitem>
  1612. </itemizedlist>
  1613. </para>
  1614. </section>
  1615. <section id='package-splitting-dev-environment'>
  1616. <title>Package Splitting</title>
  1617. <para>
  1618. After source code is configured and compiled, the
  1619. OpenEmbedded build system analyzes
  1620. the results and splits the output into packages:
  1621. <imagedata fileref="figures/analysis-for-package-splitting.png" align="center" width="7in" depth="7in" />
  1622. </para>
  1623. <para>
  1624. The
  1625. <link linkend='ref-tasks-package'><filename>do_package</filename></link>
  1626. and
  1627. <link linkend='ref-tasks-packagedata'><filename>do_packagedata</filename></link>
  1628. tasks combine to analyze
  1629. the files found in the
  1630. <link linkend='var-D'><filename>D</filename></link> directory
  1631. and split them into subsets based on available packages and
  1632. files.
  1633. The analyzing process involves the following as well as other
  1634. items: splitting out debugging symbols,
  1635. looking at shared library dependencies between packages,
  1636. and looking at package relationships.
  1637. The <filename>do_packagedata</filename> task creates package
  1638. metadata based on the analysis such that the
  1639. OpenEmbedded build system can generate the final packages.
  1640. Working, staged, and intermediate results of the analysis
  1641. and package splitting process use these areas:
  1642. <itemizedlist>
  1643. <listitem><para><link linkend='var-PKGD'><filename>PKGD</filename></link> -
  1644. The destination directory for packages before they are
  1645. split.
  1646. </para></listitem>
  1647. <listitem><para><link linkend='var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></link> -
  1648. A shared, global-state directory that holds data
  1649. generated during the packaging process.
  1650. </para></listitem>
  1651. <listitem><para><link linkend='var-PKGDESTWORK'><filename>PKGDESTWORK</filename></link> -
  1652. A temporary work area used by the
  1653. <filename>do_package</filename> task.
  1654. </para></listitem>
  1655. <listitem><para><link linkend='var-PKGDEST'><filename>PKGDEST</filename></link> -
  1656. The parent directory for packages after they have
  1657. been split.
  1658. </para></listitem>
  1659. </itemizedlist>
  1660. The <link linkend='var-FILES'><filename>FILES</filename></link>
  1661. variable defines the files that go into each package in
  1662. <link linkend='var-PACKAGES'><filename>PACKAGES</filename></link>.
  1663. If you want details on how this is accomplished, you can
  1664. look at the
  1665. <link linkend='ref-classes-package'><filename>package</filename></link>
  1666. class.
  1667. </para>
  1668. <para>
  1669. Depending on the type of packages being created (RPM, DEB, or
  1670. IPK), the <filename>do_package_write_*</filename> task
  1671. creates the actual packages and places them in the
  1672. Package Feed area, which is
  1673. <filename>${TMPDIR}/deploy</filename>.
  1674. You can see the
  1675. "<link linkend='package-feeds-dev-environment'>Package Feeds</link>"
  1676. section for more detail on that part of the build process.
  1677. <note>
  1678. Support for creating feeds directly from the
  1679. <filename>deploy/*</filename> directories does not exist.
  1680. Creating such feeds usually requires some kind of feed
  1681. maintenance mechanism that would upload the new packages
  1682. into an official package feed (e.g. the
  1683. Ångström distribution).
  1684. This functionality is highly distribution-specific
  1685. and thus is not provided out of the box.
  1686. </note>
  1687. </para>
  1688. </section>
  1689. <section id='image-generation-dev-environment'>
  1690. <title>Image Generation</title>
  1691. <para>
  1692. Once packages are split and stored in the Package Feeds area,
  1693. the OpenEmbedded build system uses BitBake to generate the
  1694. root filesystem image:
  1695. <imagedata fileref="figures/image-generation.png" align="center" width="6in" depth="7in" />
  1696. </para>
  1697. <para>
  1698. The image generation process consists of several stages and
  1699. depends on several tasks and variables.
  1700. The
  1701. <link linkend='ref-tasks-rootfs'><filename>do_rootfs</filename></link>
  1702. task creates the root filesystem (file and directory structure)
  1703. for an image.
  1704. This task uses several key variables to help create the list
  1705. of packages to actually install:
  1706. <itemizedlist>
  1707. <listitem><para><link linkend='var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></link>:
  1708. Lists out the base set of packages to install from
  1709. the Package Feeds area.</para></listitem>
  1710. <listitem><para><link linkend='var-PACKAGE_EXCLUDE'><filename>PACKAGE_EXCLUDE</filename></link>:
  1711. Specifies packages that should not be installed.
  1712. </para></listitem>
  1713. <listitem><para><link linkend='var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></link>:
  1714. Specifies features to include in the image.
  1715. Most of these features map to additional packages for
  1716. installation.</para></listitem>
  1717. <listitem><para><link linkend='var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></link>:
  1718. Specifies the package backend to use and consequently
  1719. helps determine where to locate packages within the
  1720. Package Feeds area.</para></listitem>
  1721. <listitem><para><link linkend='var-IMAGE_LINGUAS'><filename>IMAGE_LINGUAS</filename></link>:
  1722. Determines the language(s) for which additional
  1723. language support packages are installed.
  1724. </para></listitem>
  1725. <listitem><para><link linkend='var-PACKAGE_INSTALL'><filename>PACKAGE_INSTALL</filename></link>:
  1726. The final list of packages passed to the package manager
  1727. for installation into the image.
  1728. </para></listitem>
  1729. </itemizedlist>
  1730. </para>
  1731. <para>
  1732. With
  1733. <link linkend='var-IMAGE_ROOTFS'><filename>IMAGE_ROOTFS</filename></link>
  1734. pointing to the location of the filesystem under construction and
  1735. the <filename>PACKAGE_INSTALL</filename> variable providing the
  1736. final list of packages to install, the root file system is
  1737. created.
  1738. </para>
  1739. <para>
  1740. Package installation is under control of the package manager
  1741. (e.g. dnf/rpm, opkg, or apt/dpkg) regardless of whether or
  1742. not package management is enabled for the target.
  1743. At the end of the process, if package management is not
  1744. enabled for the target, the package manager's data files
  1745. are deleted from the root filesystem.
  1746. As part of the final stage of package installation, postinstall
  1747. scripts that are part of the packages are run.
  1748. Any scripts that fail to run
  1749. on the build host are run on the target when the target system
  1750. is first booted.
  1751. If you are using a
  1752. <ulink url='&YOCTO_DOCS_DEV_URL;#creating-a-read-only-root-filesystem'>read-only root filesystem</ulink>,
  1753. all the post installation scripts must succeed during the
  1754. package installation phase since the root filesystem is
  1755. read-only.
  1756. </para>
  1757. <para>
  1758. The final stages of the <filename>do_rootfs</filename> task
  1759. handle post processing.
  1760. Post processing includes creation of a manifest file and
  1761. optimizations.
  1762. </para>
  1763. <para>
  1764. The manifest file (<filename>.manifest</filename>) resides
  1765. in the same directory as the root filesystem image.
  1766. This file lists out, line-by-line, the installed packages.
  1767. The manifest file is useful for the
  1768. <link linkend='ref-classes-testimage*'><filename>testimage</filename></link>
  1769. class, for example, to determine whether or not to run
  1770. specific tests.
  1771. See the
  1772. <link linkend='var-IMAGE_MANIFEST'><filename>IMAGE_MANIFEST</filename></link>
  1773. variable for additional information.
  1774. </para>
  1775. <para>
  1776. Optimizing processes run across the image include
  1777. <filename>mklibs</filename>, <filename>prelink</filename>,
  1778. and any other post-processing commands as defined by the
  1779. <link linkend='var-ROOTFS_POSTPROCESS_COMMAND'><filename>ROOTFS_POSTPROCESS_COMMAND</filename></link>
  1780. variable.
  1781. The <filename>mklibs</filename> process optimizes the size
  1782. of the libraries, while the
  1783. <filename>prelink</filename> process optimizes the dynamic
  1784. linking of shared libraries to reduce start up time of
  1785. executables.
  1786. </para>
  1787. <para>
  1788. After the root filesystem is built, processing begins on
  1789. the image through the <filename>do_image</filename> task.
  1790. The build system runs any pre-processing commands as defined
  1791. by the
  1792. <link linkend='var-IMAGE_PREPROCESS_COMMAND'><filename>IMAGE_PREPROCESS_COMMAND</filename></link>
  1793. variable.
  1794. This variable specifies a list of functions to call before
  1795. the OpenEmbedded build system creates the final image output
  1796. files.
  1797. </para>
  1798. <para>
  1799. The <filename>do_image</filename> task dynamically creates
  1800. other <filename>do_image_*</filename> tasks as needed, which
  1801. include compressing the root filesystem image to reduce the
  1802. overall size of the image.
  1803. The process turns everything into an image file or a set of
  1804. image files.
  1805. The formats used for the root filesystem depend on the
  1806. <link linkend='var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></link>
  1807. variable.
  1808. </para>
  1809. <para>
  1810. The final task involved in image creation is the
  1811. <filename>do_image_complete</filename> task.
  1812. This task completes the image by applying any image
  1813. post processing as defined through the
  1814. <link linkend='var-IMAGE_POSTPROCESS_COMMAND'><filename>IMAGE_POSTPROCESS_COMMAND</filename></link>
  1815. variable.
  1816. The variable specifies a list of functions to call once the
  1817. OpenEmbedded build system has created the final image output
  1818. files.
  1819. </para>
  1820. <note>
  1821. The entire image generation process is run under Pseudo.
  1822. Running under Pseudo ensures that the files in the root
  1823. filesystem have correct ownership.
  1824. </note>
  1825. </section>
  1826. <section id='sdk-generation-dev-environment'>
  1827. <title>SDK Generation</title>
  1828. <para>
  1829. The OpenEmbedded build system uses BitBake to generate the
  1830. Software Development Kit (SDK) installer script for both the
  1831. standard and extensible SDKs:
  1832. <imagedata fileref="figures/sdk-generation.png" align="center" />
  1833. </para>
  1834. <note>
  1835. For more information on the cross-development toolchain
  1836. generation, see the
  1837. "<link linkend='cross-development-toolchain-generation'>Cross-Development Toolchain Generation</link>"
  1838. section.
  1839. For information on advantages gained when building a
  1840. cross-development toolchain using the
  1841. <link linkend='ref-tasks-populate_sdk'><filename>do_populate_sdk</filename></link>
  1842. task, see the
  1843. "<ulink url='&YOCTO_DOCS_SDK_URL;#sdk-building-an-sdk-installer'>Building an SDK Installer</ulink>"
  1844. section in the Yocto Project Software Development Kit (SDK)
  1845. Developer's Guide.
  1846. </note>
  1847. <para>
  1848. Like image generation, the SDK script process consists of
  1849. several stages and depends on many variables.
  1850. The <filename>do_populate_sdk</filename> and
  1851. <filename>do_populate_sdk_ext</filename> tasks use these
  1852. key variables to help create the list of packages to actually
  1853. install.
  1854. For information on the variables listed in the figure, see the
  1855. "<link linkend='sdk-dev-environment'>Application Development SDK</link>"
  1856. section.
  1857. </para>
  1858. <para>
  1859. The <filename>do_populate_sdk</filename> task helps create
  1860. the standard SDK and handles two parts: a target part and a
  1861. host part.
  1862. The target part is the part built for the target hardware and
  1863. includes libraries and headers.
  1864. The host part is the part of the SDK that runs on the
  1865. <link linkend='var-SDKMACHINE'><filename>SDKMACHINE</filename></link>.
  1866. </para>
  1867. <para>
  1868. The <filename>do_populate_sdk_ext</filename> task helps create
  1869. the extensible SDK and handles host and target parts
  1870. differently than its counter part does for the standard SDK.
  1871. For the extensible SDK, the task encapsulates the build system,
  1872. which includes everything needed (host and target) for the SDK.
  1873. </para>
  1874. <para>
  1875. Regardless of the type of SDK being constructed, the
  1876. tasks perform some cleanup after which a cross-development
  1877. environment setup script and any needed configuration files
  1878. are created.
  1879. The final output is the Cross-development
  1880. toolchain installation script (<filename>.sh</filename> file),
  1881. which includes the environment setup script.
  1882. </para>
  1883. </section>
  1884. <section id='stamp-files-and-the-rerunning-of-tasks'>
  1885. <title>Stamp Files and the Rerunning of Tasks</title>
  1886. <para>
  1887. For each task that completes successfully, BitBake writes a
  1888. stamp file into the
  1889. <link linkend='var-STAMPS_DIR'><filename>STAMPS_DIR</filename></link>
  1890. directory.
  1891. The beginning of the stamp file's filename is determined by the
  1892. <link linkend='var-STAMP'><filename>STAMP</filename></link>
  1893. variable, and the end of the name consists of the task's name
  1894. and current
  1895. <ulink url='&YOCTO_DOCS_BB_URL;#checksums'>input checksum</ulink>.
  1896. <note>
  1897. This naming scheme assumes that
  1898. <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_SIGNATURE_HANDLER'><filename>BB_SIGNATURE_HANDLER</filename></ulink>
  1899. is "OEBasicHash", which is almost always the case in
  1900. current OpenEmbedded.
  1901. </note>
  1902. To determine if a task needs to be rerun, BitBake checks if a
  1903. stamp file with a matching input checksum exists for the task.
  1904. If such a stamp file exists, the task's output is assumed to
  1905. exist and still be valid.
  1906. If the file does not exist, the task is rerun.
  1907. <note>
  1908. <para>The stamp mechanism is more general than the shared
  1909. state (sstate) cache mechanism described in the
  1910. "<link linkend='setscene-tasks-and-shared-state'>Setscene Tasks and Shared State</link>"
  1911. section.
  1912. BitBake avoids rerunning any task that has a valid
  1913. stamp file, not just tasks that can be accelerated through
  1914. the sstate cache.</para>
  1915. <para>However, you should realize that stamp files only
  1916. serve as a marker that some work has been done and that
  1917. these files do not record task output.
  1918. The actual task output would usually be somewhere in
  1919. <link linkend='var-TMPDIR'><filename>TMPDIR</filename></link>
  1920. (e.g. in some recipe's
  1921. <link linkend='var-WORKDIR'><filename>WORKDIR</filename></link>.)
  1922. What the sstate cache mechanism adds is a way to cache task
  1923. output that can then be shared between build machines.
  1924. </para>
  1925. </note>
  1926. Since <filename>STAMPS_DIR</filename> is usually a subdirectory
  1927. of <filename>TMPDIR</filename>, removing
  1928. <filename>TMPDIR</filename> will also remove
  1929. <filename>STAMPS_DIR</filename>, which means tasks will
  1930. properly be rerun to repopulate <filename>TMPDIR</filename>.
  1931. </para>
  1932. <para>
  1933. If you want some task to always be considered "out of date",
  1934. you can mark it with the
  1935. <ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>nostamp</filename></ulink>
  1936. varflag.
  1937. If some other task depends on such a task, then that task will
  1938. also always be considered out of date, which might not be what
  1939. you want.
  1940. </para>
  1941. <para>
  1942. For details on how to view information about a task's
  1943. signature, see the
  1944. "<link linkend='usingpoky-viewing-task-variable-dependencies'>Viewing Task Variable Dependencies</link>"
  1945. section.
  1946. </para>
  1947. </section>
  1948. <section id='setscene-tasks-and-shared-state'>
  1949. <title>Setscene Tasks and Shared State</title>
  1950. <para>
  1951. The description of tasks so far assumes that BitBake needs to
  1952. build everything and there are no prebuilt objects available.
  1953. BitBake does support skipping tasks if prebuilt objects are
  1954. available.
  1955. These objects are usually made available in the form of a
  1956. shared state (sstate) cache.
  1957. <note>
  1958. For information on variables affecting sstate, see the
  1959. <link linkend='var-SSTATE_DIR'><filename>SSTATE_DIR</filename></link>
  1960. and
  1961. <link linkend='var-SSTATE_MIRRORS'><filename>SSTATE_MIRRORS</filename></link>
  1962. variables.
  1963. </note>
  1964. </para>
  1965. <para>
  1966. The idea of a setscene task (i.e
  1967. <filename>do_</filename><replaceable>taskname</replaceable><filename>_setscene</filename>)
  1968. is a version of the task where
  1969. instead of building something, BitBake can skip to the end
  1970. result and simply place a set of files into specific locations
  1971. as needed.
  1972. In some cases, it makes sense to have a setscene task variant
  1973. (e.g. generating package files in the
  1974. <filename>do_package_write_*</filename> task).
  1975. In other cases, it does not make sense, (e.g. a
  1976. <link linkend='ref-tasks-patch'><filename>do_patch</filename></link>
  1977. task or
  1978. <link linkend='ref-tasks-unpack'><filename>do_unpack</filename></link>
  1979. task) since the work involved would be equal to or greater than
  1980. the underlying task.
  1981. </para>
  1982. <para>
  1983. In the OpenEmbedded build system, the common tasks that have
  1984. setscene variants are <link linkend='ref-tasks-package'><filename>do_package</filename></link>,
  1985. <filename>do_package_write_*</filename>,
  1986. <link linkend='ref-tasks-deploy'><filename>do_deploy</filename></link>,
  1987. <link linkend='ref-tasks-packagedata'><filename>do_packagedata</filename></link>,
  1988. and
  1989. <link linkend='ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></link>.
  1990. Notice that these are most of the tasks whose output is an
  1991. end result.
  1992. </para>
  1993. <para>
  1994. The OpenEmbedded build system has knowledge of the relationship
  1995. between these tasks and other tasks that precede them.
  1996. For example, if BitBake runs
  1997. <filename>do_populate_sysroot_setscene</filename> for
  1998. something, there is little point in running any of the
  1999. <filename>do_fetch</filename>, <filename>do_unpack</filename>,
  2000. <filename>do_patch</filename>,
  2001. <filename>do_configure</filename>,
  2002. <filename>do_compile</filename>, and
  2003. <filename>do_install</filename> tasks.
  2004. However, if <filename>do_package</filename> needs to be run,
  2005. BitBake would need to run those other tasks.
  2006. </para>
  2007. <para>
  2008. It becomes more complicated if everything can come from an
  2009. sstate cache because some objects are simply not required at
  2010. all.
  2011. For example, you do not need a compiler or native tools, such
  2012. as quilt, if there is nothing to compile or patch.
  2013. If the <filename>do_package_write_*</filename> packages are
  2014. available from sstate, BitBake does not need the
  2015. <filename>do_package</filename> task data.
  2016. </para>
  2017. <para>
  2018. To handle all these complexities, BitBake runs in two phases.
  2019. The first is the "setscene" stage.
  2020. During this stage, BitBake first checks the sstate cache for
  2021. any targets it is planning to build.
  2022. BitBake does a fast check to see if the object exists rather
  2023. than a complete download.
  2024. If nothing exists, the second phase, which is the setscene
  2025. stage, completes and the main build proceeds.
  2026. </para>
  2027. <para>
  2028. If objects are found in the sstate cache, the OpenEmbedded
  2029. build system works backwards from the end targets specified
  2030. by the user.
  2031. For example, if an image is being built, the OpenEmbedded build
  2032. system first looks for the packages needed for that image and
  2033. the tools needed to construct an image.
  2034. If those are available, the compiler is not needed.
  2035. Thus, the compiler is not even downloaded.
  2036. If something was found to be unavailable, or the download or
  2037. setscene task fails, the OpenEmbedded build system then tries
  2038. to install dependencies, such as the compiler, from the cache.
  2039. </para>
  2040. <para>
  2041. The availability of objects in the sstate cache is handled by
  2042. the function specified by the
  2043. <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_HASHCHECK_FUNCTION'><filename>BB_HASHCHECK_FUNCTION</filename></ulink>
  2044. variable and returns a list of the objects that are available.
  2045. The function specified by the
  2046. <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_SETSCENE_DEPVALID'><filename>BB_SETSCENE_DEPVALID</filename></ulink>
  2047. variable is the function that determines whether a given
  2048. dependency needs to be followed, and whether for any given
  2049. relationship the function needs to be passed.
  2050. The function returns a True or False value.
  2051. </para>
  2052. </section>
  2053. </section>
  2054. <section id='images-dev-environment'>
  2055. <title>Images</title>
  2056. <para>
  2057. The images produced by the OpenEmbedded build system
  2058. are compressed forms of the
  2059. root filesystem that are ready to boot on a target device.
  2060. You can see from the
  2061. <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>
  2062. that BitBake output, in part, consists of images.
  2063. This section is going to look more closely at this output:
  2064. <imagedata fileref="figures/images.png" align="center" width="5.5in" depth="5.5in" />
  2065. </para>
  2066. <para>
  2067. For a list of example images that the Yocto Project provides,
  2068. see the
  2069. "<link linkend='ref-images'>Images</link>" chapter.
  2070. </para>
  2071. <para>
  2072. Images are written out to the
  2073. <link linkend='build-directory'>Build Directory</link>
  2074. inside the <filename>tmp/deploy/images/<replaceable>machine</replaceable>/</filename>
  2075. folder as shown in the figure.
  2076. This folder contains any files expected to be loaded on the
  2077. target device.
  2078. The
  2079. <link linkend='var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></link>
  2080. variable points to the <filename>deploy</filename> directory,
  2081. while the
  2082. <link linkend='var-DEPLOY_DIR_IMAGE'><filename>DEPLOY_DIR_IMAGE</filename></link>
  2083. variable points to the appropriate directory containing images for
  2084. the current configuration.
  2085. <itemizedlist>
  2086. <listitem><para><filename><replaceable>kernel-image</replaceable></filename>:
  2087. A kernel binary file.
  2088. The <link linkend='var-KERNEL_IMAGETYPE'><filename>KERNEL_IMAGETYPE</filename></link>
  2089. variable setting determines the naming scheme for the
  2090. kernel image file.
  2091. Depending on that variable, the file could begin with
  2092. a variety of naming strings.
  2093. The <filename>deploy/images/<replaceable>machine</replaceable></filename>
  2094. directory can contain multiple image files for the
  2095. machine.</para></listitem>
  2096. <listitem><para><filename><replaceable>root-filesystem-image</replaceable></filename>:
  2097. Root filesystems for the target device (e.g.
  2098. <filename>*.ext3</filename> or <filename>*.bz2</filename>
  2099. files).
  2100. The <link linkend='var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></link>
  2101. variable setting determines the root filesystem image
  2102. type.
  2103. The <filename>deploy/images/<replaceable>machine</replaceable></filename>
  2104. directory can contain multiple root filesystems for the
  2105. machine.</para></listitem>
  2106. <listitem><para><filename><replaceable>kernel-modules</replaceable></filename>:
  2107. Tarballs that contain all the modules built for the kernel.
  2108. Kernel module tarballs exist for legacy purposes and
  2109. can be suppressed by setting the
  2110. <link linkend='var-MODULE_TARBALL_DEPLOY'><filename>MODULE_TARBALL_DEPLOY</filename></link>
  2111. variable to "0".
  2112. The <filename>deploy/images/<replaceable>machine</replaceable></filename>
  2113. directory can contain multiple kernel module tarballs
  2114. for the machine.</para></listitem>
  2115. <listitem><para><filename><replaceable>bootloaders</replaceable></filename>:
  2116. Bootloaders supporting the image, if applicable to the
  2117. target machine.
  2118. The <filename>deploy/images/<replaceable>machine</replaceable></filename>
  2119. directory can contain multiple bootloaders for the
  2120. machine.</para></listitem>
  2121. <listitem><para><filename><replaceable>symlinks</replaceable></filename>:
  2122. The <filename>deploy/images/<replaceable>machine</replaceable></filename>
  2123. folder contains
  2124. a symbolic link that points to the most recently built file
  2125. for each machine.
  2126. These links might be useful for external scripts that
  2127. need to obtain the latest version of each file.
  2128. </para></listitem>
  2129. </itemizedlist>
  2130. </para>
  2131. </section>
  2132. <section id='sdk-dev-environment'>
  2133. <title>Application Development SDK</title>
  2134. <para>
  2135. In the
  2136. <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>,
  2137. the output labeled "Application Development SDK" represents an
  2138. SDK.
  2139. The SDK generation process differs depending on whether you build
  2140. a standard SDK
  2141. (e.g. <filename>bitbake -c populate_sdk</filename> <replaceable>imagename</replaceable>)
  2142. or an extensible SDK
  2143. (e.g. <filename>bitbake -c populate_sdk_ext</filename> <replaceable>imagename</replaceable>).
  2144. This section is going to take a closer look at this output:
  2145. <imagedata fileref="figures/sdk.png" align="center" width="9in" depth="7.25in" />
  2146. </para>
  2147. <para>
  2148. The specific form of this output is a self-extracting
  2149. SDK installer (<filename>*.sh</filename>) that, when run,
  2150. installs the SDK, which consists of a cross-development
  2151. toolchain, a set of libraries and headers, and an SDK
  2152. environment setup script.
  2153. Running this installer essentially sets up your
  2154. cross-development environment.
  2155. You can think of the cross-toolchain as the "host"
  2156. part because it runs on the SDK machine.
  2157. You can think of the libraries and headers as the "target"
  2158. part because they are built for the target hardware.
  2159. The environment setup script is added so that you can initialize
  2160. the environment before using the tools.
  2161. </para>
  2162. <note>
  2163. <para>
  2164. The Yocto Project supports several methods by which you can
  2165. set up this cross-development environment.
  2166. These methods include downloading pre-built SDK installers
  2167. or building and installing your own SDK installer.
  2168. </para>
  2169. <para>
  2170. For background information on cross-development toolchains
  2171. in the Yocto Project development environment, see the
  2172. "<link linkend='cross-development-toolchain-generation'>Cross-Development Toolchain Generation</link>"
  2173. section.
  2174. For information on setting up a cross-development
  2175. environment, see the
  2176. <ulink url='&YOCTO_DOCS_SDK_URL;#sdk-manual'>Yocto Project Software Development Kit (SDK) Developer's Guide</ulink>.
  2177. </para>
  2178. </note>
  2179. <para>
  2180. Once built, the SDK installers are written out to the
  2181. <filename>deploy/sdk</filename> folder inside the
  2182. <link linkend='build-directory'>Build Directory</link>
  2183. as shown in the figure at the beginning of this section.
  2184. Depending on the type of SDK, several variables exist that help
  2185. configure these files.
  2186. The following list shows the variables associated with a standard
  2187. SDK:
  2188. <itemizedlist>
  2189. <listitem><para><link linkend='var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></link>:
  2190. Points to the <filename>deploy</filename>
  2191. directory.</para></listitem>
  2192. <listitem><para><link linkend='var-SDKMACHINE'><filename>SDKMACHINE</filename></link>:
  2193. Specifies the architecture of the machine
  2194. on which the cross-development tools are run to
  2195. create packages for the target hardware.
  2196. </para></listitem>
  2197. <listitem><para><link linkend='var-SDKIMAGE_FEATURES'><filename>SDKIMAGE_FEATURES</filename></link>:
  2198. Lists the features to include in the "target" part
  2199. of the SDK.
  2200. </para></listitem>
  2201. <listitem><para><link linkend='var-TOOLCHAIN_HOST_TASK'><filename>TOOLCHAIN_HOST_TASK</filename></link>:
  2202. Lists packages that make up the host
  2203. part of the SDK (i.e. the part that runs on
  2204. the <filename>SDKMACHINE</filename>).
  2205. When you use
  2206. <filename>bitbake -c populate_sdk <replaceable>imagename</replaceable></filename>
  2207. to create the SDK, a set of default packages
  2208. apply.
  2209. This variable allows you to add more packages.
  2210. </para></listitem>
  2211. <listitem><para><link linkend='var-TOOLCHAIN_TARGET_TASK'><filename>TOOLCHAIN_TARGET_TASK</filename></link>:
  2212. Lists packages that make up the target part
  2213. of the SDK (i.e. the part built for the
  2214. target hardware).
  2215. </para></listitem>
  2216. <listitem><para><link linkend='var-SDKPATH'><filename>SDKPATH</filename></link>:
  2217. Defines the default SDK installation path offered by the
  2218. installation script.
  2219. </para></listitem>
  2220. </itemizedlist>
  2221. This next list, shows the variables associated with an extensible
  2222. SDK:
  2223. <itemizedlist>
  2224. <listitem><para><link linkend='var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></link>:
  2225. Points to the <filename>deploy</filename> directory.
  2226. </para></listitem>
  2227. <listitem><para><link linkend='var-SDK_EXT_TYPE'><filename>SDK_EXT_TYPE</filename></link>:
  2228. Controls whether or not shared state artifacts are copied
  2229. into the extensible SDK.
  2230. By default, all required shared state artifacts are copied
  2231. into the SDK.
  2232. </para></listitem>
  2233. <listitem><para><link linkend='var-SDK_INCLUDE_PKGDATA'><filename>SDK_INCLUDE_PKGDATA</filename></link>:
  2234. Specifies whether or not packagedata will be included in
  2235. the extensible SDK for all recipes in the "world" target.
  2236. </para></listitem>
  2237. <listitem><para><link linkend='var-SDK_INCLUDE_TOOLCHAIN'><filename>SDK_INCLUDE_TOOLCHAIN</filename></link>:
  2238. Specifies whether or not the toolchain will be included
  2239. when building the extensible SDK.
  2240. </para></listitem>
  2241. <listitem><para><link linkend='var-SDK_LOCAL_CONF_WHITELIST'><filename>SDK_LOCAL_CONF_WHITELIST</filename></link>:
  2242. A list of variables allowed through from the build system
  2243. configuration into the extensible SDK configuration.
  2244. </para></listitem>
  2245. <listitem><para><link linkend='var-SDK_LOCAL_CONF_BLACKLIST'><filename>SDK_LOCAL_CONF_BLACKLIST</filename></link>:
  2246. A list of variables not allowed through from the build
  2247. system configuration into the extensible SDK configuration.
  2248. </para></listitem>
  2249. <listitem><para><link linkend='var-SDK_INHERIT_BLACKLIST'><filename>SDK_INHERIT_BLACKLIST</filename></link>:
  2250. A list of classes to remove from the
  2251. <link linkend='var-INHERIT'><filename>INHERIT</filename></link>
  2252. value globally within the extensible SDK configuration.
  2253. </para></listitem>
  2254. </itemizedlist>
  2255. </para>
  2256. </section>
  2257. </section>
  2258. </chapter>
  2259. <!--
  2260. vim: expandtab tw=80 ts=4
  2261. -->