adding-packages-virtual.txt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // -*- mode:doc; -*-
  2. // vim: set syntax=asciidoc:
  3. Infrastructure for virtual packages
  4. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. [[virtual-package-tutorial]]
  6. In Buildroot, a virtual package is a package whose functionalities are
  7. provided by one or more packages, referred to as 'providers'. The virtual
  8. package management is an extensible mechanism allowing the user to choose
  9. the provider used in the rootfs.
  10. For example, 'OpenGL ES' is an API for 2D and 3D graphics on embedded systems.
  11. The implementation of this API is different for the 'Allwinner Tech Sunxi' and
  12. the 'Texas Instruments OMAP35xx' plaftorms. So +libgles+ will be a virtual
  13. package and +sunxi-mali+ and +ti-gfx+ will be the providers.
  14. +virtual-package+ tutorial
  15. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  16. In the following example, we will explain how to add a new virtual package
  17. ('something-virtual') and a provider for it ('some-provider').
  18. First, let's create the virtual package.
  19. Virtual package's +Config.in+ file
  20. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  21. The +Config.in+ file of virtual package 'something-virtual' should contain:
  22. ---------------------------
  23. 01: config BR2_PACKAGE_HAS_SOMETHING_VIRTUAL
  24. 02: bool
  25. 03:
  26. 04: config BR2_PACKAGE_PROVIDES_SOMETHING_VIRTUAL
  27. 05: depends on BR2_PACKAGE_HAS_SOMETHING_VIRTUAL
  28. 06: string
  29. ---------------------------
  30. In this file, we declare two options, +BR2_PACKAGE_HAS_SOMETHING_VIRTUAL+ and
  31. +BR2_PACKAGE_PROVIDES_SOMETHING_VIRTUAL+, whose values will be used by the
  32. providers.
  33. Virtual package's +*.mk+ file
  34. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  35. The +.mk+ for the virtual package should just evaluate the +virtual-package+ macro:
  36. ---------------------------
  37. 01: ################################################################################
  38. 02: #
  39. 03: # something-virtual
  40. 04: #
  41. 05: ################################################################################
  42. 06:
  43. 07: $(eval $(virtual-package))
  44. ---------------------------
  45. The ability to have target and host packages is also available, with the
  46. +host-virtual-package+ macro.
  47. Provider's +Config.in+ file
  48. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  49. When adding a package as a provider, only the +Config.in+ file requires some
  50. modifications. The +*.mk+ file should follow the Buildroot infrastructure with
  51. no change at all.
  52. The +Config.in+ file of the package 'some-provider', which provides the
  53. functionalities of 'something-virtual', should contain:
  54. ---------------------------
  55. 01: config BR2_PACKAGE_SOME_PROVIDER
  56. 02: bool "some-provider"
  57. 03: select BR2_PACKAGE_HAS_SOMETHING_VIRTUAL
  58. 04: help
  59. 05: This is a comment that explains what some-provider is.
  60. 06:
  61. 07: http://foosoftware.org/some-provider/
  62. 08:
  63. 09: if BR2_PACKAGE_SOME_PROVIDER
  64. 10: config BR2_PACKAGE_PROVIDES_SOMETHING_VIRTUAL
  65. 11: default "some-provider"
  66. 12: endif
  67. ---------------------------
  68. On line 3, we select +BR2_PACKAGE_HAS_SOMETHING_VIRTUAL+, and on line 11, we
  69. set the value of +BR2_PACKAGE_PROVIDES_SOMETHING_VIRTUAL+ to the name of the
  70. provider, but only if it is selected.
  71. Of course, do not forget to add the proper build and runtime dependencies for
  72. this package!