Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / targets / host / target_toolchains.gni
1 # Copyright 2020 The Pigweed Authors
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 # use this file except in compliance with the License. You may obtain a copy of
5 # the License at
6 #
7 #     https://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, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations under
13 # the License.
14
15 import("//build_overrides/pigweed.gni")
16
17 import("$dir_pw_chrono/backend.gni")
18 import("$dir_pw_protobuf_compiler/proto.gni")
19 import("$dir_pw_rpc/system_server/backend.gni")
20 import("$dir_pw_sync/backend.gni")
21 import("$dir_pw_sys_io/backend.gni")
22 import("$dir_pw_third_party/nanopb/nanopb.gni")
23 import("$dir_pw_thread/backend.gni")
24 import("$dir_pw_toolchain/host_clang/toolchains.gni")
25 import("$dir_pw_toolchain/host_gcc/toolchains.gni")
26
27 _host_common = {
28   # Use logging-based test output on host.
29   pw_unit_test_MAIN = "$dir_pw_unit_test:logging_main"
30
31   # Configure backend for assert facade.
32   pw_assert_BACKEND = "$dir_pw_assert_basic"
33
34   # Configure backend for logging facade.
35   pw_log_BACKEND = "$dir_pw_log_basic"
36
37   # Configure backends for pw_sync's facades.
38   pw_sync_SPIN_LOCK_BACKEND = "$dir_pw_sync_stl:spin_lock_backend"
39
40   # Configure backend for pw_sys_io facade.
41   pw_sys_io_BACKEND = "$dir_pw_sys_io_stdio"
42
43   # Configure backend for pw_rpc_system_server.
44   pw_rpc_system_server_BACKEND = "$dir_pigweed/targets/host:system_rpc_server"
45
46   # Configure backend for trace facade.
47   pw_trace_BACKEND = "$dir_pw_trace_tokenized"
48
49   # Tokenizer trace time.
50   pw_trace_tokenizer_time = "$dir_pw_trace_tokenized:host_trace_time"
51
52   # Configure backend for pw_chrono's system_clock facade.
53   pw_chrono_SYSTEM_CLOCK_BACKEND = "$dir_pw_chrono_stl:system_clock"
54
55   # Specify builtin GN variables.
56   current_os = host_os
57   current_cpu = host_cpu
58 }
59
60 # Linux-specific target configuration.
61 _linux_config = {
62   pw_bloat_BLOATY_CONFIG = get_path_info("linux.bloaty", "abspath")
63   pw_unit_test_AUTOMATIC_RUNNER = get_path_info("run_test", "abspath")
64 }
65
66 # macOS-specific target configuration.
67 _mac_config = {
68   pw_bloat_BLOATY_CONFIG = get_path_info("macos.bloaty", "abspath")
69   pw_unit_test_AUTOMATIC_RUNNER = get_path_info("run_test", "abspath")
70 }
71
72 # Windows-specific target configuration.
73 _win_config = {
74   # This is here as bloaty_config_file cannot be an empty string or GN fails.
75   # TODO(frolv): Add this file and enable size reports on Windows.
76   pw_bloat_BLOATY_CONFIG = get_path_info("windows.bloaty", "abspath")
77   pw_unit_test_AUTOMATIC_RUNNER = get_path_info("run_test.bat", "abspath")
78 }
79
80 # TODO(amontanez): figure out why std::mutex doesn't work on Windows.
81 # These current target configurations do not work on windows.
82 _win_incompatible_config = {
83   # Configure backends for pw_sync's facades.
84   pw_sync_BINARY_SEMAPHORE_BACKEND = "$dir_pw_sync_stl:binary_semaphore_backend"
85   pw_sync_COUNTING_SEMAPHORE_BACKEND =
86       "$dir_pw_sync_stl:counting_semaphore_backend"
87   pw_sync_MUTEX_BACKEND = "$dir_pw_sync_stl:mutex_backend"
88
89   # Configure backends for pw_thread's facades.
90   pw_thread_ID_BACKEND = "$dir_pw_thread_stl:id"
91   pw_thread_SLEEP_BACKEND = "$dir_pw_thread_stl:sleep"
92   pw_thread_YIELD_BACKEND = "$dir_pw_thread_stl:yield"
93 }
94
95 _os_specific_config = {
96   if (host_os == "linux") {
97     forward_variables_from(_linux_config, "*")
98     forward_variables_from(_win_incompatible_config, "*")
99   } else if (host_os == "mac") {
100     forward_variables_from(_mac_config, "*")
101     forward_variables_from(_win_incompatible_config, "*")
102   } else if (host_os == "win") {
103     forward_variables_from(_win_config, "*")
104   }
105 }
106
107 _target_default_configs = [ "$dir_pw_build:extra_strict_warnings" ]
108
109 pw_target_toolchain_host = {
110   _excluded_members = [
111     "defaults",
112     "name",
113   ]
114
115   clang_debug = {
116     name = "host_clang_debug"
117     _toolchain_base = pw_toolchain_host_clang.debug
118     forward_variables_from(_toolchain_base, "*", _excluded_members)
119     defaults = {
120       forward_variables_from(_toolchain_base.defaults, "*")
121       forward_variables_from(_host_common, "*")
122       forward_variables_from(_os_specific_config, "*")
123       default_configs += _target_default_configs
124     }
125   }
126
127   clang_speed_optimized = {
128     name = "host_clang_speed_optimized"
129     _toolchain_base = pw_toolchain_host_clang.speed_optimized
130     forward_variables_from(_toolchain_base, "*", _excluded_members)
131     defaults = {
132       forward_variables_from(_toolchain_base.defaults, "*")
133       forward_variables_from(_host_common, "*")
134       forward_variables_from(_os_specific_config, "*")
135       default_configs += _target_default_configs
136     }
137   }
138
139   clang_size_optimized = {
140     name = "host_clang_size_optimized"
141     _toolchain_base = pw_toolchain_host_clang.size_optimized
142     forward_variables_from(_toolchain_base, "*", _excluded_members)
143     defaults = {
144       forward_variables_from(_toolchain_base.defaults, "*")
145       forward_variables_from(_host_common, "*")
146       forward_variables_from(_os_specific_config, "*")
147       default_configs += _target_default_configs
148     }
149   }
150
151   clang_fuzz = {
152     name = "host_clang_fuzz"
153     _toolchain_base = pw_toolchain_host_clang.fuzz
154     forward_variables_from(_toolchain_base, "*", _excluded_members)
155     defaults = {
156       forward_variables_from(_toolchain_base.defaults, "*")
157       forward_variables_from(_host_common, "*")
158       forward_variables_from(_os_specific_config, "*")
159       default_configs += _target_default_configs
160     }
161   }
162
163   gcc_debug = {
164     name = "host_gcc_debug"
165     _toolchain_base = pw_toolchain_host_gcc.debug
166     forward_variables_from(_toolchain_base, "*", _excluded_members)
167     defaults = {
168       forward_variables_from(_toolchain_base.defaults, "*")
169       forward_variables_from(_host_common, "*")
170       forward_variables_from(_os_specific_config, "*")
171       default_configs += _target_default_configs
172     }
173   }
174
175   gcc_speed_optimized = {
176     name = "host_gcc_speed_optimized"
177     _toolchain_base = pw_toolchain_host_gcc.speed_optimized
178     forward_variables_from(_toolchain_base, "*", _excluded_members)
179     defaults = {
180       forward_variables_from(_toolchain_base.defaults, "*")
181       forward_variables_from(_host_common, "*")
182       forward_variables_from(_os_specific_config, "*")
183       default_configs += _target_default_configs
184     }
185   }
186
187   gcc_size_optimized = {
188     name = "host_gcc_size_optimized"
189     _toolchain_base = pw_toolchain_host_gcc.size_optimized
190     forward_variables_from(_toolchain_base, "*", _excluded_members)
191     defaults = {
192       forward_variables_from(_toolchain_base.defaults, "*")
193       forward_variables_from(_host_common, "*")
194       forward_variables_from(_os_specific_config, "*")
195       default_configs += _target_default_configs
196     }
197   }
198 }
199
200 # This list just contains the members of the above scope for convenience to make
201 # it trivial to generate all the toolchains in this file via a
202 # `generate_toolchains` target.
203 pw_target_toolchain_host_list = [
204   pw_target_toolchain_host.clang_debug,
205   pw_target_toolchain_host.clang_speed_optimized,
206   pw_target_toolchain_host.clang_size_optimized,
207   pw_target_toolchain_host.clang_fuzz,
208   pw_target_toolchain_host.gcc_debug,
209   pw_target_toolchain_host.gcc_speed_optimized,
210   pw_target_toolchain_host.gcc_size_optimized,
211 ]