From f351bc378710bb3c2bece71b7b0ed3b9ec6b5f92 Mon Sep 17 00:00:00 2001 From: M1nd3r Date: Mon, 10 Jun 2024 14:18:39 +0200 Subject: [PATCH] fixup!: revert changes in pb2py and build_protobuf --- common/protob/pb2py | 22 ++++++++-------------- tools/build_protobuf | 3 +-- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/common/protob/pb2py b/common/protob/pb2py index 53bd7234b..5eddadd42 100755 --- a/common/protob/pb2py +++ b/common/protob/pb2py @@ -327,13 +327,12 @@ def find_by_name(haystack, name, default=None): class Descriptor: - def __init__(self, data, include_deprecated: bool, bitcoin_only: bool, exclude_internal_only: bool): + def __init__(self, data, include_deprecated: bool, bitcoin_only: bool): self.descriptor = descriptor_pb2.FileDescriptorSet() self.descriptor.ParseFromString(data) self.include_deprecated = include_deprecated self.bitcoin_only = bitcoin_only - self.exclude_internal_only = exclude_internal_only self.files = self.descriptor.file logging.debug(f"found {len(self.files)} files") @@ -379,15 +378,13 @@ class Descriptor: for enum in self.enums: self.convert_enum_value_names(enum) - def _filter_items(self, items): - def should_include(item)-> bool: - if not self.include_deprecated and item.options.deprecated: - return False - if self.exclude_internal_only and self._get_extension(item,"internal_only",False): - return False - return True - - return [item for item in items if should_include(item)] + def _filter_items(self, iter): + return [ + item + for item in iter + # exclude deprecated items unless specified + if (self.include_deprecated or not item.options.deprecated) + ] def _get_extension(self, something, extension_name, default=None): if something is None: @@ -700,7 +697,6 @@ WritableDirectory = click.Path(exists=True, file_okay=False, writable=True) @click.option("-v", "--verbose", is_flag=True) @click.option("-d", "--include-deprecated", is_flag=True, help="Include deprecated fields, messages and enums") @click.option("-b", "--bitcoin-only", type=int, default=0, help="Exclude fields, messages and enums that do not belong to bitcoin_only builds") -@click.option("--exclude-internal-only", is_flag=True, help="Exclude fields, messages and enums that are only for internal purposes") # fmt: on def main( proto, @@ -714,7 +710,6 @@ def main( verbose, include_deprecated, bitcoin_only, - exclude_internal_only ): if verbose: logging.basicConfig(level=logging.DEBUG) @@ -724,7 +719,6 @@ def main( descriptor_proto, include_deprecated=include_deprecated, bitcoin_only=bitcoin_only, - exclude_internal_only=exclude_internal_only ) if python_outdir: diff --git a/tools/build_protobuf b/tools/build_protobuf index a9ad8f818..e0c898fab 100755 --- a/tools/build_protobuf +++ b/tools/build_protobuf @@ -65,6 +65,5 @@ $func file core/src/trezor/messages.py "$CORE_PROTOBUF_SOURCES" --template=core/ $func file python/src/trezorlib/messages.py "$PYTHON_PROTOBUF_SOURCES" \ --template=python/src/trezorlib/_proto_messages.mako \ - --include-deprecated \ - --exclude-internal-only + --include-deprecated exit $RETURN