sdk-appendix-customizing.rst 15 KB

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