Extensions > API reference > ProtoInfo

ProtoInfo

Encapsulates information provided by proto_library.

Please consider using `load("@rules_proto//proto:defs.bzl", "ProtoInfo")` to load this symbol from rules_proto.

check_deps_sources

depset ProtoInfo.check_deps_sources

Proto sources from the 'srcs' attribute. If the library is a proxy library that has no sources, it contains the check_deps_sources from this library's direct deps.

direct_descriptor_set

File ProtoInfo.direct_descriptor_set

The FileDescriptorSet of the direct sources. If no srcs, contains an empty file.

direct_sources

list ProtoInfo.direct_sources

Proto sources from the 'srcs' attribute.

proto_source_root

string ProtoInfo.proto_source_root

The directory relative to which the .proto files defined in the proto_library are defined. For example, if this is 'a/b' and the rule has the file 'a/b/c/d.proto' as a source, that source file would be imported as 'import c/d.proto'

to_json

string ProtoInfo.to_json()

Deprecated. This API is deprecated and will be removed soon. Please do not depend on it. It is disabled with ---incompatible_struct_has_no_methods. Use this flag to verify your code is compatible with its imminent removal.
Creates a JSON string from the struct parameter. This method only works if all struct elements (recursively) are strings, ints, booleans, other structs, a list of these types or a dictionary with string keys and values of these types. Quotes and new lines in strings are escaped. Examples:
struct(key=123).to_json()
# {"key":123}

struct(key=True).to_json()
# {"key":true}

struct(key=[1, 2, 3]).to_json()
# {"key":[1,2,3]}

struct(key='text').to_json()
# {"key":"text"}

struct(key=struct(inner_key='text')).to_json()
# {"key":{"inner_key":"text"}}

struct(key=[struct(inner_key=1), struct(inner_key=2)]).to_json()
# {"key":[{"inner_key":1},{"inner_key":2}]}

struct(key=struct(inner_key=struct(inner_inner_key='text'))).to_json()
# {"key":{"inner_key":{"inner_inner_key":"text"}}}
.

Deprecated: instead, use json.encode(x) or json.encode_indent(x), which work for values other than structs and do not pollute the struct field namespace.

to_proto

string ProtoInfo.to_proto()

Deprecated. This API is deprecated and will be removed soon. Please do not depend on it. It is disabled with ---incompatible_struct_has_no_methods. Use this flag to verify your code is compatible with its imminent removal.
Creates a text message from the struct parameter. This method only works if all struct elements (recursively) are strings, ints, booleans, other structs or dicts or lists of these types. Quotes and new lines in strings are escaped. Struct keys are iterated in the sorted order. Examples:
struct(key=123).to_proto()
# key: 123

struct(key=True).to_proto()
# key: true

struct(key=[1, 2, 3]).to_proto()
# key: 1
# key: 2
# key: 3

struct(key='text').to_proto()
# key: "text"

struct(key=struct(inner_key='text')).to_proto()
# key {
#   inner_key: "text"
# }

struct(key=[struct(inner_key=1), struct(inner_key=2)]).to_proto()
# key {
#   inner_key: 1
# }
# key {
#   inner_key: 2
# }

struct(key=struct(inner_key=struct(inner_inner_key='text'))).to_proto()
# key {
#    inner_key {
#     inner_inner_key: "text"
#   }
# }

struct(foo={4: 3, 2: 1}).to_proto()
# foo: {
#   key: 4
#   value: 3
# }
# foo: {
#   key: 2
#   value: 1
# }

Deprecated: use proto.encode_text(x) instead.

transitive_descriptor_sets

depset ProtoInfo.transitive_descriptor_sets

A set of FileDescriptorSet files of all dependent proto_library rules, and this one's. This is not the same as passing --include_imports to proto-compiler. Will be empty if no dependencies.

transitive_imports

depset ProtoInfo.transitive_imports

Transitive imports including weak dependencies.

transitive_proto_path

depset ProtoInfo.transitive_proto_path

A set of proto source roots collected from the transitive closure of this rule.

transitive_sources

depset ProtoInfo.transitive_sources

Proto sources for this rule and all its dependent protocol buffer rules.