Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / lwip / BUILD.gn
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/build.gni")
16 import("//build_overrides/chip.gni")
17 import("//build_overrides/lwip.gni")
18
19 import("${chip_root}/build/chip/buildconfig_header.gni")
20 import("${chip_root}/src/lwip/lwip.gni")
21 import("${lwip_root}/lwip.gni")
22
23 assert(chip_with_lwip)
24
25 if (lwip_platform == "") {
26   if (current_os != "freertos") {
27     lwip_platform = "standalone"
28   }
29 }
30
31 assert(lwip_platform == "external" || lwip_platform == "standalone" ||
32            lwip_platform == "cc13x2_26x2" || lwip_platform == "efr32" ||
33            lwip_platform == "k32w" || lwip_platform == "qpg6100",
34        "Unsupported lwIP platform: ${lwip_platform}")
35
36 if (lwip_platform != "external") {
37   declare_args() {
38     # Enable lwIP debugging.
39     lwip_debug = is_debug
40   }
41 }
42
43 if (lwip_platform == "cc13x2_26x2") {
44   import("//build_overrides/ti_simplelink_sdk.gni")
45 } else if (lwip_platform == "efr32") {
46   import("//build_overrides/efr32_sdk.gni")
47 } else if (lwip_platform == "qpg6100") {
48   import("//build_overrides/qpg6100_sdk.gni")
49 } else if (lwip_platform == "k32w") {
50   import("//build_overrides/k32w_sdk.gni")
51 }
52
53 buildconfig_header("lwip_buildconfig") {
54   header = "lwip_buildconfig.h"
55   header_dir = "lwip"
56
57   defines = [ "HAVE_LWIP_UDP_BIND_NETIF=1" ]
58   if (lwip_platform != "external") {
59     if (is_debug) {
60       # Automatically enable LWIP_DEBUG for internal is_debug builds.
61       defines += [ "LWIP_DEBUG=1" ]
62     }
63
64     if (current_os == "android") {
65       defines += [ "LWIP_NO_STDINT_H=1" ]
66     }
67   }
68 }
69
70 if (current_os == "zephyr") {
71   group("lwip") {
72   }
73 } else if (lwip_platform == "external") {
74   group("lwip") {
75     public_deps = [ ":lwip_buildconfig" ]
76   }
77
78   group("all") {
79     deps = [ ":lwip" ]
80   }
81 } else {
82   config("lwip_config") {
83     include_dirs = [ lwip_platform ]
84
85     if (lwip_platform != "standalone") {
86       include_dirs += [ "freertos" ]
87     }
88   }
89
90   lwip_target("lwip") {
91     public = [
92       "${lwip_platform}/arch/cc.h",
93       "${lwip_platform}/arch/perf.h",
94       "${lwip_platform}/lwipopts.h",
95     ]
96
97     sources = []
98
99     if (lwip_platform == "standalone") {
100       public += [ "standalone/arch/sys_arch.h" ]
101       sources += [ "standalone/sys_arch.c" ]
102     } else {
103       public += [
104         "${lwip_platform}/lwippools.h",
105         "freertos/arch/sys_arch.h",
106       ]
107       sources += [ "freertos/sys_arch.c" ]
108     }
109
110     public_deps = [ ":lwip_buildconfig" ]
111     if (lwip_platform == "cc13x2_26x2") {
112       public_deps += [ "${ti_simplelink_sdk_build_root}:ti_simplelink_sdk" ]
113     } else if (lwip_platform == "efr32") {
114       public_deps += [ "${efr32_sdk_build_root}:efr32_sdk" ]
115     } else if (lwip_platform == "qpg6100") {
116       public_deps += [ "${qpg6100_sdk_build_root}:qpg6100_sdk" ]
117     } else if (lwip_platform == "standalone") {
118       public_deps += [ "${chip_root}/src/lib/support" ]
119     } else if (lwip_platform == "k32w") {
120       public_deps += [ "${k32w_sdk_build_root}:k32w_sdk" ]
121     }
122
123     public_configs = [
124       ":lwip_config",
125       "${chip_root}/src:includes",
126     ]
127   }
128   group("all") {
129     deps = [ ":lwip_all" ]
130   }
131 }