third_party.pigweed.src/targets/host/target_toolchains.gni
Ewout van Bekkum e3b5603919 pw_thread: adds the initial pw_thread module
Adds a std::this_thread like API through the pw_thread facades, that
is:
1) this_thread::yield
2) this_thread::sleep_{for,until}
3) this_thread::get_id

This module is split into many different facades in order to let users
decide what functionality they want to use as they may not always
be available, for example when using opaque SDKs.

In addition this provides an initial set of backends based on using
the STL's std::this_thread directly and selects them for the host
target.

Change-Id: I0ee8e4390ba988b2b13e9ee59f976f2333715f1f
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/30040
Commit-Queue: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
2021-01-28 01:47:20 +00:00

199 lines
6.8 KiB
Plaintext

# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
import("//build_overrides/pigweed.gni")
import("$dir_pw_chrono/backend.gni")
import("$dir_pw_protobuf_compiler/proto.gni")
import("$dir_pw_rpc/system_server/backend.gni")
import("$dir_pw_sync/backend.gni")
import("$dir_pw_sys_io/backend.gni")
import("$dir_pw_third_party/nanopb/nanopb.gni")
import("$dir_pw_thread/backend.gni")
import("$dir_pw_toolchain/host_clang/toolchains.gni")
import("$dir_pw_toolchain/host_gcc/toolchains.gni")
_host_common = {
# Use logging-based test output on host.
pw_unit_test_MAIN = "$dir_pw_unit_test:logging_main"
# Configure backend for assert facade.
pw_assert_BACKEND = "$dir_pw_assert_basic"
# Configure backend for logging facade.
pw_log_BACKEND = "$dir_pw_log_basic"
# Configure backends for pw_sync's facades.
pw_sync_SPIN_LOCK_BACKEND = "$dir_pw_sync_stl:spin_lock_backend"
# Configure backend for pw_sys_io facade.
pw_sys_io_BACKEND = "$dir_pw_sys_io_stdio"
# Configure backend for pw_rpc_system_server.
pw_rpc_system_server_BACKEND = "$dir_pigweed/targets/host:system_rpc_server"
# Configure backend for trace facade.
pw_trace_BACKEND = "$dir_pw_trace_tokenized"
# Tokenizer trace time.
pw_trace_tokenizer_time = "$dir_pw_trace_tokenized:host_trace_time"
# Configure backend for pw_chrono's system_clock facade.
pw_chrono_SYSTEM_CLOCK_BACKEND = "$dir_pw_chrono_stl:system_clock"
# Specify builtin GN variables.
current_os = host_os
current_cpu = host_cpu
}
# Linux-specific target configuration.
_linux_config = {
pw_bloat_BLOATY_CONFIG = get_path_info("linux.bloaty", "abspath")
pw_unit_test_AUTOMATIC_RUNNER = get_path_info("run_test", "abspath")
}
# macOS-specific target configuration.
_mac_config = {
pw_bloat_BLOATY_CONFIG = get_path_info("macos.bloaty", "abspath")
pw_unit_test_AUTOMATIC_RUNNER = get_path_info("run_test", "abspath")
}
# Windows-specific target configuration.
_win_config = {
# This is here as bloaty_config_file cannot be an empty string or GN fails.
# TODO(frolv): Add this file and enable size reports on Windows.
pw_bloat_BLOATY_CONFIG = get_path_info("windows.bloaty", "abspath")
pw_unit_test_AUTOMATIC_RUNNER = get_path_info("run_test.bat", "abspath")
}
# TODO(amontanez): figure out why std::mutex doesn't work on Windows.
# These current target configurations do not work on windows.
_win_incompatible_config = {
# Configure backends for pw_sync's facades.
pw_sync_BINARY_SEMAPHORE_BACKEND = "$dir_pw_sync_stl:binary_semaphore_backend"
pw_sync_COUNTING_SEMAPHORE_BACKEND =
"$dir_pw_sync_stl:counting_semaphore_backend"
pw_sync_MUTEX_BACKEND = "$dir_pw_sync_stl:mutex_backend"
# Configure backends for pw_thread's facades.
pw_thread_ID_BACKEND = "$dir_pw_thread_stl:id"
pw_thread_SLEEP_BACKEND = "$dir_pw_thread_stl:sleep"
pw_thread_YIELD_BACKEND = "$dir_pw_thread_stl:yield"
}
_os_specific_config = {
if (host_os == "linux") {
forward_variables_from(_linux_config, "*")
forward_variables_from(_win_incompatible_config, "*")
} else if (host_os == "mac") {
forward_variables_from(_mac_config, "*")
forward_variables_from(_win_incompatible_config, "*")
} else if (host_os == "win") {
forward_variables_from(_win_config, "*")
}
}
_target_default_configs = [ "$dir_pw_build:extra_strict_warnings" ]
pw_target_toolchain_host = {
_excluded_members = [
"defaults",
"name",
]
clang_debug = {
name = "host_clang_debug"
_toolchain_base = pw_toolchain_host_clang.debug
forward_variables_from(_toolchain_base, "*", _excluded_members)
defaults = {
forward_variables_from(_toolchain_base.defaults, "*")
forward_variables_from(_host_common, "*")
forward_variables_from(_os_specific_config, "*")
default_configs += _target_default_configs
}
}
clang_speed_optimized = {
name = "host_clang_speed_optimized"
_toolchain_base = pw_toolchain_host_clang.speed_optimized
forward_variables_from(_toolchain_base, "*", _excluded_members)
defaults = {
forward_variables_from(_toolchain_base.defaults, "*")
forward_variables_from(_host_common, "*")
forward_variables_from(_os_specific_config, "*")
default_configs += _target_default_configs
}
}
clang_size_optimized = {
name = "host_clang_size_optimized"
_toolchain_base = pw_toolchain_host_clang.size_optimized
forward_variables_from(_toolchain_base, "*", _excluded_members)
defaults = {
forward_variables_from(_toolchain_base.defaults, "*")
forward_variables_from(_host_common, "*")
forward_variables_from(_os_specific_config, "*")
default_configs += _target_default_configs
}
}
gcc_debug = {
name = "host_gcc_debug"
_toolchain_base = pw_toolchain_host_gcc.debug
forward_variables_from(_toolchain_base, "*", _excluded_members)
defaults = {
forward_variables_from(_toolchain_base.defaults, "*")
forward_variables_from(_host_common, "*")
forward_variables_from(_os_specific_config, "*")
default_configs += _target_default_configs
}
}
gcc_speed_optimized = {
name = "host_gcc_speed_optimized"
_toolchain_base = pw_toolchain_host_gcc.speed_optimized
forward_variables_from(_toolchain_base, "*", _excluded_members)
defaults = {
forward_variables_from(_toolchain_base.defaults, "*")
forward_variables_from(_host_common, "*")
forward_variables_from(_os_specific_config, "*")
default_configs += _target_default_configs
}
}
gcc_size_optimized = {
name = "host_gcc_size_optimized"
_toolchain_base = pw_toolchain_host_gcc.size_optimized
forward_variables_from(_toolchain_base, "*", _excluded_members)
defaults = {
forward_variables_from(_toolchain_base.defaults, "*")
forward_variables_from(_host_common, "*")
forward_variables_from(_os_specific_config, "*")
default_configs += _target_default_configs
}
}
}
# This list just contains the members of the above scope for convenience to make
# it trivial to generate all the toolchains in this file via a
# `generate_toolchains` target.
pw_target_toolchain_host_list = [
pw_target_toolchain_host.clang_debug,
pw_target_toolchain_host.clang_speed_optimized,
pw_target_toolchain_host.clang_size_optimized,
pw_target_toolchain_host.gcc_debug,
pw_target_toolchain_host.gcc_speed_optimized,
pw_target_toolchain_host.gcc_size_optimized,
]