Apply Upstream code (2021-03-15)
[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   if (chip_device_platform == "linux" || chip_device_platform == "esp32") {
50     chip_mdns = "minimal"
51   } else {
52     chip_mdns = "none"
53   }
54 }
55
56 _chip_device_layer = "none"
57 if (chip_device_platform == "cc13x2_26x2") {
58   _chip_device_layer = "cc13x2_26x2"
59 } else if (chip_device_platform == "darwin") {
60   _chip_device_layer = "Darwin"
61 } else if (chip_device_platform == "efr32") {
62   _chip_device_layer = "EFR32"
63 } else if (chip_device_platform == "esp32") {
64   _chip_device_layer = "ESP32"
65 } else if (chip_device_platform == "linux") {
66   _chip_device_layer = "Linux"
67 } else if (chip_device_platform == "nrfconnect") {
68   _chip_device_layer = "nrfconnect"
69 } else if (chip_device_platform == "qpg6100") {
70   _chip_device_layer = "qpg6100"
71 } else if (chip_device_platform == "k32w") {
72   _chip_device_layer = "K32W"
73 }
74
75 if (chip_device_platform != "external") {
76   chip_ble_platform_config_include = ""
77   chip_device_platform_config_include = ""
78   chip_platform_config_include = ""
79   chip_inet_platform_config_include = ""
80   chip_system_platform_config_include = ""
81 } else {
82   declare_args() {
83     chip_ble_platform_config_include = ""
84     chip_device_platform_config_include = ""
85     chip_platform_config_include = ""
86     chip_inet_platform_config_include = ""
87     chip_system_platform_config_include = ""
88   }
89 }
90
91 if (_chip_device_layer != "none" && chip_device_platform != "external") {
92   chip_ble_platform_config_include =
93       "<platform/" + _chip_device_layer + "/BlePlatformConfig.h>"
94   chip_device_platform_config_include =
95       "<platform/" + _chip_device_layer + "/CHIPDevicePlatformConfig.h>"
96   chip_platform_config_include =
97       "<platform/" + _chip_device_layer + "/CHIPPlatformConfig.h>"
98   chip_inet_platform_config_include =
99       "<platform/" + _chip_device_layer + "/InetPlatformConfig.h>"
100   chip_system_platform_config_include =
101       "<platform/" + _chip_device_layer + "/SystemPlatformConfig.h>"
102 }
103
104 assert(
105     (current_os != "freertos" && chip_device_platform == "none") ||
106         chip_device_platform == "cc13x2_26x2" ||
107         chip_device_platform == "darwin" || chip_device_platform == "efr32" ||
108         chip_device_platform == "esp32" || chip_device_platform == "external" ||
109         chip_device_platform == "linux" ||
110         chip_device_platform == "nrfconnect" ||
111         chip_device_platform == "k32w" || chip_device_platform == "qpg6100",
112     "Please select a valid value for chip_device_platform")