github.com/metux/go-metabuild@v0.0.0-20240118143255-d9ed5ab697f9/doc/spec/targets.md (about)

     1  # Project spec: targets
     2  
     3  This section is a map of all targets to be built and installed. Most types use
     4  the key as the object's name / output file. Each target must have an `type`
     5  attribute set.
     6  
     7  | Type                   | Description                                                             |
     8  |------------------------|-------------------------------------------------------------------------|
     9  | c/executable           | executable program written in C                                         |
    10  | c/library              | library written in C *(building shared/static/pkgconfig per default)*   |
    11  | c/glib-marshal         | generate and compile glib marshaling code as static library             |
    12  | c++/executable         | executable program written in C++                                       |
    13  | c++/library            | library written in C++ *(building shared/static/pkgconfig per default)* |
    14  | data/desktop           | simple FreeDesktop.org `*.desktop` file                                 |
    15  | data/misc              | misc data *(installed to $datadir)                                      |
    16  | data/pixmaps           | pixmap files *(installed to $datadir/pixmaps)*                          |
    17  | data/lib-script        | install script to arch-independent libdir                               |
    18  | data/lib-script-subdir | install script to arch-independent libdir (subdir by target id)         |
    19  | doc/man                | Unix manual page *(troff/nroff)*                                        |
    20  | doc/misc               | Simple documentation files *(placed under $datadir/doc/...)*            |
    21  | gen/glib-resource      | Generate Glib resource and source code files from XML                   |
    22  | gen/glib-marshal       | Generate Glib marshalling code                                          |
    23  | gen/xdt-csource        | Generate source code for compiling-in XML files *(eg. `*.glade`)*       |
    24  | gen/xxd-csource        | Generate source for compiling in binary data (like xxd -i)              |
    25  | i18n/desktop           | multilingual FreeDesktop.org `*.desktop` file                           |
    26  | i18n/po                | gettext translation files *(building `*.mo` files)*                     |
    27  
    28  ## Common attributes
    29  
    30  | Attribute   | Type    | Description                                           |
    31  |-------------|---------|-------------------------------------------------------|
    32  | build       | bool    | true if compiled for `build` system instead of `host` |
    33  | install     | bool    | true if output should be installed in package         |
    34  | job/depends | list    | additional job dependencies                           |
    35  | optional    | string  | only build if given feature/option is enabled         |
    36  | skip        | bool    | skip building this target                             |
    37  | type        | string  | target type                                           |
    38  
    39  ## Automatic attributes
    40  
    41  Some attributes are automatically set in the post-load phase.
    42  
    43  | Attribute  | Description                                                    |
    44  |------------|----------------------------------------------------------------|
    45  | @id        | The ID-part of the target key name (used eg. for target names) |
    46  | @id/suffix | Suffix (extension) of the ID, without leading dot              |
    47  | @type      | target type, extracted from target key                         |
    48  
    49  ## Special key notation
    50  
    51  For convenience, the target key (in the yaml struct) may encode the target type:
    52  
    53     `target_id{target_type}`
    54  
    55  ## Target types
    56  
    57  ### c/executable: executable program written in C
    58  
    59  #### Attributes:
    60  
    61  | Attribute       | Default                            | Description                       |
    62  |-----------------|------------------------------------|-----------------------------------|
    63  | c/cflags        |                                    | extra C-flags                     |
    64  | c/defines       |                                    | extra C-defines                   |
    65  | c/ldflags       |                                    | extra linker flags                |
    66  | compiler/lang   | C                                  | compiler language                 |
    67  | file            | ${@@^::name}                       | file name                         |
    68  | headers         |                                    | map of header file bundles        |
    69  | include/dir     |                                    | extra include dirs                |
    70  | install         | ${@@^2::install}                   | whether to install                |
    71  | install/dir     | ${buildconf::install-dirs::bindir} | install directory                 |
    72  | install/package | prog                               | install package                   |
    73  | install/perm    | 0755                               | install permissions               |
    74  | install/subdir  |                                    | install subdirectory              |
    75  | link/shared     |                                    | dynamically link internal libs    |
    76  | link/static     |                                    | statically link internal libs     |
    77  | name            | ${@@^::@id}                        | object name                       |
    78  | pkgconf/import  |                                    | IDs of pkgconf-packages to import |
    79  | source          |                                    | source files *(globs)*            |
    80  | source/dir      |                                    | source subdir                     |
    81  
    82  #### Example:
    83  ```
    84      settings-dialogs/xfwm4-tweaks-settings:
    85          type:               c/executable
    86          pkgconf/import:     [LIBXFCE4KBD_PRIVATE]
    87          source:             [tweaks-settings.c, range-debouncer.c]
    88          source/dir:         settings-dialogs
    89          include/dir:        .
    90          c/defines:          ${c/defines}
    91          link/static:        xfwm-common
    92          install/package:    main
    93          headers:
    94              install:        false
    95              priv:
    96                  source:     [xfwm4-tweaks-dialog_ui.h, range-debouncer.h]
    97  ```
    98  
    99  ### c/library: library written in C
   100  
   101  This builds and installs a library written in C, including static _(`*.a`)_, shared _(`*.so.<version>`)_,
   102  pkgconf _(`*.pc`)_, symbolic link _(`*.so`)_ for development, header files, etc.
   103  
   104  The target `c++/library` is pretty much the same, but using language `C++` instead.
   105  
   106  The attributes are those of `c/executable` plus some more:
   107  
   108  | Attribute       | Default            | Description                                               |
   109  |-----------------|--------------------|-----------------------------------------------------------|
   110  | abi             | 1                  | shared object version                                     |
   111  | compiler/lang   | C                  | compiler language                                         |
   112  | description     | ${description}     | description _(for pkgconf)_                               |
   113  | install         | true               | whether to install                                        |
   114  | install/dir     |                    | installation dir                                          |
   115  | install/subdir  |                    | installation subdir                                       |
   116  | library/name    | ${@basename^::@id} | library name _(as used in `-l...` flag)`                  |
   117  | library/mapfile |                    | linker map file                                           |
   118  | pkgconf         |                    | map of pkg-config metadata _(`name:` and `description:`)_ |
   119  | skip/devlink    |                    | skip devlink _(to shared object)_                         |
   120  | skip/pkgconf    |                    | skip `.pc` file                                           |
   121  | skip/shared     |                    | skip shared object                                        |
   122  | skip/static     |                    | skip static archive                                       |
   123  | version         | ${version}         | version _(for pkgconf)_                                   |
   124  
   125  #### Example:
   126  ```
   127      zlib:
   128          type:             c/library
   129          version:          1
   130          library/mapfile:  zlib.map
   131          library/name:     z
   132          c/defines:        ${buildconf::host::flags::c/defines}
   133          pkgconf:
   134              name:        zlib
   135              description: ZLib compression library
   136          source: "*.c"
   137  ```
   138  
   139  ### data/misc: arbitrary data files (/usr/share/...)
   140  
   141  #### Attributes:
   142  
   143  | Attribute       | Default                             | Description                                           |
   144  |-----------------|-------------------------------------|-------------------------------------------------------|
   145  | install         | ${@@^2::install}                    | whether to install into distro package                |
   146  | install/dir     | ${buildconf::install-dirs::datadir} | install directory                                     |
   147  | install/package | data                                | install package                                       |
   148  | install/perm    | 0064                                | install permissions                                   |
   149  | install/subdir  |                                     | subdirectory _(under standard $datadir) to install to |
   150  | source          |                                     | source files globs                                    |
   151  | source/dir      |                                     | source subdirector                                    |
   152  
   153  #### Example:
   154  ```
   155      data/opening:
   156          type:           data/misc
   157          install/subdir: lincity/opening
   158          source:         "*"
   159          source/dir:     opening
   160  ```
   161  
   162  ### data/lib-script: script libs
   163  
   164  Similar to data/misc, but putting it into arch-independent libdir and sets executable flag.
   165  
   166  #### Attributes:
   167  
   168  | Attribute       | Default                                              | Description                            |
   169  |-----------------|------------------------------------------------------|----------------------------------------|
   170  | install         | ${@@^2::install}                                     | whether to install into distro package |
   171  | install/dir     | ${buildconf::install-dirs::libdir-noarch}/${package} | install directory                      |
   172  | install/package | data                                                 | install package                        |
   173  | install/perm    | 0775                                                 | install permissions                    |
   174  | source          |                                                      | source files globs                     |
   175  | source/dir      |                                                      | source subdirector                     |
   176  
   177  #### Example:
   178  ```
   179      foo:
   180          type:           data/lib-script
   181          source:         "foo-helper"
   182  ```
   183  
   184  ### data/lib-script-subdir: script libs
   185  
   186  Like data/lib-script, but taking `source/dir` from target id.
   187  
   188  #### Attributes:
   189  
   190  | Attribute       | Default                                              | Description                            |
   191  |-----------------|------------------------------------------------------|----------------------------------------|
   192  | install         | ${@@^2::install}                                     | whether to install into distro package |
   193  | install/dir     | ${buildconf::install-dirs::libdir-noarch}/${package} | install directory                      |
   194  | install/package | data                                                 | install package                        |
   195  | install/perm    | 0775                                                 | install permissions                    |
   196  | source          |                                                      | source files globs                     |
   197  | source/dir      | ${@@^::@id}                                          | source subdirector                     |
   198  
   199  #### Example:
   200  ```
   201      plugin-foo:
   202          type:           data/lib-script-subdir
   203          source:         "*.sh"
   204  ```
   205  
   206  ### data/desktop
   207  
   208  #### Attributes:
   209  
   210  | Attribute           | Default                                                    | Description                            |
   211  |---------------------|------------------------------------------------------------|----------------------------------------|
   212  | desktop/type        | Application                                                | `Type=` field                          |
   213  | desktop/name        | ${shortname}                                               | `Name=` field                          |
   214  | desktop/categories  |                                                            | `Categories=` field                    |
   215  | desktop/genericname | ${name}                                                    | `GenericName=` field                   |
   216  | desktop/comment     | ${description}                                             | `Comment=` field                       |
   217  | desktop/icon-file   | ${buildconf::install-dirs::pixmapdir}/${@@^::desktop/icon} | `Icon=` field                          |
   218  | desktop/terminal    | false                                                      | `Terminal=` field                      |
   219  | desktop/exec        |                                                            | `Exec=` field                          |
   220  | desktop/tryexec     |                                                            | `TryExec=` field                       |
   221  | file                | ${@@^::@id}                                                | output file name                       |
   222  | install             | ${@@^2::install}                                           | whether to install into distro package |
   223  | install/dir         | ${buildconf::install-dirs::fdo-appdir}                     | install directory                      |
   224  | install/package     | data                                                       | install package                        |
   225  | install/perm        | 0064                                                       | install permissions                    |
   226  | install/subdir      |                                                            | install subdir                         |
   227  
   228  #### Example:
   229  ```
   230      lincity.desktop:
   231          type:               data/desktop
   232          desktop/categories: Application;Game;StrategyGame
   233          desktop/exec:       lincity
   234          desktop/tryexec:    ${buildconf::install-dirs::bindir}/lincity
   235  ```
   236  
   237  ### data/pixmap
   238  
   239  #### Attributes:
   240  
   241  | Attribute           | Default                               | Description                            |
   242  |---------------------|---------------------------------------|----------------------------------------|
   243  | install             | ${@@^2::install}                      | whether to install into distro package |
   244  | install/dir         | ${buildconf::install-dirs::pixmapdir} | install directory                      |
   245  | install/package     | data                                  | install package                        |
   246  | install/perm        | 0064                                  | install permissions                    |
   247  | install/subdir      |                                       | install subdir                         |
   248  | source              | ${@@^::@id}                           | source file                            |
   249  
   250  #### Example:
   251  ```
   252      data/pixmap:
   253          type:           data/pixmaps
   254          source:         debian/lincity.xpm
   255  ```
   256  
   257  ### doc/misc
   258  
   259  #### Attributes:
   260  
   261  | Attribute           | Default                            | Description                            |
   262  |---------------------|------------------------------------|----------------------------------------|
   263  | source              |                                    | source files _(globs)_                 |
   264  | install             | ${@@^2::install}                   | whether to install into distro package |
   265  | install/dir         | ${buildconf::install-dirs::docdir} | install directory                      |
   266  | install/package     | doc                                | install package                        |
   267  | install/perm        | 0064                               | install permissions                    |
   268  | install/subdir      | ${package}                         | install subdir                         |
   269  | compress            | gz                                 | compression method                     |
   270  
   271  #### Example:
   272  ```
   273      doc/misc:
   274          type:           doc/misc
   275          source:
   276              - Acknowledgements
   277              - README
   278              - TODO
   279              - CHANGES
   280              - COPYING
   281              - COPYRIGHT
   282  ```
   283  
   284  ### doc/man
   285  
   286  #### Attributes:
   287  
   288  | Attribute           | Default                            | Description                            |
   289  |---------------------|------------------------------------|----------------------------------------|
   290  | source              |                                    | source file                            |
   291  | install             | ${@@^2::install}                   | whether to install into distro package |
   292  | install/dir         | ${buildconf::install-dirs::mandir} | install directory                      |
   293  | install/package     | data                               | install package                        |
   294  | install/perm        | 0064                               | install permissions                    |
   295  | install/subdir      |                                    | install subdir                         |
   296  | man/alias           |                                    | manpage alias                          |
   297  | man/compress        | gz                                 | compression method                     |
   298  | man/section         | ${@@^::@id/suffix}                 | manual section                         |
   299  | source              | ${@@^::@id}                        | manual page (nroff/troff) file         |
   300  
   301  #### Example:
   302  ```
   303      lincity.6:
   304          type:           doc/man
   305          man/alias:      xlincity
   306  ```
   307  
   308  ### i18n/po
   309  
   310  This builds/installs gettext `*.mo` files for given linguas. If the `linguas` attribute is missing,
   311  the global variable `${i18n::linguas}` is used. Per default, the `*.po` files are expected in
   312  the `po/` subdirectory.
   313  
   314  #### Attributes:
   315  
   316  | Attribute       | Default                               | Description                                           |
   317  |-----------------|---------------------------------------|-------------------------------------------------------|
   318  | install         | true                                  | whether to install into distro package                |
   319  | install/dir     | ${buildconf::install-dirs::localedir} | install target directory                              |
   320  | install/package | data                                  | install target package                                |
   321  | install/perm    | 0664                                  | install file permissions                              |
   322  | install/subdir  |                                       | subdirectory _(under standard $datadir) to install to |
   323  | i18n/linguas    | ${i18n::linguas}                      | list of locale names to build for                     |
   324  | i18n/category:  | LC_MESSAGES                           | locale category                                       |
   325  | i18n/domain:    | ${package}                            | locale domain                                         |
   326  | source/dir:     | po                                    | source subdirectory                                   |
   327  | name:           | ${@@^::domain}.mo                     | `*.mo` target file name                               |
   328  
   329  #### Example:
   330  ```
   331      po:
   332          type:    i18n/po
   333  ```
   334  
   335  ### i18n/desktop
   336  
   337  #### Attributes:
   338  
   339  | Attribute       | Default                                | Description                                           |
   340  |-----------------|----------------------------------------|-------------------------------------------------------|
   341  | i18n/linguas    | ${i18n::linguas}                       | list of locale names to build for                     |
   342  | i18n/po/dir     | po                                     | po file directory                                     |
   343  | install         | true                                   | whether to install into distro package                |
   344  | install/dir     | ${buildconf::install-dirs::fdo-appdir} | install target directory                              |
   345  | install/package | data                                   | install target package                                |
   346  | install/perm    | 0664                                   | install file permissions                              |
   347  | install/subdir  |                                        | subdirectory _(under standard $datadir) to install to |
   348  | output/suffix   | .desktop                               |                                                       |
   349  | source          |                                        | source item names _(not files)_                       |
   350  | source/dir:     |                                        | source subdirectory                                   |
   351  | source/suffix   | .desktop.in                            | input file suffix                                     |
   352  
   353  #### Example:
   354  ```
   355      desktop:
   356          type:           i18n/desktop
   357          source:         [xfce-wm-settings, xfce-wmtweaks-settings, xfce-workspaces-settings]
   358          source/dir:     settings-dialogs
   359  ```
   360  
   361  ### gen/glib-resource:
   362  
   363  #### Attributes:
   364  
   365  | Attribute        | Default                                              | Description               |
   366  |------------------|------------------------------------------------------|---------------------------|
   367  | source           |                                                      | XML source file           |
   368  | source/dir       | .                                                    | source subdir             |
   369  | include/dir      | ${@@^::source/dir}                                   | include directory         |
   370  | resource/dir     | ${@@^::source/dir}                                   | resource output directory |
   371  | resource/name    | ${@@^::name}                                         | resource name             |
   372  | output/c/header  | ${@@^::resource/dir}/${@@^::resource/name}.h         | c header output file      |
   373  | output/c/source  | ${@@^::resource/dir}/${@@^::resource/name}.c         | c source output file      |
   374  | output/gresource | ${@@^::resource/dir}/${@@^::resource/name}.gresource | `.gresource` output file  |
   375  | name             | ${@@^::@id}                                          | target name               |
   376  
   377  #### Example:
   378  ```
   379      settings-dialogs/workspace-resource:
   380          type:               gen/glib-resource
   381          name:               workspace-resource
   382          source:             workspace.gresource.xml
   383          source/dir:         settings-dialogs
   384  ```
   385  
   386  ### c/glib-resource:
   387  
   388  Generate sources from Glib resources and compile it as static library.
   389  
   390  #### Attributes:
   391  
   392  | Attribute        | Default                                              | Description               |
   393  |------------------|------------------------------------------------------|---------------------------|
   394  | source           |                                                      | XML source file           |
   395  | source/dir       | .                                                    | source subdir             |
   396  | resource/dir     | ${@@^::source/dir}                                   | resource output directory |
   397  | resource/name    | ${@@^::name}                                         | resource name             |
   398  | output/c/header  | ${@@^::resource/dir}/${@@^::resource/name}.h         | c header output file      |
   399  | output/c/source  | ${@@^::resource/dir}/${@@^::resource/name}.c         | c source output file      |
   400  | output/gresource | ${@@^::resource/dir}/${@@^::resource/name}.gresource | `.gresource` output file  |
   401  | name             | ${@@^::@id}                                          | target name               |
   402  | library/name     | ${@@^::resource/name}                                | library name              |
   403  | install          | false                                                | install into packages     |
   404  
   405  #### Example:
   406  ```
   407      settings-dialogs/workspace-resource:
   408          type:               gen/glib-resource
   409          name:               workspace-resource
   410          source:             workspace.gresource.xml
   411          source/dir:         settings-dialogs
   412  ```
   413  
   414  ### gen/glib-marshal:
   415  
   416  Generate Glib marshalling code from prototype definition file.
   417  
   418  #### Attributes:
   419  
   420  | Attribute       | Default               | Description             |
   421  |-----------------|-----------------------|-------------------------|
   422  | source          | ${@@^::@id}.list      | prototype list source   |
   423  | source/dir      | .                     | source subdir           |
   424  | resource/name   | ${@@^::@id}           | resource name           |
   425  | output/name     | ${@@^::@id}           | prefix for output files |
   426  | output/c/header | ${@@^::output/name}.h | c header output file    |
   427  | output/c/source | ${@@^::output/name}.c | c source output file    |
   428  
   429  #### Example:
   430  ```
   431      src/gq-marshal:
   432          type:               gen/glib-marshal
   433          resource/name:      gq_marshal
   434  ```
   435  
   436  ### c/glib-marshal:
   437  
   438  Generate Glib marshalling code and compile it as static library.
   439  
   440  The library can be linked-in by other targets just like any other C library, via `link/static`.
   441  
   442  #### Attributes:
   443  
   444  | Attribute       | Default                 | Description                   |
   445  |-----------------|-------------------------|-------------------------------|
   446  | source          | ${@@^::@id}.list        | prototype list source         |
   447  | source/dir      | .                       | source subdir                 |
   448  | resource/name   | ${@@^::name}            | resource name                 |
   449  | output/name     | ${@@^::resource/name}.h | prefix for output files       |
   450  | output/c/header | ${@@^::output/name}.h   | c header output file          |
   451  | output/c/source | ${@@^::output/name}.c   | c source output file          |
   452  | library/name    | ${@@^::resource/name}   | library name                  |
   453  | pkgconf/import  | GLIB                    | imports for compiling library |
   454  
   455  #### Example:
   456  ```
   457      src/gq-marshal:
   458          type:               gen/glib-marshal
   459          resource/name:      gq_marshal
   460  ```
   461  
   462  ### gen/xdt-csource:
   463  
   464  #### Attributes:
   465  
   466  | Attribute       | Default           | Description                   |
   467  |-----------------|-------------------|-------------------------------|
   468  | source          | ${@@^::@id}.glade | XML source file               |
   469  | resource/name   |                   | name of resource _(C symbol)_ |
   470  | output/c/header | ${@@^::@id}_ui.h  | c header output file          |
   471  
   472  #### Example:
   473  ```
   474      settings-dialogs/workspace-resource:
   475          type:               gen/glib-resource
   476          name:               workspace-resource
   477          source:             workspace.gresource.xml
   478          source/dir:         settings-dialogs
   479  ```
   480  
   481  ### gen/xxd-csource:
   482  
   483  Generate code fragment (header) for compiling in binary data, like `xxd -i`.
   484  
   485  #### Attributes:
   486  
   487  | Attribute        | Default     | Description          |
   488  |------------------|-------------|----------------------|
   489  | source           |             | binary input file    |
   490  | output/c/header  | ${@@^::@id} | c header output file |
   491  
   492  #### Example:
   493  ```
   494      ClayRGB1998_icc.h:
   495          type:               gen/xxd-csource
   496          source:             src/ClayRGB1998.icc
   497  ```
   498  
   499  ### exec/basic:
   500  
   501  Simple command executor (no shell)
   502  
   503  #### Attributes:
   504  
   505  | Attribute        | Default | Description          |
   506  |------------------|---------|----------------------|
   507  | exec/command     |         | command line (list)  |
   508  | exec/workdir     |         | working directory    |
   509  | exec/log         |         | log output           |
   510  
   511  #### Example:
   512  ```
   513      foo:
   514          type:               exec/basic
   515          exec/command:       ["uptime"]
   516          exec/log:           true
   517  
   518  ```