blob: 40e4dcde2ff180199d65e231c40ff7627719bae1 [file]
// Copyright 2022 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.
package {
default_applicable_licenses: ["external_pigweed_license"],
}
filegroup {
name: "pw_detokenizer_src_files",
srcs: [
"base64.cc",
"csv.cc",
"decode.cc",
"detokenize.cc",
],
}
cc_library_headers {
name: "pw_detokenizer_include_dirs",
export_include_dirs: ["public"],
defaults: [
"pw_android_common_target_support",
],
}
// Downstream projects can configure the pw_tokenizer by defining their own
// static library and changing the flags found under
// pw_tokenizer/public/pw_tokenizer/config.h
//
// cc_library_static {
// name: "custom_detokenizer",
// defaults: ["pw_detokenizer_defaults"],
// cflags: [
// "-DPW_TOKENIZER_NESTED_PREFIX_STR=\"`\"",
// ],
// include_dirs: [
// "external/pigweed",
// ],
// }
cc_defaults {
name: "pw_detokenizer_defaults",
defaults: [
"pw_android_common_backends",
"pw_android_common_target_support",
],
local_include_dirs: ["private"],
header_libs: [
"fuchsia_sdk_lib_stdcompat",
"pw_assert",
"pw_containers_headers",
"pw_log",
"pw_detokenizer_include_dirs",
],
export_header_lib_headers: [
"fuchsia_sdk_lib_stdcompat",
"pw_assert",
"pw_containers_headers",
"pw_log",
"pw_detokenizer_include_dirs",
],
srcs: [
":pw_detokenizer_src_files",
],
static_libs: [
"pw_base64",
"pw_bytes",
"pw_elf_reader",
"pw_log_tokenized",
"pw_polyfill",
"pw_preprocessor",
"pw_result",
"pw_span",
"pw_stream",
"pw_varint",
],
export_static_lib_headers: [
"pw_base64",
"pw_bytes",
"pw_elf_reader",
"pw_polyfill",
"pw_preprocessor",
"pw_result",
"pw_span",
"pw_stream",
"pw_varint",
],
}
cc_library_static {
name: "pw_detokenizer",
defaults: [
"pw_detokenizer_defaults",
],
}
cc_library_static {
name: "pw_tokenizer",
defaults: [
"pw_android_common_backends",
"pw_android_common_target_support",
],
export_include_dirs: ["public"],
srcs: [
"encode_args.cc",
"hash.cc",
"tokenize.cc",
],
header_libs: [
"pw_assert",
"pw_containers_headers",
"pw_log",
],
export_header_lib_headers: [
"pw_assert",
"pw_containers_headers",
"pw_log",
],
static_libs: [
"pw_log_tokenized",
"pw_polyfill",
"pw_preprocessor",
"pw_span",
"pw_varint",
],
export_static_lib_headers: [
"pw_log_tokenized",
"pw_polyfill",
"pw_preprocessor",
"pw_span",
"pw_varint",
],
}
cc_library_static {
name: "pw_tokenizer_base64",
defaults: [
"pw_android_common_backends",
"pw_android_common_target_support",
],
export_include_dirs: ["public"],
srcs: [
"base64.cc",
],
header_libs: [
"pw_containers_headers",
],
export_header_lib_headers: [
"pw_containers_headers",
],
static_libs: [
"pw_base64",
"pw_preprocessor",
"pw_span",
"pw_string",
"pw_tokenizer",
],
export_static_lib_headers: [
"pw_base64",
"pw_preprocessor",
"pw_span",
"pw_string",
"pw_tokenizer",
],
}
cc_library_headers {
name: "pw_tokenizer_pwpb",
defaults: [
"pw_android_common_target_support",
],
generated_headers: [
"google_protobuf_descriptor_pwpb_h",
"pw_tokenizer_proto_options_pwpb_h",
],
export_generated_headers: [
"google_protobuf_descriptor_pwpb_h",
"pw_tokenizer_proto_options_pwpb_h",
],
}
// Expose pw_tokenizer_proto/options.proto.
filegroup {
name: "pw_tokenizer_proto_options_proto",
srcs: [
"pw_tokenizer_proto/options.proto",
],
}
genrule {
name: "pw_tokenizer_proto_options_pwpb_h",
srcs: [
":libprotobuf-internal-protos",
"pw_tokenizer_proto/options.proto",
],
cmd: "python3 $(location pw_protobuf_compiler_py) " +
"--proto-path=external/pigweed/pw_tokenizer/ " +
"--proto-path=external/protobuf/src/ " +
"--out-dir=$$(dirname $(location pw_tokenizer_proto/options.pwpb.h)) " +
"--plugin-path=$(location pw_protobuf_plugin_py) " +
"--compile-dir=$$(dirname $(location pw_tokenizer_proto/options.proto)) " +
"--sources $(location pw_tokenizer_proto/options.proto) " +
"--language pwpb " +
"--no-experimental-proto3-optional " +
"--no-experimental-editions " +
"--pwpb-no-oneof-callbacks " +
"--protoc=$(location aprotoc) ",
out: [
"pw_tokenizer_proto/options.pwpb.h",
],
tools: [
"aprotoc",
"pw_protobuf_compiler_py",
"pw_protobuf_plugin_py",
],
}
rust_protobuf {
name: "libpw_tokenizer_proto_rs",
crate_name: "pw_tokenizer_proto",
protos: [":pw_tokenizer_proto_options_proto"],
source_stem: "pw_tokenizer_source",
exported_include_dirs: ["."],
proto_flags: ["-I external/protobuf/src"],
vendor_available: true,
}
rust_library {
name: "libpw_tokenizer_core",
crate_name: "pw_tokenizer_core",
srcs: ["rust/pw_tokenizer_core.rs"],
vendor_available: true,
host_supported: true,
}
rust_library {
name: "libpw_tokenizer",
crate_name: "pw_tokenizer",
srcs: ["rust/pw_tokenizer/lib.rs"],
cfgs: ["feature=\"std\""],
rustlibs: [
"libnom",
"libpw_base64",
"libpw_bytes",
"libpw_format",
"libpw_format_core",
"libpw_status",
"libpw_stream",
"libpw_tokenizer_core",
"libpw_varint",
],
vendor_available: true,
host_supported: true,
}