1// Copyright 2022 The Pigweed Authors 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); you may not 4// use this file except in compliance with the License. You may obtain a copy of 5// the License at 6// 7// https://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12// License for the specific language governing permissions and limitations under 13// the License. 14 15package { 16 default_applicable_licenses: ["external_pigweed_license"], 17} 18 19cc_library_headers { 20 name: "pw_log", 21 cpp_std: "c++20", 22 vendor_available: true, 23 export_include_dirs: ["public"], 24 host_supported: true, 25} 26 27cc_library_headers { 28 name: "pw_log_pwpb", 29 cpp_std: "c++20", 30 vendor_available: true, 31 static_libs: [ 32 "pw_toolchain", 33 ], 34 export_static_lib_headers: [ 35 "pw_toolchain", 36 ], 37 host_supported: true, 38 generated_headers: [ 39 "google_protobuf_descriptor_pwpb_h", 40 "pw_log_log_proto_pwpb_h", 41 "pw_log_log_rpc_pwpb_h", 42 "pw_log_log_raw_rpc_h", 43 "pw_protobuf_protos_common_pwpb_h", 44 "pw_tokenizer_proto_options_pwpb_h", 45 ], 46 export_generated_headers: [ 47 "google_protobuf_descriptor_pwpb_h", 48 "pw_log_log_proto_pwpb_h", 49 "pw_log_log_rpc_pwpb_h", 50 "pw_log_log_raw_rpc_h", 51 "pw_protobuf_protos_common_pwpb_h", 52 "pw_tokenizer_proto_options_pwpb_h", 53 ], 54} 55 56// Copies the proto files to a prefix directory to add the prefix to the 57// compiled proto. The prefix is taken from the directory name of the first 58// item listen in out. 59genrule_defaults { 60 name: "pw_log_add_prefix_to_proto", 61 cmd: "out_files=($(out)); prefix=$$(dirname $${out_files[0]}); " + 62 "mkdir -p $${prefix}; cp -t $${prefix} $(in);", 63} 64 65genrule { 66 name: "pw_log_log_proto_with_prefix", 67 defaults: ["pw_log_add_prefix_to_proto"], 68 srcs: [ 69 "log.proto", 70 ], 71 out: [ 72 "pw_log/proto/log.proto", 73 ], 74} 75 76genrule { 77 name: "pw_log_log_proto_pwpb_h", 78 srcs: [ 79 ":libprotobuf-internal-protos", 80 ":pw_log_log_proto_with_prefix", 81 ":pw_protobuf_common_proto", 82 ":pw_tokenizer_proto_options_proto", 83 ], 84 cmd: "python3 $(location pw_protobuf_compiler_py) " + 85 "--proto-path=external/pigweed/pw_protobuf/ " + 86 "--proto-path=external/pigweed/pw_tokenizer/ " + 87 "--proto-path=$$(dirname $$(dirname $$(dirname $(location :pw_log_log_proto_with_prefix)))) " + 88 "--proto-path=external/protobuf/src/ " + 89 "--out-dir=$(genDir) " + 90 "--plugin-path=$(location pw_protobuf_plugin_py) " + 91 "--compile-dir=$(genDir) " + 92 "--sources $(location :pw_log_log_proto_with_prefix) " + 93 "--language pwpb " + 94 "--no-experimental-proto3-optional " + 95 "--protoc=$(location aprotoc) && " + 96 // TODO(b/308678575) - Avoid making an extra copy of the created file. 97 "python3 -c \"import os; import shutil; " + 98 "shutil.copy2(os.path.splitext('$(location :pw_log_log_proto_with_prefix)')[0]+'.pwpb.h', '$(out)')\"", 99 out: [ 100 "pw_log/proto/log.pwpb.h", 101 ], 102 tools: [ 103 "aprotoc", 104 "pw_protobuf_plugin_py", 105 "pw_protobuf_compiler_py", 106 ], 107} 108 109genrule { 110 name: "pw_log_log_rpc_pwpb_h", 111 srcs: [ 112 ":libprotobuf-internal-protos", 113 ":pw_log_log_proto_with_prefix", 114 ":pw_protobuf_common_proto", 115 ":pw_tokenizer_proto_options_proto", 116 ], 117 cmd: "python3 $(location pw_protobuf_compiler_py) " + 118 "--proto-path=external/pigweed/pw_protobuf/ " + 119 "--proto-path=external/pigweed/pw_tokenizer/ " + 120 "--proto-path=$$(dirname $$(dirname $$(dirname $(location :pw_log_log_proto_with_prefix)))) " + 121 "--proto-path=external/protobuf/src/ " + 122 "--out-dir=$(genDir) " + 123 "--plugin-path=$(location pw_rpc_plugin_pwpb_py) " + 124 "--compile-dir=$(genDir) " + 125 "--sources $(location :pw_log_log_proto_with_prefix) " + 126 "--language pwpb_rpc " + 127 "--no-experimental-proto3-optional " + 128 "--protoc=$(location aprotoc) && " + 129 // TODO(b/308678575) - Avoid making an extra copy of the created file. 130 "python3 -c \"import os; import shutil; " + 131 "shutil.copy2(os.path.splitext('$(location :pw_log_log_proto_with_prefix)')[0]+'.rpc.pwpb.h', '$(out)')\"", 132 out: [ 133 "pw_log/proto/log.rpc.pwpb.h", 134 ], 135 tools: [ 136 "aprotoc", 137 "pw_protobuf_compiler_py", 138 "pw_rpc_plugin_pwpb_py", 139 ], 140} 141 142genrule { 143 name: "pw_log_log_raw_rpc_h", 144 srcs: [ 145 ":libprotobuf-internal-protos", 146 ":pw_log_log_proto_with_prefix", 147 ":pw_protobuf_common_proto", 148 ":pw_tokenizer_proto_options_proto", 149 ], 150 cmd: "python3 $(location pw_protobuf_compiler_py) " + 151 "--proto-path=external/pigweed/pw_protobuf/ " + 152 "--proto-path=external/pigweed/pw_tokenizer/ " + 153 "--proto-path=$$(dirname $$(dirname $$(dirname $(location :pw_log_log_proto_with_prefix)))) " + 154 "--proto-path=external/protobuf/src/ " + 155 "--out-dir=$(genDir) " + 156 "--plugin-path=$(location pw_rpc_plugin_rawpb_py) " + 157 "--compile-dir=$(genDir) " + 158 "--sources $(location :pw_log_log_proto_with_prefix) " + 159 "--language raw_rpc " + 160 "--no-experimental-proto3-optional " + 161 "--protoc=$(location aprotoc) && " + 162 // TODO(b/308678575) - Avoid making an extra copy of the created file. 163 "python3 -c \"import os; import shutil; " + 164 "shutil.copy2(os.path.splitext('$(location :pw_log_log_proto_with_prefix)')[0]+'.raw_rpc.pb.h', '$(out)')\"", 165 out: [ 166 "pw_log/proto/log.raw_rpc.pb.h", 167 ], 168 tools: [ 169 "aprotoc", 170 "pw_protobuf_compiler_py", 171 "pw_rpc_plugin_rawpb_py", 172 ], 173} 174 175android_library { 176 name: "pw_log_android_java", 177 srcs: ["java/android_main/dev/pigweed/pw_log/*.java"], 178 visibility: ["//visibility:public"], 179 sdk_version: "current", 180} 181