aboutsummaryrefslogtreecommitdiff
path: root/docs/selects_doc.md
blob: 55711c90792b48354b6efd1b0b581fa74dce779c (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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<!-- Generated with Stardoc: http://skydoc.bazel.build -->

<a name="#selects.with_or"></a>

## selects.with_or

<pre>
selects.with_or(<a href="#selects.with_or-input_dict">input_dict</a>, <a href="#selects.with_or-no_match_error">no_match_error</a>)
</pre>

Drop-in replacement for `select()` that supports ORed keys.

Example:

      ```build
      deps = selects.with_or({
          "//configs:one": [":dep1"],
          ("//configs:two", "//configs:three"): [":dep2or3"],
          "//configs:four": [":dep4"],
          "//conditions:default": [":default"]
      })
      ```

      Key labels may appear at most once anywhere in the input.


### Parameters

<table class="params-table">
  <colgroup>
    <col class="col-param" />
    <col class="col-description" />
  </colgroup>
  <tbody>
    <tr id="selects.with_or-input_dict">
      <td><code>input_dict</code></td>
      <td>
        required.
        <p>
          The same dictionary `select()` takes, except keys may take
    either the usual form `"//foo:config1"` or
    `("//foo:config1", "//foo:config2", ...)` to signify
    `//foo:config1` OR `//foo:config2` OR `...`.
        </p>
      </td>
    </tr>
    <tr id="selects.with_or-no_match_error">
      <td><code>no_match_error</code></td>
      <td>
        optional. default is <code>""</code>
        <p>
          Optional custom error to report if no condition matches.
        </p>
      </td>
    </tr>
  </tbody>
</table>


<a name="#selects.with_or_dict"></a>

## selects.with_or_dict

<pre>
selects.with_or_dict(<a href="#selects.with_or_dict-input_dict">input_dict</a>)
</pre>

Variation of `with_or` that returns the dict of the `select()`.

Unlike `select()`, the contents of the dict can be inspected by Starlark
macros.


### Parameters

<table class="params-table">
  <colgroup>
    <col class="col-param" />
    <col class="col-description" />
  </colgroup>
  <tbody>
    <tr id="selects.with_or_dict-input_dict">
      <td><code>input_dict</code></td>
      <td>
        required.
        <p>
          Same as `with_or`.
        </p>
      </td>
    </tr>
  </tbody>
</table>


<a name="#selects.config_setting_group"></a>

## selects.config_setting_group

<pre>
selects.config_setting_group(<a href="#selects.config_setting_group-name">name</a>, <a href="#selects.config_setting_group-match_any">match_any</a>, <a href="#selects.config_setting_group-match_all">match_all</a>)
</pre>

Matches if all or any of its member `config_setting`s match.

Example:

  ```build
  config_setting(name = "one", define_values = {"foo": "true"})
  config_setting(name = "two", define_values = {"bar": "false"})
  config_setting(name = "three", define_values = {"baz": "more_false"})

  config_setting_group(
      name = "one_two_three",
      match_all = [":one", ":two", ":three"]
  )

  cc_binary(
      name = "myapp",
      srcs = ["myapp.cc"],
      deps = select({
          ":one_two_three": [":special_deps"],
          "//conditions:default": [":default_deps"]
      })
  ```


### Parameters

<table class="params-table">
  <colgroup>
    <col class="col-param" />
    <col class="col-description" />
  </colgroup>
  <tbody>
    <tr id="selects.config_setting_group-name">
      <td><code>name</code></td>
      <td>
        required.
        <p>
          The group's name. This is how `select()`s reference it.
        </p>
      </td>
    </tr>
    <tr id="selects.config_setting_group-match_any">
      <td><code>match_any</code></td>
      <td>
        optional. default is <code>[]</code>
        <p>
          A list of `config_settings`. This group matches if *any* member
    in the list matches. If this is set, `match_all` must not be set.
        </p>
      </td>
    </tr>
    <tr id="selects.config_setting_group-match_all">
      <td><code>match_all</code></td>
      <td>
        optional. default is <code>[]</code>
        <p>
          A list of `config_settings`. This group matches if *every*
    member in the list matches. If this is set, `match_any` must be not
    set.
        </p>
      </td>
    </tr>
  </tbody>
</table>