blob: 4c019f38e52368c97c5f5c744b168ddc6185ed24 [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_pw_build/module_config.gni")
import("$dir_pw_docgen/docs.gni")
import("$dir_pw_protobuf_compiler/proto.gni")
import("$dir_pw_rpc/internal/integration_test_ports.gni")
import("$dir_pw_unit_test/test.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_transfer_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
}
config("public_include_path") {
include_dirs = [ "public" ]
visibility = [ ":*" ]
}
pw_source_set("config") {
public = [ "public/pw_transfer/internal/config.h" ]
public_configs = [ ":public_include_path" ]
public_deps = [
"$dir_pw_chrono:system_timer",
pw_transfer_CONFIG,
]
visibility = [ ":*" ]
}
pw_source_set("pw_transfer") {
public_configs = [ ":public_include_path" ]
public_deps = [
":context",
":proto.raw_rpc",
"$dir_pw_containers:intrusive_list",
dir_pw_assert,
dir_pw_result,
dir_pw_status,
dir_pw_stream,
]
deps = [
":proto.pwpb",
dir_pw_log,
]
public = [
"public/pw_transfer/handler.h",
"public/pw_transfer/transfer.h",
]
sources = [
"client_connection.cc",
"public/pw_transfer/internal/client_connection.h",
"public/pw_transfer/internal/server_context.h",
"server_context.cc",
"transfer.cc",
]
}
pw_source_set("client") {
public_configs = [ ":public_include_path" ]
public_deps = [
":context",
":proto.raw_rpc",
"$dir_pw_sync:lock_annotations",
"$dir_pw_sync:mutex",
dir_pw_assert,
dir_pw_function,
dir_pw_stream,
]
deps = [
":proto.pwpb",
dir_pw_log,
]
public = [ "public/pw_transfer/client.h" ]
sources = [
"client.cc",
"client_context.cc",
"public/pw_transfer/internal/client_context.h",
]
}
pw_source_set("context") {
public_configs = [ ":public_include_path" ]
public_deps = [
":config",
"$dir_pw_rpc:client",
"$dir_pw_sync:interrupt_spin_lock",
"$dir_pw_sync:lock_annotations",
dir_pw_bytes,
dir_pw_result,
dir_pw_status,
dir_pw_stream,
dir_pw_work_queue,
]
deps = [
":proto.pwpb",
dir_pw_protobuf,
dir_pw_varint,
]
sources = [
"chunk.cc",
"chunk_data_buffer.cc",
"context.cc",
"public/pw_transfer/internal/chunk.h",
"public/pw_transfer/internal/chunk_data_buffer.h",
"public/pw_transfer/internal/context.h",
]
friend = [ ":*" ]
}
pw_source_set("test_helpers") {
public_deps = [
":context",
dir_pw_containers,
]
sources = [ "pw_transfer_private/chunk_testing.h" ]
friend = [ ":*" ]
visibility = [ ":*" ]
}
pw_proto_library("proto") {
sources = [ "transfer.proto" ]
python_package = "py"
prefix = "pw_transfer"
}
pw_test_group("tests") {
tests = [
# TODO(pwbug/562): These tests flake in CQ as they're timed-based. Rewrite
# them to access transfer internals and avoid sleeping.
# ":client_test",
":handler_test",
":transfer_test",
]
}
pw_test("handler_test") {
sources = [ "handler_test.cc" ]
deps = [ ":pw_transfer" ]
}
pw_test("transfer_test") {
sources = [ "transfer_test.cc" ]
deps = [
":proto.pwpb",
":pw_transfer",
":test_helpers",
"$dir_pw_rpc/raw:test_method_context",
]
}
pw_test("client_test") {
sources = [ "client_test.cc" ]
deps = [
":client",
":test_helpers",
"$dir_pw_rpc/raw:client_testing",
"$dir_pw_thread:sleep",
"$dir_pw_thread:thread",
]
}
pw_doc_group("docs") {
sources = [ "docs.rst" ]
inputs = [
"transfer.proto",
"read.svg",
"write.svg",
]
}
pw_proto_library("test_server_proto") {
sources = [ "test_server.proto" ]
prefix = "pw_transfer_test"
deps = [ "$dir_pw_protobuf:common_protos" ]
}
pw_executable("test_rpc_server") {
sources = [ "test_rpc_server.cc" ]
deps = [
":pw_transfer",
":test_server_proto.raw_rpc",
"$dir_pw_rpc/system_server",
"$dir_pw_rpc/system_server:socket",
"$dir_pw_stream:std_file_stream",
"$dir_pw_thread:thread",
dir_pw_log,
]
}
pw_executable("integration_test") {
sources = [ "integration_test.cc" ]
deps = [
":client",
":test_server_proto.raw_rpc",
"$dir_pw_rpc:integration_testing",
"$dir_pw_sync:binary_semaphore",
dir_pw_assert,
dir_pw_log,
dir_pw_unit_test,
]
}
pw_python_action("cpp_client_integration_test") {
script = "$dir_pw_rpc/py/pw_rpc/testing.py"
args = [
"--server",
"<TARGET_FILE(:test_rpc_server)>",
"--client",
"<TARGET_FILE(:integration_test)>",
"--",
"$pw_transfer_CPP_CPP_TRANSFER_TEST_PORT",
"(pw_rpc:CREATE_TEMP_DIR)",
]
deps = [
":integration_test",
":test_rpc_server",
]
stamp = true
}