aboutsummaryrefslogtreecommitdiff
path: root/docs/yaml/objects/feature.yaml
blob: 9cb597be819907735dd49ee784d974dc0885b72f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: feature
long_name: Feature option object
since: 0.47.0
description: Meson object representing a [`feature` options](Build-options.md#features)

methods:
- name: enabled
  returns: bool
  description: Returns whether the feature was set to `'enabled'`

- name: disabled
  returns: bool
  description: Returns whether the feature was set to `'disabled'`

- name: auto
  returns: bool
  description: Returns whether the feature was set to `'auto'`

- name: allowed
  since: 0.59.0
  returns: bool
  description: Returns whether the feature was set to `'enabled'` or `'auto'`

- name: disable_auto_if
  since: 0.59.0
  returns: feature
  description: |
    Returns the feature, with `'auto'` converted to `'disabled'` if value is true.

    | Feature / Condition | `value = true` | `value = false` |
    | ------------------- | -------------- | --------------- |
    | Enabled             | Enabled        | Enabled         |
    | Disabled            | Disabled       | Disabled        |
    | Auto                | Disabled       | Auto            |

  posargs:
    value:
      type: bool
      description: See the table above

- name: enable_auto_if
  since: 1.1.0
  returns: feature
  description: |
    Returns the feature, with `'auto'` converted to `'enabled'` if value is true.

    | Feature / Condition | `value = true` | `value = false` |
    | ------------------- | -------------- | --------------- |
    | Enabled             | Enabled        | Enabled         |
    | Disabled            | Disabled       | Disabled        |
    | Auto                | Enabled        | Auto            |

  posargs:
    value:
      type: bool
      description: See the table above

- name: require
  returns: feature
  since: 0.59.0
  description: |
    Returns the object itself if the value is true; an error if the object is
    `'enabled'` and the value is false; a disabled feature if the object
    is `'auto'` or `'disabled'` and the value is false.

  example: |
    `require` is useful to restrict the applicability of `'auto'` features,
    for example based on other features or on properties of the host machine:

    ```
    if get_option('directx').require(host_machine.system() == 'windows',
          error_message: 'DirectX only available on Windows').allowed() then
      src += ['directx.c']
      config.set10('HAVE_DIRECTX', true)
    endif
    ```

  posargs:
    value:
      type: bool
      description: The value to check

  kwargs:
    error_message:
      type: str
      default: "''"
      description: The error Message to print if the check fails

- name: enable_if
  returns: feature
  since: 1.1.0
  description: |
    Returns the object itself if the value is false; an error if the object is
    `'disabled'` and the value is true; an enabled feature if the object
    is `'auto'` or `'enabled'` and the value is true.

  example: |
    `enable_if` is useful to restrict the applicability of `'auto'` features,
    particularly when passing them to [[dependency]]:

    ```
    use_llvm = get_option('llvm').enable_if(with_clang).enable_if(with_llvm_libs)
    dep_llvm = dependency('llvm', require : use_llvm)
    ```

  posargs:
    value:
      type: bool
      description: The value to check

  kwargs:
    error_message:
      type: str
      default: "''"
      description: The error Message to print if the check fails

- name: disable_if
  returns: feature
  since: 1.1.0
  description: |
    Returns the object itself if the value is false; an error if the object is
    `'enabled'` and the value is true; a disabled feature if the object
    is `'auto'` or `'disabled'` and the value is true.

    This is equivalent to `feature_opt.require(not condition)`, but may make
    code easier to reason about, especially when mixed with `enable_if`

  example: |
    `disable_if` is useful to restrict the applicability of `'auto'` features,
    particularly when passing them to [[dependency]]:

    ```
    use_os_feature = get_option('foo') \
      .disable_if(host_machine.system() == 'darwin', error_message : 'os feature not supported on MacOS')
    dep_os_feature = dependency('os_feature', require : use_os_feature)
    ```

  posargs:
    value:
      type: bool
      description: The value to check

  kwargs:
    error_message:
      type: str
      default: "''"
      description: The error Message to print if the check fails