From 6ba75b267d8e8630f3495b739c23c8fbb1e2ef48 Mon Sep 17 00:00:00 2001 From: M1nd3r Date: Tue, 8 Oct 2024 23:21:20 +0200 Subject: [PATCH] chore(core): exclude THP modules and messages from non-THP builds [no changelog] --- core/SConscript.firmware | 11 ++++++++++- core/SConscript.unix | 11 ++++++++++- core/src/all_modules.py.mako | 12 +++++++++--- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/core/SConscript.firmware b/core/SConscript.firmware index 63744c2bdc..04da78afac 100644 --- a/core/SConscript.firmware +++ b/core/SConscript.firmware @@ -473,9 +473,15 @@ env.Replace( # PROTO_SOURCES_DIR = '../../../common/protob/' + +exclude_list = [PROTO_SOURCES_DIR + 'messages-bootloader.proto'] +if not THP: + exclude_list.append(PROTO_SOURCES_DIR + 'messages-thp.proto') + PROTO_SOURCES = Glob(PROTO_SOURCES_DIR + '*.proto', - exclude=[PROTO_SOURCES_DIR + 'messages-bootloader.proto'] + exclude=exclude_list ) + qstr_protobuf = env.Command( target=[ 'genhdr/qstrdefs.protobuf.h', @@ -652,6 +658,9 @@ if FROZEN: SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/tezos/*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Tezos*.py')) + if THP: + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/thp/*.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/zcash/*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/webauthn/*.py')) diff --git a/core/SConscript.unix b/core/SConscript.unix index c23bad1fdb..e7f1bfe5f4 100644 --- a/core/SConscript.unix +++ b/core/SConscript.unix @@ -551,9 +551,15 @@ env.Replace( # PROTO_SOURCES_DIR = '../../../common/protob/' + +exclude_list = [PROTO_SOURCES_DIR + 'messages-bootloader.proto'] +if not THP: + exclude_list.append(PROTO_SOURCES_DIR + 'messages-thp.proto') + PROTO_SOURCES = Glob(PROTO_SOURCES_DIR + '*.proto', - exclude=[PROTO_SOURCES_DIR + 'messages-bootloader.proto'] + exclude=exclude_list ) + qstr_protobuf = env.Command( target=[ 'genhdr/qstrdefs.protobuf.h', @@ -733,6 +739,9 @@ if FROZEN: SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/tezos/*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Tezos*.py')) + if THP: + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/thp/*.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/zcash/*.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/webauthn/*.py')) diff --git a/core/src/all_modules.py.mako b/core/src/all_modules.py.mako index b37fcd9bbd..73aeb01d61 100644 --- a/core/src/all_modules.py.mako +++ b/core/src/all_modules.py.mako @@ -43,8 +43,9 @@ def make_import_name(pyfile): imports = [make_import_name(f) for f in pyfiles] -imports_common = [import_name for import_name in imports if not any(a in import_name.lower() for a in ALTCOINS)] -imports_altcoin = [import_name for import_name in imports if import_name not in imports_common] +imports_thp = [import_name for import_name in imports if ".thp" in import_name.lower()] +imports_common = [import_name for import_name in imports if (not any(a in import_name.lower() for a in ALTCOINS) and import_name not in imports_thp)] +imports_altcoin = [import_name for import_name in imports if import_name not in imports_common and import_name not in imports_thp] %>\ from trezor.utils import halt @@ -79,12 +80,17 @@ ${import_name} import ${import_name} % endfor +if utils.USE_THP: +% for import_name in imports_thp: + ${import_name} + import ${import_name} +% endfor + if not utils.BITCOIN_ONLY: % for import_name in imports_altcoin: ${import_name} import ${import_name} % endfor - # generate full alphabet <% ALPHABET = "abcdefghijklmnopqrstuvwxyz"