blob: bd5278493fdbb9b55970c489e2265e6c73c0e78b [file] [log] [blame]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001<!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
5<chapter id='sdk-extensible'>
6
Patrick Williamsc0f7c042017-02-23 20:41:17 -06007 <title>Using the Extensible SDK</title>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05008
9 <para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -060010 This chapter describes the extensible SDK and how to install it.
11 Information covers the pieces of the SDK, how to install it, and
12 presents a look at using the <filename>devtool</filename>
13 functionality.
14 The extensible SDK makes it easy to add new applications and libraries
15 to an image, modify the source for an existing component, test
16 changes on the target hardware, and ease integration into the rest of
17 the
Brad Bishopd7bf8c12018-02-25 22:55:05 -050018 <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink>.
Patrick Williamsc0f7c042017-02-23 20:41:17 -060019 <note>
20 For a side-by-side comparison of main features supported for an
21 extensible SDK as compared to a standard SDK, see the
22 "<link linkend='sdk-manual-intro'>Introduction</link>"
23 section.
24 </note>
25 </para>
26
27 <para>
28 In addition to the functionality available through
29 <filename>devtool</filename>, you can alternatively make use of the
Brad Bishopc342db32019-05-15 21:57:59 -040030 toolchain directly, for example from Makefile and Autotools.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050031 See the
Patrick Williamsc0f7c042017-02-23 20:41:17 -060032 "<link linkend='sdk-working-projects'>Using the SDK Toolchain Directly</link>"
33 chapter for more information.
34 </para>
35
36 <section id='sdk-extensible-sdk-intro'>
37 <title>Why use the Extensible SDK and What is in It?</title>
38
39 <para>
40 The extensible SDK provides a cross-development toolchain and
41 libraries tailored to the contents of a specific image.
42 You would use the Extensible SDK if you want a toolchain experience
43 supplemented with the powerful set of <filename>devtool</filename>
44 commands tailored for the Yocto Project environment.
45 </para>
46
47 <para>
48 The installed extensible SDK consists of several files and
49 directories.
50 Basically, it contains an SDK environment setup script, some
51 configuration files, an internal build system, and the
52 <filename>devtool</filename> functionality.
53 </para>
54 </section>
55
Brad Bishop316dfdd2018-06-25 12:45:53 -040056 <section id='sdk-installing-the-extensible-sdk'>
57 <title>Installing the Extensible SDK</title>
Patrick Williamsc0f7c042017-02-23 20:41:17 -060058
59 <para>
Brad Bishop316dfdd2018-06-25 12:45:53 -040060 The first thing you need to do is install the SDK on your
61 <ulink url='&YOCTO_DOCS_REF_URL;#hardware-build-system-term'>Build Host</ulink>
62 by running the <filename>*.sh</filename> installation script.
Patrick Williamsc0f7c042017-02-23 20:41:17 -060063 </para>
64
65 <para>
66 You can download a tarball installer, which includes the
67 pre-built toolchain, the <filename>runqemu</filename>
68 script, the internal build system, <filename>devtool</filename>,
Brad Bishop316dfdd2018-06-25 12:45:53 -040069 and support files from the appropriate
70 <ulink url='&YOCTO_TOOLCHAIN_DL_URL;'>toolchain</ulink>
71 directory within the Index of Releases.
72 Toolchains are available for several 32-bit and 64-bit
73 architectures with the <filename>x86_64</filename> directories,
74 respectively.
Patrick Williamsc0f7c042017-02-23 20:41:17 -060075 The toolchains the Yocto Project provides are based off the
Brad Bishop316dfdd2018-06-25 12:45:53 -040076 <filename>core-image-sato</filename> and
77 <filename>core-image-minimal</filename> images and contain
Patrick Williamsc0f7c042017-02-23 20:41:17 -060078 libraries appropriate for developing against that image.
Patrick Williamsc0f7c042017-02-23 20:41:17 -060079 </para>
80
81 <para>
82 The names of the tarball installer scripts are such that a
83 string representing the host system appears first in the
84 filename and then is immediately followed by a string
85 representing the target architecture.
86 An extensible SDK has the string "-ext" as part of the name.
Brad Bishop316dfdd2018-06-25 12:45:53 -040087 Following is the general form:
Patrick Williamsc0f7c042017-02-23 20:41:17 -060088 <literallayout class='monospaced'>
89 poky-glibc-<replaceable>host_system</replaceable>-<replaceable>image_type</replaceable>-<replaceable>arch</replaceable>-toolchain-ext-<replaceable>release_version</replaceable>.sh
90
91 Where:
92 <replaceable>host_system</replaceable> is a string representing your development system:
93
94 i686 or x86_64.
95
Brad Bishop316dfdd2018-06-25 12:45:53 -040096 <replaceable>image_type</replaceable> is the image for which the SDK was built:
97
98 core-image-sato or core-image-minimal
Patrick Williamsc0f7c042017-02-23 20:41:17 -060099
100 <replaceable>arch</replaceable> is a string representing the tuned target architecture:
101
Brad Bishop316dfdd2018-06-25 12:45:53 -0400102 aarch64, armv5e, core2-64, i586, mips32r2, mips64, ppc7400, or cortexa8hf-neon
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600103
Brad Bishop316dfdd2018-06-25 12:45:53 -0400104 <replaceable>release_version</replaceable> is a string representing the release number of the Yocto Project:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600105
106 &DISTRO;, &DISTRO;+snapshot
107 </literallayout>
108 For example, the following SDK installer is for a 64-bit
109 development host system and a i586-tuned target architecture
110 based off the SDK for <filename>core-image-sato</filename> and
111 using the current &DISTRO; snapshot:
112 <literallayout class='monospaced'>
113 poky-glibc-x86_64-core-image-sato-i586-toolchain-ext-&DISTRO;.sh
114 </literallayout>
115 <note>
116 As an alternative to downloading an SDK, you can build the
117 SDK installer.
118 For information on building the installer, see the
119 "<link linkend='sdk-building-an-sdk-installer'>Building an SDK Installer</link>"
120 section.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600121 </note>
122 </para>
123
124 <para>
125 The SDK and toolchains are self-contained and by default are
126 installed into the <filename>poky_sdk</filename> folder in your
127 home directory.
128 You can choose to install the extensible SDK in any location when
129 you run the installer.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400130 However, because files need to be written under that directory
131 during the normal course of operation, the location you choose
132 for installation must be writable for whichever
133 users need to use the SDK.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600134 </para>
135
136 <para>
137 The following command shows how to run the installer given a
138 toolchain tarball for a 64-bit x86 development host system and
139 a 64-bit x86 target architecture.
140 The example assumes the SDK installer is located in
Brad Bishop316dfdd2018-06-25 12:45:53 -0400141 <filename>~/Downloads/</filename> and has execution rights.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600142 <note>
143 If you do not have write permissions for the directory
144 into which you are installing the SDK, the installer
145 notifies you and exits.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400146 For that case, set up the proper permissions in the directory
147 and run the installer again.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600148 </note>
149 <literallayout class='monospaced'>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400150 $ ./Downloads/poky-glibc-x86_64-core-image-minimal-core2-64-toolchain-ext-2.5.sh
151 Poky (Yocto Project Reference Distro) Extensible SDK installer version 2.5
152 ==========================================================================
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500153 Enter target directory for SDK (default: ~/poky_sdk):
Brad Bishopd89cb5f2019-04-10 09:02:41 -0400154 You are about to install the SDK to "/home/scottrif/poky_sdk". Proceed [Y/n]? Y
Brad Bishop316dfdd2018-06-25 12:45:53 -0400155 Extracting SDK..............done
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500156 Setting it up...
157 Extracting buildtools...
158 Preparing build system...
Brad Bishop316dfdd2018-06-25 12:45:53 -0400159 Parsing recipes: 100% |##################################################################| Time: 0:00:52
160 Initialising tasks: 100% |###############################################################| Time: 0:00:00
161 Checking sstate mirror object availability: 100% |#######################################| Time: 0:00:00
162 Loading cache: 100% |####################################################################| Time: 0:00:00
163 Initialising tasks: 100% |###############################################################| Time: 0:00:00
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500164 done
165 SDK has been successfully set up and is ready to be used.
166 Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
167 $ . /home/scottrif/poky_sdk/environment-setup-core2-64-poky-linux
Brad Bishop316dfdd2018-06-25 12:45:53 -0400168
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600169 </literallayout>
170 </para>
171 </section>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500172
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600173 <section id='sdk-running-the-extensible-sdk-environment-setup-script'>
174 <title>Running the Extensible SDK Environment Setup Script</title>
175
176 <para>
177 Once you have the SDK installed, you must run the SDK environment
Brad Bishop316dfdd2018-06-25 12:45:53 -0400178 setup script before you can actually use the SDK.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600179 This setup script resides in the directory you chose when you
180 installed the SDK, which is either the default
181 <filename>poky_sdk</filename> directory or the directory you
182 chose during installation.
183 </para>
184
185 <para>
186 Before running the script, be sure it is the one that matches the
187 architecture for which you are developing.
188 Environment setup scripts begin with the string
189 "<filename>environment-setup</filename>" and include as part of
190 their name the tuned target architecture.
191 As an example, the following commands set the working directory
192 to where the SDK was installed and then source the environment
193 setup script.
194 In this example, the setup script is for an IA-based
195 target machine using i586 tuning:
196 <literallayout class='monospaced'>
197 $ cd /home/scottrif/poky_sdk
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500198 $ source environment-setup-core2-64-poky-linux
199 SDK environment now set up; additionally you may now run devtool to perform development tasks.
200 Run devtool --help for further details.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600201 </literallayout>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400202 Running the setup script defines many environment variables needed
203 in order to use the SDK (e.g. <filename>PATH</filename>,
204 <ulink url='&YOCTO_DOCS_REF_URL;#var-CC'><filename>CC</filename></ulink>,
205 <ulink url='&YOCTO_DOCS_REF_URL;#var-LD'><filename>LD</filename></ulink>,
206 and so forth).
207 If you want to see all the environment variables the script
208 exports, examine the installation file itself.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600209 </para>
210 </section>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500211
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600212 <section id='using-devtool-in-your-sdk-workflow'>
213 <title>Using <filename>devtool</filename> in Your SDK Workflow</title>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500214
215 <para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600216 The cornerstone of the extensible SDK is a command-line tool
217 called <filename>devtool</filename>.
218 This tool provides a number of features that help
219 you build, test and package software within the extensible SDK, and
220 optionally integrate it into an image built by the OpenEmbedded
221 build system.
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500222 <note><title>Tip</title>
223 The use of <filename>devtool</filename> is not limited to
224 the extensible SDK.
225 You can use <filename>devtool</filename> to help you easily
226 develop any project whose build output must be part of an
Brad Bishop316dfdd2018-06-25 12:45:53 -0400227 image built using the build system.
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500228 </note>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500229 </para>
230
231 <para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600232 The <filename>devtool</filename> command line is organized
233 similarly to
Brad Bishop316dfdd2018-06-25 12:45:53 -0400234 <ulink url='&YOCTO_DOCS_OM_URL;#git'>Git</ulink> in that it
235 has a number of sub-commands for each function.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600236 You can run <filename>devtool --help</filename> to see all the
237 commands.
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500238 <note>
239 See the
240 "<ulink url='&YOCTO_DOCS_REF_URL;#ref-devtool-reference'><filename>devtool</filename>&nbsp;Quick Reference</ulink>"
241 in the Yocto Project Reference Manual for a
242 <filename>devtool</filename> quick reference.
243 </note>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500244 </para>
245
246 <para>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400247 Three <filename>devtool</filename> subcommands exist that provide
248 entry-points into development:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600249 <itemizedlist>
250 <listitem><para>
251 <emphasis><filename>devtool add</filename></emphasis>:
252 Assists in adding new software to be built.
253 </para></listitem>
254 <listitem><para>
255 <emphasis><filename>devtool modify</filename></emphasis>:
256 Sets up an environment to enable you to modify the source of
257 an existing component.
258 </para></listitem>
259 <listitem><para>
260 <emphasis><filename>devtool upgrade</filename></emphasis>:
261 Updates an existing recipe so that you can build it for
262 an updated set of source files.
263 </para></listitem>
264 </itemizedlist>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400265 As with the build system, "recipes" represent software packages
266 within <filename>devtool</filename>.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600267 When you use <filename>devtool add</filename>, a recipe is
268 automatically created.
269 When you use <filename>devtool modify</filename>, the specified
Brad Bishop316dfdd2018-06-25 12:45:53 -0400270 existing recipe is used in order to determine where to get the
271 source code and how to patch it.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600272 In both cases, an environment is set up so that when you build the
273 recipe a source tree that is under your control is used in order to
274 allow you to make changes to the source as desired.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400275 By default, new recipes and the source go into a "workspace"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600276 directory under the SDK.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500277 </para>
278
279 <para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600280 The remainder of this section presents the
281 <filename>devtool add</filename>,
282 <filename>devtool modify</filename>, and
283 <filename>devtool upgrade</filename> workflows.
284 </para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500285
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600286 <section id='sdk-use-devtool-to-add-an-application'>
287 <title>Use <filename>devtool add</filename> to Add an Application</title>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500288
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600289 <para>
290 The <filename>devtool add</filename> command generates
291 a new recipe based on existing source code.
292 This command takes advantage of the
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500293 <ulink url='&YOCTO_DOCS_REF_URL;#devtool-the-workspace-layer-structure'>workspace</ulink>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600294 layer that many <filename>devtool</filename> commands
295 use.
296 The command is flexible enough to allow you to extract source
297 code into both the workspace or a separate local Git repository
298 and to use existing code that does not need to be extracted.
299 </para>
300
301 <para>
302 Depending on your particular scenario, the arguments and options
303 you use with <filename>devtool add</filename> form different
304 combinations.
305 The following diagram shows common development flows
306 you would use with the <filename>devtool add</filename>
307 command:
308 </para>
309
310 <para>
311 <imagedata fileref="figures/sdk-devtool-add-flow.png" align="center" />
312 </para>
313
314 <para>
315 <orderedlist>
316 <listitem><para><emphasis>Generating the New Recipe</emphasis>:
317 The top part of the flow shows three scenarios by which
318 you could use <filename>devtool add</filename> to
319 generate a recipe based on existing source code.</para>
320
321 <para>In a shared development environment, it is
Brad Bishop316dfdd2018-06-25 12:45:53 -0400322 typical for other developers to be responsible for
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600323 various areas of source code.
324 As a developer, you are probably interested in using
Brad Bishop316dfdd2018-06-25 12:45:53 -0400325 that source code as part of your development within
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600326 the Yocto Project.
327 All you need is access to the code, a recipe, and a
328 controlled area in which to do your work.</para>
329
330 <para>Within the diagram, three possible scenarios
331 feed into the <filename>devtool add</filename> workflow:
332 <itemizedlist>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400333 <listitem><para>
334 <emphasis>Left</emphasis>:
335 The left scenario in the figure represents a
336 common situation where the source code does not
337 exist locally and needs to be extracted.
338 In this situation, the source code is extracted
339 to the default workspace - you do not
340 want the files in some specific location
341 outside of the workspace.
342 Thus, everything you need will be located in
343 the workspace:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600344 <literallayout class='monospaced'>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500345 $ devtool add <replaceable>recipe fetchuri</replaceable>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600346 </literallayout>
347 With this command, <filename>devtool</filename>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400348 extracts the upstream source files into a local
349 Git repository within the
350 <filename>sources</filename> folder.
351 The command then creates a recipe named
352 <replaceable>recipe</replaceable> and a
353 corresponding append file in the workspace.
354 If you do not provide
355 <replaceable>recipe</replaceable>, the command
356 makes an attempt to determine the recipe name.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600357 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400358 <listitem><para>
359 <emphasis>Middle</emphasis>:
360 The middle scenario in the figure also
361 represents a situation where the source code
362 does not exist locally.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600363 In this case, the code is again upstream
364 and needs to be extracted to some
365 local area - this time outside of the default
366 workspace.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400367 <note>
368 If required, <filename>devtool</filename>
369 always creates
370 a Git repository locally during the
371 extraction.
372 </note>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600373 Furthermore, the first positional argument
Brad Bishop316dfdd2018-06-25 12:45:53 -0400374 <replaceable>srctree</replaceable> in this
375 case identifies where the
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600376 <filename>devtool add</filename> command
377 will locate the extracted code outside of the
Brad Bishop316dfdd2018-06-25 12:45:53 -0400378 workspace.
379 You need to specify an empty directory:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600380 <literallayout class='monospaced'>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500381 $ devtool add <replaceable>recipe srctree fetchuri</replaceable>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600382 </literallayout>
383 In summary, the source code is pulled from
Brad Bishop316dfdd2018-06-25 12:45:53 -0400384 <replaceable>fetchuri</replaceable> and
385 extracted into the location defined by
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600386 <replaceable>srctree</replaceable> as a local
387 Git repository.</para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500388
Brad Bishop316dfdd2018-06-25 12:45:53 -0400389 <para>Within workspace,
390 <filename>devtool</filename> creates a
391 recipe named <replaceable>recipe</replaceable>
392 along with an associated append file.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600393 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400394 <listitem><para>
395 <emphasis>Right</emphasis>:
396 The right scenario in the figure represents a
397 situation where the
398 <replaceable>srctree</replaceable> has been
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600399 previously prepared outside of the
Brad Bishop316dfdd2018-06-25 12:45:53 -0400400 <filename>devtool</filename> workspace.</para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500401
Brad Bishop316dfdd2018-06-25 12:45:53 -0400402 <para>The following command provides a new
403 recipe name and identifies the existing source
404 tree location:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600405 <literallayout class='monospaced'>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500406 $ devtool add <replaceable>recipe srctree</replaceable>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600407 </literallayout>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400408 The command examines the source code and
409 creates a recipe named
410 <replaceable>recipe</replaceable> for the code
411 and places the recipe into the workspace.
412 </para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500413
Brad Bishop316dfdd2018-06-25 12:45:53 -0400414 <para>Because the extracted source code already
415 exists, <filename>devtool</filename> does not
416 try to relocate the source code into the
417 workspace - only the new recipe is placed
418 in the workspace.</para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500419
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600420 <para>Aside from a recipe folder, the command
Brad Bishop316dfdd2018-06-25 12:45:53 -0400421 also creates an associated append folder and
422 places an initial
423 <filename>*.bbappend</filename> file within.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600424 </para></listitem>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500425 </itemizedlist>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600426 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400427 <listitem><para>
428 <emphasis>Edit the Recipe</emphasis>:
429 You can use <filename>devtool edit-recipe</filename>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600430 to open up the editor as defined by the
431 <filename>$EDITOR</filename> environment variable
432 and modify the file:
433 <literallayout class='monospaced'>
434 $ devtool edit-recipe <replaceable>recipe</replaceable>
435 </literallayout>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400436 From within the editor, you can make modifications to
437 the recipe that take affect when you build it later.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600438 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400439 <listitem><para>
440 <emphasis>Build the Recipe or Rebuild the Image</emphasis>:
441 The next step you take depends on what you are going
442 to do with the new code.</para>
443
444 <para>If you need to eventually move the build output
445 to the target hardware, use the following
446 <filename>devtool</filename> command:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600447 <literallayout class='monospaced'>
448 $ devtool build <replaceable>recipe</replaceable>
449 </literallayout></para>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400450
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600451 <para>On the other hand, if you want an image to
Brad Bishop316dfdd2018-06-25 12:45:53 -0400452 contain the recipe's packages from the workspace
453 for immediate deployment onto a device (e.g. for
454 testing purposes), you can use
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600455 the <filename>devtool build-image</filename> command:
456 <literallayout class='monospaced'>
457 $ devtool build-image <replaceable>image</replaceable>
458 </literallayout>
459 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400460 <listitem><para>
461 <emphasis>Deploy the Build Output</emphasis>:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600462 When you use the <filename>devtool build</filename>
463 command to build out your recipe, you probably want to
Brad Bishop316dfdd2018-06-25 12:45:53 -0400464 see if the resulting build output works as expected
465 on the target hardware.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600466 <note>
467 This step assumes you have a previously built
468 image that is already either running in QEMU or
Brad Bishop316dfdd2018-06-25 12:45:53 -0400469 is running on actual hardware.
470 Also, it is assumed that for deployment of the
471 image to the target, SSH is installed in the image
472 and, if the image is running on real hardware,
473 you have network access to and from your
474 development machine.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600475 </note>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400476 You can deploy your build output to that target
477 hardware by using the
478 <filename>devtool deploy-target</filename> command:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600479 <literallayout class='monospaced'>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500480 $ devtool deploy-target <replaceable>recipe target</replaceable>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600481 </literallayout>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400482 The <replaceable>target</replaceable> is a live target
483 machine running as an SSH server.</para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500484
Brad Bishop316dfdd2018-06-25 12:45:53 -0400485 <para>You can, of course, also deploy the image you
486 build to actual hardware by using the
487 <filename>devtool build-image</filename> command.
488 However, <filename>devtool</filename> does not provide
489 a specific command that allows you to deploy the
490 image to actual hardware.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600491 </para></listitem>
492 <listitem><para>
493 <emphasis>Finish Your Work With the Recipe</emphasis>:
494 The <filename>devtool finish</filename> command creates
495 any patches corresponding to commits in the local
496 Git repository, moves the new recipe to a more permanent
497 layer, and then resets the recipe so that the recipe is
498 built normally rather than from the workspace.
499 <literallayout class='monospaced'>
500 $ devtool finish <replaceable>recipe layer</replaceable>
501 </literallayout>
502 <note>
503 Any changes you want to turn into patches must be
504 committed to the Git repository in the source tree.
505 </note></para>
506
Brad Bishop316dfdd2018-06-25 12:45:53 -0400507 <para>As mentioned, the
508 <filename>devtool finish</filename> command moves the
509 final recipe to its permanent layer.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600510 </para>
511
512 <para>As a final process of the
513 <filename>devtool finish</filename> command, the state
514 of the standard layers and the upstream source is
515 restored so that you can build the recipe from those
516 areas rather than the workspace.
517 <note>
518 You can use the <filename>devtool reset</filename>
519 command to put things back should you decide you
520 do not want to proceed with your work.
521 If you do use this command, realize that the source
522 tree is preserved.
523 </note>
524 </para></listitem>
525 </orderedlist>
526 </para>
527 </section>
528
529 <section id='sdk-devtool-use-devtool-modify-to-modify-the-source-of-an-existing-component'>
530 <title>Use <filename>devtool modify</filename> to Modify the Source of an Existing Component</title>
531
532 <para>
533 The <filename>devtool modify</filename> command prepares the
Brad Bishop316dfdd2018-06-25 12:45:53 -0400534 way to work on existing code that already has a local recipe in
535 place that is used to build the software.
536 The command is flexible enough to allow you to extract code
537 from an upstream source, specify the existing recipe, and
538 keep track of and gather any patch files from other developers
539 that are associated with the code.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600540 </para>
541
542 <para>
543 Depending on your particular scenario, the arguments and options
544 you use with <filename>devtool modify</filename> form different
545 combinations.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400546 The following diagram shows common development flows for the
547 <filename>devtool modify</filename> command:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600548 </para>
549
550 <para>
551 <imagedata fileref="figures/sdk-devtool-modify-flow.png" align="center" />
552 </para>
553
554 <para>
555 <orderedlist>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400556 <listitem><para>
557 <emphasis>Preparing to Modify the Code</emphasis>:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600558 The top part of the flow shows three scenarios by which
559 you could use <filename>devtool modify</filename> to
560 prepare to work on source files.
561 Each scenario assumes the following:
562 <itemizedlist>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400563 <listitem><para>
564 The recipe exists locally in a layer external
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600565 to the <filename>devtool</filename> workspace.
566 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400567 <listitem><para>
568 The source files exist either upstream in an
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600569 un-extracted state or locally in a previously
570 extracted state.
571 </para></listitem>
572 </itemizedlist>
573 The typical situation is where another developer has
Brad Bishop316dfdd2018-06-25 12:45:53 -0400574 created a layer for use with the Yocto Project and
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600575 their recipe already resides in that layer.
576 Furthermore, their source code is readily available
577 either upstream or locally.
578 <itemizedlist>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400579 <listitem><para>
580 <emphasis>Left</emphasis>:
581 The left scenario in the figure represents a
582 common situation where the source code does
583 not exist locally and it needs to be extracted
584 from an upstream source.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600585 In this situation, the source is extracted
Brad Bishop316dfdd2018-06-25 12:45:53 -0400586 into the default <filename>devtool</filename>
587 workspace location.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600588 The recipe, in this scenario, is in its own
589 layer outside the workspace
590 (i.e.
591 <filename>meta-</filename><replaceable>layername</replaceable>).
592 </para>
593
Brad Bishop316dfdd2018-06-25 12:45:53 -0400594 <para>The following command identifies the
595 recipe and, by default, extracts the source
596 files:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600597 <literallayout class='monospaced'>
598 $ devtool modify <replaceable>recipe</replaceable>
599 </literallayout>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400600 Once <filename>devtool</filename>locates the
601 recipe, <filename>devtool</filename> uses the
602 recipe's
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600603 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400604 statements to locate the source code and any
605 local patch files from other developers.</para>
606
607 <para>With this scenario, no
608 <replaceable>srctree</replaceable> argument
609 exists.
610 Consequently, the default behavior of the
611 <filename>devtool modify</filename> command is
612 to extract the source files pointed to by the
613 <filename>SRC_URI</filename> statements into a
614 local Git structure.
615 Furthermore, the location for the extracted
616 source is the default area within the
617 <filename>devtool</filename> workspace.
618 The result is that the command sets up both
619 the source code and an append file within the
620 workspace while the recipe remains in its
621 original location.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600622 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400623 <listitem><para>
624 <emphasis>Middle</emphasis>:
625 The middle scenario in the figure represents a
626 situation where the source code also does not
627 exist locally.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600628 In this case, the code is again upstream
629 and needs to be extracted to some
630 local area as a Git repository.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400631 The recipe, in this scenario, is again local
632 and in its own layer outside the workspace.
633 </para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600634
635 <para>The following command tells
636 <filename>devtool</filename> what recipe with
Brad Bishop316dfdd2018-06-25 12:45:53 -0400637 which to work and, in this case, identifies a
638 local area for the extracted source files that
639 is outside of the default
640 <filename>devtool</filename> workspace:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600641 <literallayout class='monospaced'>
642 $ devtool modify <replaceable>recipe srctree</replaceable>
643 </literallayout>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400644 <note>
645 You cannot provide a URL for
646 <replaceable>srctree</replaceable> using
647 the <filename>devtool</filename> command.
648 </note>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600649 As with all extractions, the command uses
Brad Bishop316dfdd2018-06-25 12:45:53 -0400650 the recipe's <filename>SRC_URI</filename>
651 statements to locate the source files and any
652 associated patch files.
653 Once the files are located, the command by
654 default extracts them into
655 <replaceable>srctree</replaceable>.</para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600656
Brad Bishop316dfdd2018-06-25 12:45:53 -0400657 <para>Within workspace,
658 <filename>devtool</filename> creates an append
659 file for the recipe.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600660 The recipe remains in its original location but
Brad Bishop316dfdd2018-06-25 12:45:53 -0400661 the source files are extracted to the location
662 you provide with
663 <replaceable>srctree</replaceable>.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600664 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400665 <listitem><para>
666 <emphasis>Right</emphasis>:
667 The right scenario in the figure represents a
668 situation where the source tree
669 (<replaceable>srctree</replaceable>) already
670 exists locally as a previously extracted Git
671 structure outside of the
672 <filename>devtool</filename> workspace.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600673 In this example, the recipe also exists
Brad Bishop316dfdd2018-06-25 12:45:53 -0400674 elsewhere locally in its own layer.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600675 </para>
676
677 <para>The following command tells
678 <filename>devtool</filename> the recipe
Brad Bishop316dfdd2018-06-25 12:45:53 -0400679 with which to work, uses the "-n" option to
680 indicate source does not need to be extracted,
681 and uses <replaceable>srctree</replaceable> to
682 point to the previously extracted source files:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600683 <literallayout class='monospaced'>
684 $ devtool modify -n <replaceable>recipe srctree</replaceable>
685 </literallayout>
686 </para>
687
688 <para>Once the command finishes, it creates only
Brad Bishop316dfdd2018-06-25 12:45:53 -0400689 an append file for the recipe in the
690 <filename>devtool</filename> workspace.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600691 The recipe and the source code remain in their
692 original locations.
693 </para></listitem>
694 </itemizedlist>
695 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400696 <listitem><para>
697 <emphasis>Edit the Source</emphasis>:
698 Once you have used the
699 <filename>devtool modify</filename> command, you are
700 free to make changes to the source files.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600701 You can use any editor you like to make and save
702 your source code modifications.
703 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400704 <listitem><para>
705 <emphasis>Build the Recipe or Rebuild the Image</emphasis>:
706 The next step you take depends on what you are going
707 to do with the new code.</para>
708
709 <para>If you need to eventually move the build output
710 to the target hardware, use the following
711 <filename>devtool</filename> command:
712 <literallayout class='monospaced'>
713 $ devtool build <replaceable>recipe</replaceable>
714 </literallayout></para>
715
716 <para>On the other hand, if you want an image to
717 contain the recipe's packages from the workspace
718 for immediate deployment onto a device (e.g. for
719 testing purposes), you can use
720 the <filename>devtool build-image</filename> command:
721 <literallayout class='monospaced'>
722 $ devtool build-image <replaceable>image</replaceable>
723 </literallayout>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600724 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400725 <listitem><para>
726 <emphasis>Deploy the Build Output</emphasis>:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600727 When you use the <filename>devtool build</filename>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400728 command to build out your recipe, you probably want to
729 see if the resulting build output works as expected
730 on target hardware.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600731 <note>
732 This step assumes you have a previously built
733 image that is already either running in QEMU or
734 running on actual hardware.
735 Also, it is assumed that for deployment of the image
736 to the target, SSH is installed in the image and if
737 the image is running on real hardware that you have
738 network access to and from your development machine.
739 </note>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400740 You can deploy your build output to that target
741 hardware by using the
742 <filename>devtool deploy-target</filename> command:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600743 <literallayout class='monospaced'>
744 $ devtool deploy-target <replaceable>recipe target</replaceable>
745 </literallayout>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400746 The <replaceable>target</replaceable> is a live target
747 machine running as an SSH server.</para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600748
Brad Bishop316dfdd2018-06-25 12:45:53 -0400749 <para>You can, of course, use other methods to deploy
750 the image you built using the
751 <filename>devtool build-image</filename> command to
752 actual hardware.
753 <filename>devtool</filename> does not provide
754 a specific command to deploy the image to actual
755 hardware.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600756 </para></listitem>
757 <listitem><para>
758 <emphasis>Finish Your Work With the Recipe</emphasis>:
759 The <filename>devtool finish</filename> command creates
760 any patches corresponding to commits in the local
761 Git repository, updates the recipe to point to them
762 (or creates a <filename>.bbappend</filename> file to do
763 so, depending on the specified destination layer), and
Brad Bishop316dfdd2018-06-25 12:45:53 -0400764 then resets the recipe so that the recipe is built
765 normally rather than from the workspace.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600766 <literallayout class='monospaced'>
767 $ devtool finish <replaceable>recipe layer</replaceable>
768 </literallayout>
769 <note>
770 Any changes you want to turn into patches must be
Brad Bishop316dfdd2018-06-25 12:45:53 -0400771 staged and committed within the local Git
772 repository before you use the
773 <filename>devtool finish</filename> command.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600774 </note></para>
775
776 <para>Because there is no need to move the recipe,
777 <filename>devtool finish</filename> either updates the
778 original recipe in the original layer or the command
Brad Bishop316dfdd2018-06-25 12:45:53 -0400779 creates a <filename>.bbappend</filename> file in a
780 different layer as provided by
781 <replaceable>layer</replaceable>.</para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600782
783 <para>As a final process of the
784 <filename>devtool finish</filename> command, the state
785 of the standard layers and the upstream source is
786 restored so that you can build the recipe from those
Brad Bishop316dfdd2018-06-25 12:45:53 -0400787 areas rather than from the workspace.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600788 <note>
789 You can use the <filename>devtool reset</filename>
790 command to put things back should you decide you
791 do not want to proceed with your work.
792 If you do use this command, realize that the source
793 tree is preserved.
794 </note>
795 </para></listitem>
796 </orderedlist>
797 </para>
798 </section>
799
800 <section id='sdk-devtool-use-devtool-upgrade-to-create-a-version-of-the-recipe-that-supports-a-newer-version-of-the-software'>
801 <title>Use <filename>devtool upgrade</filename> to Create a Version of the Recipe that Supports a Newer Version of the Software</title>
802
803 <para>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400804 The <filename>devtool upgrade</filename> command upgrades
805 an existing recipe to that of a more up-to-date version
806 found upstream.
807 Throughout the life of software, recipes continually undergo
808 version upgrades by their upstream publishers.
809 You can use the <filename>devtool upgrade</filename>
810 workflow to make sure your recipes you are using for builds
811 are up-to-date with their upstream counterparts.
812 <note>
813 Several methods exist by which you can upgrade recipes -
814 <filename>devtool upgrade</filename> happens to be one.
815 You can read about all the methods by which you can
816 upgrade recipes in the
817 "<ulink url='&YOCTO_DOCS_DEV_URL;#gs-upgrading-recipes'>Upgrading Recipes</ulink>"
818 section of the Yocto Project Development Tasks Manual.
819 </note>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600820 </para>
821
822 <para>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400823 The <filename>devtool upgrade</filename> command is flexible
824 enough to allow you to specify source code revision and
825 versioning schemes, extract code into or out of the
826 <filename>devtool</filename>
827 <ulink url='&YOCTO_DOCS_REF_URL;#devtool-the-workspace-layer-structure'>workspace</ulink>,
Brad Bishop15ae2502019-06-18 21:44:24 -0400828 and work with any source file forms that the
829 <ulink url='&YOCTO_DOCS_BB_URL;#bb-fetchers'>fetchers</ulink>
830 support.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400831 </para>
832
833 <para>
834 The following diagram shows the common development flow
835 used with the <filename>devtool upgrade</filename> command:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600836 </para>
837
838 <para>
839 <imagedata fileref="figures/sdk-devtool-upgrade-flow.png" align="center" />
840 </para>
841
842 <para>
843 <orderedlist>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400844 <listitem><para>
845 <emphasis>Initiate the Upgrade</emphasis>:
846 The top part of the flow shows the typical scenario by
847 which you use the <filename>devtool upgrade</filename>
848 command.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600849 The following conditions exist:
850 <itemizedlist>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400851 <listitem><para>
852 The recipe exists in a local layer external
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600853 to the <filename>devtool</filename> workspace.
854 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400855 <listitem><para>
856 The source files for the new release
857 exist in the same location pointed to by
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600858 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400859 in the recipe (e.g. a tarball with the new
860 version number in the name, or as a different
861 revision in the upstream Git repository).
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600862 </para></listitem>
863 </itemizedlist>
864 A common situation is where third-party software has
865 undergone a revision so that it has been upgraded.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400866 The recipe you have access to is likely in your own
867 layer.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600868 Thus, you need to upgrade the recipe to use the
869 newer version of the software:
870 <literallayout class='monospaced'>
871 $ devtool upgrade -V <replaceable>version recipe</replaceable>
872 </literallayout>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400873 By default, the <filename>devtool upgrade</filename>
874 command extracts source code into the
875 <filename>sources</filename> directory in the
876 <ulink url='&YOCTO_DOCS_REF_URL;#devtool-the-workspace-layer-structure'>workspace</ulink>.
877 If you want the code extracted to any other location,
878 you need to provide the
879 <replaceable>srctree</replaceable> positional argument
880 with the command as follows:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600881 <literallayout class='monospaced'>
882 $ devtool upgrade -V <replaceable>version recipe srctree</replaceable>
883 </literallayout>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400884 <note>
885 In this example, the "-V" option specifies the new
886 version.
887 If you don't use "-V", the command upgrades the
888 recipe to the latest version.
889 </note>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600890 If the source files pointed to by the
Brad Bishop316dfdd2018-06-25 12:45:53 -0400891 <filename>SRC_URI</filename> statement in the recipe
892 are in a Git repository, you must provide the "-S"
893 option and specify a revision for the software.</para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600894
Brad Bishop316dfdd2018-06-25 12:45:53 -0400895 <para>Once <filename>devtool</filename> locates the
896 recipe, it uses the <filename>SRC_URI</filename>
897 variable to locate the source code and any local patch
898 files from other developers.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600899 The result is that the command sets up the source
900 code, the new version of the recipe, and an append file
901 all within the workspace.
902 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400903 <listitem><para>
904 <emphasis>Resolve any Conflicts created by the Upgrade</emphasis>:
905 Conflicts could exist due to the software being
906 upgraded to a new version.
907 Conflicts occur if your recipe specifies some patch
908 files in <filename>SRC_URI</filename> that conflict
909 with changes made in the new version of the software.
910 For such cases, you need to resolve the conflicts
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600911 by editing the source and following the normal
912 <filename>git rebase</filename> conflict resolution
913 process.</para>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400914
915 <para>Before moving onto the next step, be sure to
916 resolve any such conflicts created through use of a
917 newer or different version of the software.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600918 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400919 <listitem><para>
920 <emphasis>Build the Recipe or Rebuild the Image</emphasis>:
921 The next step you take depends on what you are going
922 to do with the new code.</para>
923
924 <para>If you need to eventually move the build output
925 to the target hardware, use the following
926 <filename>devtool</filename> command:
927 <literallayout class='monospaced'>
928 $ devtool build <replaceable>recipe</replaceable>
929 </literallayout></para>
930
931 <para>On the other hand, if you want an image to
932 contain the recipe's packages from the workspace
933 for immediate deployment onto a device (e.g. for
934 testing purposes), you can use
935 the <filename>devtool build-image</filename> command:
936 <literallayout class='monospaced'>
937 $ devtool build-image <replaceable>image</replaceable>
938 </literallayout>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600939 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400940 <listitem><para>
941 <emphasis>Deploy the Build Output</emphasis>:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600942 When you use the <filename>devtool build</filename>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400943 command or <filename>bitbake</filename> to build
944 your recipe, you probably want to see if the resulting
945 build output works as expected on target hardware.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600946 <note>
947 This step assumes you have a previously built
948 image that is already either running in QEMU or
949 running on actual hardware.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400950 Also, it is assumed that for deployment of the
951 image to the target, SSH is installed in the image
952 and if the image is running on real hardware that
953 you have network access to and from your
954 development machine.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600955 </note>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400956 You can deploy your build output to that target
957 hardware by using the
958 <filename>devtool deploy-target</filename> command:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600959 <literallayout class='monospaced'>
960 $ devtool deploy-target <replaceable>recipe target</replaceable>
961 </literallayout>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400962 The <replaceable>target</replaceable> is a live target
963 machine running as an SSH server.</para>
964
965 <para>You can, of course, also deploy the image you
966 build using the
967 <filename>devtool build-image</filename> command
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600968 to actual hardware.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400969 However, <filename>devtool</filename> does not provide
970 a specific command that allows you to do this.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600971 </para></listitem>
972 <listitem><para>
973 <emphasis>Finish Your Work With the Recipe</emphasis>:
974 The <filename>devtool finish</filename> command creates
975 any patches corresponding to commits in the local
Brad Bishop316dfdd2018-06-25 12:45:53 -0400976 Git repository, moves the new recipe to a more
977 permanent layer, and then resets the recipe so that
978 the recipe is built normally rather than from the
979 workspace.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600980 If you specify a destination layer that is the same as
981 the original source, then the old version of the
982 recipe and associated files will be removed prior to
983 adding the new version.
984 <literallayout class='monospaced'>
985 $ devtool finish <replaceable>recipe layer</replaceable>
986 </literallayout>
987 <note>
988 Any changes you want to turn into patches must be
989 committed to the Git repository in the source tree.
990 </note></para>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400991
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600992 <para>As a final process of the
993 <filename>devtool finish</filename> command, the state
994 of the standard layers and the upstream source is
995 restored so that you can build the recipe from those
996 areas rather than the workspace.
997 <note>
998 You can use the <filename>devtool reset</filename>
999 command to put things back should you decide you
1000 do not want to proceed with your work.
1001 If you do use this command, realize that the source
1002 tree is preserved.
1003 </note>
1004 </para></listitem>
1005 </orderedlist>
1006 </para>
1007 </section>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001008 </section>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001009
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001010 <section id='sdk-a-closer-look-at-devtool-add'>
1011 <title>A Closer Look at <filename>devtool add</filename></title>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001012
1013 <para>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001014 The <filename>devtool add</filename> command automatically creates
1015 a recipe based on the source tree you provide with the command.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001016 Currently, the command has support for the following:
1017 <itemizedlist>
1018 <listitem><para>
1019 Autotools (<filename>autoconf</filename> and
1020 <filename>automake</filename>)
1021 </para></listitem>
1022 <listitem><para>
1023 CMake
1024 </para></listitem>
1025 <listitem><para>
1026 Scons
1027 </para></listitem>
1028 <listitem><para>
1029 <filename>qmake</filename>
1030 </para></listitem>
1031 <listitem><para>
1032 Plain <filename>Makefile</filename>
1033 </para></listitem>
1034 <listitem><para>
1035 Out-of-tree kernel module
1036 </para></listitem>
1037 <listitem><para>
1038 Binary package (i.e. "-b" option)
1039 </para></listitem>
1040 <listitem><para>
1041 Node.js module
1042 </para></listitem>
1043 <listitem><para>
1044 Python modules that use <filename>setuptools</filename>
1045 or <filename>distutils</filename>
1046 </para></listitem>
1047 </itemizedlist>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001048 </para>
1049
1050 <para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001051 Apart from binary packages, the determination of how a source tree
1052 should be treated is automatic based on the files present within
1053 that source tree.
1054 For example, if a <filename>CMakeLists.txt</filename> file is found,
1055 then the source tree is assumed to be using
1056 CMake and is treated accordingly.
1057 <note>
1058 In most cases, you need to edit the automatically generated
1059 recipe in order to make it build properly.
1060 Typically, you would go through several edit and build cycles
Brad Bishop316dfdd2018-06-25 12:45:53 -04001061 until the recipe successfully builds.
1062 Once the recipe builds, you could use possible further
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001063 iterations to test the recipe on the target device.
1064 </note>
1065 </para>
1066
1067 <para>
1068 The remainder of this section covers specifics regarding how parts
1069 of the recipe are generated.
1070 </para>
1071
1072 <section id='sdk-name-and-version'>
1073 <title>Name and Version</title>
1074
1075 <para>
1076 If you do not specify a name and version on the command
Brad Bishop316dfdd2018-06-25 12:45:53 -04001077 line, <filename>devtool add</filename> uses various metadata
1078 within the source tree in an attempt to determine
1079 the name and version of the software being built.
1080 Based on what the tool determines, <filename>devtool</filename>
1081 sets the name of the created recipe file accordingly.
1082 </para>
1083
1084 <para>
1085 If <filename>devtool</filename> cannot determine the name and
1086 version, the command prints an error.
1087 For such cases, you must re-run the command and provide
1088 the name and version, just the name, or just the version as
1089 part of the command line.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001090 </para>
1091
1092 <para>
1093 Sometimes the name or version determined from the source tree
1094 might be incorrect.
1095 For such a case, you must reset the recipe:
1096 <literallayout class='monospaced'>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001097 $ devtool reset -n <replaceable>recipename</replaceable>
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001098 </literallayout>
1099 After running the <filename>devtool reset</filename> command,
1100 you need to run <filename>devtool add</filename> again and
1101 provide the name or the version.
1102 </para>
1103 </section>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001104
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001105 <section id='sdk-dependency-detection-and-mapping'>
1106 <title>Dependency Detection and Mapping</title>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001107
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001108 <para>
1109 The <filename>devtool add</filename> command attempts to
1110 detect build-time dependencies and map them to other recipes
1111 in the system.
1112 During this mapping, the command fills in the names of those
Brad Bishop316dfdd2018-06-25 12:45:53 -04001113 recipes as part of the
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001114 <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001115 variable within the recipe.
1116 If a dependency cannot be mapped, <filename>devtool</filename>
1117 places a comment in the recipe indicating such.
1118 The inability to map a dependency can result from naming not
1119 being recognized or because the dependency simply is not
1120 available.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001121 For cases where the dependency is not available, you must use
1122 the <filename>devtool add</filename> command to add an
Brad Bishop316dfdd2018-06-25 12:45:53 -04001123 additional recipe that satisfies the dependency.
1124 Once you add that recipe, you need to update the
1125 <filename>DEPENDS</filename> variable in the original recipe
1126 to include the new recipe.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001127 </para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001128
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001129 <para>
1130 If you need to add runtime dependencies, you can do so by
1131 adding the following to your recipe:
1132 <literallayout class='monospaced'>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001133 RDEPENDS_${PN} += "<replaceable>dependency1 dependency2 ...</replaceable>"
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001134 </literallayout>
1135 <note>
1136 The <filename>devtool add</filename> command often cannot
1137 distinguish between mandatory and optional dependencies.
1138 Consequently, some of the detected dependencies might
1139 in fact be optional.
1140 When in doubt, consult the documentation or the configure
1141 script for the software the recipe is building for further
1142 details.
1143 In some cases, you might find you can substitute the
Brad Bishop316dfdd2018-06-25 12:45:53 -04001144 dependency with an option that disables the associated
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001145 functionality passed to the configure script.
1146 </note>
1147 </para>
1148 </section>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001149
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001150 <section id='sdk-license-detection'>
1151 <title>License Detection</title>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001152
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001153 <para>
1154 The <filename>devtool add</filename> command attempts to
1155 determine if the software you are adding is able to be
Brad Bishop316dfdd2018-06-25 12:45:53 -04001156 distributed under a common, open-source license.
1157 If so, the command sets the
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001158 <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink>
1159 value accordingly.
Brad Bishop316dfdd2018-06-25 12:45:53 -04001160 You should double-check the value added by the command against
1161 the documentation or source files for the software you are
1162 building and, if necessary, update that
1163 <filename>LICENSE</filename> value.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001164 </para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001165
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001166 <para>
1167 The <filename>devtool add</filename> command also sets the
1168 <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink>
1169 value to point to all files that appear to be license-related.
Brad Bishop316dfdd2018-06-25 12:45:53 -04001170 Realize that license statements often appear in comments at
1171 the top of source files or within the documentation.
1172 In such cases, the command does not recognize those license
1173 statements.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001174 Consequently, you might need to amend the
1175 <filename>LIC_FILES_CHKSUM</filename> variable to point to one
1176 or more of those comments if present.
1177 Setting <filename>LIC_FILES_CHKSUM</filename> is particularly
1178 important for third-party software.
1179 The mechanism attempts to ensure correct licensing should you
1180 upgrade the recipe to a newer upstream version in future.
1181 Any change in licensing is detected and you receive an error
1182 prompting you to check the license text again.
1183 </para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001184
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001185 <para>
1186 If the <filename>devtool add</filename> command cannot
Brad Bishop316dfdd2018-06-25 12:45:53 -04001187 determine licensing information, <filename>devtool</filename>
1188 sets the <filename>LICENSE</filename> value to "CLOSED" and
1189 leaves the <filename>LIC_FILES_CHKSUM</filename> value unset.
1190 This behavior allows you to continue with development even
1191 though the settings are unlikely to be correct in all cases.
1192 You should check the documentation or source files for the
1193 software you are building to determine the actual license.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001194 </para>
1195 </section>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001196
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001197 <section id='sdk-adding-makefile-only-software'>
1198 <title>Adding Makefile-Only Software</title>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001199
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001200 <para>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001201 The use of Make by itself is very common in both proprietary
1202 and open-source software.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001203 Unfortunately, Makefiles are often not written with
1204 cross-compilation in mind.
1205 Thus, <filename>devtool add</filename> often cannot do very
1206 much to ensure that these Makefiles build correctly.
1207 It is very common, for example, to explicitly call
1208 <filename>gcc</filename> instead of using the
1209 <ulink url='&YOCTO_DOCS_REF_URL;#var-CC'><filename>CC</filename></ulink>
1210 variable.
1211 Usually, in a cross-compilation environment,
1212 <filename>gcc</filename> is the compiler for the build host
1213 and the cross-compiler is named something similar to
1214 <filename>arm-poky-linux-gnueabi-gcc</filename> and might
Brad Bishop316dfdd2018-06-25 12:45:53 -04001215 require arguments (e.g. to point to the associated sysroot
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001216 for the target machine).
1217 </para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001218
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001219 <para>
1220 When writing a recipe for Makefile-only software, keep the
1221 following in mind:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001222 <itemizedlist>
1223 <listitem><para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001224 You probably need to patch the Makefile to use
1225 variables instead of hardcoding tools within the
1226 toolchain such as <filename>gcc</filename> and
1227 <filename>g++</filename>.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001228 </para></listitem>
1229 <listitem><para>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001230 The environment in which Make runs is set up with
1231 various standard variables for compilation (e.g.
1232 <filename>CC</filename>, <filename>CXX</filename>, and
1233 so forth) in a similar manner to the environment set
1234 up by the SDK's environment setup script.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001235 One easy way to see these variables is to run the
1236 <filename>devtool build</filename> command on the
1237 recipe and then look in
1238 <filename>oe-logs/run.do_compile</filename>.
Brad Bishop316dfdd2018-06-25 12:45:53 -04001239 Towards the top of this file, a list of environment
1240 variables exists that are being set.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001241 You can take advantage of these variables within the
1242 Makefile.
1243 </para></listitem>
1244 <listitem><para>
1245 If the Makefile sets a default for a variable using "=",
1246 that default overrides the value set in the environment,
1247 which is usually not desirable.
Brad Bishop316dfdd2018-06-25 12:45:53 -04001248 For this case, you can either patch the Makefile
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001249 so it sets the default using the "?=" operator, or
1250 you can alternatively force the value on the
1251 <filename>make</filename> command line.
1252 To force the value on the command line, add the
1253 variable setting to
1254 <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OEMAKE'><filename>EXTRA_OEMAKE</filename></ulink>
1255 or
1256 <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink>
1257 within the recipe.
1258 Here is an example using <filename>EXTRA_OEMAKE</filename>:
1259 <literallayout class='monospaced'>
1260 EXTRA_OEMAKE += "'CC=${CC}' 'CXX=${CXX}'"
1261 </literallayout>
1262 In the above example, single quotes are used around the
1263 variable settings as the values are likely to contain
1264 spaces because required default options are passed to
1265 the compiler.
1266 </para></listitem>
1267 <listitem><para>
1268 Hardcoding paths inside Makefiles is often problematic
1269 in a cross-compilation environment.
1270 This is particularly true because those hardcoded paths
1271 often point to locations on the build host and thus
1272 will either be read-only or will introduce
Brad Bishop316dfdd2018-06-25 12:45:53 -04001273 contamination into the cross-compilation because they
1274 are specific to the build host rather than the target.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001275 Patching the Makefile to use prefix variables or other
Brad Bishop316dfdd2018-06-25 12:45:53 -04001276 path variables is usually the way to handle this
1277 situation.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001278 </para></listitem>
1279 <listitem><para>
1280 Sometimes a Makefile runs target-specific commands such
1281 as <filename>ldconfig</filename>.
Brad Bishop316dfdd2018-06-25 12:45:53 -04001282 For such cases, you might be able to apply patches that
1283 remove these commands from the Makefile.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001284 </para></listitem>
1285 </itemizedlist>
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001286 </para>
1287 </section>
1288
1289 <section id='sdk-adding-native-tools'>
1290 <title>Adding Native Tools</title>
1291
1292 <para>
1293 Often, you need to build additional tools that run on the
Brad Bishop316dfdd2018-06-25 12:45:53 -04001294 <ulink url='&YOCTO_DOCS_REF_URL;#hardware-build-system-term'>build host</ulink>
1295 as opposed to the target.
1296 You should indicate this requirement by using one of the
1297 following methods when you run
1298 <filename>devtool add</filename>:
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001299 <itemizedlist>
1300 <listitem><para>
1301 Specify the name of the recipe such that it ends
1302 with "-native".
1303 Specifying the name like this produces a recipe that
1304 only builds for the build host.
1305 </para></listitem>
1306 <listitem><para>
1307 Specify the "&dash;&dash;also-native" option with the
1308 <filename>devtool add</filename> command.
1309 Specifying this option creates a recipe file that still
1310 builds for the target but also creates a variant with
1311 a "-native" suffix that builds for the build host.
1312 </para></listitem>
1313 </itemizedlist>
1314 <note>
1315 If you need to add a tool that is shipped as part of a
1316 source tree that builds code for the target, you can
1317 typically accomplish this by building the native and target
1318 parts separately rather than within the same compilation
1319 process.
Brad Bishop316dfdd2018-06-25 12:45:53 -04001320 Realize though that with the "&dash;&dash;also-native"
1321 option, you can add the tool using just one recipe file.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001322 </note>
1323 </para>
1324 </section>
1325
1326 <section id='sdk-adding-node-js-modules'>
1327 <title>Adding Node.js Modules</title>
1328
1329 <para>
1330 You can use the <filename>devtool add</filename> command two
1331 different ways to add Node.js modules: 1) Through
1332 <filename>npm</filename> and, 2) from a repository or local
1333 source.
1334 </para>
1335
1336 <para>
1337 Use the following form to add Node.js modules through
1338 <filename>npm</filename>:
1339 <literallayout class='monospaced'>
1340 $ devtool add "npm://registry.npmjs.org;name=forever;version=0.15.1"
1341 </literallayout>
1342 The name and version parameters are mandatory.
1343 Lockdown and shrinkwrap files are generated and pointed to by
1344 the recipe in order to freeze the version that is fetched for
1345 the dependencies according to the first time.
1346 This also saves checksums that are verified on future fetches.
1347 Together, these behaviors ensure the reproducibility and
1348 integrity of the build.
1349 <note><title>Notes</title>
1350 <itemizedlist>
1351 <listitem><para>
1352 You must use quotes around the URL.
1353 The <filename>devtool add</filename> does not require
1354 the quotes, but the shell considers ";" as a splitter
1355 between multiple commands.
1356 Thus, without the quotes,
1357 <filename>devtool add</filename> does not receive the
1358 other parts, which results in several "command not
1359 found" errors.
1360 </para></listitem>
1361 <listitem><para>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001362 In order to support adding Node.js modules, a
1363 <filename>nodejs</filename> recipe must be part
1364 of your SDK.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001365 </para></listitem>
1366 </itemizedlist>
1367 </note>
1368 </para>
1369
1370 <para>
1371 As mentioned earlier, you can also add Node.js modules
1372 directly from a repository or local source tree.
Brad Bishop316dfdd2018-06-25 12:45:53 -04001373 To add modules this way, use <filename>devtool add</filename>
1374 in the following form:
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001375 <literallayout class='monospaced'>
1376 $ devtool add https://github.com/diversario/node-ssdp
1377 </literallayout>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001378 In this example, <filename>devtool</filename> fetches the
1379 specified Git repository, detects the code as Node.js
1380 code, fetches dependencies using <filename>npm</filename>, and
1381 sets
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001382 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
1383 accordingly.
1384 </para>
1385 </section>
1386 </section>
1387
1388 <section id='sdk-working-with-recipes'>
1389 <title>Working With Recipes</title>
1390
1391 <para>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001392 When building a recipe using the
1393 <filename>devtool build</filename> command, the typical build
1394 progresses as follows:
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001395 <orderedlist>
1396 <listitem><para>
1397 Fetch the source
1398 </para></listitem>
1399 <listitem><para>
1400 Unpack the source
1401 </para></listitem>
1402 <listitem><para>
1403 Configure the source
1404 </para></listitem>
1405 <listitem><para>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001406 Compile the source
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001407 </para></listitem>
1408 <listitem><para>
1409 Install the build output
1410 </para></listitem>
1411 <listitem><para>
1412 Package the installed output
1413 </para></listitem>
1414 </orderedlist>
1415 For recipes in the workspace, fetching and unpacking is disabled
1416 as the source tree has already been prepared and is persistent.
Brad Bishop316dfdd2018-06-25 12:45:53 -04001417 Each of these build steps is defined as a function (task), usually
1418 with a "do_" prefix (e.g.
1419 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>,
1420 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>,
1421 and so forth).
1422 These functions are typically shell scripts but can instead be
1423 written in Python.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001424 </para>
1425
1426 <para>
1427 If you look at the contents of a recipe, you will see that the
1428 recipe does not include complete instructions for building the
1429 software.
1430 Instead, common functionality is encapsulated in classes inherited
Brad Bishop316dfdd2018-06-25 12:45:53 -04001431 with the <filename>inherit</filename> directive.
1432 This technique leaves the recipe to describe just the things that
1433 are specific to the software being built.
1434 A
1435 <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-base'><filename>base</filename></ulink>
1436 class exists that is implicitly inherited by all recipes and
1437 provides the functionality that most recipes typically need.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001438 </para>
1439
1440 <para>
1441 The remainder of this section presents information useful when
1442 working with recipes.
1443 </para>
1444
1445 <section id='sdk-finding-logs-and-work-files'>
1446 <title>Finding Logs and Work Files</title>
1447
1448 <para>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001449 After the first run of the <filename>devtool build</filename>
1450 command, recipes that were previously created using the
1451 <filename>devtool add</filename> command or whose sources were
1452 modified using the <filename>devtool modify</filename>
1453 command contain symbolic links created within the source tree:
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001454 <itemizedlist>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001455 <listitem><para>
1456 <filename>oe-logs</filename>:
1457 This link points to the directory in which log files
1458 and run scripts for each build step are created.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001459 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001460 <listitem><para>
1461 <filename>oe-workdir</filename>:
1462 This link points to the temporary work area for the
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001463 recipe.
Brad Bishop316dfdd2018-06-25 12:45:53 -04001464 The following locations under
1465 <filename>oe-workdir</filename> are particularly
1466 useful:
1467 <itemizedlist>
1468 <listitem><para>
1469 <filename>image/</filename>:
1470 Contains all of the files installed during
1471 the
1472 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
1473 stage.
1474 Within a recipe, this directory is referred
1475 to by the expression
1476 <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>.
1477 </para></listitem>
1478 <listitem><para>
1479 <filename>sysroot-destdir/</filename>:
1480 Contains a subset of files installed within
1481 <filename>do_install</filename> that have
1482 been put into the shared sysroot.
1483 For more information, see the
1484 "<link linkend='sdk-sharing-files-between-recipes'>Sharing Files Between Recipes</link>"
1485 section.
1486 </para></listitem>
1487 <listitem><para>
1488 <filename>packages-split/</filename>:
1489 Contains subdirectories for each package
1490 produced by the recipe.
1491 For more information, see the
1492 "<link linkend='sdk-packaging'>Packaging</link>"
1493 section.
1494 </para></listitem>
1495 </itemizedlist>
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001496 </para></listitem>
1497 </itemizedlist>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001498 You can use these links to get more information on what is
1499 happening at each build step.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001500 </para>
1501 </section>
1502
1503 <section id='sdk-setting-configure-arguments'>
1504 <title>Setting Configure Arguments</title>
1505
1506 <para>
1507 If the software your recipe is building uses GNU autoconf,
1508 then a fixed set of arguments is passed to it to enable
1509 cross-compilation plus any extras specified by
1510 <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECONF'><filename>EXTRA_OECONF</filename></ulink>
1511 or
1512 <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink>
1513 set within the recipe.
1514 If you wish to pass additional options, add them to
1515 <filename>EXTRA_OECONF</filename> or
1516 <filename>PACKAGECONFIG_CONFARGS</filename>.
1517 Other supported build tools have similar variables
1518 (e.g.
1519 <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECMAKE'><filename>EXTRA_OECMAKE</filename></ulink>
1520 for CMake,
1521 <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OESCONS'><filename>EXTRA_OESCONS</filename></ulink>
1522 for Scons, and so forth).
1523 If you need to pass anything on the <filename>make</filename>
1524 command line, you can use <filename>EXTRA_OEMAKE</filename> or the
1525 <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink>
1526 variables to do so.
1527 </para>
1528
1529 <para>
1530 You can use the <filename>devtool configure-help</filename> command
1531 to help you set the arguments listed in the previous paragraph.
1532 The command determines the exact options being passed, and shows
1533 them to you along with any custom arguments specified through
1534 <filename>EXTRA_OECONF</filename> or
1535 <filename>PACKAGECONFIG_CONFARGS</filename>.
1536 If applicable, the command also shows you the output of the
1537 configure script's "&dash;&dash;help" option as a reference.
1538 </para>
1539 </section>
1540
1541 <section id='sdk-sharing-files-between-recipes'>
1542 <title>Sharing Files Between Recipes</title>
1543
1544 <para>
1545 Recipes often need to use files provided by other recipes on
Brad Bishop316dfdd2018-06-25 12:45:53 -04001546 the
1547 <ulink url='&YOCTO_DOCS_REF_URL;#hardware-build-system-term'>build host</ulink>.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001548 For example, an application linking to a common library needs
1549 access to the library itself and its associated headers.
1550 The way this access is accomplished within the extensible SDK is
1551 through the sysroot.
Brad Bishop316dfdd2018-06-25 12:45:53 -04001552 One sysroot exists per "machine" for which the SDK is being
1553 built.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001554 In practical terms, this means a sysroot exists for the target
1555 machine, and a sysroot exists for the build host.
1556 </para>
1557
1558 <para>
1559 Recipes should never write files directly into the sysroot.
1560 Instead, files should be installed into standard locations
1561 during the
1562 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
1563 task within the
1564 <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>
1565 directory.
Brad Bishop316dfdd2018-06-25 12:45:53 -04001566 A subset of these files automatically goes into the sysroot.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001567 The reason for this limitation is that almost all files that go
1568 into the sysroot are cataloged in manifests in order to ensure
1569 they can be removed later when a recipe is modified or removed.
1570 Thus, the sysroot is able to remain free from stale files.
1571 </para>
1572 </section>
1573
1574 <section id='sdk-packaging'>
1575 <title>Packaging</title>
1576
1577 <para>
1578 Packaging is not always particularly relevant within the
1579 extensible SDK.
1580 However, if you examine how build output gets into the final image
1581 on the target device, it is important to understand packaging
1582 because the contents of the image are expressed in terms of
1583 packages and not recipes.
1584 </para>
1585
1586 <para>
1587 During the
1588 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>
1589 task, files installed during the
1590 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001591 task are split into one main package, which is almost always
1592 named the same as the recipe, and into several other packages.
1593 This separation exists because not all of those installed files
1594 are useful in every image.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001595 For example, you probably do not need any of the documentation
1596 installed in a production image.
Brad Bishop316dfdd2018-06-25 12:45:53 -04001597 Consequently, for each recipe the documentation files are
1598 separated into a <filename>-doc</filename> package.
1599 Recipes that package software containing optional modules or
1600 plugins might undergo additional package splitting as well.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001601 </para>
1602
1603 <para>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001604 After building a recipe, you can see where files have gone by
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001605 looking in the <filename>oe-workdir/packages-split</filename>
1606 directory, which contains a subdirectory for each package.
1607 Apart from some advanced cases, the
1608 <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
1609 and
1610 <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>
1611 variables controls splitting.
1612 The <filename>PACKAGES</filename> variable lists all of the
1613 packages to be produced, while the <filename>FILES</filename>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001614 variable specifies which files to include in each package by
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001615 using an override to specify the package.
Brad Bishop316dfdd2018-06-25 12:45:53 -04001616 For example, <filename>FILES_${PN}</filename> specifies the
1617 files to go into the main package (i.e. the main package has
1618 the same name as the recipe and
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001619 <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>
1620 evaluates to the recipe name).
Brad Bishop316dfdd2018-06-25 12:45:53 -04001621 The order of the <filename>PACKAGES</filename> value is
1622 significant.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001623 For each installed file, the first package whose
Brad Bishop316dfdd2018-06-25 12:45:53 -04001624 <filename>FILES</filename> value matches the file is the
1625 package into which the file goes.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001626 Defaults exist for both the <filename>PACKAGES</filename> and
1627 <filename>FILES</filename> variables.
1628 Consequently, you might find you do not even need to set these
1629 variables in your recipe unless the software the recipe is
1630 building installs files into non-standard locations.
1631 </para>
1632 </section>
1633 </section>
1634
1635 <section id='sdk-restoring-the-target-device-to-its-original-state'>
1636 <title>Restoring the Target Device to its Original State</title>
1637
1638 <para>
1639 If you use the <filename>devtool deploy-target</filename>
1640 command to write a recipe's build output to the target, and
1641 you are working on an existing component of the system, then you
1642 might find yourself in a situation where you need to restore the
1643 original files that existed prior to running the
1644 <filename>devtool deploy-target</filename> command.
1645 Because the <filename>devtool deploy-target</filename> command
1646 backs up any files it overwrites, you can use the
Brad Bishop316dfdd2018-06-25 12:45:53 -04001647 <filename>devtool undeploy-target</filename> command to restore
1648 those files and remove any other files the recipe deployed.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001649 Consider the following example:
1650 <literallayout class='monospaced'>
1651 $ devtool undeploy-target lighttpd root@192.168.7.2
1652 </literallayout>
1653 If you have deployed multiple applications, you can remove them
Brad Bishop316dfdd2018-06-25 12:45:53 -04001654 all using the "-a" option thus restoring the target device to its
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001655 original state:
1656 <literallayout class='monospaced'>
1657 $ devtool undeploy-target -a root@192.168.7.2
1658 </literallayout>
1659 Information about files deployed to the target as well as any
1660 backed up files are stored on the target itself.
Brad Bishop316dfdd2018-06-25 12:45:53 -04001661 This storage, of course, requires some additional space
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001662 on the target machine.
1663 <note>
1664 The <filename>devtool deploy-target</filename> and
Brad Bishop316dfdd2018-06-25 12:45:53 -04001665 <filename>devtool undeploy-target</filename> commands do not
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001666 currently interact with any package management system on the
1667 target device (e.g. RPM or OPKG).
Brad Bishop316dfdd2018-06-25 12:45:53 -04001668 Consequently, you should not intermingle
1669 <filename>devtool deploy-target</filename> and package
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001670 manager operations on the target device.
1671 Doing so could result in a conflicting set of files.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001672 </note>
1673 </para>
1674 </section>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001675
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001676 <section id='sdk-installing-additional-items-into-the-extensible-sdk'>
1677 <title>Installing Additional Items Into the Extensible SDK</title>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001678
1679 <para>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001680 Out of the box the extensible SDK typically only comes with a small
1681 number of tools and libraries.
1682 A minimal SDK starts mostly empty and is populated on-demand.
1683 Sometimes you must explicitly install extra items into the SDK.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001684 If you need these extra items, you can first search for the items
1685 using the <filename>devtool search</filename> command.
1686 For example, suppose you need to link to libGL but you are not sure
Brad Bishop316dfdd2018-06-25 12:45:53 -04001687 which recipe provides libGL.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001688 You can use the following command to find out:
1689 <literallayout class='monospaced'>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001690 $ devtool search libGL
1691 mesa A free implementation of the OpenGL API
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001692 </literallayout>
1693 Once you know the recipe (i.e. <filename>mesa</filename> in this
1694 example), you can install it:
1695 <literallayout class='monospaced'>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001696 $ devtool sdk-install mesa
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001697 </literallayout>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001698 By default, the <filename>devtool sdk-install</filename> command
1699 assumes the item is available in pre-built form from your SDK
1700 provider.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001701 If the item is not available and it is acceptable to build the item
1702 from source, you can add the "-s" option as follows:
1703 <literallayout class='monospaced'>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001704 $ devtool sdk-install -s mesa
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001705 </literallayout>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001706 It is important to remember that building the item from source
1707 takes significantly longer than installing the pre-built artifact.
1708 Also, if no recipe exists for the item you want to add to the SDK,
1709 you must instead add the item using the
1710 <filename>devtool add</filename> command.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001711 </para>
1712 </section>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001713
Brad Bishopd5ae7d92018-06-14 09:52:03 -07001714 <section id='sdk-applying-updates-to-an-installed-extensible-sdk'>
1715 <title>Applying Updates to an Installed Extensible SDK</title>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001716
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001717 <para>
Brad Bishopd5ae7d92018-06-14 09:52:03 -07001718 If you are working with an installed extensible SDK that gets
1719 occasionally updated (e.g. a third-party SDK), then you will need
1720 to manually "pull down" the updates into the installed SDK.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001721 </para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001722
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001723 <para>
Brad Bishopd5ae7d92018-06-14 09:52:03 -07001724 To update your installed SDK, use <filename>devtool</filename> as
1725 follows:
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001726 <literallayout class='monospaced'>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001727 $ devtool sdk-update
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001728 </literallayout>
1729 The previous command assumes your SDK provider has set the default
Brad Bishopd5ae7d92018-06-14 09:52:03 -07001730 update URL for you through the
1731 <ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_UPDATE_URL'><filename>SDK_UPDATE_URL</filename></ulink>
1732 variable as described in the
1733 "<link linkend='sdk-providing-updates-to-the-extensible-sdk-after-installation'>Providing Updates to the Extensible SDK After Installation</link>"
1734 section.
1735 If the SDK provider has not set that default URL, you need to
1736 specify it yourself in the command as follows:
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001737 <literallayout class='monospaced'>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001738 $ devtool sdk-update <replaceable>path_to_update_directory</replaceable>
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001739 </literallayout>
1740 <note>
Brad Bishopd5ae7d92018-06-14 09:52:03 -07001741 The URL needs to point specifically to a published SDK and
1742 not to an SDK installer that you would download and install.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001743 </note>
1744 </para>
1745 </section>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001746
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001747 <section id='sdk-creating-a-derivative-sdk-with-additional-components'>
1748 <title>Creating a Derivative SDK With Additional Components</title>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001749
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001750 <para>
1751 You might need to produce an SDK that contains your own custom
Brad Bishop316dfdd2018-06-25 12:45:53 -04001752 libraries.
1753 A good example would be if you were a vendor with customers that
1754 use your SDK to build their own platform-specific software and
1755 those customers need an SDK that has custom libraries.
1756 In such a case, you can produce a derivative SDK based on the
1757 currently installed SDK fairly easily by following these steps:
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001758 <orderedlist>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001759 <listitem><para>
1760 If necessary, install an extensible SDK that
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001761 you want to use as a base for your derivative SDK.
1762 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001763 <listitem><para>
1764 Source the environment script for the SDK.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001765 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001766 <listitem><para>
1767 Add the extra libraries or other components you want by
1768 using the <filename>devtool add</filename> command.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001769 </para></listitem>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001770 <listitem><para>
1771 Run the <filename>devtool build-sdk</filename> command.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001772 </para></listitem>
1773 </orderedlist>
Brad Bishop316dfdd2018-06-25 12:45:53 -04001774 The previous steps take the recipes added to the workspace and
1775 construct a new SDK installer that contains those recipes and the
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001776 resulting binary artifacts.
1777 The recipes go into their own separate layer in the constructed
Brad Bishop316dfdd2018-06-25 12:45:53 -04001778 derivative SDK, which leaves the workspace clean and ready for
1779 users to add their own recipes.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001780 </para>
1781 </section>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001782</chapter>
1783<!--
1784vim: expandtab tw=80 ts=4
1785-->