2024-01-19 11:39:34 +00:00
|
|
|
# generated from ${THIS_FILE.name}
|
2022-04-28 10:22:53 +00:00
|
|
|
# (by running `make templates` in `core`)
|
2021-03-22 15:10:21 +00:00
|
|
|
# do not edit manually!
|
|
|
|
# flake8: noqa
|
|
|
|
# fmt: off
|
|
|
|
# isort:skip_file
|
|
|
|
<%
|
|
|
|
from itertools import chain
|
|
|
|
|
2024-01-19 11:39:34 +00:00
|
|
|
SRCDIR = THIS_FILE.parent
|
2021-03-22 15:10:21 +00:00
|
|
|
|
|
|
|
PATTERNS = (
|
|
|
|
"*.py",
|
|
|
|
"storage/**/*.py",
|
|
|
|
"trezor/**/*.py",
|
|
|
|
"apps/**/*.py",
|
|
|
|
)
|
|
|
|
|
2021-06-01 13:23:07 +00:00
|
|
|
ALTCOINS = (
|
|
|
|
"binance",
|
|
|
|
"cardano",
|
|
|
|
"eos",
|
|
|
|
"ethereum",
|
|
|
|
"monero",
|
|
|
|
"nem",
|
|
|
|
"ripple",
|
2023-10-18 09:40:19 +00:00
|
|
|
"solana",
|
2021-06-01 13:23:07 +00:00
|
|
|
"stellar",
|
|
|
|
"tezos",
|
|
|
|
"webauthn",
|
2021-09-27 22:43:11 +00:00
|
|
|
"zcash",
|
2021-06-01 13:23:07 +00:00
|
|
|
)
|
|
|
|
|
2021-03-22 15:10:21 +00:00
|
|
|
pyfiles = chain.from_iterable(sorted(SRCDIR.glob(p)) for p in PATTERNS)
|
2021-06-01 13:23:07 +00:00
|
|
|
|
|
|
|
def make_import_name(pyfile):
|
|
|
|
importfile = pyfile.relative_to(SRCDIR)
|
|
|
|
if importfile.name == "__init__.py":
|
|
|
|
import_name = str(importfile.parent)
|
|
|
|
else:
|
|
|
|
import_name = str(importfile.with_suffix(""))
|
|
|
|
return import_name.replace("/", ".")
|
|
|
|
|
|
|
|
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]
|
|
|
|
|
2021-03-22 15:10:21 +00:00
|
|
|
%>\
|
|
|
|
from trezor.utils import halt
|
|
|
|
|
|
|
|
# this module should not be part of the build, its purpose is only to add missed Qstrings
|
|
|
|
halt("Tried to import excluded module.")
|
|
|
|
|
|
|
|
# explanation:
|
|
|
|
# uPy collects string literals and symbol names from all frozen modules, and converts
|
|
|
|
# them to qstrings for certain usages. In particular, it appears that qualified names
|
|
|
|
# of modules in sys.modules must be qstrings. However, the collection process is
|
|
|
|
# imperfect. If `apps.common.mnemonic` is always imported as `from ..common import mnemonic`,
|
|
|
|
# the string "apps.common.mnemonic" never appears in source code, is never collected,
|
|
|
|
# but then is generated and interned at runtime.
|
|
|
|
# A similar thing happens in reverse: if module `storage.cache` is always imported as
|
|
|
|
# this name, then "storage.cache" is collected but neither "storage" nor "cache" alone.
|
|
|
|
# Which is a problem, because "cache" is a symbol that is added to `storage`'s dict.
|
|
|
|
#
|
|
|
|
# We need to avoid run-time interning as much as possible, because it creates
|
|
|
|
# uncollectable garbage in the GC arena.
|
|
|
|
#
|
|
|
|
# Below, every module is listed both as import (which collects the qualified name)
|
|
|
|
# and as a symbol (which collects each individual component).
|
|
|
|
# In addition, we list the alphabet, because apparently one-character strings are always
|
|
|
|
# interned, and some operation somewhere (rendering?) is reading strings character by
|
|
|
|
# character.
|
|
|
|
|
2021-06-01 13:23:07 +00:00
|
|
|
from trezor import utils
|
|
|
|
|
|
|
|
% for import_name in imports_common:
|
2021-03-22 15:10:21 +00:00
|
|
|
${import_name}
|
|
|
|
import ${import_name}
|
|
|
|
% endfor
|
|
|
|
|
2021-09-27 22:43:11 +00:00
|
|
|
if not utils.BITCOIN_ONLY:
|
2021-06-01 13:23:07 +00:00
|
|
|
% for import_name in imports_altcoin:
|
|
|
|
${import_name}
|
|
|
|
import ${import_name}
|
|
|
|
% endfor
|
|
|
|
|
2021-03-22 15:10:21 +00:00
|
|
|
# generate full alphabet
|
|
|
|
<%
|
|
|
|
ALPHABET = "abcdefghijklmnopqrstuvwxyz"
|
|
|
|
%>\
|
|
|
|
% for letter in ALPHABET:
|
|
|
|
${letter}
|
|
|
|
${letter.upper()}
|
|
|
|
% endfor
|