blob: aee1db0f0fafc5149dbb86332a1386de4d1d5290 [file]
# Copyright 2022 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.
load("@com_google_protobuf//bazel:java_lite_proto_library.bzl", "java_lite_proto_library")
load("@com_google_protobuf//bazel:java_proto_library.bzl", "java_proto_library")
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@sphinxdocs//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
load("//pw_build:copy_to_bin.bzl", "copy_to_bin")
load(
"//pw_protobuf_compiler:pw_proto_library.bzl",
"pwpb_proto_library",
"raw_rpc_proto_library",
)
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)
licenses(["notice"])
hosts_lin_mac = {
"@platforms//os:linux": [],
"@platforms//os:macos": [],
"//conditions:default": ["@platforms//:incompatible"],
}
cc_library(
name = "config",
hdrs = ["public/pw_transfer/internal/config.h"],
strip_include_prefix = "public",
deps = [
":config_override",
"//pw_chrono:system_clock",
"//pw_preprocessor",
],
)
label_flag(
name = "config_override",
build_setting_default = "//pw_build:default_module_config",
)
cc_library(
name = "core",
srcs = [
"chunk.cc",
"client.cc",
"client_context.cc",
"context.cc",
"rate_estimate.cc",
"server_context.cc",
"transfer_thread.cc",
],
hdrs = [
"public/pw_transfer/client.h",
"public/pw_transfer/handler.h",
"public/pw_transfer/internal/chunk.h",
"public/pw_transfer/internal/client_context.h",
"public/pw_transfer/internal/context.h",
"public/pw_transfer/internal/event.h",
"public/pw_transfer/internal/protocol.h",
"public/pw_transfer/internal/server_context.h",
"public/pw_transfer/rate_estimate.h",
"public/pw_transfer/transfer_thread.h",
],
features = ["-conversion_warnings"],
implementation_deps = ["//pw_assert:check"],
strip_include_prefix = "public",
deps = [
":config",
":transfer_pwpb",
":transfer_raw_rpc",
"//pw_assert:assert",
"//pw_bytes",
"//pw_chrono:system_clock",
"//pw_containers:intrusive_forward_list",
"//pw_log",
"//pw_log:rate_limited",
"//pw_preprocessor",
"//pw_protobuf",
"//pw_result",
"//pw_rpc:client_server",
"//pw_rpc:internal_packet_pwpb",
"//pw_rpc/raw:client_api",
"//pw_rpc/raw:server_api",
"//pw_status",
"//pw_stream",
"//pw_sync:binary_semaphore",
"//pw_sync:timed_thread_notification",
"//pw_thread:thread_core",
"//pw_varint",
],
)
cc_library(
name = "pw_transfer",
srcs = [
"transfer.cc",
],
hdrs = [
"public/pw_transfer/transfer.h",
],
features = ["-conversion_warnings"],
implementation_deps = ["//pw_assert:check"],
strip_include_prefix = "public",
deps = [
":core",
"//pw_bytes",
"//pw_log",
"//pw_result",
"//pw_rpc:internal_packet_pwpb",
"//pw_rpc/raw:server_api",
"//pw_status",
"//pw_stream",
],
)
cc_library(
name = "handler_allocator",
srcs = [
"handler_allocator.cc",
],
hdrs = ["public/pw_transfer/handler_allocator.h"],
features = ["-conversion_warnings"],
strip_include_prefix = "public",
deps = [
":pw_transfer",
"//pw_allocator",
"//pw_assert:assert",
"//pw_containers:dynamic_deque",
"//pw_sync:lock_annotations",
"//pw_sync:mutex",
],
)
alias(
name = "client",
actual = ":core",
)
cc_library(
name = "atomic_file_transfer_handler",
srcs = ["atomic_file_transfer_handler.cc"],
hdrs = [
"public/pw_transfer/atomic_file_transfer_handler.h",
],
features = ["-conversion_warnings"],
strip_include_prefix = "public",
deps = [
":atomic_file_transfer_handler_internal",
":core",
"//pw_log",
"//pw_stream:std_file_stream",
],
)
cc_library(
name = "atomic_file_transfer_handler_internal",
srcs = [
"pw_transfer_private/filename_generator.h",
],
)
cc_library(
name = "test_helpers",
testonly = True,
srcs = [
"pw_transfer_private/chunk_testing.h",
],
features = ["-conversion_warnings"],
implementation_deps = ["//pw_containers:vector"],
deps = [
":core",
"//pw_unit_test",
],
)
pw_cc_test(
name = "chunk_test",
srcs = ["chunk_test.cc"],
features = ["-conversion_warnings"],
deps = [":core"],
)
pw_cc_test(
name = "handler_test",
srcs = ["handler_test.cc"],
features = ["-conversion_warnings"],
# TODO: b/235345886 - Fix transfer tests on Windows and non-host builds.
target_compatible_with = select(hosts_lin_mac),
deps = [":pw_transfer"],
)
pw_cc_test(
name = "handler_allocator_test",
srcs = ["handler_allocator_test.cc"],
features = ["-conversion_warnings"],
# TODO: b/235345886 - Fix transfer tests on Windows and non-host builds.
target_compatible_with = select(hosts_lin_mac),
deps = [
":handler_allocator",
"//pw_allocator:best_fit",
"//pw_allocator/block:small_block",
"//pw_stream",
"//pw_thread:test_thread_context",
"//pw_thread:thread",
],
)
pw_cc_test(
name = "atomic_file_transfer_handler_test",
srcs = ["atomic_file_transfer_handler_test.cc"],
features = ["-conversion_warnings"],
# TODO: b/235345886 - Fix transfer tests on Windows and non-host builds.
target_compatible_with = select(hosts_lin_mac),
deps = [
":atomic_file_transfer_handler",
":atomic_file_transfer_handler_internal",
":pw_transfer",
"//pw_random",
"//pw_string",
],
)
pw_cc_test(
name = "transfer_thread_test",
srcs = ["transfer_thread_test.cc"],
features = ["-conversion_warnings"],
# TODO: b/235345886 - Fix transfer tests on Windows and non-host builds.
target_compatible_with = select(hosts_lin_mac),
deps = [
":pw_transfer",
":test_helpers",
"//pw_assert:check",
"//pw_rpc:test_helpers",
"//pw_rpc/raw:client_testing",
"//pw_rpc/raw:test_method_context",
"//pw_thread:thread",
],
)
pw_cc_test(
name = "transfer_test",
srcs = ["transfer_test.cc"],
features = ["-conversion_warnings"],
# TODO: b/235345886 - Fix transfer tests on Windows and non-host builds.
target_compatible_with = select(hosts_lin_mac),
deps = [
":pw_transfer",
":test_helpers",
"//pw_assert:check",
"//pw_containers:algorithm",
"//pw_rpc:test_helpers",
"//pw_rpc/raw:test_method_context",
"//pw_thread:thread",
],
)
pw_cc_test(
name = "client_test",
srcs = ["client_test.cc"],
features = ["-conversion_warnings"],
# TODO: b/235345886 - Fix transfer tests on Windows and non-host builds.
target_compatible_with = select(hosts_lin_mac),
deps = [
":client",
":test_helpers",
"//pw_assert:check",
"//pw_rpc:test_helpers",
"//pw_rpc/raw:client_testing",
"//pw_thread:sleep",
"//pw_thread:thread",
],
)
proto_library(
name = "transfer_proto",
srcs = [
"transfer.proto",
],
)
pwpb_proto_library(
name = "transfer_pwpb",
deps = [":transfer_proto"],
)
raw_rpc_proto_library(
name = "transfer_raw_rpc",
deps = [":transfer_proto"],
)
py_proto_library(
name = "transfer_proto_pb2",
deps = [":transfer_proto"],
)
java_proto_library(
name = "transfer_proto_java",
deps = [":transfer_proto"],
)
java_lite_proto_library(
name = "transfer_proto_java_lite",
deps = [":transfer_proto"],
)
filegroup(
name = "doxygen",
srcs = [
"public/pw_transfer/atomic_file_transfer_handler.h",
],
)
sphinx_docs_library(
name = "docs",
srcs = [
"docs.rst",
"transfer.proto",
],
prefix = "pw_transfer/",
target_compatible_with = incompatible_with_mcu(),
)
copy_to_bin(
name = "js_protos",
srcs = ["transfer.proto"],
)