sdk-appendix-customizing.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. .. SPDX-License-Identifier: CC-BY-SA-2.0-UK
  2. ******************************
  3. Customizing the Extensible SDK
  4. ******************************
  5. This appendix describes customizations you can apply to the extensible
  6. SDK.
  7. Configuring the Extensible SDK
  8. ==============================
  9. The extensible SDK primarily consists of a pre-configured copy of the
  10. OpenEmbedded build system from which it was produced. Thus, the SDK's
  11. configuration is derived using that build system and the filters shown
  12. in the following list. When these filters are present, the OpenEmbedded
  13. build system applies them against ``local.conf`` and ``auto.conf``:
  14. - Variables whose values start with "/" are excluded since the
  15. assumption is that those values are paths that are likely to be
  16. specific to the :term:`Build Host`.
  17. - Variables listed in
  18. :term:`SDK_LOCAL_CONF_BLACKLIST`
  19. are excluded. These variables are not allowed through from the
  20. OpenEmbedded build system configuration into the extensible SDK
  21. configuration. Typically, these variables are specific to the machine
  22. on which the build system is running and could be problematic as part
  23. of the extensible SDK configuration.
  24. For a list of the variables excluded by default, see the
  25. :term:`SDK_LOCAL_CONF_BLACKLIST`
  26. in the glossary of the Yocto Project Reference Manual.
  27. - Variables listed in
  28. :term:`SDK_LOCAL_CONF_WHITELIST`
  29. are included. Including a variable in the value of
  30. ``SDK_LOCAL_CONF_WHITELIST`` overrides either of the previous two
  31. filters. The default value is blank.
  32. - Classes inherited globally with
  33. :term:`INHERIT` that are listed in
  34. :term:`SDK_INHERIT_BLACKLIST`
  35. are disabled. Using ``SDK_INHERIT_BLACKLIST`` to disable these
  36. classes is the typical method to disable classes that are problematic
  37. or unnecessary in the SDK context. The default value blacklists the
  38. :ref:`buildhistory <ref-classes-buildhistory>`
  39. and :ref:`icecc <ref-classes-icecc>` classes.
  40. Additionally, the contents of ``conf/sdk-extra.conf``, when present, are
  41. appended to the end of ``conf/local.conf`` within the produced SDK,
  42. without any filtering. The ``sdk-extra.conf`` file is particularly
  43. useful if you want to set a variable value just for the SDK and not the
  44. OpenEmbedded build system used to create the SDK.
  45. Adjusting the Extensible SDK to Suit Your Build Host's Setup
  46. ============================================================
  47. In most cases, the extensible SDK defaults should work with your :term:`Build
  48. Host`'s setup.
  49. However, some cases exist for which you might consider making
  50. adjustments:
  51. - If your SDK configuration inherits additional classes using the
  52. :term:`INHERIT` variable and you
  53. do not need or want those classes enabled in the SDK, you can
  54. blacklist them by adding them to the
  55. :term:`SDK_INHERIT_BLACKLIST`
  56. variable as described in the fourth bullet of the previous section.
  57. .. note::
  58. The default value of
  59. SDK_INHERIT_BLACKLIST
  60. is set using the "?=" operator. Consequently, you will need to
  61. either define the entire list by using the "=" operator, or you
  62. will need to append a value using either "_append" or the "+="
  63. operator. You can learn more about these operators in the "
  64. Basic Syntax
  65. " section of the BitBake User Manual.
  66. .
  67. - If you have classes or recipes that add additional tasks to the
  68. standard build flow (i.e. the tasks execute as the recipe builds as
  69. opposed to being called explicitly), then you need to do one of the
  70. following:
  71. - After ensuring the tasks are :ref:`shared
  72. state <overview-manual/overview-manual-concepts:shared state cache>` tasks (i.e. the
  73. output of the task is saved to and can be restored from the shared
  74. state cache) or ensuring the tasks are able to be produced quickly
  75. from a task that is a shared state task, add the task name to the
  76. value of
  77. :term:`SDK_RECRDEP_TASKS`.
  78. - Disable the tasks if they are added by a class and you do not need
  79. the functionality the class provides in the extensible SDK. To
  80. disable the tasks, add the class to the ``SDK_INHERIT_BLACKLIST``
  81. variable as described in the previous section.
  82. - Generally, you want to have a shared state mirror set up so users of
  83. the SDK can add additional items to the SDK after installation
  84. without needing to build the items from source. See the "`Providing
  85. Additional Installable Extensible SDK
  86. Content <#sdk-providing-additional-installable-extensible-sdk-content>`__"
  87. section for information.
  88. - If you want users of the SDK to be able to easily update the SDK, you
  89. need to set the
  90. :term:`SDK_UPDATE_URL`
  91. variable. For more information, see the "`Providing Updates to the
  92. Extensible SDK After
  93. Installation <#sdk-providing-updates-to-the-extensible-sdk-after-installation>`__"
  94. section.
  95. - If you have adjusted the list of files and directories that appear in
  96. :term:`COREBASE` (other than
  97. layers that are enabled through ``bblayers.conf``), then you must
  98. list these files in
  99. :term:`COREBASE_FILES` so
  100. that the files are copied into the SDK.
  101. - If your OpenEmbedded build system setup uses a different environment
  102. setup script other than
  103. :ref:`structure-core-script`, then you must
  104. set
  105. :term:`OE_INIT_ENV_SCRIPT`
  106. to point to the environment setup script you use.
  107. .. note::
  108. You must also reflect this change in the value used for the
  109. COREBASE_FILES
  110. variable as previously described.
  111. Changing the Extensible SDK Installer Title
  112. ===========================================
  113. You can change the displayed title for the SDK installer by setting the
  114. :term:`SDK_TITLE` variable and then
  115. rebuilding the the SDK installer. For information on how to build an SDK
  116. installer, see the "`Building an SDK
  117. Installer <#sdk-building-an-sdk-installer>`__" section.
  118. By default, this title is derived from
  119. :term:`DISTRO_NAME` when it is
  120. set. If the ``DISTRO_NAME`` variable is not set, the title is derived
  121. from the :term:`DISTRO` variable.
  122. The
  123. :ref:`populate_sdk_base <ref-classes-populate-sdk-*>`
  124. class defines the default value of the ``SDK_TITLE`` variable as
  125. follows:
  126. ::
  127. SDK_TITLE ??= "${@d.getVar('DISTRO_NAME') or d.getVar('DISTRO')} SDK"
  128. While several ways exist to change this variable, an efficient method is
  129. to set the variable in your distribution's configuration file. Doing so
  130. creates an SDK installer title that applies across your distribution. As
  131. an example, assume you have your own layer for your distribution named
  132. "meta-mydistro" and you are using the same type of file hierarchy as
  133. does the default "poky" distribution. If so, you could update the
  134. ``SDK_TITLE`` variable in the
  135. ``~/meta-mydistro/conf/distro/mydistro.conf`` file using the following
  136. form:
  137. ::
  138. SDK_TITLE = "your_title"
  139. Providing Updates to the Extensible SDK After Installation
  140. ==========================================================
  141. When you make changes to your configuration or to the metadata and if
  142. you want those changes to be reflected in installed SDKs, you need to
  143. perform additional steps. These steps make it possible for anyone using
  144. the installed SDKs to update the installed SDKs by using the
  145. ``devtool sdk-update`` command:
  146. 1. Create a directory that can be shared over HTTP or HTTPS. You can do
  147. this by setting up a web server such as an `Apache HTTP
  148. Server <https://en.wikipedia.org/wiki/Apache_HTTP_Server>`__ or
  149. `Nginx <https://en.wikipedia.org/wiki/Nginx>`__ server in the cloud
  150. to host the directory. This directory must contain the published SDK.
  151. 2. Set the
  152. :term:`SDK_UPDATE_URL`
  153. variable to point to the corresponding HTTP or HTTPS URL. Setting
  154. this variable causes any SDK built to default to that URL and thus,
  155. the user does not have to pass the URL to the ``devtool sdk-update``
  156. command as described in the "`Applying Updates to an Installed
  157. Extensible
  158. SDK <#sdk-applying-updates-to-an-installed-extensible-sdk>`__"
  159. section.
  160. 3. Build the extensible SDK normally (i.e., use the
  161. ``bitbake -c populate_sdk_ext`` imagename command).
  162. 4. Publish the SDK using the following command:
  163. ::
  164. $ oe-publish-sdk some_path/sdk-installer.sh path_to_shared_http_directory
  165. You must
  166. repeat this step each time you rebuild the SDK with changes that you
  167. want to make available through the update mechanism.
  168. Completing the above steps allows users of the existing installed SDKs
  169. to simply run ``devtool sdk-update`` to retrieve and apply the latest
  170. updates. See the "`Applying Updates to an Installed Extensible
  171. SDK <#sdk-applying-updates-to-an-installed-extensible-sdk>`__" section
  172. for further information.
  173. Changing the Default SDK Installation Directory
  174. ===============================================
  175. When you build the installer for the Extensible SDK, the default
  176. installation directory for the SDK is based on the
  177. :term:`DISTRO` and
  178. :term:`SDKEXTPATH` variables from
  179. within the
  180. :ref:`populate_sdk_base <ref-classes-populate-sdk-*>`
  181. class as follows:
  182. ::
  183. SDKEXTPATH ??= "~/${@d.getVar('DISTRO')}_sdk"
  184. You can
  185. change this default installation directory by specifically setting the
  186. ``SDKEXTPATH`` variable.
  187. While a number of ways exist through which you can set this variable,
  188. the method that makes the most sense is to set the variable in your
  189. distribution's configuration file. Doing so creates an SDK installer
  190. default directory that applies across your distribution. As an example,
  191. assume you have your own layer for your distribution named
  192. "meta-mydistro" and you are using the same type of file hierarchy as
  193. does the default "poky" distribution. If so, you could update the
  194. ``SDKEXTPATH`` variable in the
  195. ``~/meta-mydistro/conf/distro/mydistro.conf`` file using the following
  196. form:
  197. ::
  198. SDKEXTPATH = "some_path_for_your_installed_sdk"
  199. After building your installer, running it prompts the user for
  200. acceptance of the some_path_for_your_installed_sdk directory as the
  201. default location to install the Extensible SDK.
  202. Providing Additional Installable Extensible SDK Content
  203. =======================================================
  204. If you want the users of an extensible SDK you build to be able to add
  205. items to the SDK without requiring the users to build the items from
  206. source, you need to do a number of things:
  207. 1. Ensure the additional items you want the user to be able to install
  208. are already built:
  209. - Build the items explicitly. You could use one or more "meta"
  210. recipes that depend on lists of other recipes.
  211. - Build the "world" target and set
  212. ``EXCLUDE_FROM_WORLD_pn-``\ recipename for the recipes you do not
  213. want built. See the
  214. :term:`EXCLUDE_FROM_WORLD`
  215. variable for additional information.
  216. 2. Expose the ``sstate-cache`` directory produced by the build.
  217. Typically, you expose this directory by making it available through
  218. an `Apache HTTP
  219. Server <https://en.wikipedia.org/wiki/Apache_HTTP_Server>`__ or
  220. `Nginx <https://en.wikipedia.org/wiki/Nginx>`__ server.
  221. 3. Set the appropriate configuration so that the produced SDK knows how
  222. to find the configuration. The variable you need to set is
  223. :term:`SSTATE_MIRRORS`:
  224. ::
  225. SSTATE_MIRRORS = "file://.* http://example.com/some_path/sstate-cache/PATH"
  226. You can set the
  227. ``SSTATE_MIRRORS`` variable in two different places:
  228. - If the mirror value you are setting is appropriate to be set for
  229. both the OpenEmbedded build system that is actually building the
  230. SDK and the SDK itself (i.e. the mirror is accessible in both
  231. places or it will fail quickly on the OpenEmbedded build system
  232. side, and its contents will not interfere with the build), then
  233. you can set the variable in your ``local.conf`` or custom distro
  234. configuration file. You can then "whitelist" the variable through
  235. to the SDK by adding the following:
  236. ::
  237. SDK_LOCAL_CONF_WHITELIST = "SSTATE_MIRRORS"
  238. - Alternatively, if you just want to set the ``SSTATE_MIRRORS``
  239. variable's value for the SDK alone, create a
  240. ``conf/sdk-extra.conf`` file either in your
  241. :term:`Build Directory` or within any
  242. layer and put your ``SSTATE_MIRRORS`` setting within that file.
  243. .. note::
  244. This second option is the safest option should you have any
  245. doubts as to which method to use when setting
  246. SSTATE_MIRRORS
  247. .
  248. Minimizing the Size of the Extensible SDK Installer Download
  249. ============================================================
  250. By default, the extensible SDK bundles the shared state artifacts for
  251. everything needed to reconstruct the image for which the SDK was built.
  252. This bundling can lead to an SDK installer file that is a Gigabyte or
  253. more in size. If the size of this file causes a problem, you can build
  254. an SDK that has just enough in it to install and provide access to the
  255. ``devtool command`` by setting the following in your configuration:
  256. ::
  257. SDK_EXT_TYPE = "minimal"
  258. Setting
  259. :term:`SDK_EXT_TYPE` to
  260. "minimal" produces an SDK installer that is around 35 Mbytes in size,
  261. which downloads and installs quickly. You need to realize, though, that
  262. the minimal installer does not install any libraries or tools out of the
  263. box. These libraries and tools must be installed either "on the fly" or
  264. through actions you perform using ``devtool`` or explicitly with the
  265. ``devtool sdk-install`` command.
  266. In most cases, when building a minimal SDK you need to also enable
  267. bringing in the information on a wider range of packages produced by the
  268. system. Requiring this wider range of information is particularly true
  269. so that ``devtool add`` is able to effectively map dependencies it
  270. discovers in a source tree to the appropriate recipes. Additionally, the
  271. information enables the ``devtool search`` command to return useful
  272. results.
  273. To facilitate this wider range of information, you would need to set the
  274. following:
  275. ::
  276. SDK_INCLUDE_PKGDATA = "1"
  277. See the :term:`SDK_INCLUDE_PKGDATA` variable for additional information.
  278. Setting the ``SDK_INCLUDE_PKGDATA`` variable as shown causes the "world"
  279. target to be built so that information for all of the recipes included
  280. within it are available. Having these recipes available increases build
  281. time significantly and increases the size of the SDK installer by 30-80
  282. Mbytes depending on how many recipes are included in your configuration.
  283. You can use ``EXCLUDE_FROM_WORLD_pn-``\ recipename for recipes you want
  284. to exclude. However, it is assumed that you would need to be building
  285. the "world" target if you want to provide additional items to the SDK.
  286. Consequently, building for "world" should not represent undue overhead
  287. in most cases.
  288. .. note::
  289. If you set
  290. SDK_EXT_TYPE
  291. to "minimal", then providing a shared state mirror is mandatory so
  292. that items can be installed as needed. See the "
  293. Providing Additional Installable Extensible SDK Content
  294. " section for more information.
  295. You can explicitly control whether or not to include the toolchain when
  296. you build an SDK by setting the
  297. :term:`SDK_INCLUDE_TOOLCHAIN`
  298. variable to "1". In particular, it is useful to include the toolchain
  299. when you have set ``SDK_EXT_TYPE`` to "minimal", which by default,
  300. excludes the toolchain. Also, it is helpful if you are building a small
  301. SDK for use with an IDE or some other tool where you do not want to take
  302. extra steps to install a toolchain.