diff options
Diffstat (limited to 'pw_rpc/Android.bp')
-rw-r--r-- | pw_rpc/Android.bp | 360 |
1 files changed, 313 insertions, 47 deletions
diff --git a/pw_rpc/Android.bp b/pw_rpc/Android.bp index e62b96157..516fb0a8c 100644 --- a/pw_rpc/Android.bp +++ b/pw_rpc/Android.bp @@ -75,7 +75,6 @@ filegroup { cc_library_headers { name: "pw_rpc_include_dirs", - cpp_std: "c++20", export_include_dirs: [ "public", ], @@ -99,7 +98,7 @@ cc_library_headers { // name: "pw_rpc_cflags_<instance_name>", // cflags: [ // "-DPW_RPC_USE_GLOBAL_MUTEX=0", -// "-DPW_RPC_CLIENT_STREAM_END_CALLBACK", +// "-DPW_RPC_COMPLETION_REQUEST_CALLBACK", // "-DPW_RPC_DYNAMIC_ALLOCATION", // ], // } @@ -109,8 +108,8 @@ cc_defaults { name: "pw_rpc_defaults", cpp_std: "c++20", header_libs: [ - "fuschia_sdk_lib_fit", - "fuschia_sdk_lib_stdcompat", + "fuchsia_sdk_lib_fit", + "fuchsia_sdk_lib_stdcompat", "pw_assert_headers", "pw_assert_log_headers", "pw_function_headers", @@ -126,8 +125,8 @@ cc_defaults { "pw_toolchain", ], export_header_lib_headers: [ - "fuschia_sdk_lib_fit", - "fuschia_sdk_lib_stdcompat", + "fuchsia_sdk_lib_fit", + "fuchsia_sdk_lib_stdcompat", "pw_assert_headers", "pw_assert_log_headers", "pw_function_headers", @@ -167,23 +166,21 @@ cc_defaults { "pw_rpc_internal_packet_pwpb_h", ], srcs: [ - ":pw_rpc_src_files" + ":pw_rpc_src_files", ], - host_supported: true, - vendor_available: true, } genrule { name: "pw_rpc_internal_packet_pwpb_h", srcs: ["internal/packet.proto"], cmd: "python3 $(location pw_protobuf_compiler_py) " + - "--out-dir=$$(dirname $(location pw_rpc/internal/packet.pwpb.h)) " + - "--plugin-path=$(location pw_protobuf_plugin_py) " + - "--compile-dir=$$(dirname $(in)) " + - "--sources $(in) " + - "--language pwpb " + - "--no-experimental-proto3-optional " + - "--protoc=$(location aprotoc) ", + "--out-dir=$$(dirname $(location pw_rpc/internal/packet.pwpb.h)) " + + "--plugin-path=$(location pw_protobuf_plugin_py) " + + "--compile-dir=$$(dirname $(in)) " + + "--sources $(in) " + + "--language pwpb " + + "--no-experimental-proto3-optional " + + "--protoc=$(location aprotoc) ", out: [ "pw_rpc/internal/packet.pwpb.h", ], @@ -198,13 +195,13 @@ genrule { name: "pw_rpc_internal_packet_py", srcs: ["internal/packet.proto"], cmd: "python3 $(location pw_protobuf_compiler_py) " + - "--out-dir=$(genDir) " + - "--compile-dir=$$(dirname $(in)) " + - "--sources $(in) " + - "--language python " + - "--no-generate-type-hints " + - "--no-experimental-proto3-optional " + - "--protoc=$(location aprotoc)", + "--out-dir=$(genDir) " + + "--compile-dir=$$(dirname $(in)) " + + "--sources $(in) " + + "--language python " + + "--no-generate-type-hints " + + "--no-experimental-proto3-optional " + + "--protoc=$(location aprotoc)", out: [ "packet_pb2.py", ], @@ -218,14 +215,45 @@ genrule { // The output file names are based on the srcs file name with a .pb.c / .pb.h extension. genrule_defaults { name: "pw_rpc_generate_nanopb_proto", - cmd: "python3 $(location pw_protobuf_compiler_py) " + - "--plugin-path=$(location protoc-gen-nanopb) " + - "--out-dir=$(genDir) " + - "--compile-dir=$$(dirname $(in)) " + - "--language nanopb " + - "--sources $(in) " + - "--no-experimental-proto3-optional " + - "--protoc=$(location aprotoc)", + cmd: "in_files=($(in)); compile_dir=$$(dirname $${in_files[0]}); " + + "python3 $(location pw_protobuf_compiler_py) " + + "--plugin-path=$(location protoc-gen-nanopb) " + + "--out-dir=$(genDir) " + + "--compile-dir=$${compile_dir} " + + "--language nanopb " + + "--sources $(in) " + + "--no-experimental-proto3-optional " + + "--protoc=$(location aprotoc)", + tools: [ + "aprotoc", + "protoc-gen-nanopb", + "pw_protobuf_compiler_py", + ], +} + +// Same as pw_rpc_generate_nanopb_proto but the proto files are compiled with a +// single prefix, which can be added with pw_rpc_add_prefix_to_proto. +// Since pw_rpc_add_prefix_to_proto may include .option files as an input, only +// .proto files are passed to the compile script. Make sure .option files are +// prefixed in the same rule as their .proto files. +// +// See the pw_rpc_echo_service_nanopb target for an example. The echo.proto file +// is compiled with "pw_rpc" as the prefix. +genrule_defaults { + name: "pw_rpc_generate_nanopb_proto_with_prefix", + cmd: "in_files=($(in)); prefix_dir=$$(dirname $${in_files[0]}); " + + "compile_dir=$$(dirname $${prefix_dir}); proto_files=(); " + + "for f in \"$${in_files[@]}\"; do " + + "if [[ \"$${f##*.}\" == \"proto\" ]]; then " + + "proto_files+=(\"$${f}\"); fi; done; " + + "python3 $(location pw_protobuf_compiler_py) " + + "--plugin-path=$(location protoc-gen-nanopb) " + + "--out-dir=$(genDir) " + + "--compile-dir=$${compile_dir} " + + "--language nanopb " + + "--sources $${proto_files} " + + "--no-experimental-proto3-optional " + + "--protoc=$(location aprotoc)", tools: [ "aprotoc", "protoc-gen-nanopb", @@ -237,14 +265,45 @@ genrule_defaults { // The output file name is based on the srcs file name with a .rpc.pb.h extension. genrule_defaults { name: "pw_rpc_generate_nanopb_rpc_header", - cmd: "python3 $(location pw_protobuf_compiler_py) " + - "--plugin-path=$(location pw_rpc_plugin_nanopb_py) " + - "--out-dir=$(genDir) " + - "--compile-dir=$$(dirname $(in)) " + - "--language nanopb_rpc " + - "--sources $(in) " + - "--no-experimental-proto3-optional " + - "--protoc=$(location aprotoc)", + cmd: "in_files=($(in)); compile_dir=$$(dirname $${in_files[0]}); " + + "python3 $(location pw_protobuf_compiler_py) " + + "--plugin-path=$(location pw_rpc_plugin_nanopb_py) " + + "--out-dir=$(genDir) " + + "--compile-dir=$${compile_dir} " + + "--language nanopb_rpc " + + "--sources $(in) " + + "--no-experimental-proto3-optional " + + "--protoc=$(location aprotoc)", + tools: [ + "aprotoc", + "pw_protobuf_compiler_py", + "pw_rpc_plugin_nanopb_py", + ], +} + +// Same as pw_rpc_generate_nanopb_rpc_header but the proto files are compiled +// with a single prefix, which can be added with pw_rpc_add_prefix_to_proto. +// Since pw_rpc_add_prefix_to_proto may include .option files as an input, only +// .proto files are passed to the compile script. Make sure .option files are +// prefixed in the same rule as their .proto files. +// +// See the pw_rpc_echo_service_nanopb target for an example. The echo.proto file +// is compiled with "pw_rpc" as the prefix. +genrule_defaults { + name: "pw_rpc_generate_nanopb_rpc_header_with_prefix", + cmd: "in_files=($(in)); prefix_dir=$$(dirname $${in_files[0]}); " + + "compile_dir=$$(dirname $${prefix_dir}); proto_files=(); " + + "for f in \"$${in_files[@]}\"; do " + + "if [[ \"$${f##*.}\" == \"proto\" ]]; then " + + "proto_files+=(\"$${f}\"); fi; done; " + + "python3 $(location pw_protobuf_compiler_py) " + + "--plugin-path=$(location pw_rpc_plugin_nanopb_py) " + + "--out-dir=$(genDir) " + + "--compile-dir=$${compile_dir} " + + "--language nanopb_rpc " + + "--sources $${proto_files} " + + "--no-experimental-proto3-optional " + + "--protoc=$(location aprotoc)", tools: [ "aprotoc", "pw_protobuf_compiler_py", @@ -256,14 +315,15 @@ genrule_defaults { // The output file name is based on the srcs file name with a .raw_rpc.pb.h extension. genrule_defaults { name: "pw_rpc_generate_raw_rpc_header", - cmd: "python3 $(location pw_protobuf_compiler_py) " + - "--plugin-path=$(location pw_rpc_plugin_rawpb_py) " + - "--out-dir=$(genDir) " + - "--compile-dir=$$(dirname $(in)) " + - "--language raw_rpc " + - "--sources $(in) " + - "--no-experimental-proto3-optional " + - "--protoc=$(location aprotoc)", + cmd: "in_files=($(in)); compile_dir=$$(dirname $${in_files[0]}); " + + "python3 $(location pw_protobuf_compiler_py) " + + "--plugin-path=$(location pw_rpc_plugin_rawpb_py) " + + "--out-dir=$(genDir) " + + "--compile-dir=$${compile_dir} " + + "--language raw_rpc " + + "--sources $(in) " + + "--no-experimental-proto3-optional " + + "--protoc=$(location aprotoc)", tools: [ "aprotoc", "pw_protobuf_compiler_py", @@ -271,6 +331,212 @@ genrule_defaults { ], } +// Generate header pwpb files. +// The output file names are based on the srcs file name with a .pwpb.h extension. +genrule_defaults { + name: "pw_rpc_generate_pwpb_proto", + cmd: "in_files=($(in)); compile_dir=$$(dirname $${in_files[0]}); " + + "python3 $(location pw_protobuf_compiler_py) " + + "--plugin-path=$(location pw_protobuf_plugin_py) " + + "--out-dir=$(genDir) " + + "--compile-dir=$${compile_dir} " + + "--language pwpb " + + "--sources $(in) " + + "--no-experimental-proto3-optional " + + "--protoc=$(location aprotoc)", + tools: [ + "aprotoc", + "pw_protobuf_plugin_py", + "pw_protobuf_compiler_py", + ], +} + +// Same as pw_rpc_generate_pwpb_proto but the proto files are compiled with a +// single prefix, which can be added with pw_rpc_add_prefix_to_proto. +// Since pw_rpc_add_prefix_to_proto may include .option files as an input, only +// .proto files are passed to the compile script. Make sure .option files are +// prefixed in the same rule as their .proto files. +// +// See the pw_rpc_echo_service_pwpb target for an example. The echo.proto file +// is compiled with "pw_rpc" as the prefix. +genrule_defaults { + name: "pw_rpc_generate_pwpb_proto_with_prefix", + cmd: "in_files=($(in)); prefix_dir=$$(dirname $${in_files[0]}); " + + "compile_dir=$$(dirname $${prefix_dir}); proto_files=(); " + + "for f in \"$${in_files[@]}\"; do " + + "if [[ \"$${f##*.}\" == \"proto\" ]]; then " + + "proto_files+=(\"$${f}\"); fi; done; " + + "python3 $(location pw_protobuf_compiler_py) " + + "--plugin-path=$(location pw_protobuf_plugin_py) " + + "--out-dir=$(genDir) " + + "--compile-dir=$${compile_dir} " + + "--language pwpb " + + "--sources $${proto_files} " + + "--no-experimental-proto3-optional " + + "--protoc=$(location aprotoc)", + tools: [ + "aprotoc", + "pw_protobuf_plugin_py", + "pw_protobuf_compiler_py", + ], +} + +// Generate the header pwpb RPC file. +// The output file name is based on the srcs file name with a .rpc.pwpb.h extension. +genrule_defaults { + name: "pw_rpc_generate_pwpb_rpc_header", + cmd: "in_files=($(in)); compile_dir=$$(dirname $${in_files[0]}); " + + "python3 $(location pw_protobuf_compiler_py) " + + "--plugin-path=$(location pw_rpc_plugin_pwpb_py) " + + "--out-dir=$(genDir) " + + "--compile-dir=$${compile_dir} " + + "--language pwpb_rpc " + + "--sources $(in) " + + "--no-experimental-proto3-optional " + + "--protoc=$(location aprotoc)", + tools: [ + "aprotoc", + "pw_protobuf_compiler_py", + "pw_rpc_plugin_pwpb_py", + ], +} + +// Same as pw_rpc_generate_pwpb_rpc_header but the proto files are compiled +// with a single prefix, which can be added with pw_rpc_add_prefix_to_proto. +// Since pw_rpc_add_prefix_to_proto may include .option files as an input, only +// .proto files are passed to the compile script. Make sure .option files are +// prefixed in the same rule as their .proto files. +// +// See the pw_rpc_echo_service_pwpb target for an example. The echo.proto file +// is compiled with "pw_rpc" as the prefix. +genrule_defaults { + name: "pw_rpc_generate_pwpb_rpc_header_with_prefix", + cmd: "in_files=($(in)); prefix_dir=$$(dirname $${in_files[0]}); " + + "compile_dir=$$(dirname $${prefix_dir}); proto_files=(); " + + "for f in \"$${in_files[@]}\"; do " + + "if [[ \"$${f##*.}\" == \"proto\" ]]; then " + + "proto_files+=(\"$${f}\"); fi; done; " + + "python3 $(location pw_protobuf_compiler_py) " + + "--plugin-path=$(location pw_rpc_plugin_pwpb_py) " + + "--out-dir=$(genDir) " + + "--compile-dir=$${compile_dir} " + + "--language pwpb_rpc " + + "--sources $${proto_files} " + + "--no-experimental-proto3-optional " + + "--protoc=$(location aprotoc)", + tools: [ + "aprotoc", + "pw_protobuf_compiler_py", + "pw_rpc_plugin_pwpb_py", + ], +} + +// Copies the proto files to a prefix directory to add the prefix to the +// compiled proto. The prefix is taken from the directory name of the first +// item listen in out. +genrule_defaults { + name: "pw_rpc_add_prefix_to_proto", + cmd: "out_files=($(out)); prefix=$$(dirname $${out_files[0]}); " + + "mkdir -p $${prefix}; cp -t $${prefix} $(in);", +} + +genrule { + name: "pw_rpc_echo_proto_with_prefix", + defaults: ["pw_rpc_add_prefix_to_proto"], + srcs: [ + "echo.options", + "echo.proto", + ], + out: [ + "pw_rpc/echo.options", + "pw_rpc/echo.proto", + ], +} + +genrule { + name: "pw_rpc_echo_rpc_header", + defaults: ["pw_rpc_generate_nanopb_rpc_header_with_prefix"], + srcs: [":pw_rpc_echo_proto_with_prefix"], + out: ["pw_rpc/echo.rpc.pb.h"], +} + +genrule { + name: "pw_rpc_echo_proto_header", + defaults: ["pw_rpc_generate_nanopb_proto_with_prefix"], + srcs: [":pw_rpc_echo_proto_with_prefix"], + out: ["pw_rpc/echo.pb.h"], +} + +genrule { + name: "pw_rpc_echo_proto_source", + defaults: ["pw_rpc_generate_nanopb_proto_with_prefix"], + srcs: [":pw_rpc_echo_proto_with_prefix"], + out: ["pw_rpc/echo.pb.c"], +} + +// This is a copy of the echo.pb.h header, since the generated echo.pb.c +// includes it by file name, while pw_rpc/nanopb/echo_service_nanopb.h includes +// it with a prefix. +// Soong makes it very hard to add include directories when they don't come from +// modules, so this is a kludge to add an include directory path without a +// prefix. +genrule { + name: "pw_rpc_echo_proto_header_copy", + cmd: "cp $(in) $(out)", + srcs: [":pw_rpc_echo_proto_header"], + out: ["echo.pb.h"], +} + +cc_library_static { + name: "pw_rpc_echo_service_nanopb", + cpp_std: "c++20", + vendor_available: true, + host_supported: true, + export_include_dirs: ["public/pw_rpc"], + generated_headers: [ + "pw_rpc_echo_proto_header", + "pw_rpc_echo_proto_header_copy", + "pw_rpc_echo_rpc_header", + ], + export_generated_headers: [ + "pw_rpc_echo_proto_header", + "pw_rpc_echo_proto_header_copy", + "pw_rpc_echo_rpc_header", + ], + generated_sources: ["pw_rpc_echo_proto_source"], + static_libs: ["libprotobuf-c-nano"], +} + +genrule { + name: "pw_rpc_echo_pwpb_rpc_header", + defaults: ["pw_rpc_generate_pwpb_rpc_header_with_prefix"], + srcs: [":pw_rpc_echo_proto_with_prefix"], + out: ["pw_rpc/echo.rpc.pwpb.h"], +} + +genrule { + name: "pw_rpc_echo_pwpb_proto_header", + defaults: ["pw_rpc_generate_pwpb_proto_with_prefix"], + srcs: [":pw_rpc_echo_proto_with_prefix"], + out: ["pw_rpc/echo.pwpb.h"], +} + +cc_library_static { + name: "pw_rpc_echo_service_pwpb", + cpp_std: "c++20", + vendor_available: true, + host_supported: true, + export_include_dirs: ["public/pw_rpc"], + generated_headers: [ + "pw_rpc_echo_pwpb_proto_header", + "pw_rpc_echo_pwpb_rpc_header", + ], + export_generated_headers: [ + "pw_rpc_echo_pwpb_proto_header", + "pw_rpc_echo_pwpb_rpc_header", + ], +} + python_library_host { name: "pw_rpc_internal_packet_py_lib", srcs: [ |