overview-manual-concepts.xml 188 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605
  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=' overview-manual-concepts'>
  5. <title>Yocto Project Concepts</title>
  6. <section id='yocto-project-components'>
  7. <title>Yocto Project Components</title>
  8. <para>
  9. The
  10. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  11. task executor together with various types of configuration files
  12. form the OpenEmbedded-Core.
  13. This section overviews these components by describing their use and
  14. how they interact.
  15. </para>
  16. <para>
  17. BitBake handles the parsing and execution of the data files.
  18. The data itself is of various types:
  19. <itemizedlist>
  20. <listitem><para>
  21. <emphasis>Recipes:</emphasis>
  22. Provides details about particular pieces of software.
  23. </para></listitem>
  24. <listitem><para>
  25. <emphasis>Class Data:</emphasis>
  26. Abstracts common build information (e.g. how to build a
  27. Linux kernel).
  28. </para></listitem>
  29. <listitem><para>
  30. <emphasis>Configuration Data:</emphasis>
  31. Defines machine-specific settings, policy decisions, and
  32. so forth.
  33. Configuration data acts as the glue to bind everything
  34. together.
  35. </para></listitem>
  36. </itemizedlist>
  37. </para>
  38. <para>
  39. BitBake knows how to combine multiple data sources together and
  40. refers to each data source as a layer.
  41. For information on layers, see the
  42. "<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>"
  43. section of the Yocto Project Development Tasks Manual.
  44. </para>
  45. <para>
  46. Following are some brief details on these core components.
  47. For additional information on how these components interact during
  48. a build, see the
  49. "<link linkend='development-concepts'>Development Concepts</link>"
  50. section.
  51. </para>
  52. <section id='usingpoky-components-bitbake'>
  53. <title>BitBake</title>
  54. <para>
  55. BitBake is the tool at the heart of the
  56. <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink>
  57. and is responsible for parsing the
  58. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>,
  59. generating a list of tasks from it, and then executing those
  60. tasks.
  61. </para>
  62. <para>
  63. This section briefly introduces BitBake.
  64. If you want more information on BitBake, see the
  65. <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual'>BitBake User Manual</ulink>.
  66. </para>
  67. <para>
  68. To see a list of the options BitBake supports, use either of
  69. the following commands:
  70. <literallayout class='monospaced'>
  71. $ bitbake -h
  72. $ bitbake --help
  73. </literallayout>
  74. </para>
  75. <para>
  76. The most common usage for BitBake is
  77. <filename>bitbake <replaceable>packagename</replaceable></filename>,
  78. where <filename>packagename</filename> is the name of the
  79. package you want to build (referred to as the "target").
  80. The target often equates to the first part of a recipe's
  81. filename (e.g. "foo" for a recipe named
  82. <filename>foo_1.3.0-r0.bb</filename>).
  83. So, to process the
  84. <filename>matchbox-desktop_1.2.3.bb</filename> recipe file, you
  85. might type the following:
  86. <literallayout class='monospaced'>
  87. $ bitbake matchbox-desktop
  88. </literallayout>
  89. Several different versions of
  90. <filename>matchbox-desktop</filename> might exist.
  91. BitBake chooses the one selected by the distribution
  92. configuration.
  93. You can get more details about how BitBake chooses between
  94. different target versions and providers in the
  95. "<ulink url='&YOCTO_DOCS_BB_URL;#bb-bitbake-preferences'>Preferences</ulink>"
  96. section of the BitBake User Manual.
  97. </para>
  98. <para>
  99. BitBake also tries to execute any dependent tasks first.
  100. So for example, before building
  101. <filename>matchbox-desktop</filename>, BitBake would build a
  102. cross compiler and <filename>glibc</filename> if they had not
  103. already been built.
  104. </para>
  105. <para>
  106. A useful BitBake option to consider is the
  107. <filename>-k</filename> or <filename>--continue</filename>
  108. option.
  109. This option instructs BitBake to try and continue processing
  110. the job as long as possible even after encountering an error.
  111. When an error occurs, the target that failed and those that
  112. depend on it cannot be remade.
  113. However, when you use this option other dependencies can
  114. still be processed.
  115. </para>
  116. </section>
  117. <section id='concepts-components-metadata'>
  118. <title>Metadata (Recipes)</title>
  119. <para>
  120. Files that have the <filename>.bb</filename> suffix are
  121. "recipes" files.
  122. In general, a recipe contains information about a single piece
  123. of software.
  124. This information includes the location from which to download
  125. the unaltered source, any source patches to be applied to that
  126. source (if needed), which special configuration options to
  127. apply, how to compile the source files, and how to package the
  128. compiled output.
  129. </para>
  130. <para>
  131. The term "package" is sometimes used to refer to recipes.
  132. However, since the word "package" is used for the packaged
  133. output from the OpenEmbedded build system (i.e.
  134. <filename>.ipk</filename> or <filename>.deb</filename> files),
  135. this document avoids using the term "package" when referring
  136. to recipes.
  137. </para>
  138. </section>
  139. <section id='concepts-components-classes'>
  140. <title>Classes</title>
  141. <para>
  142. Class files (<filename>.bbclass</filename>) contain information
  143. that is useful to share between Metadata files.
  144. An example is the
  145. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  146. class, which contains common settings for any application that
  147. Autotools uses.
  148. The
  149. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes'>Classes</ulink>"
  150. chapter in the Yocto Project Reference Manual provides
  151. details about classes and how to use them.
  152. </para>
  153. </section>
  154. <section id='concepts-components-configuration'>
  155. <title>Configuration</title>
  156. <para>
  157. The configuration files (<filename>.conf</filename>) define
  158. various configuration variables that govern the OpenEmbedded
  159. build process.
  160. These files fall into several areas that define machine
  161. configuration options, distribution configuration options,
  162. compiler tuning options, general common configuration options,
  163. and user configuration options in
  164. <filename>local.conf</filename>, which is found in the
  165. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  166. </para>
  167. </section>
  168. </section>
  169. <section id='cm-layers'>
  170. <title>Layers</title>
  171. <para>
  172. Layers are repositories that contain related sets of instructions
  173. that tell the OpenEmbedded build system what to do.
  174. You use different layers to logically separate information in your
  175. build.
  176. You can collaborate, share, and reuse layers.
  177. The Layer Model simultaneously supports collaboration and
  178. customization.
  179. </para>
  180. <para>
  181. For more introductory information on the Yocto Project's layer
  182. model, see the
  183. "<link linkend='the-yocto-project-layer-model'>The Yocto Project Layer Model</link>"
  184. section.
  185. For procedures on how to create layers, see the
  186. "<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>"
  187. section in the Yocto Project Development Tasks Manual.
  188. </para>
  189. </section>
  190. <section id="development-concepts">
  191. <title>Development Concepts</title>
  192. <para>
  193. This section takes a more detailed look inside the build
  194. process used by the OpenEmbedded build system.
  195. The following diagram represents the build at a high level.
  196. The remainder of this section expands on the fundamental input,
  197. output, process, and
  198. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>
  199. blocks that make up the build process.
  200. </para>
  201. <para id='general-yocto-environment-figure'>
  202. <imagedata fileref="figures/yocto-environment-ref.png" align="center" width="8in" depth="4.25in" />
  203. </para>
  204. <para>
  205. In general, the build process consists of several functional areas:
  206. <itemizedlist>
  207. <listitem><para>
  208. <emphasis>User Configuration:</emphasis>
  209. Metadata you can use to control the build process.
  210. </para></listitem>
  211. <listitem><para>
  212. <emphasis>Metadata Layers:</emphasis>
  213. Various layers that provide software, machine, and
  214. distro Metadata.
  215. </para></listitem>
  216. <listitem><para>
  217. <emphasis>Source Files:</emphasis>
  218. Upstream releases, local projects, and SCMs.
  219. </para></listitem>
  220. <listitem><para>
  221. <emphasis>Build System:</emphasis>
  222. Processes under the control of
  223. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>.
  224. This block expands on how BitBake fetches source, applies
  225. patches, completes compilation, analyzes output for package
  226. generation, creates and tests packages, generates images,
  227. and generates cross-development tools.
  228. </para></listitem>
  229. <listitem><para>
  230. <emphasis>Package Feeds:</emphasis>
  231. Directories containing output packages (RPM, DEB or IPK),
  232. which are subsequently used in the construction of an
  233. image or SDK, produced by the build system.
  234. These feeds can also be copied and shared using a web
  235. server or other means to facilitate extending or updating
  236. existing images on devices at runtime if runtime package
  237. management is enabled.
  238. </para></listitem>
  239. <listitem><para>
  240. <emphasis>Images:</emphasis>
  241. Images produced by the development process.
  242. </para></listitem>
  243. <listitem><para>
  244. <emphasis>Application Development SDK:</emphasis>
  245. Cross-development tools that are produced along with
  246. an image or separately with BitBake.
  247. </para></listitem>
  248. </itemizedlist>
  249. </para>
  250. <section id="user-configuration">
  251. <title>User Configuration</title>
  252. <para>
  253. User configuration helps define the build.
  254. Through user configuration, you can tell BitBake the
  255. target architecture for which you are building the image,
  256. where to store downloaded source, and other build properties.
  257. </para>
  258. <para>
  259. The following figure shows an expanded representation of the
  260. "User Configuration" box of the
  261. <link linkend='general-yocto-environment-figure'>general Build Process figure</link>:
  262. </para>
  263. <para>
  264. <imagedata fileref="figures/user-configuration.png" align="center" width="8in" depth="4.5in" />
  265. </para>
  266. <para>
  267. BitBake needs some basic configuration files in order to
  268. complete a build.
  269. These files are <filename>*.conf</filename> files.
  270. The minimally necessary ones reside as example files in the
  271. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  272. For simplicity, this section refers to the Source Directory as
  273. the "Poky Directory."
  274. </para>
  275. <para>
  276. When you clone the <filename>poky</filename> Git repository
  277. or you download and unpack a Yocto Project release, you
  278. can set up the Source Directory to be named anything you want.
  279. For this discussion, the cloned repository uses the default
  280. name <filename>poky</filename>.
  281. <note>
  282. The
  283. <ulink url='&YOCTO_DOCS_REF_URL;#poky'>Poky</ulink>
  284. repository is primarily an aggregation of existing
  285. repositories.
  286. It is not a canonical upstream source.
  287. </note>
  288. </para>
  289. <para>
  290. The <filename>meta-poky</filename> layer inside Poky contains
  291. a <filename>conf</filename> directory that has example
  292. configuration files.
  293. These example files are used as a basis for creating actual
  294. configuration files when you source the build environment
  295. script
  296. (i.e.
  297. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>).
  298. </para>
  299. <para>
  300. Sourcing the build environment script creates a
  301. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  302. if one does not already exist.
  303. BitBake uses the Build Directory for all its work during
  304. builds.
  305. The Build Directory has a <filename>conf</filename> directory
  306. that contains default versions of your
  307. <filename>local.conf</filename> and
  308. <filename>bblayers.conf</filename> configuration files.
  309. These default configuration files are created only if versions
  310. do not already exist in the Build Directory at the time you
  311. source the build environment setup script.
  312. </para>
  313. <para>
  314. Because the Poky repository is fundamentally an aggregation of
  315. existing repositories, some users might be familiar with
  316. running the <filename>&OE_INIT_FILE;</filename> script
  317. in the context of separate
  318. <ulink url='&YOCTO_DOCS_REF_URL;#oe-core'>OpenEmbedded-Core</ulink>
  319. and BitBake repositories rather than a single Poky repository.
  320. This discussion assumes the script is executed from
  321. within a cloned or unpacked version of Poky.
  322. </para>
  323. <para>
  324. Depending on where the script is sourced, different
  325. sub-scripts are called to set up the Build Directory
  326. (Yocto or OpenEmbedded).
  327. Specifically, the script
  328. <filename>scripts/oe-setup-builddir</filename> inside the
  329. poky directory sets up the Build Directory and seeds the
  330. directory (if necessary) with configuration files appropriate
  331. for the Yocto Project development environment.
  332. <note>
  333. The <filename>scripts/oe-setup-builddir</filename> script
  334. uses the <filename>$TEMPLATECONF</filename> variable to
  335. determine which sample configuration files to locate.
  336. </note>
  337. </para>
  338. <para>
  339. The <filename>local.conf</filename> file provides many
  340. basic variables that define a build environment.
  341. Here is a list of a few.
  342. To see the default configurations in a
  343. <filename>local.conf</filename> file created by the build
  344. environment script, see the
  345. <filename>local.conf.sample</filename> in the
  346. <filename>meta-poky</filename> layer:
  347. <itemizedlist>
  348. <listitem><para>
  349. <emphasis>Parallelism Options:</emphasis>
  350. Controlled by the
  351. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_NUMBER_THREADS'><filename>BB_NUMBER_THREADS</filename></ulink>,
  352. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>,
  353. and
  354. <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_NUMBER_PARSE_THREADS'><filename>BB_NUMBER_PARSE_THREADS</filename></ulink>
  355. variables.
  356. </para></listitem>
  357. <listitem><para>
  358. <emphasis>Target Machine Selection:</emphasis>
  359. Controlled by the
  360. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  361. variable.
  362. </para></listitem>
  363. <listitem><para>
  364. <emphasis>Download Directory:</emphasis>
  365. Controlled by the
  366. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  367. variable.
  368. </para></listitem>
  369. <listitem><para>
  370. <emphasis>Shared State Directory:</emphasis>
  371. Controlled by the
  372. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>
  373. variable.
  374. </para></listitem>
  375. <listitem><para>
  376. <emphasis>Build Output:</emphasis>
  377. Controlled by the
  378. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  379. variable.
  380. </para></listitem>
  381. </itemizedlist>
  382. <note>
  383. Configurations set in the
  384. <filename>conf/local.conf</filename> file can also be set
  385. in the <filename>conf/site.conf</filename> and
  386. <filename>conf/auto.conf</filename> configuration files.
  387. </note>
  388. </para>
  389. <para>
  390. The <filename>bblayers.conf</filename> file tells BitBake what
  391. layers you want considered during the build.
  392. By default, the layers listed in this file include layers
  393. minimally needed by the build system.
  394. However, you must manually add any custom layers you have
  395. created.
  396. You can find more information on working with the
  397. <filename>bblayers.conf</filename> file in the
  398. "<ulink url='&YOCTO_DOCS_DEV_URL;#enabling-your-layer'>Enabling Your Layer</ulink>"
  399. section in the Yocto Project Development Tasks Manual.
  400. </para>
  401. <para>
  402. The files <filename>site.conf</filename> and
  403. <filename>auto.conf</filename> are not created by the
  404. environment initialization script.
  405. If you want the <filename>site.conf</filename> file, you
  406. need to create that yourself.
  407. The <filename>auto.conf</filename> file is typically created by
  408. an autobuilder:
  409. <itemizedlist>
  410. <listitem><para>
  411. <emphasis><filename>site.conf</filename>:</emphasis>
  412. You can use the <filename>conf/site.conf</filename>
  413. configuration file to configure multiple
  414. build directories.
  415. For example, suppose you had several build environments
  416. and they shared some common features.
  417. You can set these default build properties here.
  418. A good example is perhaps the packaging format to use
  419. through the
  420. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  421. variable.</para>
  422. <para>One useful scenario for using the
  423. <filename>conf/site.conf</filename> file is to extend
  424. your
  425. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>
  426. variable to include the path to a
  427. <filename>conf/site.conf</filename>.
  428. Then, when BitBake looks for Metadata using
  429. <filename>BBPATH</filename>, it finds the
  430. <filename>conf/site.conf</filename> file and applies
  431. your common configurations found in the file.
  432. To override configurations in a particular build
  433. directory, alter the similar configurations within
  434. that build directory's
  435. <filename>conf/local.conf</filename> file.
  436. </para></listitem>
  437. <listitem><para>
  438. <emphasis><filename>auto.conf</filename>:</emphasis>
  439. The file is usually created and written to by
  440. an autobuilder.
  441. The settings put into the file are typically the
  442. same as you would find in the
  443. <filename>conf/local.conf</filename> or the
  444. <filename>conf/site.conf</filename> files.
  445. </para></listitem>
  446. </itemizedlist>
  447. </para>
  448. <para>
  449. You can edit all configuration files to further define
  450. any particular build environment.
  451. This process is represented by the "User Configuration Edits"
  452. box in the figure.
  453. </para>
  454. <para>
  455. When you launch your build with the
  456. <filename>bitbake <replaceable>target</replaceable></filename>
  457. command, BitBake sorts out the configurations to ultimately
  458. define your build environment.
  459. It is important to understand that the
  460. <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink>
  461. reads the configuration files in a specific order:
  462. <filename>site.conf</filename>, <filename>auto.conf</filename>,
  463. and <filename>local.conf</filename>.
  464. And, the build system applies the normal assignment statement
  465. rules.
  466. Because the files are parsed in a specific order, variable
  467. assignments for the same variable could be affected.
  468. For example, if the <filename>auto.conf</filename> file and
  469. the <filename>local.conf</filename> set
  470. <replaceable>variable1</replaceable> to different values,
  471. because the build system parses <filename>local.conf</filename>
  472. after <filename>auto.conf</filename>,
  473. <replaceable>variable1</replaceable> is assigned the value from
  474. the <filename>local.conf</filename> file.
  475. </para>
  476. </section>
  477. <section id="metadata-machine-configuration-and-policy-configuration">
  478. <title>Metadata, Machine Configuration, and Policy Configuration</title>
  479. <para>
  480. The previous section described the user configurations that
  481. define BitBake's global behavior.
  482. This section takes a closer look at the layers the build system
  483. uses to further control the build.
  484. These layers provide Metadata for the software, machine, and
  485. policy.
  486. </para>
  487. <para>
  488. In general, three types of layer input exist:
  489. <itemizedlist>
  490. <listitem><para>
  491. <emphasis>Policy Configuration:</emphasis>
  492. Distribution Layers provide top-level or general
  493. policies for the image or SDK being built.
  494. For example, this layer would dictate whether BitBake
  495. produces RPM or IPK packages.
  496. </para></listitem>
  497. <listitem><para>
  498. <emphasis>Machine Configuration:</emphasis>
  499. Board Support Package (BSP) layers provide machine
  500. configurations.
  501. This type of information is specific to a particular
  502. target architecture.
  503. </para></listitem>
  504. <listitem><para>
  505. <emphasis>Metadata:</emphasis>
  506. Software layers contain user-supplied recipe files,
  507. patches, and append files.
  508. </para></listitem>
  509. </itemizedlist>
  510. </para>
  511. <para>
  512. The following figure shows an expanded representation of the
  513. Metadata, Machine Configuration, and Policy Configuration input
  514. (layers) boxes of the
  515. <link linkend='general-yocto-environment-figure'>general Build Process figure</link>:
  516. </para>
  517. <para>
  518. <imagedata fileref="figures/layer-input.png" align="center" width="8in" depth="7.5in" />
  519. </para>
  520. <para>
  521. In general, all layers have a similar structure.
  522. They all contain a licensing file
  523. (e.g. <filename>COPYING</filename>) if the layer is to be
  524. distributed, a <filename>README</filename> file as good
  525. practice and especially if the layer is to be distributed, a
  526. configuration directory, and recipe directories.
  527. </para>
  528. <para>
  529. The Yocto Project has many layers that can be used.
  530. You can see a web-interface listing of them on the
  531. <ulink url="http://git.yoctoproject.org/">Source Repositories</ulink>
  532. page.
  533. The layers appear at the bottom categorized under
  534. "Yocto Metadata Layers."
  535. These layers are fundamentally a subset of the
  536. <ulink url="http://layers.openembedded.org/layerindex/layers/">OpenEmbedded Layer Index</ulink>,
  537. which lists all layers provided by the OpenEmbedded community.
  538. <note>
  539. Layers exist in the Yocto Project Source Repositories that
  540. cannot be found in the OpenEmbedded Layer Index.
  541. These layers are either deprecated or experimental
  542. in nature.
  543. </note>
  544. </para>
  545. <para>
  546. BitBake uses the <filename>conf/bblayers.conf</filename> file,
  547. which is part of the user configuration, to find what layers it
  548. should be using as part of the build.
  549. </para>
  550. <para>
  551. For more information on layers, see the
  552. "<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>"
  553. section in the Yocto Project Development Tasks Manual.
  554. </para>
  555. <section id="distro-layer">
  556. <title>Distro Layer</title>
  557. <para>
  558. The distribution layer provides policy configurations for
  559. your distribution.
  560. Best practices dictate that you isolate these types of
  561. configurations into their own layer.
  562. Settings you provide in
  563. <filename>conf/distro/<replaceable>distro</replaceable>.conf</filename> override
  564. similar settings that BitBake finds in your
  565. <filename>conf/local.conf</filename> file in the Build
  566. Directory.
  567. </para>
  568. <para>
  569. The following list provides some explanation and references
  570. for what you typically find in the distribution layer:
  571. <itemizedlist>
  572. <listitem><para>
  573. <emphasis>classes:</emphasis>
  574. Class files (<filename>.bbclass</filename>) hold
  575. common functionality that can be shared among
  576. recipes in the distribution.
  577. When your recipes inherit a class, they take on the
  578. settings and functions for that class.
  579. You can read more about class files in the
  580. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes'>Classes</ulink>"
  581. chapter of the Yocto Reference Manual.
  582. </para></listitem>
  583. <listitem><para>
  584. <emphasis>conf:</emphasis>
  585. This area holds configuration files for the
  586. layer (<filename>conf/layer.conf</filename>),
  587. the distribution
  588. (<filename>conf/distro/<replaceable>distro</replaceable>.conf</filename>),
  589. and any distribution-wide include files.
  590. </para></listitem>
  591. <listitem><para>
  592. <emphasis>recipes-*:</emphasis>
  593. Recipes and append files that affect common
  594. functionality across the distribution.
  595. This area could include recipes and append files
  596. to add distribution-specific configuration,
  597. initialization scripts, custom image recipes,
  598. and so forth.
  599. </para></listitem>
  600. </itemizedlist>
  601. </para>
  602. </section>
  603. <section id="bsp-layer">
  604. <title>BSP Layer</title>
  605. <para>
  606. The BSP Layer provides machine configurations.
  607. Everything in this layer is specific to the machine for
  608. which you are building the image or the SDK.
  609. A common structure or form is defined for BSP layers.
  610. You can learn more about this structure in the
  611. <ulink url='&YOCTO_DOCS_BSP_URL;'>Yocto Project Board Support Package (BSP) Developer's Guide</ulink>.
  612. <note>
  613. In order for a BSP layer to be considered compliant
  614. with the Yocto Project, it must meet some structural
  615. requirements.
  616. </note>
  617. </para>
  618. <para>
  619. The BSP Layer's configuration directory contains
  620. configuration files for the machine
  621. (<filename>conf/machine/<replaceable>machine</replaceable>.conf</filename>)
  622. and, of course, the layer
  623. (<filename>conf/layer.conf</filename>).
  624. </para>
  625. <para>
  626. The remainder of the layer is dedicated to specific recipes
  627. by function: <filename>recipes-bsp</filename>,
  628. <filename>recipes-core</filename>,
  629. <filename>recipes-graphics</filename>, and
  630. <filename>recipes-kernel</filename>.
  631. Metadata can exist for multiple formfactors, graphics
  632. support systems, and so forth.
  633. <note>
  634. While the figure shows several
  635. <filename>recipes-*</filename> directories, not all
  636. these directories appear in all BSP layers.
  637. </note>
  638. </para>
  639. </section>
  640. <section id="software-layer">
  641. <title>Software Layer</title>
  642. <para>
  643. The software layer provides the Metadata for additional
  644. software packages used during the build.
  645. This layer does not include Metadata that is specific to
  646. the distribution or the machine, which are found in their
  647. respective layers.
  648. </para>
  649. <para>
  650. This layer contains any new recipes that your project
  651. needs in the form of recipe files.
  652. </para>
  653. </section>
  654. </section>
  655. <section id="sources-dev-environment">
  656. <title>Sources</title>
  657. <para>
  658. In order for the OpenEmbedded build system to create an
  659. image or any target, it must be able to access source files.
  660. The
  661. <link linkend='general-yocto-environment-figure'>general Build Process figure</link>
  662. represents source files using the "Upstream Project Releases",
  663. "Local Projects", and "SCMs (optional)" boxes.
  664. The figure represents mirrors, which also play a role in
  665. locating source files, with the "Source Mirror(s)" box.
  666. </para>
  667. <para>
  668. The method by which source files are ultimately organized is
  669. a function of the project.
  670. For example, for released software, projects tend to use
  671. tarballs or other archived files that can capture the
  672. state of a release guaranteeing that it is statically
  673. represented.
  674. On the other hand, for a project that is more dynamic or
  675. experimental in nature, a project might keep source files in a
  676. repository controlled by a Source Control Manager (SCM) such as
  677. Git.
  678. Pulling source from a repository allows you to control
  679. the point in the repository (the revision) from which you
  680. want to build software.
  681. Finally, a combination of the two might exist, which would
  682. give the consumer a choice when deciding where to get
  683. source files.
  684. </para>
  685. <para>
  686. BitBake uses the
  687. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  688. variable to point to source files regardless of their location.
  689. Each recipe must have a <filename>SRC_URI</filename> variable
  690. that points to the source.
  691. </para>
  692. <para>
  693. Another area that plays a significant role in where source
  694. files come from is pointed to by the
  695. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  696. variable.
  697. This area is a cache that can hold previously downloaded
  698. source.
  699. You can also instruct the OpenEmbedded build system to create
  700. tarballs from Git repositories, which is not the default
  701. behavior, and store them in the <filename>DL_DIR</filename>
  702. by using the
  703. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink>
  704. variable.
  705. </para>
  706. <para>
  707. Judicious use of a <filename>DL_DIR</filename> directory can
  708. save the build system a trip across the Internet when looking
  709. for files.
  710. A good method for using a download directory is to have
  711. <filename>DL_DIR</filename> point to an area outside of your
  712. Build Directory.
  713. Doing so allows you to safely delete the Build Directory
  714. if needed without fear of removing any downloaded source file.
  715. </para>
  716. <para>
  717. The remainder of this section provides a deeper look into the
  718. source files and the mirrors.
  719. Here is a more detailed look at the source file area of the
  720. <link linkend='general-yocto-environment-figure'>general Build Process figure</link>:
  721. <imagedata fileref="figures/source-input.png" align="center" width="7in" depth="7.5in" />
  722. </para>
  723. <section id='upstream-project-releases'>
  724. <title>Upstream Project Releases</title>
  725. <para>
  726. Upstream project releases exist anywhere in the form of an
  727. archived file (e.g. tarball or zip file).
  728. These files correspond to individual recipes.
  729. For example, the figure uses specific releases each for
  730. BusyBox, Qt, and Dbus.
  731. An archive file can be for any released product that can be
  732. built using a recipe.
  733. </para>
  734. </section>
  735. <section id='local-projects'>
  736. <title>Local Projects</title>
  737. <para>
  738. Local projects are custom bits of software the user
  739. provides.
  740. These bits reside somewhere local to a project - perhaps
  741. a directory into which the user checks in items (e.g.
  742. a local directory containing a development source tree
  743. used by the group).
  744. </para>
  745. <para>
  746. The canonical method through which to include a local
  747. project is to use the
  748. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink>
  749. class to include that local project.
  750. You use either the <filename>local.conf</filename> or a
  751. recipe's append file to override or set the
  752. recipe to point to the local directory on your disk to pull
  753. in the whole source tree.
  754. </para>
  755. </section>
  756. <section id='scms'>
  757. <title>Source Control Managers (Optional)</title>
  758. <para>
  759. Another place the build system can get source files from is
  760. through an SCM such as Git or Subversion.
  761. In this case, a repository is cloned or checked out.
  762. The
  763. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>
  764. task inside BitBake uses
  765. the <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  766. variable and the argument's prefix to determine the correct
  767. fetcher module.
  768. <note>
  769. For information on how to have the OpenEmbedded build
  770. system generate tarballs for Git repositories and place
  771. them in the
  772. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  773. directory, see the
  774. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink>
  775. variable.
  776. </note>
  777. </para>
  778. <para>
  779. When fetching a repository, BitBake uses the
  780. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  781. variable to determine the specific revision from which to
  782. build.
  783. </para>
  784. </section>
  785. <section id='source-mirrors'>
  786. <title>Source Mirror(s)</title>
  787. <para>
  788. Two kinds of mirrors exist: pre-mirrors and regular
  789. mirrors.
  790. The
  791. <ulink url='&YOCTO_DOCS_REF_URL;#var-PREMIRRORS'><filename>PREMIRRORS</filename></ulink>
  792. and
  793. <ulink url='&YOCTO_DOCS_REF_URL;#var-MIRRORS'><filename>MIRRORS</filename></ulink>
  794. variables point to these, respectively.
  795. BitBake checks pre-mirrors before looking upstream for any
  796. source files.
  797. Pre-mirrors are appropriate when you have a shared
  798. directory that is not a directory defined by the
  799. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  800. variable.
  801. A Pre-mirror typically points to a shared directory that is
  802. local to your organization.
  803. </para>
  804. <para>
  805. Regular mirrors can be any site across the Internet
  806. that is used as an alternative location for source
  807. code should the primary site not be functioning for
  808. some reason or another.
  809. </para>
  810. </section>
  811. </section>
  812. <section id="package-feeds-dev-environment">
  813. <title>Package Feeds</title>
  814. <para>
  815. When the OpenEmbedded build system generates an image or an
  816. SDK, it gets the packages from a package feed area located
  817. in the
  818. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  819. The
  820. <link linkend='general-yocto-environment-figure'>general Build Process figure</link>
  821. shows this package feeds area in the upper-right corner.
  822. </para>
  823. <para>
  824. This section looks a little closer into the package feeds
  825. area used by the build system.
  826. Here is a more detailed look at the area:
  827. <imagedata fileref="figures/package-feeds.png" align="center" width="7in" depth="6in" />
  828. </para>
  829. <para>
  830. Package feeds are an intermediary step in the build process.
  831. The OpenEmbedded build system provides classes to generate
  832. different package types, and you specify which classes to
  833. enable through the
  834. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  835. variable.
  836. Before placing the packages into package feeds,
  837. the build process validates them with generated output quality
  838. assurance checks through the
  839. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink>
  840. class.
  841. </para>
  842. <para>
  843. The package feed area resides in the Build Directory.
  844. The directory the build system uses to temporarily store
  845. packages is determined by a combination of variables and the
  846. particular package manager in use.
  847. See the "Package Feeds" box in the illustration and note the
  848. information to the right of that area.
  849. In particular, the following defines where package files are
  850. kept:
  851. <itemizedlist>
  852. <listitem><para>
  853. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></ulink>:
  854. Defined as <filename>tmp/deploy</filename> in the Build
  855. Directory.
  856. </para></listitem>
  857. <listitem><para>
  858. <filename>DEPLOY_DIR_*</filename>:
  859. Depending on the package manager used, the package type
  860. sub-folder.
  861. Given RPM, IPK, or DEB packaging and tarball creation,
  862. the
  863. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR_RPM'><filename>DEPLOY_DIR_RPM</filename></ulink>,
  864. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR_IPK'><filename>DEPLOY_DIR_IPK</filename></ulink>,
  865. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR_DEB'><filename>DEPLOY_DIR_DEB</filename></ulink>,
  866. or
  867. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR_TAR'><filename>DEPLOY_DIR_TAR</filename></ulink>,
  868. variables are used, respectively.
  869. </para></listitem>
  870. <listitem><para>
  871. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>:
  872. Defines architecture-specific sub-folders.
  873. For example, packages could exist for the i586 or
  874. qemux86 architectures.
  875. </para></listitem>
  876. </itemizedlist>
  877. </para>
  878. <para>
  879. BitBake uses the
  880. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_deb'><filename>do_package_write_*</filename></ulink>
  881. tasks to generate packages and place them into the package
  882. holding area (e.g. <filename>do_package_write_ipk</filename>
  883. for IPK packages).
  884. See the
  885. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_deb'><filename>do_package_write_deb</filename></ulink>",
  886. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_ipk'><filename>do_package_write_ipk</filename></ulink>",
  887. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_rpm'><filename>do_package_write_rpm</filename></ulink>",
  888. and
  889. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_tar'><filename>do_package_write_tar</filename></ulink>"
  890. sections in the Yocto Project Reference Manual
  891. for additional information.
  892. As an example, consider a scenario where an IPK packaging
  893. manager is being used and package architecture support for
  894. both i586 and qemux86 exist.
  895. Packages for the i586 architecture are placed in
  896. <filename>build/tmp/deploy/ipk/i586</filename>, while packages
  897. for the qemux86 architecture are placed in
  898. <filename>build/tmp/deploy/ipk/qemux86</filename>.
  899. </para>
  900. </section>
  901. <section id='bitbake-dev-environment'>
  902. <title>BitBake</title>
  903. <para>
  904. The OpenEmbedded build system uses
  905. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  906. to produce images.
  907. You can see from the
  908. <link linkend='general-yocto-environment-figure'>general Build Process figure</link>,
  909. the BitBake area consists of several functional areas.
  910. This section takes a closer look at each of those areas.
  911. </para>
  912. <para>
  913. Separate documentation exists for the BitBake tool.
  914. See the
  915. <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual'>BitBake User Manual</ulink>
  916. for reference material on BitBake.
  917. </para>
  918. <section id='source-fetching-dev-environment'>
  919. <title>Source Fetching</title>
  920. <para>
  921. The first stages of building a recipe are to fetch and
  922. unpack the source code:
  923. <imagedata fileref="figures/source-fetching.png" align="center" width="6.5in" depth="5in" />
  924. </para>
  925. <para>
  926. The
  927. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>
  928. and
  929. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>
  930. tasks fetch the source files and unpack them into the work
  931. directory.
  932. <note>
  933. For every local file (e.g. <filename>file://</filename>)
  934. that is part of a recipe's
  935. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  936. statement, the OpenEmbedded build system takes a
  937. checksum of the file for the recipe and inserts the
  938. checksum into the signature for the
  939. <filename>do_fetch</filename>.
  940. If any local file has been modified, the
  941. <filename>do_fetch</filename> task and all tasks that
  942. depend on it are re-executed.
  943. </note>
  944. By default, everything is accomplished in the
  945. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  946. which has a defined structure.
  947. For additional general information on the Build Directory,
  948. see the
  949. "<ulink url='&YOCTO_DOCS_REF_URL;#structure-core-build'><filename>build/</filename></ulink>"
  950. section in the Yocto Project Reference Manual.
  951. </para>
  952. <para>
  953. Unpacked source files are pointed to by the
  954. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
  955. variable.
  956. Each recipe has an area in the Build Directory where the
  957. unpacked source code resides.
  958. The name of that directory for any given recipe is defined
  959. from several different variables.
  960. You can see the variables that define these directories
  961. by looking at the figure:
  962. <itemizedlist>
  963. <listitem><para>
  964. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>:
  965. The base directory where the OpenEmbedded build
  966. system performs all its work during the build.
  967. </para></listitem>
  968. <listitem><para>
  969. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>:
  970. The architecture of the built package or packages.
  971. </para></listitem>
  972. <listitem><para>
  973. <ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_OS'><filename>TARGET_OS</filename></ulink>:
  974. The operating system of the target device.
  975. </para></listitem>
  976. <listitem><para>
  977. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>:
  978. The name of the built package.
  979. </para></listitem>
  980. <listitem><para>
  981. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>:
  982. The version of the recipe used to build the
  983. package.
  984. </para></listitem>
  985. <listitem><para>
  986. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>:
  987. The revision of the recipe used to build the
  988. package.
  989. </para></listitem>
  990. <listitem><para>
  991. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>:
  992. The location within <filename>TMPDIR</filename>
  993. where a specific package is built.
  994. </para></listitem>
  995. <listitem><para>
  996. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>:
  997. Contains the unpacked source files for a given
  998. recipe.
  999. </para></listitem>
  1000. </itemizedlist>
  1001. </para>
  1002. </section>
  1003. <section id='patching-dev-environment'>
  1004. <title>Patching</title>
  1005. <para>
  1006. Once source code is fetched and unpacked, BitBake locates
  1007. patch files and applies them to the source files:
  1008. <imagedata fileref="figures/patching.png" align="center" width="6in" depth="5in" />
  1009. </para>
  1010. <para>
  1011. The
  1012. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  1013. task processes recipes by using the
  1014. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1015. variable to locate applicable patch files, which by default
  1016. are <filename>*.patch</filename> or
  1017. <filename>*.diff</filename> files, or any file if
  1018. "apply=yes" is specified for the file in
  1019. <filename>SRC_URI</filename>.
  1020. </para>
  1021. <para>
  1022. BitBake finds and applies multiple patches for a single
  1023. recipe in the order in which it finds the patches.
  1024. Patches are applied to the recipe's source files located
  1025. in the
  1026. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
  1027. directory.
  1028. </para>
  1029. <para>
  1030. For more information on how the source directories are
  1031. created, see the
  1032. "<link linkend='source-fetching-dev-environment'>Source Fetching</link>"
  1033. section.
  1034. </para>
  1035. </section>
  1036. <section id='configuration-and-compilation-dev-environment'>
  1037. <title>Configuration and Compilation</title>
  1038. <para>
  1039. After source code is patched, BitBake executes tasks that
  1040. configure and compile the source code:
  1041. <imagedata fileref="figures/configuration-compile-autoreconf.png" align="center" width="7in" depth="5in" />
  1042. </para>
  1043. <para>
  1044. This step in the build process consists of three tasks:
  1045. <itemizedlist>
  1046. <listitem><para>
  1047. <emphasis><ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-prepare_recipe_sysroot'><filename>do_prepare_recipe_sysroot</filename></ulink></emphasis>:
  1048. This task sets up the two sysroots in
  1049. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>
  1050. (i.e. <filename>recipe-sysroot</filename> and
  1051. <filename>recipe-sysroot-native</filename>) so that
  1052. the sysroots contain the contents of the
  1053. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>
  1054. tasks of the recipes on which the recipe
  1055. containing the tasks depends.
  1056. A sysroot exists for both the target and for the
  1057. native binaries, which run on the host system.
  1058. </para></listitem>
  1059. <listitem><para>
  1060. <emphasis><filename>do_configure</filename></emphasis>:
  1061. This task configures the source by enabling and
  1062. disabling any build-time and configuration options
  1063. for the software being built.
  1064. Configurations can come from the recipe itself as
  1065. well as from an inherited class.
  1066. Additionally, the software itself might configure
  1067. itself depending on the target for which it is
  1068. being built.</para>
  1069. <para>The configurations handled by the
  1070. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  1071. task are specific to source code configuration for
  1072. the source code being built by the recipe.</para>
  1073. <para>If you are using the
  1074. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  1075. class, you can add additional configuration options
  1076. by using the
  1077. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECONF'><filename>EXTRA_OECONF</filename></ulink>
  1078. or
  1079. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink>
  1080. variables.
  1081. For information on how this variable works within
  1082. that class, see the
  1083. <filename>meta/classes/autotools.bbclass</filename>
  1084. file.
  1085. </para></listitem>
  1086. <listitem><para>
  1087. <emphasis><filename>do_compile</filename></emphasis>:
  1088. Once a configuration task has been satisfied, BitBake
  1089. compiles the source using the
  1090. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  1091. task.
  1092. Compilation occurs in the directory pointed to by
  1093. the
  1094. <ulink url='&YOCTO_DOCS_REF_URL;#var-B'><filename>B</filename></ulink>
  1095. variable.
  1096. Realize that the <filename>B</filename> directory
  1097. is, by default, the same as the
  1098. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
  1099. directory.
  1100. </para></listitem>
  1101. <listitem><para>
  1102. <emphasis><filename>do_install</filename></emphasis>:
  1103. Once compilation is done, BitBake executes the
  1104. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  1105. task.
  1106. This task copies files from the
  1107. <filename>B</filename> directory and places them
  1108. in a holding area pointed to by the
  1109. <ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  1110. variable.
  1111. </para></listitem>
  1112. </itemizedlist>
  1113. </para>
  1114. </section>
  1115. <section id='package-splitting-dev-environment'>
  1116. <title>Package Splitting</title>
  1117. <para>
  1118. After source code is configured and compiled, the
  1119. OpenEmbedded build system analyzes
  1120. the results and splits the output into packages:
  1121. <imagedata fileref="figures/analysis-for-package-splitting.png" align="center" width="7in" depth="7in" />
  1122. </para>
  1123. <para>
  1124. The
  1125. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>
  1126. and
  1127. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-packagedata'><filename>do_packagedata</filename></ulink>
  1128. tasks combine to analyze the files found in the
  1129. <ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  1130. directory and split them into subsets based on available
  1131. packages and files.
  1132. The analyzing process involves the following as well as
  1133. other items: splitting out debugging symbols, looking at
  1134. shared library dependencies between packages, and looking
  1135. at package relationships.
  1136. The <filename>do_packagedata</filename> task creates
  1137. package metadata based on the analysis such that the
  1138. OpenEmbedded build system can generate the final packages.
  1139. Working, staged, and intermediate results of the analysis
  1140. and package splitting process use these areas:
  1141. <itemizedlist>
  1142. <listitem><para>
  1143. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGD'><filename>PKGD</filename></ulink>:
  1144. The destination directory for packages before they
  1145. are split.
  1146. </para></listitem>
  1147. <listitem><para>
  1148. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></ulink>:
  1149. A shared, global-state directory that holds data
  1150. generated during the packaging process.
  1151. </para></listitem>
  1152. <listitem><para>
  1153. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDESTWORK'><filename>PKGDESTWORK</filename></ulink>:
  1154. A temporary work area used by the
  1155. <filename>do_package</filename> task.
  1156. </para></listitem>
  1157. <listitem><para>
  1158. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDEST'><filename>PKGDEST</filename></ulink>:
  1159. The parent directory for packages after they have
  1160. been split.
  1161. </para></listitem>
  1162. </itemizedlist>
  1163. The
  1164. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>
  1165. variable defines the files that go into each package in
  1166. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>.
  1167. If you want details on how this is accomplished, you can
  1168. look at the
  1169. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-package'><filename>package</filename></ulink>
  1170. class.
  1171. </para>
  1172. <para>
  1173. Depending on the type of packages being created (RPM, DEB,
  1174. or IPK), the
  1175. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_deb'><filename>do_package_write_*</filename></ulink>
  1176. task creates the actual packages and places them in the
  1177. Package Feed area, which is
  1178. <filename>${TMPDIR}/deploy</filename>.
  1179. You can see the
  1180. "<link linkend='package-feeds-dev-environment'>Package Feeds</link>"
  1181. section for more detail on that part of the build process.
  1182. <note>
  1183. Support for creating feeds directly from the
  1184. <filename>deploy/*</filename> directories does not
  1185. exist.
  1186. Creating such feeds usually requires some kind of feed
  1187. maintenance mechanism that would upload the new
  1188. packages into an official package feed (e.g. the
  1189. Ångström distribution).
  1190. This functionality is highly distribution-specific
  1191. and thus is not provided out of the box.
  1192. </note>
  1193. </para>
  1194. </section>
  1195. <section id='image-generation-dev-environment'>
  1196. <title>Image Generation</title>
  1197. <para>
  1198. Once packages are split and stored in the Package Feeds
  1199. area, the OpenEmbedded build system uses BitBake to
  1200. generate the root filesystem image:
  1201. <imagedata fileref="figures/image-generation.png" align="center" width="6in" depth="7in" />
  1202. </para>
  1203. <para>
  1204. The image generation process consists of several stages and
  1205. depends on several tasks and variables.
  1206. The
  1207. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-rootfs'><filename>do_rootfs</filename></ulink>
  1208. task creates the root filesystem (file and directory
  1209. structure) for an image.
  1210. This task uses several key variables to help create the
  1211. list of packages to actually install:
  1212. <itemizedlist>
  1213. <listitem><para>
  1214. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>:
  1215. Lists out the base set of packages to install from
  1216. the Package Feeds area.
  1217. </para></listitem>
  1218. <listitem><para>
  1219. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXCLUDE'><filename>PACKAGE_EXCLUDE</filename></ulink>:
  1220. Specifies packages that should not be installed.
  1221. </para></listitem>
  1222. <listitem><para>
  1223. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>:
  1224. Specifies features to include in the image.
  1225. Most of these features map to additional packages
  1226. for installation.
  1227. </para></listitem>
  1228. <listitem><para>
  1229. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>:
  1230. Specifies the package backend to use and
  1231. consequently helps determine where to locate
  1232. packages within the Package Feeds area.
  1233. </para></listitem>
  1234. <listitem><para>
  1235. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_LINGUAS'><filename>IMAGE_LINGUAS</filename></ulink>:
  1236. Determines the language(s) for which additional
  1237. language support packages are installed.
  1238. </para></listitem>
  1239. <listitem><para>
  1240. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_INSTALL'><filename>PACKAGE_INSTALL</filename></ulink>:
  1241. The final list of packages passed to the package manager
  1242. for installation into the image.
  1243. </para></listitem>
  1244. </itemizedlist>
  1245. </para>
  1246. <para>
  1247. With
  1248. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_ROOTFS'><filename>IMAGE_ROOTFS</filename></ulink>
  1249. pointing to the location of the filesystem under
  1250. construction and the <filename>PACKAGE_INSTALL</filename>
  1251. variable providing the final list of packages to install,
  1252. the root file system is created.
  1253. </para>
  1254. <para>
  1255. Package installation is under control of the package
  1256. manager (e.g. dnf/rpm, opkg, or apt/dpkg) regardless of
  1257. whether or not package management is enabled for the
  1258. target.
  1259. At the end of the process, if package management is not
  1260. enabled for the target, the package manager's data files
  1261. are deleted from the root filesystem.
  1262. As part of the final stage of package installation,
  1263. postinstall scripts that are part of the packages are run.
  1264. Any scripts that fail to run
  1265. on the build host are run on the target when the target
  1266. system is first booted.
  1267. If you are using a
  1268. <ulink url='&YOCTO_DOCS_DEV_URL;#creating-a-read-only-root-filesystem'>read-only root filesystem</ulink>,
  1269. all the post installation scripts must succeed during the
  1270. package installation phase since the root filesystem is
  1271. read-only.
  1272. </para>
  1273. <para>
  1274. The final stages of the <filename>do_rootfs</filename> task
  1275. handle post processing.
  1276. Post processing includes creation of a manifest file and
  1277. optimizations.
  1278. </para>
  1279. <para>
  1280. The manifest file (<filename>.manifest</filename>) resides
  1281. in the same directory as the root filesystem image.
  1282. This file lists out, line-by-line, the installed packages.
  1283. The manifest file is useful for the
  1284. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-testimage*'><filename>testimage</filename></ulink>
  1285. class, for example, to determine whether or not to run
  1286. specific tests.
  1287. See the
  1288. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_MANIFEST'><filename>IMAGE_MANIFEST</filename></ulink>
  1289. variable for additional information.
  1290. </para>
  1291. <para>
  1292. Optimizing processes run across the image include
  1293. <filename>mklibs</filename>, <filename>prelink</filename>,
  1294. and any other post-processing commands as defined by the
  1295. <ulink url='&YOCTO_DOCS_REF_URL;#var-ROOTFS_POSTPROCESS_COMMAND'><filename>ROOTFS_POSTPROCESS_COMMAND</filename></ulink>
  1296. variable.
  1297. The <filename>mklibs</filename> process optimizes the size
  1298. of the libraries, while the <filename>prelink</filename>
  1299. process optimizes the dynamic linking of shared libraries
  1300. to reduce start up time of executables.
  1301. </para>
  1302. <para>
  1303. After the root filesystem is built, processing begins on
  1304. the image through the
  1305. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-image'><filename>do_image</filename></ulink>
  1306. task.
  1307. The build system runs any pre-processing commands as
  1308. defined by the
  1309. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_PREPROCESS_COMMAND'><filename>IMAGE_PREPROCESS_COMMAND</filename></ulink>
  1310. variable.
  1311. This variable specifies a list of functions to call before
  1312. the OpenEmbedded build system creates the final image
  1313. output files.
  1314. </para>
  1315. <para>
  1316. The OpenEmbedded build system dynamically creates
  1317. <filename>do_image_*</filename> tasks as needed, based
  1318. on the image types specified in the
  1319. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink>
  1320. variable.
  1321. The process turns everything into an image file or a set of
  1322. image files and can compress the root filesystem image to
  1323. reduce the overall size of the image.
  1324. The formats used for the root filesystem depend on the
  1325. <filename>IMAGE_FSTYPES</filename> variable.
  1326. Compression depends on whether the formats support
  1327. compression.
  1328. </para>
  1329. <para>
  1330. As an example, a dynamically created task when creating a
  1331. particular image <replaceable>type</replaceable> would
  1332. take the following form:
  1333. <literallayout class='monospaced'>
  1334. do_image_<replaceable>type</replaceable>
  1335. </literallayout>
  1336. So, if the <replaceable>type</replaceable> as specified by
  1337. the <filename>IMAGE_FSTYPES</filename> were
  1338. <filename>ext4</filename>, the dynamically generated task
  1339. would be as follows:
  1340. <literallayout class='monospaced'>
  1341. do_image_ext4
  1342. </literallayout>
  1343. </para>
  1344. <para>
  1345. The final task involved in image creation is the
  1346. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-image-complete'><filename>do_image_complete</filename></ulink>
  1347. task.
  1348. This task completes the image by applying any image
  1349. post processing as defined through the
  1350. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_POSTPROCESS_COMMAND'><filename>IMAGE_POSTPROCESS_COMMAND</filename></ulink>
  1351. variable.
  1352. The variable specifies a list of functions to call once the
  1353. OpenEmbedded build system has created the final image
  1354. output files.
  1355. <note>
  1356. The entire image generation process is run under
  1357. Pseudo.
  1358. Running under Pseudo ensures that the files in the
  1359. root filesystem have correct ownership.
  1360. </note>
  1361. </para>
  1362. </section>
  1363. <section id='sdk-generation-dev-environment'>
  1364. <title>SDK Generation</title>
  1365. <para>
  1366. The OpenEmbedded build system uses BitBake to generate the
  1367. Software Development Kit (SDK) installer script for both
  1368. the standard and extensible SDKs:
  1369. <imagedata fileref="figures/sdk-generation.png" align="center" />
  1370. <note>
  1371. For more information on the cross-development toolchain
  1372. generation, see the
  1373. "<link linkend='cross-development-toolchain-generation'>Cross-Development Toolchain Generation</link>"
  1374. section.
  1375. For information on advantages gained when building a
  1376. cross-development toolchain using the
  1377. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sdk'><filename>do_populate_sdk</filename></ulink>
  1378. task, see the
  1379. "<ulink url='&YOCTO_DOCS_SDK_URL;#sdk-building-an-sdk-installer'>Building an SDK Installer</ulink>"
  1380. section in the Yocto Project Application Development
  1381. and the Extensible Software Development Kit (SDK)
  1382. manual.
  1383. </note>
  1384. </para>
  1385. <para>
  1386. Like image generation, the SDK script process consists of
  1387. several stages and depends on many variables.
  1388. The <filename>do_populate_sdk</filename> and
  1389. <filename>do_populate_sdk_ext</filename> tasks use these
  1390. key variables to help create the list of packages to
  1391. actually install.
  1392. For information on the variables listed in the figure,
  1393. see the
  1394. "<link linkend='sdk-dev-environment'>Application Development SDK</link>"
  1395. section.
  1396. </para>
  1397. <para>
  1398. The <filename>do_populate_sdk</filename> task helps create
  1399. the standard SDK and handles two parts: a target part and a
  1400. host part.
  1401. The target part is the part built for the target hardware
  1402. and includes libraries and headers.
  1403. The host part is the part of the SDK that runs on the
  1404. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKMACHINE'><filename>SDKMACHINE</filename></ulink>.
  1405. </para>
  1406. <para>
  1407. The <filename>do_populate_sdk_ext</filename> task helps
  1408. create the extensible SDK and handles host and target parts
  1409. differently than its counter part does for the standard SDK.
  1410. For the extensible SDK, the task encapsulates the build
  1411. system, which includes everything needed (host and target)
  1412. for the SDK.
  1413. </para>
  1414. <para>
  1415. Regardless of the type of SDK being constructed, the
  1416. tasks perform some cleanup after which a cross-development
  1417. environment setup script and any needed configuration files
  1418. are created.
  1419. The final output is the Cross-development
  1420. toolchain installation script (<filename>.sh</filename>
  1421. file), which includes the environment setup script.
  1422. </para>
  1423. </section>
  1424. <section id='stamp-files-and-the-rerunning-of-tasks'>
  1425. <title>Stamp Files and the Rerunning of Tasks</title>
  1426. <para>
  1427. For each task that completes successfully, BitBake writes a
  1428. stamp file into the
  1429. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAMPS_DIR'><filename>STAMPS_DIR</filename></ulink>
  1430. directory.
  1431. The beginning of the stamp file's filename is determined
  1432. by the
  1433. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAMP'><filename>STAMP</filename></ulink>
  1434. variable, and the end of the name consists of the task's
  1435. name and current
  1436. <link linkend='overview-checksums'>input checksum</link>.
  1437. <note>
  1438. This naming scheme assumes that
  1439. <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_SIGNATURE_HANDLER'><filename>BB_SIGNATURE_HANDLER</filename></ulink>
  1440. is "OEBasicHash", which is almost always the case in
  1441. current OpenEmbedded.
  1442. </note>
  1443. To determine if a task needs to be rerun, BitBake checks
  1444. if a stamp file with a matching input checksum exists
  1445. for the task.
  1446. If such a stamp file exists, the task's output is
  1447. assumed to exist and still be valid.
  1448. If the file does not exist, the task is rerun.
  1449. <note>
  1450. <para>The stamp mechanism is more general than the
  1451. shared state (sstate) cache mechanism described in the
  1452. "<link linkend='setscene-tasks-and-shared-state'>Setscene Tasks and Shared State</link>"
  1453. section.
  1454. BitBake avoids rerunning any task that has a valid
  1455. stamp file, not just tasks that can be accelerated
  1456. through the sstate cache.</para>
  1457. <para>However, you should realize that stamp files only
  1458. serve as a marker that some work has been done and that
  1459. these files do not record task output.
  1460. The actual task output would usually be somewhere in
  1461. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  1462. (e.g. in some recipe's
  1463. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>.)
  1464. What the sstate cache mechanism adds is a way to cache
  1465. task output that can then be shared between build
  1466. machines.</para>
  1467. </note>
  1468. Since <filename>STAMPS_DIR</filename> is usually a
  1469. subdirectory of <filename>TMPDIR</filename>, removing
  1470. <filename>TMPDIR</filename> will also remove
  1471. <filename>STAMPS_DIR</filename>, which means tasks will
  1472. properly be rerun to repopulate
  1473. <filename>TMPDIR</filename>.
  1474. </para>
  1475. <para>
  1476. If you want some task to always be considered "out of
  1477. date", you can mark it with the
  1478. <ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>nostamp</filename></ulink>
  1479. varflag.
  1480. If some other task depends on such a task, then that
  1481. task will also always be considered out of date, which
  1482. might not be what you want.
  1483. </para>
  1484. <para>
  1485. For details on how to view information about a task's
  1486. signature, see the
  1487. "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-viewing-task-variable-dependencies'>Viewing Task Variable Dependencies</ulink>"
  1488. section in the Yocto Project Development Tasks Manual.
  1489. </para>
  1490. </section>
  1491. <section id='setscene-tasks-and-shared-state'>
  1492. <title>Setscene Tasks and Shared State</title>
  1493. <para>
  1494. The description of tasks so far assumes that BitBake needs
  1495. to build everything and there are no prebuilt objects
  1496. available.
  1497. BitBake does support skipping tasks if prebuilt objects are
  1498. available.
  1499. These objects are usually made available in the form of a
  1500. shared state (sstate) cache.
  1501. <note>
  1502. For information on variables affecting sstate, see the
  1503. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>
  1504. and
  1505. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_MIRRORS'><filename>SSTATE_MIRRORS</filename></ulink>
  1506. variables.
  1507. </note>
  1508. </para>
  1509. <para>
  1510. The idea of a setscene task (i.e
  1511. <filename>do_</filename><replaceable>taskname</replaceable><filename>_setscene</filename>)
  1512. is a version of the task where
  1513. instead of building something, BitBake can skip to the end
  1514. result and simply place a set of files into specific
  1515. locations as needed.
  1516. In some cases, it makes sense to have a setscene task
  1517. variant (e.g. generating package files in the
  1518. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_deb'><filename>do_package_write_*</filename></ulink>
  1519. task).
  1520. In other cases, it does not make sense, (e.g. a
  1521. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  1522. task or
  1523. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>
  1524. task) since the work involved would be equal to or greater
  1525. than the underlying task.
  1526. </para>
  1527. <para>
  1528. In the OpenEmbedded build system, the common tasks that
  1529. have setscene variants are
  1530. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>,
  1531. <filename>do_package_write_*</filename>,
  1532. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-deploy'><filename>do_deploy</filename></ulink>,
  1533. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-packagedata'><filename>do_packagedata</filename></ulink>,
  1534. and
  1535. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>.
  1536. Notice that these are most of the tasks whose output is an
  1537. end result.
  1538. </para>
  1539. <para>
  1540. The OpenEmbedded build system has knowledge of the
  1541. relationship between these tasks and other tasks that
  1542. precede them.
  1543. For example, if BitBake runs
  1544. <filename>do_populate_sysroot_setscene</filename> for
  1545. something, there is little point in running any of the
  1546. <filename>do_fetch</filename>,
  1547. <filename>do_unpack</filename>,
  1548. <filename>do_patch</filename>,
  1549. <filename>do_configure</filename>,
  1550. <filename>do_compile</filename>, and
  1551. <filename>do_install</filename> tasks.
  1552. However, if <filename>do_package</filename> needs to be
  1553. run, BitBake would need to run those other tasks.
  1554. </para>
  1555. <para>
  1556. It becomes more complicated if everything can come
  1557. from an sstate cache because some objects are simply
  1558. not required at all.
  1559. For example, you do not need a compiler or native tools,
  1560. such as quilt, if there is nothing to compile or patch.
  1561. If the <filename>do_package_write_*</filename> packages
  1562. are available from sstate, BitBake does not need the
  1563. <filename>do_package</filename> task data.
  1564. </para>
  1565. <para>
  1566. To handle all these complexities, BitBake runs in two
  1567. phases.
  1568. The first is the "setscene" stage.
  1569. During this stage, BitBake first checks the sstate cache
  1570. for any targets it is planning to build.
  1571. BitBake does a fast check to see if the object exists
  1572. rather than a complete download.
  1573. If nothing exists, the second phase, which is the setscene
  1574. stage, completes and the main build proceeds.
  1575. </para>
  1576. <para>
  1577. If objects are found in the sstate cache, the OpenEmbedded
  1578. build system works backwards from the end targets specified
  1579. by the user.
  1580. For example, if an image is being built, the OpenEmbedded
  1581. build system first looks for the packages needed for
  1582. that image and the tools needed to construct an image.
  1583. If those are available, the compiler is not needed.
  1584. Thus, the compiler is not even downloaded.
  1585. If something was found to be unavailable, or the
  1586. download or setscene task fails, the OpenEmbedded build
  1587. system then tries to install dependencies, such as the
  1588. compiler, from the cache.
  1589. </para>
  1590. <para>
  1591. The availability of objects in the sstate cache is
  1592. handled by the function specified by the
  1593. <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_HASHCHECK_FUNCTION'><filename>BB_HASHCHECK_FUNCTION</filename></ulink>
  1594. variable and returns a list of the objects that are
  1595. available.
  1596. The function specified by the
  1597. <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_SETSCENE_DEPVALID'><filename>BB_SETSCENE_DEPVALID</filename></ulink>
  1598. variable is the function that determines whether a given
  1599. dependency needs to be followed, and whether for any given
  1600. relationship the function needs to be passed.
  1601. The function returns a True or False value.
  1602. </para>
  1603. </section>
  1604. </section>
  1605. <section id='images-dev-environment'>
  1606. <title>Images</title>
  1607. <para>
  1608. The images produced by the OpenEmbedded build system
  1609. are compressed forms of the
  1610. root filesystem that are ready to boot on a target device.
  1611. You can see from the
  1612. <link linkend='general-yocto-environment-figure'>general Build Process figure</link>
  1613. that BitBake output, in part, consists of images.
  1614. This section is going to look more closely at this output:
  1615. <imagedata fileref="figures/images.png" align="center" width="5.5in" depth="5.5in" />
  1616. </para>
  1617. <para>
  1618. For a list of example images that the Yocto Project provides,
  1619. see the
  1620. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  1621. chapter in the Yocto Project Reference Manual.
  1622. </para>
  1623. <para>
  1624. Images are written out to the
  1625. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  1626. inside the
  1627. <filename>tmp/deploy/images/<replaceable>machine</replaceable>/</filename>
  1628. folder as shown in the figure.
  1629. This folder contains any files expected to be loaded on the
  1630. target device.
  1631. The
  1632. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></ulink>
  1633. variable points to the <filename>deploy</filename> directory,
  1634. while the
  1635. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR_IMAGE'><filename>DEPLOY_DIR_IMAGE</filename></ulink>
  1636. variable points to the appropriate directory containing images
  1637. for the current configuration.
  1638. <itemizedlist>
  1639. <listitem><para>
  1640. <filename><replaceable>kernel-image</replaceable></filename>:
  1641. A kernel binary file.
  1642. The
  1643. <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_IMAGETYPE'><filename>KERNEL_IMAGETYPE</filename></ulink>
  1644. variable setting determines the naming scheme for the
  1645. kernel image file.
  1646. Depending on that variable, the file could begin with
  1647. a variety of naming strings.
  1648. The
  1649. <filename>deploy/images/<replaceable>machine</replaceable></filename>
  1650. directory can contain multiple image files for the
  1651. machine.
  1652. </para></listitem>
  1653. <listitem><para>
  1654. <filename><replaceable>root-filesystem-image</replaceable></filename>:
  1655. Root filesystems for the target device (e.g.
  1656. <filename>*.ext3</filename> or
  1657. <filename>*.bz2</filename> files).
  1658. The
  1659. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink>
  1660. variable setting determines the root filesystem image
  1661. type.
  1662. The
  1663. <filename>deploy/images/<replaceable>machine</replaceable></filename>
  1664. directory can contain multiple root filesystems for the
  1665. machine.
  1666. </para></listitem>
  1667. <listitem><para>
  1668. <filename><replaceable>kernel-modules</replaceable></filename>:
  1669. Tarballs that contain all the modules built for the
  1670. kernel.
  1671. Kernel module tarballs exist for legacy purposes and
  1672. can be suppressed by setting the
  1673. <ulink url='&YOCTO_DOCS_REF_URL;#var-MODULE_TARBALL_DEPLOY'><filename>MODULE_TARBALL_DEPLOY</filename></ulink>
  1674. variable to "0".
  1675. The
  1676. <filename>deploy/images/<replaceable>machine</replaceable></filename>
  1677. directory can contain multiple kernel module tarballs
  1678. for the machine.
  1679. </para></listitem>
  1680. <listitem><para>
  1681. <filename><replaceable>bootloaders</replaceable></filename>:
  1682. Bootloaders supporting the image, if applicable to the
  1683. target machine.
  1684. The <filename>deploy/images/<replaceable>machine</replaceable></filename>
  1685. directory can contain multiple bootloaders for the
  1686. machine.
  1687. </para></listitem>
  1688. <listitem><para>
  1689. <filename><replaceable>symlinks</replaceable></filename>:
  1690. The
  1691. <filename>deploy/images/<replaceable>machine</replaceable></filename>
  1692. folder contains a symbolic link that points to the
  1693. most recently built file for each machine.
  1694. These links might be useful for external scripts that
  1695. need to obtain the latest version of each file.
  1696. </para></listitem>
  1697. </itemizedlist>
  1698. </para>
  1699. </section>
  1700. <section id='sdk-dev-environment'>
  1701. <title>Application Development SDK</title>
  1702. <para>
  1703. In the
  1704. <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>,
  1705. the output labeled "Application Development SDK" represents an
  1706. SDK.
  1707. The SDK generation process differs depending on whether you
  1708. build a standard SDK (e.g.
  1709. <filename>bitbake -c populate_sdk</filename> <replaceable>imagename</replaceable>)
  1710. or an extensible SDK (e.g.
  1711. <filename>bitbake -c populate_sdk_ext</filename> <replaceable>imagename</replaceable>).
  1712. This section is going to take a closer look at this output:
  1713. <imagedata fileref="figures/sdk.png" align="center" width="9in" depth="7.25in" />
  1714. </para>
  1715. <para>
  1716. The specific form of this output is a self-extracting
  1717. SDK installer (<filename>*.sh</filename>) that, when run,
  1718. installs the SDK, which consists of a cross-development
  1719. toolchain, a set of libraries and headers, and an SDK
  1720. environment setup script.
  1721. Running this installer essentially sets up your
  1722. cross-development environment.
  1723. You can think of the cross-toolchain as the "host"
  1724. part because it runs on the SDK machine.
  1725. You can think of the libraries and headers as the "target"
  1726. part because they are built for the target hardware.
  1727. The environment setup script is added so that you can
  1728. initialize the environment before using the tools.
  1729. </para>
  1730. <note><title>Notes</title>
  1731. <itemizedlist>
  1732. <listitem><para>
  1733. The Yocto Project supports several methods by which
  1734. you can set up this cross-development environment.
  1735. These methods include downloading pre-built SDK
  1736. installers or building and installing your own SDK
  1737. installer.
  1738. </para></listitem>
  1739. <listitem><para>
  1740. For background information on cross-development
  1741. toolchains in the Yocto Project development
  1742. environment, see the
  1743. "<link linkend='cross-development-toolchain-generation'>Cross-Development Toolchain Generation</link>"
  1744. section.
  1745. </para></listitem>
  1746. <listitem><para>
  1747. For information on setting up a cross-development
  1748. environment, see the
  1749. <ulink url='&YOCTO_DOCS_SDK_URL;'>Yocto Project Application Development and the Extensible Software Development Kit (eSDK)</ulink>
  1750. manual.
  1751. </para></listitem>
  1752. </itemizedlist>
  1753. </note>
  1754. <para>
  1755. Once built, the SDK installers are written out to the
  1756. <filename>deploy/sdk</filename> folder inside the
  1757. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  1758. as shown in the figure at the beginning of this section.
  1759. Depending on the type of SDK, several variables exist that help
  1760. configure these files.
  1761. The following list shows the variables associated with
  1762. a standard SDK:
  1763. <itemizedlist>
  1764. <listitem><para>
  1765. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></ulink>:
  1766. Points to the <filename>deploy</filename>
  1767. directory.
  1768. </para></listitem>
  1769. <listitem><para>
  1770. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKMACHINE'><filename>SDKMACHINE</filename></ulink>:
  1771. Specifies the architecture of the machine
  1772. on which the cross-development tools are run to
  1773. create packages for the target hardware.
  1774. </para></listitem>
  1775. <listitem><para>
  1776. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKIMAGE_FEATURES'><filename>SDKIMAGE_FEATURES</filename></ulink>:
  1777. Lists the features to include in the "target" part
  1778. of the SDK.
  1779. </para></listitem>
  1780. <listitem><para>
  1781. <ulink url='&YOCTO_DOCS_REF_URL;#var-TOOLCHAIN_HOST_TASK'><filename>TOOLCHAIN_HOST_TASK</filename></ulink>:
  1782. Lists packages that make up the host
  1783. part of the SDK (i.e. the part that runs on
  1784. the <filename>SDKMACHINE</filename>).
  1785. When you use
  1786. <filename>bitbake -c populate_sdk <replaceable>imagename</replaceable></filename>
  1787. to create the SDK, a set of default packages
  1788. apply.
  1789. This variable allows you to add more packages.
  1790. </para></listitem>
  1791. <listitem><para>
  1792. <ulink url='&YOCTO_DOCS_REF_URL;#var-TOOLCHAIN_TARGET_TASK'><filename>TOOLCHAIN_TARGET_TASK</filename></ulink>:
  1793. Lists packages that make up the target part
  1794. of the SDK (i.e. the part built for the
  1795. target hardware).
  1796. </para></listitem>
  1797. <listitem><para>
  1798. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKPATH'><filename>SDKPATH</filename></ulink>:
  1799. Defines the default SDK installation path offered
  1800. by the installation script.
  1801. </para></listitem>
  1802. </itemizedlist>
  1803. This next list, shows the variables associated with an
  1804. extensible SDK:
  1805. <itemizedlist>
  1806. <listitem><para>
  1807. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></ulink>:
  1808. Points to the <filename>deploy</filename> directory.
  1809. </para></listitem>
  1810. <listitem><para>
  1811. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_EXT_TYPE'><filename>SDK_EXT_TYPE</filename></ulink>:
  1812. Controls whether or not shared state artifacts are
  1813. copied into the extensible SDK.
  1814. By default, all required shared state artifacts are
  1815. copied into the SDK.
  1816. </para></listitem>
  1817. <listitem><para>
  1818. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_INCLUDE_PKGDATA'><filename>SDK_INCLUDE_PKGDATA</filename></ulink>:
  1819. Specifies whether or not packagedata will be
  1820. included in the extensible SDK for all recipes in
  1821. the "world" target.
  1822. </para></listitem>
  1823. <listitem><para>
  1824. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_INCLUDE_TOOLCHAIN'><filename>SDK_INCLUDE_TOOLCHAIN</filename></ulink>:
  1825. Specifies whether or not the toolchain will be included
  1826. when building the extensible SDK.
  1827. </para></listitem>
  1828. <listitem><para>
  1829. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_LOCAL_CONF_WHITELIST'><filename>SDK_LOCAL_CONF_WHITELIST</filename></ulink>:
  1830. A list of variables allowed through from the build
  1831. system configuration into the extensible SDK
  1832. configuration.
  1833. </para></listitem>
  1834. <listitem><para>
  1835. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_LOCAL_CONF_BLACKLIST'><filename>SDK_LOCAL_CONF_BLACKLIST</filename></ulink>:
  1836. A list of variables not allowed through from the build
  1837. system configuration into the extensible SDK
  1838. configuration.
  1839. </para></listitem>
  1840. <listitem><para>
  1841. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_INHERIT_BLACKLIST'><filename>SDK_INHERIT_BLACKLIST</filename></ulink>:
  1842. A list of classes to remove from the
  1843. <ulink url='&YOCTO_DOCS_REF_URL;#var-INHERIT'><filename>INHERIT</filename></ulink>
  1844. value globally within the extensible SDK configuration.
  1845. </para></listitem>
  1846. </itemizedlist>
  1847. </para>
  1848. </section>
  1849. </section>
  1850. <section id="cross-development-toolchain-generation">
  1851. <title>Cross-Development Toolchain Generation</title>
  1852. <para>
  1853. The Yocto Project does most of the work for you when it comes to
  1854. creating
  1855. <ulink url='&YOCTO_DOCS_REF_URL;#cross-development-toolchain'>cross-development toolchains</ulink>.
  1856. This section provides some technical background on how
  1857. cross-development toolchains are created and used.
  1858. For more information on toolchains, you can also see the
  1859. <ulink url='&YOCTO_DOCS_SDK_URL;'>Yocto Project Application Development and the Extensible Software Development Kit (eSDK)</ulink>
  1860. manual.
  1861. </para>
  1862. <para>
  1863. In the Yocto Project development environment, cross-development
  1864. toolchains are used to build the image and applications that run
  1865. on the target hardware.
  1866. With just a few commands, the OpenEmbedded build system creates
  1867. these necessary toolchains for you.
  1868. </para>
  1869. <para>
  1870. The following figure shows a high-level build environment regarding
  1871. toolchain construction and use.
  1872. </para>
  1873. <para>
  1874. <imagedata fileref="figures/cross-development-toolchains.png" width="8in" depth="6in" align="center" />
  1875. </para>
  1876. <para>
  1877. Most of the work occurs on the Build Host.
  1878. This is the machine used to build images and generally work within
  1879. the the Yocto Project environment.
  1880. When you run
  1881. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  1882. to create an image, the OpenEmbedded build system
  1883. uses the host <filename>gcc</filename> compiler to bootstrap a
  1884. cross-compiler named <filename>gcc-cross</filename>.
  1885. The <filename>gcc-cross</filename> compiler is what BitBake uses to
  1886. compile source files when creating the target image.
  1887. You can think of <filename>gcc-cross</filename> simply as an
  1888. automatically generated cross-compiler that is used internally
  1889. within BitBake only.
  1890. <note>
  1891. The extensible SDK does not use
  1892. <filename>gcc-cross-canadian</filename> since this SDK
  1893. ships a copy of the OpenEmbedded build system and the sysroot
  1894. within it contains <filename>gcc-cross</filename>.
  1895. </note>
  1896. </para>
  1897. <para>
  1898. The chain of events that occurs when <filename>gcc-cross</filename> is
  1899. bootstrapped is as follows:
  1900. <literallayout class='monospaced'>
  1901. gcc -> binutils-cross -> gcc-cross-initial -> linux-libc-headers -> glibc-initial -> glibc -> gcc-cross -> gcc-runtime
  1902. </literallayout>
  1903. <itemizedlist>
  1904. <listitem><para>
  1905. <filename>gcc</filename>:
  1906. The build host's GNU Compiler Collection (GCC).
  1907. </para></listitem>
  1908. <listitem><para>
  1909. <filename>binutils-cross</filename>:
  1910. The bare minimum binary utilities needed in order to run
  1911. the <filename>gcc-cross-initial</filename> phase of the
  1912. bootstrap operation.
  1913. </para></listitem>
  1914. <listitem><para>
  1915. <filename>gcc-cross-initial</filename>:
  1916. An early stage of the bootstrap process for creating
  1917. the cross-compiler.
  1918. This stage builds enough of the <filename>gcc-cross</filename>,
  1919. the C library, and other pieces needed to finish building the
  1920. final cross-compiler in later stages.
  1921. This tool is a "native" package (i.e. it is designed to run on
  1922. the build host).
  1923. </para></listitem>
  1924. <listitem><para>
  1925. <filename>linux-libc-headers</filename>:
  1926. Headers needed for the cross-compiler.
  1927. </para></listitem>
  1928. <listitem><para>
  1929. <filename>glibc-initial</filename>:
  1930. An initial version of the Embedded GLIBC needed to bootstrap
  1931. <filename>glibc</filename>.
  1932. </para></listitem>
  1933. <listitem><para>
  1934. <filename>gcc-cross</filename>:
  1935. The final stage of the bootstrap process for the
  1936. cross-compiler.
  1937. This stage results in the actual cross-compiler that
  1938. BitBake uses when it builds an image for a targeted
  1939. device.
  1940. <note>
  1941. If you are replacing this cross compiler toolchain
  1942. with a custom version, you must replace
  1943. <filename>gcc-cross</filename>.
  1944. </note>
  1945. This tool is also a "native" package (i.e. it is
  1946. designed to run on the build host).
  1947. </para></listitem>
  1948. <listitem><para>
  1949. <filename>gcc-runtime</filename>:
  1950. Runtime libraries resulting from the toolchain bootstrapping
  1951. process.
  1952. This tool produces a binary that consists of the
  1953. runtime libraries need for the targeted device.
  1954. </para></listitem>
  1955. </itemizedlist>
  1956. </para>
  1957. <para>
  1958. You can use the OpenEmbedded build system to build an installer for
  1959. the relocatable SDK used to develop applications.
  1960. When you run the installer, it installs the toolchain, which
  1961. contains the development tools (e.g.,
  1962. <filename>gcc-cross-canadian</filename>,
  1963. <filename>binutils-cross-canadian</filename>, and other
  1964. <filename>nativesdk-*</filename> tools),
  1965. which are tools native to the SDK (i.e. native to
  1966. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_ARCH'><filename>SDK_ARCH</filename></ulink>),
  1967. you need to cross-compile and test your software.
  1968. The figure shows the commands you use to easily build out this
  1969. toolchain.
  1970. This cross-development toolchain is built to execute on the
  1971. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKMACHINE'><filename>SDKMACHINE</filename></ulink>,
  1972. which might or might not be the same
  1973. machine as the Build Host.
  1974. <note>
  1975. If your target architecture is supported by the Yocto Project,
  1976. you can take advantage of pre-built images that ship with the
  1977. Yocto Project and already contain cross-development toolchain
  1978. installers.
  1979. </note>
  1980. </para>
  1981. <para>
  1982. Here is the bootstrap process for the relocatable toolchain:
  1983. <literallayout class='monospaced'>
  1984. gcc -> binutils-crosssdk -> gcc-crosssdk-initial -> linux-libc-headers ->
  1985. glibc-initial -> nativesdk-glibc -> gcc-crosssdk -> gcc-cross-canadian
  1986. </literallayout>
  1987. <itemizedlist>
  1988. <listitem><para>
  1989. <filename>gcc</filename>:
  1990. The build host's GNU Compiler Collection (GCC).
  1991. </para></listitem>
  1992. <listitem><para>
  1993. <filename>binutils-crosssdk</filename>:
  1994. The bare minimum binary utilities needed in order to run
  1995. the <filename>gcc-crosssdk-initial</filename> phase of the
  1996. bootstrap operation.
  1997. </para></listitem>
  1998. <listitem><para>
  1999. <filename>gcc-crosssdk-initial</filename>:
  2000. An early stage of the bootstrap process for creating
  2001. the cross-compiler.
  2002. This stage builds enough of the
  2003. <filename>gcc-crosssdk</filename> and supporting pieces so that
  2004. the final stage of the bootstrap process can produce the
  2005. finished cross-compiler.
  2006. This tool is a "native" binary that runs on the build host.
  2007. </para></listitem>
  2008. <listitem><para>
  2009. <filename>linux-libc-headers</filename>:
  2010. Headers needed for the cross-compiler.
  2011. </para></listitem>
  2012. <listitem><para>
  2013. <filename>glibc-initial</filename>:
  2014. An initial version of the Embedded GLIBC needed to bootstrap
  2015. <filename>nativesdk-glibc</filename>.
  2016. </para></listitem>
  2017. <listitem><para>
  2018. <filename>nativesdk-glibc</filename>:
  2019. The Embedded GLIBC needed to bootstrap the
  2020. <filename>gcc-crosssdk</filename>.
  2021. </para></listitem>
  2022. <listitem><para>
  2023. <filename>gcc-crosssdk</filename>:
  2024. The final stage of the bootstrap process for the
  2025. relocatable cross-compiler.
  2026. The <filename>gcc-crosssdk</filename> is a transitory compiler
  2027. and never leaves the build host.
  2028. Its purpose is to help in the bootstrap process to create the
  2029. eventual relocatable <filename>gcc-cross-canadian</filename>
  2030. compiler, which is relocatable.
  2031. This tool is also a "native" package (i.e. it is
  2032. designed to run on the build host).
  2033. </para></listitem>
  2034. <listitem><para>
  2035. <filename>gcc-cross-canadian</filename>:
  2036. The final relocatable cross-compiler.
  2037. When run on the
  2038. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKMACHINE'><filename>SDKMACHINE</filename></ulink>,
  2039. this tool
  2040. produces executable code that runs on the target device.
  2041. Only one cross-canadian compiler is produced per architecture
  2042. since they can be targeted at different processor optimizations
  2043. using configurations passed to the compiler through the
  2044. compile commands.
  2045. This circumvents the need for multiple compilers and thus
  2046. reduces the size of the toolchains.
  2047. </para></listitem>
  2048. </itemizedlist>
  2049. </para>
  2050. <note>
  2051. For information on advantages gained when building a
  2052. cross-development toolchain installer, see the
  2053. "<ulink url='&YOCTO_DOCS_SDK_URL;#sdk-building-an-sdk-installer'>Building an SDK Installer</ulink>"
  2054. section in the Yocto Project Application Development and the
  2055. Extensible Software Development Kit (eSDK) manual.
  2056. </note>
  2057. </section>
  2058. <section id="shared-state-cache">
  2059. <title>Shared State Cache</title>
  2060. <para>
  2061. By design, the OpenEmbedded build system builds everything from
  2062. scratch unless
  2063. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  2064. can determine that parts do not need to be rebuilt.
  2065. Fundamentally, building from scratch is attractive as it means all
  2066. parts are built fresh and there is no possibility of stale data
  2067. causing problems.
  2068. When developers hit problems, they typically default back to
  2069. building from scratch so they know the state of things from the
  2070. start.
  2071. </para>
  2072. <para>
  2073. Building an image from scratch is both an advantage and a
  2074. disadvantage to the process.
  2075. As mentioned in the previous paragraph, building from scratch
  2076. ensures that everything is current and starts from a known state.
  2077. However, building from scratch also takes much longer as it
  2078. generally means rebuilding things that do not necessarily need
  2079. to be rebuilt.
  2080. </para>
  2081. <para>
  2082. The Yocto Project implements shared state code that supports
  2083. incremental builds.
  2084. The implementation of the shared state code answers the following
  2085. questions that were fundamental roadblocks within the OpenEmbedded
  2086. incremental build support system:
  2087. <itemizedlist>
  2088. <listitem><para>
  2089. What pieces of the system have changed and what pieces have
  2090. not changed?
  2091. </para></listitem>
  2092. <listitem><para>
  2093. How are changed pieces of software removed and replaced?
  2094. </para></listitem>
  2095. <listitem><para>
  2096. How are pre-built components that do not need to be rebuilt
  2097. from scratch used when they are available?
  2098. </para></listitem>
  2099. </itemizedlist>
  2100. </para>
  2101. <para>
  2102. For the first question, the
  2103. <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink>
  2104. detects changes in the "inputs" to a given task by creating a
  2105. checksum (or signature) of the task's inputs.
  2106. If the checksum changes, the system assumes the inputs have changed
  2107. and the task needs to be rerun.
  2108. For the second question, the shared state (sstate) code tracks
  2109. which tasks add which output to the build process.
  2110. This means the output from a given task can be removed, upgraded
  2111. or otherwise manipulated.
  2112. The third question is partly addressed by the solution for the
  2113. second question assuming the build system can fetch the sstate
  2114. objects from remote locations and install them if they are deemed
  2115. to be valid.
  2116. <note>
  2117. The OpenEmbedded build system does not maintain
  2118. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  2119. information as part of the shared state packages.
  2120. Consequently, considerations exist that affect maintaining
  2121. shared state feeds.
  2122. For information on how the OpenEmbedded build system
  2123. works with packages and can track incrementing
  2124. <filename>PR</filename> information, see the
  2125. "<ulink url='&YOCTO_DOCS_DEV_URL;#automatically-incrementing-a-binary-package-revision-number'>Automatically Incrementing a Binary Package Revision Number</ulink>"
  2126. section in the Yocto Project Development Tasks Manual.
  2127. </note>
  2128. </para>
  2129. <para>
  2130. The rest of this section goes into detail about the overall
  2131. incremental build architecture, the checksums (signatures), shared
  2132. state, and some tips and tricks.
  2133. </para>
  2134. <section id='concepts-overall-architecture'>
  2135. <title>Overall Architecture</title>
  2136. <para>
  2137. When determining what parts of the system need to be built,
  2138. BitBake works on a per-task basis rather than a per-recipe
  2139. basis.
  2140. You might wonder why using a per-task basis is preferred over
  2141. a per-recipe basis.
  2142. To help explain, consider having the IPK packaging backend
  2143. enabled and then switching to DEB.
  2144. In this case, the
  2145. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  2146. and
  2147. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>
  2148. task outputs are still valid.
  2149. However, with a per-recipe approach, the build would not
  2150. include the <filename>.deb</filename> files.
  2151. Consequently, you would have to invalidate the whole build and
  2152. rerun it.
  2153. Rerunning everything is not the best solution.
  2154. Also, in this case, the core must be "taught" much about
  2155. specific tasks.
  2156. This methodology does not scale well and does not allow users
  2157. to easily add new tasks in layers or as external recipes
  2158. without touching the packaged-staging core.
  2159. </para>
  2160. </section>
  2161. <section id='overview-checksums'>
  2162. <title>Checksums (Signatures)</title>
  2163. <para>
  2164. The shared state code uses a checksum, which is a unique
  2165. signature of a task's inputs, to determine if a task needs to
  2166. be run again.
  2167. Because it is a change in a task's inputs that triggers a
  2168. rerun, the process needs to detect all the inputs to a given
  2169. task.
  2170. For shell tasks, this turns out to be fairly easy because
  2171. the build process generates a "run" shell script for each task
  2172. and it is possible to create a checksum that gives you a good
  2173. idea of when the task's data changes.
  2174. </para>
  2175. <para>
  2176. To complicate the problem, there are things that should not be
  2177. included in the checksum.
  2178. First, there is the actual specific build path of a given
  2179. task - the
  2180. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>.
  2181. It does not matter if the work directory changes because it
  2182. should not affect the output for target packages.
  2183. Also, the build process has the objective of making native
  2184. or cross packages relocatable.
  2185. <note>
  2186. Both native and cross packages run on the
  2187. <ulink url='&YOCTO_DOCS_REF_URL;#hardware-build-system-term'>build host</ulink>.
  2188. However, cross packages generate output for the target
  2189. architecture.
  2190. </note>
  2191. The checksum therefore needs to exclude
  2192. <filename>WORKDIR</filename>.
  2193. The simplistic approach for excluding the work directory is to
  2194. set <filename>WORKDIR</filename> to some fixed value and
  2195. create the checksum for the "run" script.
  2196. </para>
  2197. <para>
  2198. Another problem results from the "run" scripts containing
  2199. functions that might or might not get called.
  2200. The incremental build solution contains code that figures out
  2201. dependencies between shell functions.
  2202. This code is used to prune the "run" scripts down to the
  2203. minimum set, thereby alleviating this problem and making the
  2204. "run" scripts much more readable as a bonus.
  2205. </para>
  2206. <para>
  2207. So far, solutions for shell scripts exist.
  2208. What about Python tasks?
  2209. The same approach applies even though these tasks are more
  2210. difficult.
  2211. The process needs to figure out what variables a Python
  2212. function accesses and what functions it calls.
  2213. Again, the incremental build solution contains code that first
  2214. figures out the variable and function dependencies, and then
  2215. creates a checksum for the data used as the input to the task.
  2216. </para>
  2217. <para>
  2218. Like the <filename>WORKDIR</filename> case, situations exist
  2219. where dependencies should be ignored.
  2220. For these situations, you can instruct the build process to
  2221. ignore a dependency by using a line like the following:
  2222. <literallayout class='monospaced'>
  2223. PACKAGE_ARCHS[vardepsexclude] = "MACHINE"
  2224. </literallayout>
  2225. This example ensures that the
  2226. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCHS'><filename>PACKAGE_ARCHS</filename></ulink>
  2227. variable does not depend on the value of
  2228. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>,
  2229. even if it does reference it.
  2230. </para>
  2231. <para>
  2232. Equally, there are cases where you need to add dependencies
  2233. BitBake is not able to find.
  2234. You can accomplish this by using a line like the following:
  2235. <literallayout class='monospaced'>
  2236. PACKAGE_ARCHS[vardeps] = "MACHINE"
  2237. </literallayout>
  2238. This example explicitly adds the <filename>MACHINE</filename>
  2239. variable as a dependency for
  2240. <filename>PACKAGE_ARCHS</filename>.
  2241. </para>
  2242. <para>
  2243. As an example, consider a case with in-line Python where
  2244. BitBake is not able to figure out dependencies.
  2245. When running in debug mode (i.e. using
  2246. <filename>-DDD</filename>), BitBake produces output when it
  2247. discovers something for which it cannot figure out dependencies.
  2248. The Yocto Project team has currently not managed to cover
  2249. those dependencies in detail and is aware of the need to fix
  2250. this situation.
  2251. </para>
  2252. <para>
  2253. Thus far, this section has limited discussion to the direct
  2254. inputs into a task.
  2255. Information based on direct inputs is referred to as the
  2256. "basehash" in the code.
  2257. However, there is still the question of a task's indirect
  2258. inputs - the things that were already built and present in the
  2259. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  2260. The checksum (or signature) for a particular task needs to add
  2261. the hashes of all the tasks on which the particular task
  2262. depends.
  2263. Choosing which dependencies to add is a policy decision.
  2264. However, the effect is to generate a master checksum that
  2265. combines the basehash and the hashes of the task's
  2266. dependencies.
  2267. </para>
  2268. <para>
  2269. At the code level, a variety of ways exist by which both the
  2270. basehash and the dependent task hashes can be influenced.
  2271. Within the BitBake configuration file, you can give BitBake
  2272. some extra information to help it construct the basehash.
  2273. The following statement effectively results in a list of
  2274. global variable dependency excludes - variables never
  2275. included in any checksum:
  2276. <literallayout class='monospaced'>
  2277. BB_HASHBASE_WHITELIST ?= "TMPDIR FILE PATH PWD BB_TASKHASH BBPATH DL_DIR \
  2278. SSTATE_DIR THISDIR FILESEXTRAPATHS FILE_DIRNAME HOME LOGNAME SHELL TERM \
  2279. USER FILESPATH STAGING_DIR_HOST STAGING_DIR_TARGET COREBASE PRSERV_HOST \
  2280. PRSERV_DUMPDIR PRSERV_DUMPFILE PRSERV_LOCKDOWN PARALLEL_MAKE \
  2281. CCACHE_DIR EXTERNAL_TOOLCHAIN CCACHE CCACHE_DISABLE LICENSE_PATH SDKPKGSUFFIX"
  2282. </literallayout>
  2283. The previous example excludes
  2284. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>
  2285. since that variable is actually constructed as a path within
  2286. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>,
  2287. which is on the whitelist.
  2288. </para>
  2289. <para>
  2290. The rules for deciding which hashes of dependent tasks to
  2291. include through dependency chains are more complex and are
  2292. generally accomplished with a Python function.
  2293. The code in <filename>meta/lib/oe/sstatesig.py</filename> shows
  2294. two examples of this and also illustrates how you can insert
  2295. your own policy into the system if so desired.
  2296. This file defines the two basic signature generators
  2297. <ulink url='&YOCTO_DOCS_REF_URL;#oe-core'>OE-Core</ulink>
  2298. uses: "OEBasic" and "OEBasicHash".
  2299. By default, there is a dummy "noop" signature handler enabled
  2300. in BitBake.
  2301. This means that behavior is unchanged from previous versions.
  2302. OE-Core uses the "OEBasicHash" signature handler by default
  2303. through this setting in the <filename>bitbake.conf</filename>
  2304. file:
  2305. <literallayout class='monospaced'>
  2306. BB_SIGNATURE_HANDLER ?= "OEBasicHash"
  2307. </literallayout>
  2308. The "OEBasicHash" <filename>BB_SIGNATURE_HANDLER</filename>
  2309. is the same as the "OEBasic" version but adds the task hash to
  2310. the stamp files.
  2311. This results in any
  2312. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>
  2313. change that changes the task hash, automatically
  2314. causing the task to be run again.
  2315. This removes the need to bump
  2316. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  2317. values, and changes to Metadata automatically ripple across
  2318. the build.
  2319. </para>
  2320. <para>
  2321. It is also worth noting that the end result of these
  2322. signature generators is to make some dependency and hash
  2323. information available to the build.
  2324. This information includes:
  2325. <itemizedlist>
  2326. <listitem><para>
  2327. <filename>BB_BASEHASH_task-</filename><replaceable>taskname</replaceable>:
  2328. The base hashes for each task in the recipe.
  2329. </para></listitem>
  2330. <listitem><para>
  2331. <filename>BB_BASEHASH_</filename><replaceable>filename</replaceable><filename>:</filename><replaceable>taskname</replaceable>:
  2332. The base hashes for each dependent task.
  2333. </para></listitem>
  2334. <listitem><para>
  2335. <filename>BBHASHDEPS_</filename><replaceable>filename</replaceable><filename>:</filename><replaceable>taskname</replaceable>:
  2336. The task dependencies for each task.
  2337. </para></listitem>
  2338. <listitem><para>
  2339. <filename>BB_TASKHASH</filename>:
  2340. The hash of the currently running task.
  2341. </para></listitem>
  2342. </itemizedlist>
  2343. </para>
  2344. </section>
  2345. <section id='shared-state'>
  2346. <title>Shared State</title>
  2347. <para>
  2348. Checksums and dependencies, as discussed in the previous
  2349. section, solve half the problem of supporting a shared state.
  2350. The other part of the problem is being able to use checksum
  2351. information during the build and being able to reuse or rebuild
  2352. specific components.
  2353. </para>
  2354. <para>
  2355. The
  2356. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-sstate'><filename>sstate</filename></ulink>
  2357. class is a relatively generic implementation of how to
  2358. "capture" a snapshot of a given task.
  2359. The idea is that the build process does not care about the
  2360. source of a task's output.
  2361. Output could be freshly built or it could be downloaded and
  2362. unpacked from somewhere - the build process does not need to
  2363. worry about its origin.
  2364. </para>
  2365. <para>
  2366. Two types of output exist.
  2367. One type is just about creating a directory in
  2368. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>.
  2369. A good example is the output of either
  2370. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  2371. or
  2372. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>.
  2373. The other type of output occurs when a set of data is merged
  2374. into a shared directory tree such as the sysroot.
  2375. </para>
  2376. <para>
  2377. The Yocto Project team has tried to keep the details of the
  2378. implementation hidden in <filename>sstate</filename> class.
  2379. From a user's perspective, adding shared state wrapping to a task
  2380. is as simple as this
  2381. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-deploy'><filename>do_deploy</filename></ulink>
  2382. example taken from the
  2383. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-deploy'><filename>deploy</filename></ulink>
  2384. class:
  2385. <literallayout class='monospaced'>
  2386. DEPLOYDIR = "${WORKDIR}/deploy-${PN}"
  2387. SSTATETASKS += "do_deploy"
  2388. do_deploy[sstate-inputdirs] = "${DEPLOYDIR}"
  2389. do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
  2390. python do_deploy_setscene () {
  2391. sstate_setscene(d)
  2392. }
  2393. addtask do_deploy_setscene
  2394. do_deploy[dirs] = "${DEPLOYDIR} ${B}"
  2395. </literallayout>
  2396. The following list explains the previous example:
  2397. <itemizedlist>
  2398. <listitem><para>
  2399. Adding "do_deploy" to <filename>SSTATETASKS</filename>
  2400. adds some required sstate-related processing, which is
  2401. implemented in the
  2402. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-sstate'><filename>sstate</filename></ulink>
  2403. class, to before and after the
  2404. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-deploy'><filename>do_deploy</filename></ulink>
  2405. task.
  2406. </para></listitem>
  2407. <listitem><para>
  2408. The
  2409. <filename>do_deploy[sstate-inputdirs] = "${DEPLOYDIR}"</filename>
  2410. declares that <filename>do_deploy</filename> places its
  2411. output in <filename>${DEPLOYDIR}</filename> when run
  2412. normally (i.e. when not using the sstate cache).
  2413. This output becomes the input to the shared state cache.
  2414. </para></listitem>
  2415. <listitem><para>
  2416. The
  2417. <filename>do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"</filename>
  2418. line causes the contents of the shared state cache to be
  2419. copied to <filename>${DEPLOY_DIR_IMAGE}</filename>.
  2420. <note>
  2421. If <filename>do_deploy</filename> is not already in
  2422. the shared state cache or if its input checksum
  2423. (signature) has changed from when the output was
  2424. cached, the task will be run to populate the shared
  2425. state cache, after which the contents of the shared
  2426. state cache is copied to
  2427. <filename>${DEPLOY_DIR_IMAGE}</filename>.
  2428. If <filename>do_deploy</filename> is in the shared
  2429. state cache and its signature indicates that the
  2430. cached output is still valid (i.e. if no
  2431. relevant task inputs have changed), then the
  2432. contents of the shared state cache will be copied
  2433. directly to
  2434. <filename>${DEPLOY_DIR_IMAGE}</filename> by the
  2435. <filename>do_deploy_setscene</filename> task
  2436. instead, skipping the
  2437. <filename>do_deploy</filename> task.
  2438. </note>
  2439. </para></listitem>
  2440. <listitem><para>
  2441. The following task definition is glue logic needed to
  2442. make the previous settings effective:
  2443. <literallayout class='monospaced'>
  2444. python do_deploy_setscene () {
  2445. sstate_setscene(d)
  2446. }
  2447. addtask do_deploy_setscene
  2448. </literallayout>
  2449. <filename>sstate_setscene()</filename> takes the flags
  2450. above as input and accelerates the
  2451. <filename>do_deploy</filename> task through the
  2452. shared state cache if possible.
  2453. If the task was accelerated,
  2454. <filename>sstate_setscene()</filename> returns True.
  2455. Otherwise, it returns False, and the normal
  2456. <filename>do_deploy</filename> task runs.
  2457. For more information, see the
  2458. "<ulink url='&YOCTO_DOCS_BB_URL;#setscene'>setscene</ulink>"
  2459. section in the BitBake User Manual.
  2460. </para></listitem>
  2461. <listitem><para>
  2462. The <filename>do_deploy[dirs] = "${DEPLOYDIR} ${B}"</filename>
  2463. line creates <filename>${DEPLOYDIR}</filename> and
  2464. <filename>${B}</filename> before the
  2465. <filename>do_deploy</filename> task runs, and also sets
  2466. the current working directory of
  2467. <filename>do_deploy</filename> to
  2468. <filename>${B}</filename>.
  2469. For more information, see the
  2470. "<ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'>Variable Flags</ulink>"
  2471. section in the BitBake User Manual.
  2472. <note>
  2473. In cases where
  2474. <filename>sstate-inputdirs</filename> and
  2475. <filename>sstate-outputdirs</filename> would be the
  2476. same, you can use
  2477. <filename>sstate-plaindirs</filename>.
  2478. For example, to preserve the
  2479. <filename>${PKGD}</filename> and
  2480. <filename>${PKGDEST}</filename> output from the
  2481. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>
  2482. task, use the following:
  2483. <literallayout class='monospaced'>
  2484. do_package[sstate-plaindirs] = "${PKGD} ${PKGDEST}"
  2485. </literallayout>
  2486. </note>
  2487. </para></listitem>
  2488. <listitem><para>
  2489. <filename>sstate-inputdirs</filename> and
  2490. <filename>sstate-outputdirs</filename> can also be used
  2491. with multiple directories.
  2492. For example, the following declares
  2493. <filename>PKGDESTWORK</filename> and
  2494. <filename>SHLIBWORK</filename> as shared state
  2495. input directories, which populates the shared state
  2496. cache, and <filename>PKGDATA_DIR</filename> and
  2497. <filename>SHLIBSDIR</filename> as the corresponding
  2498. shared state output directories:
  2499. <literallayout class='monospaced'>
  2500. do_package[sstate-inputdirs] = "${PKGDESTWORK} ${SHLIBSWORKDIR}"
  2501. do_package[sstate-outputdirs] = "${PKGDATA_DIR} ${SHLIBSDIR}"
  2502. </literallayout>
  2503. </para></listitem>
  2504. <listitem><para>
  2505. These methods also include the ability to take a
  2506. lockfile when manipulating shared state directory
  2507. structures, for cases where file additions or removals
  2508. are sensitive:
  2509. <literallayout class='monospaced'>
  2510. do_package[sstate-lockfile] = "${PACKAGELOCK}"
  2511. </literallayout>
  2512. </para></listitem>
  2513. </itemizedlist>
  2514. </para>
  2515. <para>
  2516. Behind the scenes, the shared state code works by looking in
  2517. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>
  2518. and
  2519. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_MIRRORS'><filename>SSTATE_MIRRORS</filename></ulink>
  2520. for shared state files.
  2521. Here is an example:
  2522. <literallayout class='monospaced'>
  2523. SSTATE_MIRRORS ?= "\
  2524. file://.* http://someserver.tld/share/sstate/PATH;downloadfilename=PATH \n \
  2525. file://.* file:///some/local/dir/sstate/PATH"
  2526. </literallayout>
  2527. <note>
  2528. The shared state directory
  2529. (<filename>SSTATE_DIR</filename>) is organized into
  2530. two-character subdirectories, where the subdirectory
  2531. names are based on the first two characters of the hash.
  2532. If the shared state directory structure for a mirror has the
  2533. same structure as <filename>SSTATE_DIR</filename>, you must
  2534. specify "PATH" as part of the URI to enable the build system
  2535. to map to the appropriate subdirectory.
  2536. </note>
  2537. </para>
  2538. <para>
  2539. The shared state package validity can be detected just by
  2540. looking at the filename since the filename contains the task
  2541. checksum (or signature) as described earlier in this section.
  2542. If a valid shared state package is found, the build process
  2543. downloads it and uses it to accelerate the task.
  2544. </para>
  2545. <para>
  2546. The build processes use the <filename>*_setscene</filename>
  2547. tasks for the task acceleration phase.
  2548. BitBake goes through this phase before the main execution
  2549. code and tries to accelerate any tasks for which it can find
  2550. shared state packages.
  2551. If a shared state package for a task is available, the
  2552. shared state package is used.
  2553. This means the task and any tasks on which it is dependent
  2554. are not executed.
  2555. </para>
  2556. <para>
  2557. As a real world example, the aim is when building an IPK-based
  2558. image, only the
  2559. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_ipk'><filename>do_package_write_ipk</filename></ulink>
  2560. tasks would have their shared state packages fetched and
  2561. extracted.
  2562. Since the sysroot is not used, it would never get extracted.
  2563. This is another reason why a task-based approach is preferred
  2564. over a recipe-based approach, which would have to install the
  2565. output from every task.n
  2566. </para>
  2567. </section>
  2568. <section id='concepts-tips-and-tricks'>
  2569. <title>Tips and Tricks</title>
  2570. <para>
  2571. The code in the build system that supports incremental builds
  2572. is not simple code.
  2573. This section presents some tips and tricks that help you work
  2574. around issues related to shared state code.
  2575. </para>
  2576. <section id='concepts-overview-debugging'>
  2577. <title>Debugging</title>
  2578. <para>
  2579. Seeing what metadata went into creating the input signature
  2580. of a shared state (sstate) task can be a useful debugging
  2581. aid.
  2582. This information is available in signature information
  2583. (<filename>siginfo</filename>) files in
  2584. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>.
  2585. For information on how to view and interpret information in
  2586. <filename>siginfo</filename> files, see the
  2587. "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-viewing-task-variable-dependencies'>Viewing Task Variable Dependencies</ulink>"
  2588. section in the Yocto Project Development Tasks Manual.
  2589. </para>
  2590. </section>
  2591. <section id='concepts-invalidating-shared-state'>
  2592. <title>Invalidating Shared State</title>
  2593. <para>
  2594. The OpenEmbedded build system uses checksums and shared
  2595. state cache to avoid unnecessarily rebuilding tasks.
  2596. Collectively, this scheme is known as "shared state code."
  2597. </para>
  2598. <para>
  2599. As with all schemes, this one has some drawbacks.
  2600. It is possible that you could make implicit changes to your
  2601. code that the checksum calculations do not take into
  2602. account.
  2603. These implicit changes affect a task's output but do not
  2604. trigger the shared state code into rebuilding a recipe.
  2605. Consider an example during which a tool changes its output.
  2606. Assume that the output of <filename>rpmdeps</filename>
  2607. changes.
  2608. The result of the change should be that all the
  2609. <filename>package</filename> and
  2610. <filename>package_write_rpm</filename> shared state cache
  2611. items become invalid.
  2612. However, because the change to the output is
  2613. external to the code and therefore implicit,
  2614. the associated shared state cache items do not become
  2615. invalidated.
  2616. In this case, the build process uses the cached items
  2617. rather than running the task again.
  2618. Obviously, these types of implicit changes can cause
  2619. problems.
  2620. </para>
  2621. <para>
  2622. To avoid these problems during the build, you need to
  2623. understand the effects of any changes you make.
  2624. Realize that changes you make directly to a function
  2625. are automatically factored into the checksum calculation.
  2626. Thus, these explicit changes invalidate the associated
  2627. area of shared state cache.
  2628. However, you need to be aware of any implicit changes that
  2629. are not obvious changes to the code and could affect
  2630. the output of a given task.
  2631. </para>
  2632. <para>
  2633. When you identify an implicit change, you can easily
  2634. take steps to invalidate the cache and force the tasks
  2635. to run.
  2636. The steps you can take are as simple as changing a
  2637. function's comments in the source code.
  2638. For example, to invalidate package shared state files,
  2639. change the comment statements of
  2640. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>
  2641. or the comments of one of the functions it calls.
  2642. Even though the change is purely cosmetic, it causes the
  2643. checksum to be recalculated and forces the OpenEmbedded
  2644. build system to run the task again.
  2645. <note>
  2646. For an example of a commit that makes a cosmetic
  2647. change to invalidate shared state, see this
  2648. <ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/commit/meta/classes/package.bbclass?id=737f8bbb4f27b4837047cb9b4fbfe01dfde36d54'>commit</ulink>.
  2649. </note>
  2650. </para>
  2651. </section>
  2652. </section>
  2653. </section>
  2654. <section id='automatically-added-runtime-dependencies'>
  2655. <title>Automatically Added Runtime Dependencies</title>
  2656. <para>
  2657. The OpenEmbedded build system automatically adds common types of
  2658. runtime dependencies between packages, which means that you do not
  2659. need to explicitly declare the packages using
  2660. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>.
  2661. Three automatic mechanisms exist (<filename>shlibdeps</filename>,
  2662. <filename>pcdeps</filename>, and <filename>depchains</filename>)
  2663. that handle shared libraries, package configuration (pkg-config)
  2664. modules, and <filename>-dev</filename> and
  2665. <filename>-dbg</filename> packages, respectively.
  2666. For other types of runtime dependencies, you must manually declare
  2667. the dependencies.
  2668. <itemizedlist>
  2669. <listitem><para>
  2670. <filename>shlibdeps</filename>:
  2671. During the
  2672. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>
  2673. task of each recipe, all shared libraries installed by the
  2674. recipe are located.
  2675. For each shared library, the package that contains the
  2676. shared library is registered as providing the shared
  2677. library.
  2678. More specifically, the package is registered as providing
  2679. the
  2680. <ulink url='https://en.wikipedia.org/wiki/Soname'>soname</ulink>
  2681. of the library.
  2682. The resulting shared-library-to-package mapping
  2683. is saved globally in
  2684. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></ulink>
  2685. by the
  2686. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-packagedata'><filename>do_packagedata</filename></ulink>
  2687. task.</para>
  2688. <para>Simultaneously, all executables and shared libraries
  2689. installed by the recipe are inspected to see what shared
  2690. libraries they link against.
  2691. For each shared library dependency that is found,
  2692. <filename>PKGDATA_DIR</filename> is queried to
  2693. see if some package (likely from a different recipe)
  2694. contains the shared library.
  2695. If such a package is found, a runtime dependency is added
  2696. from the package that depends on the shared library to the
  2697. package that contains the library.</para>
  2698. <para>The automatically added runtime dependency also
  2699. includes a version restriction.
  2700. This version restriction specifies that at least the
  2701. current version of the package that provides the shared
  2702. library must be used, as if
  2703. "<replaceable>package</replaceable> (>= <replaceable>version</replaceable>)"
  2704. had been added to <filename>RDEPENDS</filename>.
  2705. This forces an upgrade of the package containing the shared
  2706. library when installing the package that depends on the
  2707. library, if needed.</para>
  2708. <para>If you want to avoid a package being registered as
  2709. providing a particular shared library (e.g. because the library
  2710. is for internal use only), then add the library to
  2711. <ulink url='&YOCTO_DOCS_REF_URL;#var-PRIVATE_LIBS'><filename>PRIVATE_LIBS</filename></ulink>
  2712. inside the package's recipe.
  2713. </para></listitem>
  2714. <listitem><para>
  2715. <filename>pcdeps</filename>:
  2716. During the <filename>do_package</filename> task of each
  2717. recipe, all pkg-config modules
  2718. (<filename>*.pc</filename> files) installed by the recipe
  2719. are located.
  2720. For each module, the package that contains the module is
  2721. registered as providing the module.
  2722. The resulting module-to-package mapping is saved globally in
  2723. <filename>PKGDATA_DIR</filename> by the
  2724. <filename>do_packagedata</filename> task.</para>
  2725. <para>Simultaneously, all pkg-config modules installed by
  2726. the recipe are inspected to see what other pkg-config
  2727. modules they depend on.
  2728. A module is seen as depending on another module if it
  2729. contains a "Requires:" line that specifies the other module.
  2730. For each module dependency,
  2731. <filename>PKGDATA_DIR</filename> is queried to see if some
  2732. package contains the module.
  2733. If such a package is found, a runtime dependency is added
  2734. from the package that depends on the module to the package
  2735. that contains the module.
  2736. <note>
  2737. The <filename>pcdeps</filename> mechanism most often
  2738. infers dependencies between <filename>-dev</filename>
  2739. packages.
  2740. </note>
  2741. </para></listitem>
  2742. <listitem><para>
  2743. <filename>depchains</filename>:
  2744. If a package <filename>foo</filename> depends on a package
  2745. <filename>bar</filename>, then <filename>foo-dev</filename>
  2746. and <filename>foo-dbg</filename> are also made to depend on
  2747. <filename>bar-dev</filename> and
  2748. <filename>bar-dbg</filename>, respectively.
  2749. Taking the <filename>-dev</filename> packages as an
  2750. example, the <filename>bar-dev</filename> package might
  2751. provide headers and shared library symlinks needed by
  2752. <filename>foo-dev</filename>, which shows the need
  2753. for a dependency between the packages.</para>
  2754. <para>The dependencies added by
  2755. <filename>depchains</filename> are in the form of
  2756. <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>.
  2757. <note>
  2758. By default, <filename>foo-dev</filename> also has an
  2759. <filename>RDEPENDS</filename>-style dependency on
  2760. <filename>foo</filename>, because the default value of
  2761. <filename>RDEPENDS_${PN}-dev</filename> (set in
  2762. <filename>bitbake.conf</filename>) includes
  2763. "${PN}".
  2764. </note></para>
  2765. <para>To ensure that the dependency chain is never broken,
  2766. <filename>-dev</filename> and <filename>-dbg</filename>
  2767. packages are always generated by default, even if the
  2768. packages turn out to be empty.
  2769. See the
  2770. <ulink url='&YOCTO_DOCS_REF_URL;#var-ALLOW_EMPTY'><filename>ALLOW_EMPTY</filename></ulink>
  2771. variable for more information.
  2772. </para></listitem>
  2773. </itemizedlist>
  2774. </para>
  2775. <para>
  2776. The <filename>do_package</filename> task depends on the
  2777. <filename>do_packagedata</filename> task of each recipe in
  2778. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  2779. through use of a
  2780. <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>deptask</filename></ulink><filename>]</filename>
  2781. declaration, which guarantees that the required
  2782. shared-library/module-to-package mapping information will be available
  2783. when needed as long as <filename>DEPENDS</filename> has been
  2784. correctly set.
  2785. </para>
  2786. </section>
  2787. <section id='fakeroot-and-pseudo'>
  2788. <title>Fakeroot and Pseudo</title>
  2789. <para>
  2790. Some tasks are easier to implement when allowed to perform certain
  2791. operations that are normally reserved for the root user (e.g.
  2792. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>,
  2793. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_deb'><filename>do_package_write*</filename></ulink>,
  2794. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-rootfs'><filename>do_rootfs</filename></ulink>,
  2795. and
  2796. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-image'><filename>do_image*</filename></ulink>).
  2797. For example, the <filename>do_install</filename> task benefits
  2798. from being able to set the UID and GID of installed files to
  2799. arbitrary values.
  2800. </para>
  2801. <para>
  2802. One approach to allowing tasks to perform root-only operations
  2803. would be to require
  2804. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  2805. to run as root.
  2806. However, this method is cumbersome and has security issues.
  2807. The approach that is actually used is to run tasks that benefit
  2808. from root privileges in a "fake" root environment.
  2809. Within this environment, the task and its child processes believe
  2810. that they are running as the root user, and see an internally
  2811. consistent view of the filesystem.
  2812. As long as generating the final output (e.g. a package or an image)
  2813. does not require root privileges, the fact that some earlier
  2814. steps ran in a fake root environment does not cause problems.
  2815. </para>
  2816. <para>
  2817. The capability to run tasks in a fake root environment is known as
  2818. "<ulink url='http://man.he.net/man1/fakeroot'>fakeroot</ulink>",
  2819. which is derived from the BitBake keyword/variable
  2820. flag that requests a fake root environment for a task.
  2821. </para>
  2822. <para>
  2823. In the
  2824. <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink>,
  2825. the program that implements fakeroot is known as Pseudo.
  2826. Pseudo overrides system calls by using the environment variable
  2827. <filename>LD_PRELOAD</filename>, which results in the illusion
  2828. of running as root.
  2829. To keep track of "fake" file ownership and permissions resulting
  2830. from operations that require root permissions, Pseudo uses
  2831. an SQLite 3 database.
  2832. This database is stored in
  2833. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/pseudo/files.db</filename>
  2834. for individual recipes.
  2835. Storing the database in a file as opposed to in memory
  2836. gives persistence between tasks and builds, which is not
  2837. accomplished using fakeroot.
  2838. <note><title>Caution</title>
  2839. If you add your own task that manipulates the same files or
  2840. directories as a fakeroot task, then that task also needs to
  2841. run under fakeroot.
  2842. Otherwise, the task cannot run root-only operations, and
  2843. cannot see the fake file ownership and permissions set by the
  2844. other task.
  2845. You need to also add a dependency on
  2846. <filename>virtual/fakeroot-native:do_populate_sysroot</filename>,
  2847. giving the following:
  2848. <literallayout class='monospaced'>
  2849. fakeroot do_mytask () {
  2850. ...
  2851. }
  2852. do_mytask[depends] += "virtual/fakeroot-native:do_populate_sysroot"
  2853. </literallayout>
  2854. </note>
  2855. For more information, see the
  2856. <ulink url='&YOCTO_DOCS_BB_URL;#var-FAKEROOT'><filename>FAKEROOT*</filename></ulink>
  2857. variables in the BitBake User Manual.
  2858. You can also reference the
  2859. "<ulink url='http://www.ibm.com/developerworks/opensource/library/os-aapseudo1/index.html'>Pseudo</ulink>"
  2860. and
  2861. "<ulink url='https://github.com/wrpseudo/pseudo/wiki/WhyNotFakeroot'>Why Not Fakeroot?</ulink>"
  2862. articles for background information on Pseudo.
  2863. </para>
  2864. </section>
  2865. <section id="wayland">
  2866. <title>Wayland</title>
  2867. <para>
  2868. <ulink url='http://en.wikipedia.org/wiki/Wayland_(display_server_protocol)'>Wayland</ulink>
  2869. is a computer display server protocol that
  2870. provides a method for compositing window managers to communicate
  2871. directly with applications and video hardware and expects them to
  2872. communicate with input hardware using other libraries.
  2873. Using Wayland with supporting targets can result in better control
  2874. over graphics frame rendering than an application might otherwise
  2875. achieve.
  2876. </para>
  2877. <para>
  2878. The Yocto Project provides the Wayland protocol libraries and the
  2879. reference
  2880. <ulink url='http://en.wikipedia.org/wiki/Wayland_(display_server_protocol)#Weston'>Weston</ulink>
  2881. compositor as part of its release.
  2882. This section describes what you need to do to implement Wayland and
  2883. use the compositor when building an image for a supporting target.
  2884. </para>
  2885. <section id="wayland-support">
  2886. <title>Support</title>
  2887. <para>
  2888. The Wayland protocol libraries and the reference Weston
  2889. compositor ship as integrated packages in the
  2890. <filename>meta</filename> layer of the
  2891. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  2892. Specifically, you can find the recipes that build both Wayland
  2893. and Weston at
  2894. <filename>meta/recipes-graphics/wayland</filename>.
  2895. </para>
  2896. <para>
  2897. You can build both the Wayland and Weston packages for use only
  2898. with targets that accept the
  2899. <ulink url='https://en.wikipedia.org/wiki/Mesa_(computer_graphics)'>Mesa 3D and Direct Rendering Infrastructure</ulink>,
  2900. which is also known as Mesa DRI.
  2901. This implies that you cannot build and use the packages if your
  2902. target uses, for example, the
  2903. <trademark class='registered'>Intel</trademark> Embedded Media
  2904. and Graphics Driver
  2905. (<trademark class='registered'>Intel</trademark> EMGD) that
  2906. overrides Mesa DRI.
  2907. <note>
  2908. Due to lack of EGL support, Weston 1.0.3 will not run
  2909. directly on the emulated QEMU hardware.
  2910. However, this version of Weston will run under X emulation
  2911. without issues.
  2912. </note>
  2913. </para>
  2914. </section>
  2915. <section id="enabling-wayland-in-an-image">
  2916. <title>Enabling Wayland in an Image</title>
  2917. <para>
  2918. To enable Wayland, you need to enable it to be built and enable
  2919. it to be included in the image.
  2920. </para>
  2921. <section id="enable-building">
  2922. <title>Building</title>
  2923. <para>
  2924. To cause Mesa to build the <filename>wayland-egl</filename>
  2925. platform and Weston to build Wayland with Kernel Mode
  2926. Setting
  2927. (<ulink url='https://wiki.archlinux.org/index.php/Kernel_Mode_Setting'>KMS</ulink>)
  2928. support, include the "wayland" flag in the
  2929. <ulink url="&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES"><filename>DISTRO_FEATURES</filename></ulink>
  2930. statement in your <filename>local.conf</filename> file:
  2931. <literallayout class='monospaced'>
  2932. DISTRO_FEATURES_append = " wayland"
  2933. </literallayout>
  2934. <note>
  2935. If X11 has been enabled elsewhere, Weston will build
  2936. Wayland with X11 support
  2937. </note>
  2938. </para>
  2939. </section>
  2940. <section id="enable-installation-in-an-image">
  2941. <title>Installing</title>
  2942. <para>
  2943. To install the Wayland feature into an image, you must
  2944. include the following
  2945. <ulink url='&YOCTO_DOCS_REF_URL;#var-CORE_IMAGE_EXTRA_INSTALL'><filename>CORE_IMAGE_EXTRA_INSTALL</filename></ulink>
  2946. statement in your <filename>local.conf</filename> file:
  2947. <literallayout class='monospaced'>
  2948. CORE_IMAGE_EXTRA_INSTALL += "wayland weston"
  2949. </literallayout>
  2950. </para>
  2951. </section>
  2952. </section>
  2953. <section id="running-weston">
  2954. <title>Running Weston</title>
  2955. <para>
  2956. To run Weston inside X11, enabling it as described earlier and
  2957. building a Sato image is sufficient.
  2958. If you are running your image under Sato, a Weston Launcher
  2959. appears in the "Utility" category.
  2960. </para>
  2961. <para>
  2962. Alternatively, you can run Weston through the command-line
  2963. interpretor (CLI), which is better suited for development work.
  2964. To run Weston under the CLI, you need to do the following after
  2965. your image is built:
  2966. <orderedlist>
  2967. <listitem><para>
  2968. Run these commands to export
  2969. <filename>XDG_RUNTIME_DIR</filename>:
  2970. <literallayout class='monospaced'>
  2971. mkdir -p /tmp/$USER-weston
  2972. chmod 0700 /tmp/$USER-weston
  2973. export XDG_RUNTIME_DIR=/tmp/$USER-weston
  2974. </literallayout>
  2975. </para></listitem>
  2976. <listitem><para>
  2977. Launch Weston in the shell:
  2978. <literallayout class='monospaced'>
  2979. weston
  2980. </literallayout></para></listitem>
  2981. </orderedlist>
  2982. </para>
  2983. </section>
  2984. </section>
  2985. <section id="overview-licenses">
  2986. <title>Licenses</title>
  2987. <para>
  2988. This section describes the mechanism by which the
  2989. <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink>
  2990. tracks changes to licensing text.
  2991. The section also describes how to enable commercially licensed
  2992. recipes, which by default are disabled.
  2993. </para>
  2994. <para>
  2995. For information that can help you maintain compliance with
  2996. various open source licensing during the lifecycle of the product,
  2997. see the
  2998. "<ulink url='&YOCTO_DOCS_DEV_URL;#maintaining-open-source-license-compliance-during-your-products-lifecycle'>Maintaining Open Source License Compliance During Your Project's Lifecycle</ulink>"
  2999. section in the Yocto Project Development Tasks Manual.
  3000. </para>
  3001. <section id="usingpoky-configuring-LIC_FILES_CHKSUM">
  3002. <title>Tracking License Changes</title>
  3003. <para>
  3004. The license of an upstream project might change in the future.
  3005. In order to prevent these changes going unnoticed, the
  3006. <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink>
  3007. variable tracks changes to the license text. The checksums are
  3008. validated at the end of the configure step, and if the
  3009. checksums do not match, the build will fail.
  3010. </para>
  3011. <section id="usingpoky-specifying-LIC_FILES_CHKSUM">
  3012. <title>Specifying the <filename>LIC_FILES_CHKSUM</filename> Variable</title>
  3013. <para>
  3014. The <filename>LIC_FILES_CHKSUM</filename>
  3015. variable contains checksums of the license text in the
  3016. source code for the recipe.
  3017. Following is an example of how to specify
  3018. <filename>LIC_FILES_CHKSUM</filename>:
  3019. <literallayout class='monospaced'>
  3020. LIC_FILES_CHKSUM = "file://COPYING;md5=xxxx \
  3021. file://licfile1.txt;beginline=5;endline=29;md5=yyyy \
  3022. file://licfile2.txt;endline=50;md5=zzzz \
  3023. ..."
  3024. </literallayout>
  3025. <note><title>Notes</title>
  3026. <itemizedlist>
  3027. <listitem><para>
  3028. When using "beginline" and "endline", realize
  3029. that line numbering begins with one and not
  3030. zero.
  3031. Also, the included lines are inclusive (i.e.
  3032. lines five through and including 29 in the
  3033. previous example for
  3034. <filename>licfile1.txt</filename>).
  3035. </para></listitem>
  3036. <listitem><para>
  3037. When a license check fails, the selected license
  3038. text is included as part of the QA message.
  3039. Using this output, you can determine the exact
  3040. start and finish for the needed license text.
  3041. </para></listitem>
  3042. </itemizedlist>
  3043. </note>
  3044. </para>
  3045. <para>
  3046. The build system uses the
  3047. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
  3048. variable as the default directory when searching files
  3049. listed in <filename>LIC_FILES_CHKSUM</filename>.
  3050. The previous example employs the default directory.
  3051. </para>
  3052. <para>
  3053. Consider this next example:
  3054. <literallayout class='monospaced'>
  3055. LIC_FILES_CHKSUM = "file://src/ls.c;beginline=5;endline=16;\
  3056. md5=bb14ed3c4cda583abc85401304b5cd4e"
  3057. LIC_FILES_CHKSUM = "file://${WORKDIR}/license.html;md5=5c94767cedb5d6987c902ac850ded2c6"
  3058. </literallayout>
  3059. </para>
  3060. <para>
  3061. The first line locates a file in
  3062. <filename>${S}/src/ls.c</filename> and isolates lines five
  3063. through 16 as license text.
  3064. The second line refers to a file in
  3065. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>.
  3066. </para>
  3067. <para>
  3068. Note that <filename>LIC_FILES_CHKSUM</filename> variable is
  3069. mandatory for all recipes, unless the
  3070. <filename>LICENSE</filename> variable is set to "CLOSED".
  3071. </para>
  3072. </section>
  3073. <section id="usingpoky-LIC_FILES_CHKSUM-explanation-of-syntax">
  3074. <title>Explanation of Syntax</title>
  3075. <para>
  3076. As mentioned in the previous section, the
  3077. <filename>LIC_FILES_CHKSUM</filename> variable lists all
  3078. the important files that contain the license text for the
  3079. source code.
  3080. It is possible to specify a checksum for an entire file,
  3081. or a specific section of a file (specified by beginning and
  3082. ending line numbers with the "beginline" and "endline"
  3083. parameters, respectively).
  3084. The latter is useful for source files with a license
  3085. notice header, README documents, and so forth.
  3086. If you do not use the "beginline" parameter, then it is
  3087. assumed that the text begins on the first line of the file.
  3088. Similarly, if you do not use the "endline" parameter,
  3089. it is assumed that the license text ends with the last
  3090. line of the file.
  3091. </para>
  3092. <para>
  3093. The "md5" parameter stores the md5 checksum of the license
  3094. text.
  3095. If the license text changes in any way as compared to
  3096. this parameter then a mismatch occurs.
  3097. This mismatch triggers a build failure and notifies
  3098. the developer.
  3099. Notification allows the developer to review and address
  3100. the license text changes.
  3101. Also note that if a mismatch occurs during the build,
  3102. the correct md5 checksum is placed in the build log and
  3103. can be easily copied to the recipe.
  3104. </para>
  3105. <para>
  3106. There is no limit to how many files you can specify using
  3107. the <filename>LIC_FILES_CHKSUM</filename> variable.
  3108. Generally, however, every project requires a few
  3109. specifications for license tracking.
  3110. Many projects have a "COPYING" file that stores the
  3111. license information for all the source code files.
  3112. This practice allows you to just track the "COPYING"
  3113. file as long as it is kept up to date.
  3114. <note><title>Tips</title>
  3115. <itemizedlist>
  3116. <listitem><para>
  3117. If you specify an empty or invalid "md5"
  3118. parameter,
  3119. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  3120. returns an md5 mis-match
  3121. error and displays the correct "md5" parameter
  3122. value during the build.
  3123. The correct parameter is also captured in
  3124. the build log.
  3125. </para></listitem>
  3126. <listitem><para>
  3127. If the whole file contains only license text,
  3128. you do not need to use the "beginline" and
  3129. "endline" parameters.
  3130. </para></listitem>
  3131. </itemizedlist>
  3132. </note>
  3133. </para>
  3134. </section>
  3135. </section>
  3136. <section id="enabling-commercially-licensed-recipes">
  3137. <title>Enabling Commercially Licensed Recipes</title>
  3138. <para>
  3139. By default, the OpenEmbedded build system disables
  3140. components that have commercial or other special licensing
  3141. requirements.
  3142. Such requirements are defined on a
  3143. recipe-by-recipe basis through the
  3144. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_FLAGS'><filename>LICENSE_FLAGS</filename></ulink>
  3145. variable definition in the affected recipe.
  3146. For instance, the
  3147. <filename>poky/meta/recipes-multimedia/gstreamer/gst-plugins-ugly</filename>
  3148. recipe contains the following statement:
  3149. <literallayout class='monospaced'>
  3150. LICENSE_FLAGS = "commercial"
  3151. </literallayout>
  3152. Here is a slightly more complicated example that contains both
  3153. an explicit recipe name and version (after variable expansion):
  3154. <literallayout class='monospaced'>
  3155. LICENSE_FLAGS = "license_${PN}_${PV}"
  3156. </literallayout>
  3157. In order for a component restricted by a
  3158. <filename>LICENSE_FLAGS</filename> definition to be enabled and
  3159. included in an image, it needs to have a matching entry in the
  3160. global
  3161. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_FLAGS_WHITELIST'><filename>LICENSE_FLAGS_WHITELIST</filename></ulink>
  3162. variable, which is a variable typically defined in your
  3163. <filename>local.conf</filename> file.
  3164. For example, to enable the
  3165. <filename>poky/meta/recipes-multimedia/gstreamer/gst-plugins-ugly</filename>
  3166. package, you could add either the string
  3167. "commercial_gst-plugins-ugly" or the more general string
  3168. "commercial" to <filename>LICENSE_FLAGS_WHITELIST</filename>.
  3169. See the
  3170. "<link linkend='license-flag-matching'>License Flag Matching</link>"
  3171. section for a full
  3172. explanation of how <filename>LICENSE_FLAGS</filename> matching
  3173. works.
  3174. Here is the example:
  3175. <literallayout class='monospaced'>
  3176. LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly"
  3177. </literallayout>
  3178. Likewise, to additionally enable the package built from the
  3179. recipe containing
  3180. <filename>LICENSE_FLAGS = "license_${PN}_${PV}"</filename>,
  3181. and assuming that the actual recipe name was
  3182. <filename>emgd_1.10.bb</filename>, the following string would
  3183. enable that package as well as the original
  3184. <filename>gst-plugins-ugly</filename> package:
  3185. <literallayout class='monospaced'>
  3186. LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly license_emgd_1.10"
  3187. </literallayout>
  3188. As a convenience, you do not need to specify the complete
  3189. license string in the whitelist for every package.
  3190. You can use an abbreviated form, which consists
  3191. of just the first portion or portions of the license
  3192. string before the initial underscore character or characters.
  3193. A partial string will match any license that contains the
  3194. given string as the first portion of its license.
  3195. For example, the following whitelist string will also match
  3196. both of the packages previously mentioned as well as any other
  3197. packages that have licenses starting with "commercial" or
  3198. "license".
  3199. <literallayout class='monospaced'>
  3200. LICENSE_FLAGS_WHITELIST = "commercial license"
  3201. </literallayout>
  3202. </para>
  3203. <section id="license-flag-matching">
  3204. <title>License Flag Matching</title>
  3205. <para>
  3206. License flag matching allows you to control what recipes
  3207. the OpenEmbedded build system includes in the build.
  3208. Fundamentally, the build system attempts to match
  3209. <filename>LICENSE_FLAGS</filename> strings found in recipes
  3210. against <filename>LICENSE_FLAGS_WHITELIST</filename>
  3211. strings found in the whitelist.
  3212. A match causes the build system to include a recipe in the
  3213. build, while failure to find a match causes the build
  3214. system to exclude a recipe.
  3215. </para>
  3216. <para>
  3217. In general, license flag matching is simple.
  3218. However, understanding some concepts will help you
  3219. correctly and effectively use matching.
  3220. </para>
  3221. <para>
  3222. Before a flag
  3223. defined by a particular recipe is tested against the
  3224. contents of the whitelist, the expanded string
  3225. <filename>_${PN}</filename> is appended to the flag.
  3226. This expansion makes each
  3227. <filename>LICENSE_FLAGS</filename> value recipe-specific.
  3228. After expansion, the string is then matched against the
  3229. whitelist.
  3230. Thus, specifying
  3231. <filename>LICENSE_FLAGS = "commercial"</filename>
  3232. in recipe "foo", for example, results in the string
  3233. <filename>"commercial_foo"</filename>.
  3234. And, to create a match, that string must appear in the
  3235. whitelist.
  3236. </para>
  3237. <para>
  3238. Judicious use of the <filename>LICENSE_FLAGS</filename>
  3239. strings and the contents of the
  3240. <filename>LICENSE_FLAGS_WHITELIST</filename> variable
  3241. allows you a lot of flexibility for including or excluding
  3242. recipes based on licensing.
  3243. For example, you can broaden the matching capabilities by
  3244. using license flags string subsets in the whitelist.
  3245. <note>
  3246. When using a string subset, be sure to use the part of
  3247. the expanded string that precedes the appended
  3248. underscore character (e.g.
  3249. <filename>usethispart_1.3</filename>,
  3250. <filename>usethispart_1.4</filename>, and so forth).
  3251. </note>
  3252. For example, simply specifying the string "commercial" in
  3253. the whitelist matches any expanded
  3254. <filename>LICENSE_FLAGS</filename> definition that starts
  3255. with the string "commercial" such as "commercial_foo" and
  3256. "commercial_bar", which are the strings the build system
  3257. automatically generates for hypothetical recipes named
  3258. "foo" and "bar" assuming those recipes simply specify the
  3259. following:
  3260. <literallayout class='monospaced'>
  3261. LICENSE_FLAGS = "commercial"
  3262. </literallayout>
  3263. Thus, you can choose to exhaustively
  3264. enumerate each license flag in the whitelist and
  3265. allow only specific recipes into the image, or
  3266. you can use a string subset that causes a broader range of
  3267. matches to allow a range of recipes into the image.
  3268. </para>
  3269. <para>
  3270. This scheme works even if the
  3271. <filename>LICENSE_FLAGS</filename> string already
  3272. has <filename>_${PN}</filename> appended.
  3273. For example, the build system turns the license flag
  3274. "commercial_1.2_foo" into "commercial_1.2_foo_foo" and
  3275. would match both the general "commercial" and the specific
  3276. "commercial_1.2_foo" strings found in the whitelist, as
  3277. expected.
  3278. </para>
  3279. <para>
  3280. Here are some other scenarios:
  3281. <itemizedlist>
  3282. <listitem><para>
  3283. You can specify a versioned string in the recipe
  3284. such as "commercial_foo_1.2" in a "foo" recipe.
  3285. The build system expands this string to
  3286. "commercial_foo_1.2_foo".
  3287. Combine this license flag with a whitelist that has
  3288. the string "commercial" and you match the flag
  3289. along with any other flag that starts with the
  3290. string "commercial".
  3291. </para></listitem>
  3292. <listitem><para>
  3293. Under the same circumstances, you can use
  3294. "commercial_foo" in the whitelist and the build
  3295. system not only matches "commercial_foo_1.2" but
  3296. also matches any license flag with the string
  3297. "commercial_foo", regardless of the version.
  3298. </para></listitem>
  3299. <listitem><para>
  3300. You can be very specific and use both the
  3301. package and version parts in the whitelist (e.g.
  3302. "commercial_foo_1.2") to specifically match a
  3303. versioned recipe.
  3304. </para></listitem>
  3305. </itemizedlist>
  3306. </para>
  3307. </section>
  3308. <section id="other-variables-related-to-commercial-licenses">
  3309. <title>Other Variables Related to Commercial Licenses</title>
  3310. <para>
  3311. Other helpful variables related to commercial
  3312. license handling exist and are defined in the
  3313. <filename>poky/meta/conf/distro/include/default-distrovars.inc</filename> file:
  3314. <literallayout class='monospaced'>
  3315. COMMERCIAL_AUDIO_PLUGINS ?= ""
  3316. COMMERCIAL_VIDEO_PLUGINS ?= ""
  3317. </literallayout>
  3318. If you want to enable these components, you can do so by
  3319. making sure you have statements similar to the following
  3320. in your <filename>local.conf</filename> configuration file:
  3321. <literallayout class='monospaced'>
  3322. COMMERCIAL_AUDIO_PLUGINS = "gst-plugins-ugly-mad \
  3323. gst-plugins-ugly-mpegaudioparse"
  3324. COMMERCIAL_VIDEO_PLUGINS = "gst-plugins-ugly-mpeg2dec \
  3325. gst-plugins-ugly-mpegstream gst-plugins-bad-mpegvideoparse"
  3326. LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly commercial_gst-plugins-bad commercial_qmmp"
  3327. </literallayout>
  3328. Of course, you could also create a matching whitelist
  3329. for those components using the more general "commercial"
  3330. in the whitelist, but that would also enable all the
  3331. other packages with <filename>LICENSE_FLAGS</filename>
  3332. containing "commercial", which you may or may not want:
  3333. <literallayout class='monospaced'>
  3334. LICENSE_FLAGS_WHITELIST = "commercial"
  3335. </literallayout>
  3336. </para>
  3337. <para>
  3338. Specifying audio and video plug-ins as part of the
  3339. <filename>COMMERCIAL_AUDIO_PLUGINS</filename> and
  3340. <filename>COMMERCIAL_VIDEO_PLUGINS</filename> statements
  3341. (along with the enabling
  3342. <filename>LICENSE_FLAGS_WHITELIST</filename>) includes the
  3343. plug-ins or components into built images, thus adding
  3344. support for media formats or components.
  3345. </para>
  3346. </section>
  3347. </section>
  3348. </section>
  3349. </chapter>
  3350. <!--
  3351. vim: expandtab tw=80 ts=4
  3352. -->