diff options
author | Michael Opdenacker <michael.opdenacker@bootlin.com> | 2023-01-06 17:32:10 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-25 15:12:48 +0000 |
commit | ce7b98d3637105121ff9a70ac7ab47310611205e (patch) | |
tree | 4a7ab316008b0521e36de741bb8a8e09a96e2db7 /documentation | |
parent | 383e97f8967ffc00352f1fb3c4381cae02eca8ba (diff) | |
download | poky-ce7b98d3637105121ff9a70ac7ab47310611205e.tar.gz |
ref-manual: initial documentation for go and go-mod classes
This addresses [YOCTO #14582]
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'documentation')
-rw-r--r-- | documentation/ref-manual/classes.rst | 23 | ||||
-rw-r--r-- | documentation/ref-manual/variables.rst | 67 |
2 files changed, 90 insertions, 0 deletions
diff --git a/documentation/ref-manual/classes.rst b/documentation/ref-manual/classes.rst index 7dba617db5..0cb507b500 100644 --- a/documentation/ref-manual/classes.rst +++ b/documentation/ref-manual/classes.rst | |||
@@ -758,6 +758,29 @@ software from the GNOME stack. This class sets | |||
758 | mirrors as well as extending :term:`FILES` with the typical | 758 | mirrors as well as extending :term:`FILES` with the typical |
759 | GNOME installation paths. | 759 | GNOME installation paths. |
760 | 760 | ||
761 | .. _ref-classes-go: | ||
762 | |||
763 | ``go`` | ||
764 | ====== | ||
765 | |||
766 | The :ref:`ref-classes-go` class supports building Go programs. The behavior of | ||
767 | this class is controlled by the mandatory :term:`GO_IMPORT` variable, and | ||
768 | by the optional :term:`GO_INSTALL` and :term:`GO_INSTALL_FILTEROUT` ones. | ||
769 | |||
770 | To build a Go program with the Yocto Project, you can use the | ||
771 | :yocto_git:`go-helloworld_0.1.bb </poky/tree/meta/recipes-extended/go-examples/go-helloworld_0.1.bb>` | ||
772 | recipe as an example. | ||
773 | |||
774 | .. _ref-classes-go-mod: | ||
775 | |||
776 | ``go-mod`` | ||
777 | ========== | ||
778 | |||
779 | The :ref:`ref-classes-go-mod` class allows to use Go modules, and inherits the | ||
780 | :ref:`ref-classes-go` class. | ||
781 | |||
782 | See the associated :term:`GO_WORKDIR` variable. | ||
783 | |||
761 | .. _ref-classes-gobject-introspection: | 784 | .. _ref-classes-gobject-introspection: |
762 | 785 | ||
763 | ``gobject-introspection`` | 786 | ``gobject-introspection`` |
diff --git a/documentation/ref-manual/variables.rst b/documentation/ref-manual/variables.rst index f2decd713b..8419c80d03 100644 --- a/documentation/ref-manual/variables.rst +++ b/documentation/ref-manual/variables.rst | |||
@@ -3012,6 +3012,73 @@ system and gives an overview of their function and contents. | |||
3012 | 3012 | ||
3013 | GLIBC_GENERATE_LOCALES = "en_GB.UTF-8 en_US.UTF-8" | 3013 | GLIBC_GENERATE_LOCALES = "en_GB.UTF-8 en_US.UTF-8" |
3014 | 3014 | ||
3015 | :term:`GO_IMPORT` | ||
3016 | When inheriting the :ref:`ref-classes-go` class, this mandatory variable | ||
3017 | sets the import path for the Go package that will be created for the code | ||
3018 | to build. If you have a ``go.mod`` file in the source directory, this | ||
3019 | typically matches the path in the ``module`` line in this file. | ||
3020 | |||
3021 | Other Go programs importing this package will use this path. | ||
3022 | |||
3023 | Here is an example setting from the | ||
3024 | :yocto_git:`go-helloworld_0.1.bb </poky/tree/meta/recipes-extended/go-examples/go-helloworld_0.1.bb>` | ||
3025 | recipe:: | ||
3026 | |||
3027 | GO_IMPORT = "golang.org/x/example" | ||
3028 | |||
3029 | :term:`GO_INSTALL` | ||
3030 | When inheriting the :ref:`ref-classes-go` class, this optional variable | ||
3031 | specifies which packages in the sources should be compiled and | ||
3032 | installed in the Go build space by the | ||
3033 | `go install <https://go.dev/ref/mod#go-install>`__ command. | ||
3034 | |||
3035 | Here is an example setting from the | ||
3036 | :oe_git:`crucible </meta-openembedded/tree/meta-oe/recipes-support/crucible/>` | ||
3037 | recipe:: | ||
3038 | |||
3039 | GO_INSTALL = "\ | ||
3040 | ${GO_IMPORT}/cmd/crucible \ | ||
3041 | ${GO_IMPORT}/cmd/habtool \ | ||
3042 | " | ||
3043 | |||
3044 | By default, :term:`GO_INSTALL` is defined as:: | ||
3045 | |||
3046 | GO_INSTALL ?= "${GO_IMPORT}/..." | ||
3047 | |||
3048 | The ``...`` wildcard means that it will catch all | ||
3049 | packages found in the sources. | ||
3050 | |||
3051 | See the :term:`GO_INSTALL_FILTEROUT` variable for | ||
3052 | filtering out unwanted packages from the ones | ||
3053 | found from the :term:`GO_INSTALL` value. | ||
3054 | |||
3055 | :term:`GO_INSTALL_FILTEROUT` | ||
3056 | When using the Go "vendor" mechanism to bring in dependencies for a Go | ||
3057 | package, the default :term:`GO_INSTALL` setting, which uses the ``...`` | ||
3058 | wildcard, will include the vendored packages in the build, which produces | ||
3059 | incorrect results. | ||
3060 | |||
3061 | There are also some Go packages that are structured poorly, so that the | ||
3062 | ``...`` wildcard results in building example or test code that should not | ||
3063 | be included in the build, or could fail to build. | ||
3064 | |||
3065 | This optional variable allows for filtering out a subset of the sources. | ||
3066 | It defaults to excluding everything under the ``vendor`` subdirectory | ||
3067 | under package's main directory. This is the normal location for vendored | ||
3068 | packages, but it can be overridden by a recipe to filter out other | ||
3069 | subdirectories if needed. | ||
3070 | |||
3071 | :term:`GO_WORKDIR` | ||
3072 | When using Go Modules, the current working directory must be the directory | ||
3073 | containing the ``go.mod`` file, or one of its subdirectories. When the | ||
3074 | ``go`` tool is used, it will automatically look for the ``go.mod`` file | ||
3075 | in the Go working directory or in any parent directory, but not in | ||
3076 | subdirectories. | ||
3077 | |||
3078 | When using the :ref:`ref-classes-go-mod` class to use Go modules, | ||
3079 | the optional :term:`GO_WORKDIR` variable, defaulting to the value | ||
3080 | of :term:`GO_IMPORT`, allows to specify a different Go working directory. | ||
3081 | |||
3015 | :term:`GROUPADD_PARAM` | 3082 | :term:`GROUPADD_PARAM` |
3016 | When inheriting the :ref:`ref-classes-useradd` class, | 3083 | When inheriting the :ref:`ref-classes-useradd` class, |
3017 | this variable specifies for a package what parameters should be | 3084 | this variable specifies for a package what parameters should be |