diff options
Diffstat (limited to 'pw_protobuf/Android.bp')
-rw-r--r-- | pw_protobuf/Android.bp | 120 |
1 files changed, 116 insertions, 4 deletions
diff --git a/pw_protobuf/Android.bp b/pw_protobuf/Android.bp index 0e3f8a04c..1a2c79a8f 100644 --- a/pw_protobuf/Android.bp +++ b/pw_protobuf/Android.bp @@ -22,8 +22,8 @@ cc_library_static { vendor_available: true, export_include_dirs: ["public"], 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", @@ -34,6 +34,16 @@ cc_library_static { "pw_result_headers", "pw_span_headers", ], + export_header_lib_headers: [ + "pw_assert_headers", + "pw_assert_log_headers", + "pw_function_headers", + "pw_log_headers", + "pw_log_null_headers", + "pw_preprocessor_headers", + "pw_result_headers", + "pw_span_headers", + ], host_supported: true, srcs: [ "decoder.cc", @@ -51,6 +61,108 @@ cc_library_static { "pw_string", "pw_varint", ], + export_static_lib_headers: [ + "pw_bytes", + "pw_containers", + "pw_status", + "pw_stream", + "pw_varint", + ], +} + +cc_library_headers { + name: "pw_protobuf_pwpb_headers", + cpp_std: "c++20", + vendor_available: true, + host_supported: true, + generated_headers: [ + "google_protobuf_descriptor_pwpb_h", + "pw_protobuf_protos_common_pwpb_h", + ], + export_generated_headers: [ + "google_protobuf_descriptor_pwpb_h", + "pw_protobuf_protos_common_pwpb_h", + ], +} + +// 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_protobuf_add_prefix_to_proto", + cmd: "out_files=($(out)); prefix=$$(dirname $${out_files[0]}); " + + "mkdir -p $${prefix}; cp -t $${prefix} $(in);" +} + +filegroup { + name: "pw_protobuf_common_proto", + srcs: [ + "pw_protobuf_protos/common.proto", + ], +} + +genrule { + name: "pw_protobuf_common_proto_with_prefix", + defaults: ["pw_protobuf_add_prefix_to_proto"], + srcs: [ + "pw_protobuf_protos/common.proto", + ], + out: [ + "pw_protobuf/pw_protobuf_protos/common.proto", + ], +} + +genrule { + name: "pw_protobuf_protos_common_pwpb_h", + srcs: [":pw_protobuf_common_proto_with_prefix",], + cmd: "python3 $(location pw_protobuf_compiler_py) " + + "--proto-path=external/pigweed/pw_protobuf/ " + + "--proto-path=external/protobuf/src/ " + + "--out-dir=$$(dirname $(location pw_protobuf_protos/common.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_protobuf_protos/common.pwpb.h", + ], + tools: [ + "aprotoc", + "pw_protobuf_plugin_py", + "pw_protobuf_compiler_py", + ], +} + +// Generate the google/protobuf/descriptor.pwpb.h which is commonly imported. +genrule { + name: "google_protobuf_descriptor_pwpb_h", + // The libprotobuf-internal-descriptor-proto filegroup is unavailable so + // instead filter for just the descriptor.proto. + srcs: [":libprotobuf-internal-protos",], + cmd: "in_files=($(in)); compile_dir=$$(dirname $${in_files[0]}); " + + "proto_files=(); " + + "for f in \"$${in_files[@]}\"; do " + + "if [[ \"$${f##*descriptor.}\" == \"proto\" ]]; then " + + "proto_files+=(\"$${f}\"); fi; done; " + + "python3 $(location pw_protobuf_compiler_py) " + + "--proto-path=external/protobuf/src/ " + + "--out-dir=$$(dirname $(location google/protobuf/descriptor.pwpb.h)) " + + "--plugin-path=$(location pw_protobuf_plugin_py) " + + "--compile-dir=$${compile_dir} " + + "--sources $${proto_files} " + + "--language pwpb " + + "--no-experimental-proto3-optional " + + "--protoc=$(location aprotoc) ", + out: [ + "google/protobuf/descriptor.pwpb.h", + ], + tools: [ + "aprotoc", + "pw_protobuf_plugin_py", + "pw_protobuf_compiler_py", + ], } genrule { @@ -82,7 +194,7 @@ genrule { "pw_protobuf_protos/common.proto", "pw_protobuf_protos/field_options.proto", "pw_protobuf_protos/status.proto", - ":libprotobuf-internal-descriptor-proto", + ":libprotobuf-internal-protos", ], cmd: "$(location aprotoc) " + "-I$$(dirname $(location pw_protobuf_protos/common.proto)) " + @@ -105,4 +217,4 @@ python_library_host { ":pw_protobuf_protos_py", ], pkg_path: "pw_protobuf_protos", -}
\ No newline at end of file +} |