Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / lib / support / BUILD.gn
1 # Copyright (c) 2020-2021 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/nlassert.gni")
18 import("//build_overrides/nlfaultinjection.gni")
19 import("//build_overrides/nlio.gni")
20
21 import("${chip_root}/build/chip/chip_version.gni")
22 import("${chip_root}/build/chip/tests.gni")
23 import("${chip_root}/src/lib/core/core.gni")
24
25 action("gen_chip_version") {
26   script = "${chip_root}/scripts/gen_chip_version.py"
27
28   version_file = "${root_gen_dir}/include/CHIPVersion.h"
29   outputs = [ version_file ]
30   args = [
31     "--output_file=" + rebase_path(version_file, root_build_dir),
32     "--chip_major=${chip_version_major}",
33     "--chip_minor=${chip_version_minor}",
34     "--chip_patch=${chip_version_patch}",
35     "--chip_extra=${chip_version_extra}",
36   ]
37 }
38
39 source_set("logging_constants") {
40   sources = [ "logging/Constants.h" ]
41 }
42
43 source_set("chip_version_header") {
44   sources = get_target_outputs(":gen_chip_version")
45
46   deps = [ ":gen_chip_version" ]
47 }
48
49 static_library("support") {
50   output_name = "libSupportLayer"
51
52   sources = [
53     "Base64.cpp",
54     "Base64.h",
55     "BitFlags.h",
56     "BufferReader.cpp",
57     "BufferReader.h",
58     "BufferWriter.cpp",
59     "BufferWriter.h",
60     "BytesToHex.cpp",
61     "BytesToHex.h",
62     "CHIPArgParser.cpp",
63     "CHIPCounter.cpp",
64     "CHIPCounter.h",
65     "CHIPMem.cpp",
66     "CHIPMem.h",
67     "CHIPMemString.h",
68     "CHIPPlatformMemory.cpp",
69     "CHIPPlatformMemory.h",
70     "CodeUtils.h",
71     "DLLUtil.h",
72     "ErrorStr.cpp",
73     "ErrorStr.h",
74     "FibonacciUtils.cpp",
75     "FibonacciUtils.h",
76     "LifetimePersistedCounter.cpp",
77     "LifetimePersistedCounter.h",
78     "PersistedCounter.cpp",
79     "PersistedCounter.h",
80     "Pool.cpp",
81     "Pool.h",
82     "PrivateHeap.cpp",
83     "PrivateHeap.h",
84     "RandUtils.cpp",
85     "RandUtils.h",
86     "SafeInt.h",
87     "SerializableIntegerSet.cpp",
88     "SerializableIntegerSet.h",
89     "TimeUtils.cpp",
90     "TimeUtils.h",
91     "UnitTestRegistration.cpp",
92     "UnitTestRegistration.h",
93     "logging/CHIPLogging.cpp",
94     "logging/CHIPLogging.h",
95     "verhoeff/Verhoeff.cpp",
96     "verhoeff/Verhoeff.h",
97     "verhoeff/Verhoeff10.cpp",
98     "verhoeff/Verhoeff16.cpp",
99     "verhoeff/Verhoeff32.cpp",
100     "verhoeff/Verhoeff36.cpp",
101   ]
102
103   libs = []
104
105   cflags = [ "-Wconversion" ]
106
107   public_deps = [
108     ":chip_version_header",
109     ":logging_constants",
110     "${chip_root}/src/lib/core:chip_config_header",
111     "${chip_root}/src/platform/logging:headers",
112     "${nlassert_root}:nlassert",
113     "${nlio_root}:nlio",
114   ]
115
116   # These are needed because we include CHIPCore.h, which uses config
117   # options for src/ble and src/inet, however we cannot depend on those
118   # directly as such a dependency is cyclic.
119   public_deps += [
120     "${chip_root}/src/ble:ble_config_header",
121     "${chip_root}/src/inet:inet_config_header",
122   ]
123
124   # Android has no 'platform' that provides logging
125   if (current_os == "android") {
126     public_deps += [ "${chip_root}/src/platform/logging:android" ]
127   }
128
129   public_configs = [
130     "${chip_root}/src:includes",
131     "${chip_root}/src/lib:includes",
132     "${chip_root}/src/system:system_config",
133   ]
134
135   if (chip_config_memory_management == "simple") {
136     sources += [ "CHIPMem-Simple.cpp" ]
137   }
138   if (chip_config_memory_management == "malloc") {
139     sources += [ "CHIPMem-Malloc.cpp" ]
140   }
141   if (chip_with_nlfaultinjection) {
142     sources += [
143       "CHIPFaultInjection.cpp",
144       "CHIPFaultInjection.h",
145     ]
146     public_deps += [ "${nlfaultinjection_root}:nlfaultinjection" ]
147   }
148
149   if (chip_config_memory_debug_dmalloc) {
150     libs += [ "dmallocthcxx" ]
151   }
152 }