Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / examples / lock-app / efr32 / 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/efr32_sdk.gni")
18
19 import("${build_root}/config/defaults.gni")
20 import("${efr32_sdk_build_root}/efr32_executable.gni")
21 import("${efr32_sdk_build_root}/efr32_sdk.gni")
22
23 assert(current_os == "freertos")
24
25 efr32_project_dir = "${chip_root}/examples/lock-app/efr32"
26 examples_plat_dir = "${chip_root}/examples/platform/efr32"
27
28 declare_args() {
29   # Dump memory usage at link time.
30   chip_print_memory_usage = false
31   setupPinCode = 73141520
32   enable_heap_monitoring = false
33 }
34
35 show_qr_code = true
36
37 # BRD4166A --> ThunderBoard Sense 2 (No LCD)
38 if (efr32_board == "BRD4166A") {
39   show_qr_code = false
40 }
41
42 efr32_sdk("sdk") {
43   include_dirs = [
44     "${chip_root}/src/platform/EFR32",
45     "${efr32_project_dir}/include",
46     "${examples_plat_dir}",
47     "${examples_plat_dir}/${efr32_family}/${efr32_board}",
48   ]
49
50   sources = [
51     "${efr32_project_dir}/include/CHIPProjectConfig.h",
52     "${efr32_project_dir}/include/FreeRTOSConfig.h",
53   ]
54
55   defines = [
56     "BOARD_ID=${efr32_board}",
57     "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
58     "SL_HEAP_SIZE=(10 * 1024)",
59   ]
60 }
61
62 efr32_executable("lock_app") {
63   include_dirs = []
64   defines = []
65   output_name = "chip-efr32-lock-example.out"
66
67   public_deps = [
68     ":sdk",
69     "${chip_root}/examples/common/QRCode",
70     "${chip_root}/examples/lock-app/lock-common",
71     "${chip_root}/src/lib",
72     "${chip_root}/src/setup_payload",
73     "${chip_root}/third_party/openthread/platforms:libopenthread-platform",
74     "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils",
75     "${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd",
76     "${chip_root}/third_party/openthread/repo:libopenthread-ftd",
77   ]
78
79   include_dirs += [
80     "include",
81     "${chip_root}/src/app/util",
82     "${chip_root}/src/app/server",
83     "${examples_plat_dir}",
84     "${examples_plat_dir}/${efr32_family}/${efr32_board}",
85   ]
86
87   sources = [
88     "${examples_plat_dir}/LEDWidget.cpp",
89     "${examples_plat_dir}/Service.cpp",
90     "${examples_plat_dir}/init_efrPlatform.cpp",
91     "${examples_plat_dir}/uart.c",
92     "src/AppTask.cpp",
93     "src/BoltLockManager.cpp",
94     "src/ButtonHandler.cpp",
95     "src/ZclCallbacks.cpp",
96     "src/main.cpp",
97   ]
98
99   if (show_qr_code) {
100     sources += [ "${examples_plat_dir}/display/lcd.c" ]
101
102     defines += [ "DISPLAY_ENABLED" ]
103   }
104   output_dir = root_out_dir
105
106   if (enable_heap_monitoring) {
107     defines += [ "HEAP_MONITORING" ]
108     sources += [ "${examples_plat_dir}/MemMonitoring.cpp" ]
109   }
110
111   if (efr32_family == "efr32mg12") {
112     ldscript = "${examples_plat_dir}/ldscripts/efr32-MG12P.ld"
113   } else if (efr32_family == "efr32mg21") {
114     ldscript = "${examples_plat_dir}/ldscripts/efr32-MG21.ld"
115   }
116
117   ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ]
118
119   if (chip_print_memory_usage) {
120     ldflags += [
121       "-Wl,--print-memory-usage",
122       "-fstack-usage",
123     ]
124   }
125 }
126
127 group("efr32") {
128   deps = [ ":lock_app" ]
129 }
130
131 group("default") {
132   deps = [ ":efr32" ]
133 }