-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Expand file tree
/
Copy pathenabled_devices.gni
More file actions
304 lines (292 loc) · 7.23 KB
/
Copy pathenabled_devices.gni
File metadata and controls
304 lines (292 loc) · 7.23 KB
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# Copyright (c) 2026 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Authoritative device-selection configuration for the GN (POSIX) build.
# Parallel to all-devices-common/device-factory/enabled_devices.cmake for the CMake build.
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("${chip_root}/build/chip/buildconfig_header.gni")
declare_args() {
# List of device types to enable. Empty list (default) means all devices.
# Use the factory registry key for each device: "contact-sensor", "on-off-light", etc.
all_devices_enabled_devices = []
# Output binary name override. Empty string (default) means auto-computed:
# all devices enabled → "all-devices-app"
# subset selected → "example-device-app"
# Any non-empty value is used as-is regardless of the device list.
all_devices_app_name = ""
# Ordered list of device types to instantiate at boot on platforms that
# honor this arg. Each entry is registered on a
# consecutive endpoint starting at endpoint 1. Empty list (default) means
# "use the factory's default single device".
# Every entry must also appear in all_devices_enabled_devices (or the list
# must be empty, i.e. "all enabled").
all_devices_default_devices = []
}
# Private helper — only used within this file.
_all_devices_all_enabled = all_devices_enabled_devices == []
# Devices available: list of "config name" and "define suffix"
#
# Added define suffix because gn has no "to uppercase" method beyond executing a script
# and exec_script seemed excessive.
#
# IMPORTANT:
# - Keep list in sync with enabled_devices.cmake
# - Remember to also update enabled_devices_config.h.in
# - Update scripts/build/build/targets.py to include the new device
_available_devices = [
[
"aggregator",
"AGGREGATOR",
],
[
"air-purifier",
"AIR_PURIFIER",
],
[
"air-quality-sensor",
"AIR_QUALITY_SENSOR",
],
[
"ambient-context-sensor",
"AMBIENT_CONTEXT_SENSOR",
],
[
"bridged-node",
"BRIDGED_NODE",
],
[
"chime",
"CHIME",
],
[
"contact-sensor",
"CONTACT_SENSOR",
],
[
"cooktop",
"COOKTOP",
],
[
"device-energy-management",
"DEVICE_ENERGY_MANAGEMENT",
],
[
"dimmable-light",
"DIMMABLE_LIGHT",
],
[
"dimmable-plug-in-unit",
"DIMMABLE_PLUG_IN_UNIT",
],
[
"dishwasher",
"DISHWASHER",
],
[
"doorbell",
"DOORBELL",
],
[
"electrical-sensor",
"ELECTRICAL_SENSOR",
],
[
"extractor-hood",
"EXTRACTOR_HOOD",
],
[
"fan",
"FAN",
],
[
"flow-sensor",
"FLOW_SENSOR",
],
[
"generic-switch",
"GENERIC_SWITCH",
],
[
"humidity-sensor",
"HUMIDITY_SENSOR",
],
[
"laundry-dryer",
"LAUNDRY_DRYER",
],
[
"laundry-washer",
"LAUNDRY_WASHER",
],
[
"light-sensor",
"LIGHT_SENSOR",
],
[
"microwave-oven",
"MICROWAVE_OVEN",
],
[
"mounted-dimmable-load-control",
"MOUNTED_DIMMABLE_LOAD_CONTROL",
],
[
"mounted-on-off-control",
"MOUNTED_ON_OFF_CONTROL",
],
[
"network-infrastructure-manager",
"NETWORK_INFRASTRUCTURE_MANAGER",
],
[
"occupancy-sensor",
"OCCUPANCY_SENSOR",
],
[
"on-off-light",
"ON_OFF_LIGHT",
],
[
"on-off-light-switch",
"ON_OFF_LIGHT_SWITCH",
],
[
"on-off-plug-in-unit",
"ON_OFF_PLUG_IN_UNIT",
],
[
"oven",
"OVEN",
],
[
"power-source",
"POWER_SOURCE",
],
[
"pressure-sensor",
"PRESSURE_SENSOR",
],
[
"proximity-ranger",
"PROXIMITY_RANGER",
],
[
"rain-sensor",
"RAIN_SENSOR",
],
[
"refrigerator",
"REFRIGERATOR",
],
[
"robotic-vacuum-cleaner",
"ROBOTIC_VACUUM_CLEANER",
],
[
"smoke-co-alarm",
"SMOKE_CO_ALARM",
],
[
"soil-sensor",
"SOIL_SENSOR",
],
[
"speaker",
"SPEAKER",
],
[
"temperature-sensor",
"TEMPERATURE_SENSOR",
],
[
"water-freeze-detector",
"WATER_FREEZE_DETECTOR",
],
[
"water-leak-detector",
"WATER_LEAK_DETECTOR",
],
[
"water-valve",
"WATER_VALVE",
],
]
# Computed output binary name — mirrors the three-way logic in enabled_devices.cmake.
# Exported (no leading underscore) so that posix/BUILD.gn can use it as output_name.
if (all_devices_app_name != "") {
all_devices_computed_name = all_devices_app_name
} else if (all_devices_enabled_devices == []) {
all_devices_computed_name = "all-devices-app"
} else {
all_devices_computed_name = "example-device-app"
}
template("enabled_devices_buildconfig_header") {
buildconfig_header(target_name) {
forward_variables_from(invoker,
[
"header",
"header_dir",
])
defines = []
foreach(_available_device, _available_devices) {
_enabled = _all_devices_all_enabled
foreach(_device, all_devices_enabled_devices) {
if (_device == _available_device[0]) {
_enabled = true
}
}
_name = _available_device[1]
defines += [ "ALL_DEVICES_ENABLE_${_name}=${_enabled}" ]
}
# Validate that every entry in all_devices_default_devices is a known
# device type, and (when a subset is enabled) also actually enabled.
foreach(_requested, all_devices_default_devices) {
_found = false
foreach(_available_device, _available_devices) {
if (_requested == _available_device[0]) {
_found = true
}
}
assert(_found,
"all_devices_default_devices contains unknown device type: " +
"\"${_requested}\". See _available_devices in " +
"enabled_devices.gni for the accepted values.")
if (!_all_devices_all_enabled) {
_also_enabled = false
foreach(_device, all_devices_enabled_devices) {
if (_device == _requested) {
_also_enabled = true
}
}
assert(_also_enabled,
"all_devices_default_devices entry \"${_requested}\" is not " +
"present in all_devices_enabled_devices; it would not be " +
"registered in the DeviceFactory and could not be " +
"instantiated.")
}
}
# Compile-time CSV + count of the default device set, consumed by
# platforms that pre-select their device types at build
# time rather than at runtime.
_default_devices_csv = string_join(",", all_devices_default_devices)
_default_devices_count = 0
foreach(_d, all_devices_default_devices) {
_default_devices_count = _default_devices_count + 1
}
defines += [
"ALL_DEVICES_DEFAULT_DEVICES=\"${_default_devices_csv}\"",
"ALL_DEVICES_DEFAULT_DEVICES_COUNT=${_default_devices_count}",
]
}
}