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 "--no-experimental-editions " + 96 "--pwpb-no-oneof-callbacks " + 97 "--protoc=$(location aprotoc) && " + 98 // TODO(b/308678575) - Avoid making an extra copy of the created file. 99 "python3 -c \"import os; import shutil; " + 100 "shutil.copy2(os.path.splitext('$(location :pw_log_log_proto_with_prefix)')[0]+'.pwpb.h', '$(out)')\"", 101 out: [ 102 "pw_log/proto/log.pwpb.h", 103 ], 104 tools: [ 105 "aprotoc", 106 "pw_protobuf_plugin_py", 107 "pw_protobuf_compiler_py", 108 ], 109} 110 111genrule { 112 name: "pw_log_log_rpc_pwpb_h", 113 srcs: [ 114 ":libprotobuf-internal-protos", 115 ":pw_log_log_proto_with_prefix", 116 ":pw_protobuf_common_proto", 117 ":pw_tokenizer_proto_options_proto", 118 ], 119 cmd: "python3 $(location pw_protobuf_compiler_py) " + 120 "--proto-path=external/pigweed/pw_protobuf/ " + 121 "--proto-path=external/pigweed/pw_tokenizer/ " + 122 "--proto-path=$$(dirname $$(dirname $$(dirname $(location :pw_log_log_proto_with_prefix)))) " + 123 "--proto-path=external/protobuf/src/ " + 124 "--out-dir=$(genDir) " + 125 "--plugin-path=$(location pw_rpc_plugin_pwpb_py) " + 126 "--compile-dir=$(genDir) " + 127 "--sources $(location :pw_log_log_proto_with_prefix) " + 128 "--language pwpb_rpc " + 129 "--no-experimental-proto3-optional " + 130 "--no-experimental-editions " + 131 "--pwpb-no-oneof-callbacks " + 132 "--protoc=$(location aprotoc) && " + 133 // TODO(b/308678575) - Avoid making an extra copy of the created file. 134 "python3 -c \"import os; import shutil; " + 135 "shutil.copy2(os.path.splitext('$(location :pw_log_log_proto_with_prefix)')[0]+'.rpc.pwpb.h', '$(out)')\"", 136 out: [ 137 "pw_log/proto/log.rpc.pwpb.h", 138 ], 139 tools: [ 140 "aprotoc", 141 "pw_protobuf_compiler_py", 142 "pw_rpc_plugin_pwpb_py", 143 ], 144} 145 146genrule { 147 name: "pw_log_log_raw_rpc_h", 148 srcs: [ 149 ":libprotobuf-internal-protos", 150 ":pw_log_log_proto_with_prefix", 151 ":pw_protobuf_common_proto", 152 ":pw_tokenizer_proto_options_proto", 153 ], 154 cmd: "python3 $(location pw_protobuf_compiler_py) " + 155 "--proto-path=external/pigweed/pw_protobuf/ " + 156 "--proto-path=external/pigweed/pw_tokenizer/ " + 157 "--proto-path=$$(dirname $$(dirname $$(dirname $(location :pw_log_log_proto_with_prefix)))) " + 158 "--proto-path=external/protobuf/src/ " + 159 "--out-dir=$(genDir) " + 160 "--plugin-path=$(location pw_rpc_plugin_rawpb_py) " + 161 "--compile-dir=$(genDir) " + 162 "--sources $(location :pw_log_log_proto_with_prefix) " + 163 "--language raw_rpc " + 164 "--no-experimental-proto3-optional " + 165 "--no-experimental-editions " + 166 "--pwpb-no-oneof-callbacks " + 167 "--protoc=$(location aprotoc) && " + 168 // TODO(b/308678575) - Avoid making an extra copy of the created file. 169 "python3 -c \"import os; import shutil; " + 170 "shutil.copy2(os.path.splitext('$(location :pw_log_log_proto_with_prefix)')[0]+'.raw_rpc.pb.h', '$(out)')\"", 171 out: [ 172 "pw_log/proto/log.raw_rpc.pb.h", 173 ], 174 tools: [ 175 "aprotoc", 176 "pw_protobuf_compiler_py", 177 "pw_rpc_plugin_rawpb_py", 178 ], 179} 180 181android_library { 182 name: "pw_log_android_java", 183 srcs: ["java/android_main/dev/pigweed/pw_log/*.java"], 184 visibility: ["//visibility:public"], 185 sdk_version: "current", 186} 187