blob: 0670e319279da8cec559e1edddab7eb39fe5c349 [file] [log] [blame]
# Copyright 2021 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_pigweed/third_party/freertos/freertos.gni")
import("$dir_pigweed/third_party/nanopb/nanopb.gni")
import("$dir_pigweed/third_party/stm32cube/stm32cube.gni")
import("$dir_pw_build/error.gni")
import("$dir_pw_build/facade.gni")
import("$dir_pw_build/module_config.gni")
import("$dir_pw_build/target_types.gni")
import("$dir_pw_docgen/docs.gni")
import("backend.gni")
declare_args() {
# The build target that overrides the default configuration options for this
# module. This should point to a source set that provides defines through a
# public config (which may -include a file or add defines directly).
pw_system_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
}
config("public_include_path") {
include_dirs = [ "public" ]
}
pw_source_set("config") {
sources = [ "public/pw_system/config.h" ]
public_configs = [ ":public_include_path" ]
public_deps = [ pw_system_CONFIG ]
visibility = [ "./*" ]
friend = [ "./*" ]
}
group("pw_system") {
public_deps = [
":init",
":io",
":log",
":rpc",
":work_queue",
]
deps = [ ":target_hooks" ]
}
pw_source_set("log") {
public_configs = [ ":public_include_path" ]
sources = [
"log.cc",
"pw_system_private/log.h",
]
public_deps = [
":config",
"$dir_pw_log_rpc:log_service",
"$dir_pw_log_rpc:rpc_log_drain_thread",
]
deps = [
":rpc",
"$dir_pw_bytes",
"$dir_pw_chrono:system_clock",
"$dir_pw_log",
"$dir_pw_log:proto_utils",
"$dir_pw_log_rpc:rpc_log_drain",
"$dir_pw_log_tokenized:metadata",
"$dir_pw_multisink",
"$dir_pw_result",
"$dir_pw_sync:interrupt_spin_lock",
"$dir_pw_sync:lock_annotations",
"$dir_pw_sync:mutex",
"$dir_pw_tokenizer",
"$dir_pw_tokenizer:global_handler_with_payload.facade",
]
}
pw_source_set("rpc") {
visibility = [ ":*" ]
sources = [
"pw_system_private/rpc.h",
"rpc.cc",
]
public_configs = [ ":public_include_path" ]
public_deps = [
":config",
"$dir_pw_rpc/system_server:facade",
"$dir_pw_thread:thread_core",
]
deps = [
":io",
"$dir_pw_assert",
"$dir_pw_hdlc:pw_rpc",
"$dir_pw_hdlc:rpc_channel_output",
"$dir_pw_rpc:synchronized_channel_output",
"$dir_pw_sync:mutex",
]
}
pw_facade("io") {
backend = pw_system_IO_BACKEND
visibility = [ ":*" ]
public_configs = [ ":public_include_path" ]
public = [ "public/pw_system/io.h" ]
public_deps = [ "$dir_pw_stream" ]
}
pw_source_set("init") {
public_configs = [ ":public_include_path" ]
public = [ "public/pw_system/init.h" ]
sources = [ "init.cc" ]
deps = [
":log",
":rpc",
":target_hooks.facade",
":work_queue",
"$dir_pw_rpc/nanopb:echo_service",
"$dir_pw_thread:thread",
]
}
pw_source_set("work_queue") {
visibility = [ ":*" ]
public_configs = [ ":public_include_path" ]
public = [ "public/pw_system/work_queue.h" ]
sources = [ "work_queue.cc" ]
public_deps = [ "$dir_pw_work_queue" ]
deps = [ ":config" ]
}
pw_source_set("sys_io_target_io") {
sources = [ "target_io.cc" ]
deps = [
":io.facade",
"$dir_pw_stream",
"$dir_pw_stream:sys_io_stream",
]
}
pw_facade("target_hooks") {
backend = pw_system_TARGET_HOOKS_BACKEND
public = [ "public/pw_system/target_hooks.h" ]
public_deps = [ "$dir_pw_thread:thread" ]
public_configs = [ ":public_include_path" ]
}
if (pw_system_TARGET_HOOKS_BACKEND == "") {
# Do nothing, prevents errors from trying to parse pw_system_TARGET_HOOKS_BACKEND as a
# build target when it's unset.
} else if (get_label_info(pw_system_TARGET_HOOKS_BACKEND,
"label_no_toolchain") ==
get_label_info(":stl_target_hooks", "label_no_toolchain")) {
pw_source_set("stl_target_hooks") {
deps = [
":init",
"$dir_pw_thread:sleep",
"$dir_pw_thread:thread",
"$dir_pw_thread_stl:thread",
]
sources = [ "stl_target_hooks.cc" ]
}
} else if (get_label_info(pw_system_TARGET_HOOKS_BACKEND,
"label_no_toolchain") ==
get_label_info(":freertos_target_hooks", "label_no_toolchain")) {
pw_source_set("freertos_target_hooks") {
deps = [
":init",
"$dir_pw_third_party/freertos",
"$dir_pw_thread:thread",
"$dir_pw_thread_freertos:thread",
]
sources = [ "freertos_target_hooks.cc" ]
}
}
pw_executable("system_example") {
sources = [ "example_user_app_init.cc" ]
deps = [
":pw_system",
"$dir_pw_log",
"$dir_pw_thread:sleep",
]
}
if (dir_pw_third_party_nanopb != "") {
group("system_examples") {
deps = [ ":system_example($dir_pigweed/targets/host_device_simulator:host_device_simulator.speed_optimized)" ]
if (dir_pw_third_party_stm32cube_f4 != "" &&
dir_pw_third_party_freertos != "") {
deps += [ ":system_example($dir_pigweed/targets/stm32f429i_disc1_stm32cube:stm32f429i_disc1_stm32cube.size_optimized)" ]
}
}
} else {
pw_error("system_examples") {
message_lines = [
"Building the pw_system examples requires Nanopb.",
"Nanopb can be installed by running the command below and then following the prompted setup steps:",
" pw package install nanopb",
]
}
}
pw_doc_group("docs") {
sources = [ "docs.rst" ]
}