57821d110aaa02d54ee2a6f349552b45d8e0e807
[platform/upstream/connectedhomeip.git] / src / platform / device.gni
1 # Copyright (c) 2020 Project CHIP Authors
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 import("//build_overrides/chip.gni")
16 import("${chip_root}/src/ble/ble.gni")
17
18 declare_args() {
19   # Device platform layer: cc13x2_26x2, darwin, efr32, esp32, external, freertos, linux, nrfconnect, k32w, qpg6100, none.
20   chip_device_platform = "auto"
21   chip_platform_target = ""
22 }
23
24 if (chip_device_platform == "auto") {
25   if (current_os == "mac" || current_os == "ios") {
26     chip_device_platform = "darwin"
27   } else if (current_os == "linux") {
28     chip_device_platform = "linux"
29   } else {
30     chip_device_platform = "none"
31   }
32 }
33
34 declare_args() {
35   # Enable openthread support.
36   chip_enable_openthread =
37       chip_device_platform == "linux" || chip_device_platform == "qpg6100" ||
38       chip_device_platform == "cc13x2_26x2" || chip_device_platform == "k32w"
39
40   # Enable wifi support.
41   chip_enable_wifi = chip_device_platform == "linux"
42
43   # Enable ble support.
44   chip_enable_ble =
45       chip_config_network_layer_ble &&
46       (chip_device_platform == "linux" || chip_device_platform == "darwin" ||
47        chip_device_platform == "cc13x2_26x2")
48
49   chip_enable_mdns =
50       chip_device_platform == "linux" || chip_device_platform == "esp32"
51 }
52
53 _chip_device_layer = "none"
54 if (chip_device_platform == "cc13x2_26x2") {
55   _chip_device_layer = "cc13x2_26x2"
56 } else if (chip_device_platform == "darwin") {
57   _chip_device_layer = "Darwin"
58 } else if (chip_device_platform == "efr32") {
59   _chip_device_layer = "EFR32"
60 } else if (chip_device_platform == "esp32") {
61   _chip_device_layer = "ESP32"
62 } else if (chip_device_platform == "linux") {
63   _chip_device_layer = "Linux"
64 } else if (chip_device_platform == "nrfconnect") {
65   _chip_device_layer = "nrfconnect"
66 } else if (chip_device_platform == "qpg6100") {
67   _chip_device_layer = "qpg6100"
68 } else if (chip_device_platform == "k32w") {
69   _chip_device_layer = "K32W"
70 }
71
72 if (chip_device_platform != "external") {
73   chip_ble_platform_config_include = ""
74   chip_device_platform_config_include = ""
75   chip_platform_config_include = ""
76   chip_inet_platform_config_include = ""
77   chip_system_platform_config_include = ""
78 } else {
79   declare_args() {
80     chip_ble_platform_config_include = ""
81     chip_device_platform_config_include = ""
82     chip_platform_config_include = ""
83     chip_inet_platform_config_include = ""
84     chip_system_platform_config_include = ""
85   }
86 }
87
88 if (_chip_device_layer != "none" && chip_device_platform != "external") {
89   chip_ble_platform_config_include =
90       "<platform/" + _chip_device_layer + "/BlePlatformConfig.h>"
91   chip_device_platform_config_include =
92       "<platform/" + _chip_device_layer + "/CHIPDevicePlatformConfig.h>"
93   chip_platform_config_include =
94       "<platform/" + _chip_device_layer + "/CHIPPlatformConfig.h>"
95   chip_inet_platform_config_include =
96       "<platform/" + _chip_device_layer + "/InetPlatformConfig.h>"
97   chip_system_platform_config_include =
98       "<platform/" + _chip_device_layer + "/SystemPlatformConfig.h>"
99 }
100
101 assert(
102     (current_os != "freertos" && chip_device_platform == "none") ||
103         chip_device_platform == "cc13x2_26x2" ||
104         chip_device_platform == "darwin" || chip_device_platform == "efr32" ||
105         chip_device_platform == "esp32" || chip_device_platform == "external" ||
106         chip_device_platform == "linux" ||
107         chip_device_platform == "nrfconnect" ||
108         chip_device_platform == "k32w" || chip_device_platform == "qpg6100",
109     "Please select a valid value for chip_device_platform")