Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / build / config / BUILDCONFIG.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 declare_args() {
16   # Debug build. Set this to false to remove development features.
17   is_debug = true
18 }
19
20 if (target_os == "") {
21   target_os = host_os
22 }
23
24 if (target_cpu == "") {
25   target_cpu = host_cpu
26 }
27
28 if (current_cpu == "") {
29   current_cpu = target_cpu
30 }
31 if (current_os == "") {
32   current_os = target_os
33 }
34
35 _build_overrides = {
36   import("//build_overrides/build.gni")
37 }
38
39 _pigweed_overrides = {
40   import("//build_overrides/pigweed.gni")
41 }
42
43 _chip_defaults = {
44   import("${_build_overrides.build_root}/config/defaults.gni")
45 }
46
47 declare_args() {
48   # Toolchain to use for host. This is usually set by default.
49   host_toolchain = ""
50 }
51
52 if (host_toolchain == "") {
53   if (_chip_defaults.is_clang) {
54     host_toolchain = "${_build_overrides.build_root}/toolchain/host:${host_os}_${host_cpu}_clang"
55   } else {
56     host_toolchain = "${_build_overrides.build_root}/toolchain/host:${host_os}_${host_cpu}_gcc"
57   }
58 }
59
60 if (_chip_defaults.custom_toolchain != "") {
61   _default_toolchain = _chip_defaults.custom_toolchain
62 } else if (target_os == host_os) {
63   _default_toolchain = host_toolchain
64 } else if (target_os == "all") {
65   _default_toolchain = "${_pigweed_overrides.dir_pw_toolchain}/dummy"
66 } else if (target_os == "freertos") {
67   if (target_cpu == "arm") {
68     _default_toolchain = "${_build_overrides.build_root}/toolchain/arm_gcc"
69   } else {
70     assert(false, "Unsupported target_cpu: ${target_cpu}")
71   }
72 } else if (target_os == "android") {
73   if (current_cpu == "arm") {
74     _default_toolchain =
75         "${_build_overrides.build_root}/toolchain/android:android_arm"
76   } else if (current_cpu == "arm64") {
77     _default_toolchain =
78         "${_build_overrides.build_root}/toolchain/android:android_arm64"
79   } else if (current_cpu == "x64") {
80     _default_toolchain =
81         "${_build_overrides.build_root}/toolchain/android:android_x64"
82   } else if (current_cpu == "x86") {
83     _default_toolchain =
84         "${_build_overrides.build_root}/toolchain/android:android_x86"
85   } else {
86     assert(false, "Unsupported target_cpu: ${current_cpu}")
87   }
88 } else if (target_os == "ios") {
89   _default_toolchain =
90       "${_build_overrides.build_root}/toolchain/ios:ios_${target_cpu}"
91 } else {
92   assert(false, "No toolchain specified, please specify custom_toolchain")
93 }
94
95 set_default_toolchain(_default_toolchain)
96
97 set_defaults("static_library") {
98   configs = _chip_defaults.default_configs
99 }
100 set_defaults("source_set") {
101   configs = _chip_defaults.default_configs
102 }
103 set_defaults("executable") {
104   configs =
105       _chip_defaults.default_configs + _chip_defaults.executable_default_configs
106 }
107 set_defaults("shared_library") {
108   configs = _chip_defaults.default_configs
109 }
110 set_defaults("loadable_module") {
111   configs = _chip_defaults.default_configs
112 }