mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 12:28:09 +00:00
build(core): improve model detection
instead of MODEL_IS_T2B1, we now catch INTERNAL_MODEL == Txyz this is still not perfect because it can't detect 'in'/'not in', which sucks but what can we do
This commit is contained in:
parent
87619c19ee
commit
44a6696f24
@ -42,16 +42,13 @@ def generate(env):
|
|||||||
# replace "utils.BITCOIN_ONLY" with literal constant (True/False)
|
# replace "utils.BITCOIN_ONLY" with literal constant (True/False)
|
||||||
# so the compiler can optimize out the things we don't want
|
# so the compiler can optimize out the things we don't want
|
||||||
btc_only = env["bitcoin_only"] == "1"
|
btc_only = env["bitcoin_only"] == "1"
|
||||||
is_t2b1 = env["TREZOR_MODEL"] == "R"
|
|
||||||
backlight = env["backlight"]
|
backlight = env["backlight"]
|
||||||
optiga = env["optiga"]
|
optiga = env["optiga"]
|
||||||
layout_tt = env["ui_layout"] == "UI_LAYOUT_TT"
|
layout_tt = env["ui_layout"] == "UI_LAYOUT_TT"
|
||||||
layout_tr = env["ui_layout"] == "UI_LAYOUT_TR"
|
layout_tr = env["ui_layout"] == "UI_LAYOUT_TR"
|
||||||
thp = env["thp"]
|
thp = env["thp"]
|
||||||
interim = f"{target[:-4]}.i" # replace .mpy with .i
|
interim = f"{target[:-4]}.i" # replace .mpy with .i
|
||||||
sed_scripts = " ".join(
|
sed_scripts = [
|
||||||
[
|
|
||||||
rf"-e 's/utils\.MODEL_IS_T2B1/{is_t2b1}/g'",
|
|
||||||
rf"-e 's/utils\.BITCOIN_ONLY/{btc_only}/g'",
|
rf"-e 's/utils\.BITCOIN_ONLY/{btc_only}/g'",
|
||||||
rf"-e 's/utils\.USE_BACKLIGHT/{backlight}/g'",
|
rf"-e 's/utils\.USE_BACKLIGHT/{backlight}/g'",
|
||||||
rf"-e 's/utils\.USE_OPTIGA/{optiga}/g'",
|
rf"-e 's/utils\.USE_OPTIGA/{optiga}/g'",
|
||||||
@ -63,8 +60,23 @@ def generate(env):
|
|||||||
r"-e '/from typing import (/,/^\s*)/ {s/^/# /; }'",
|
r"-e '/from typing import (/,/^\s*)/ {s/^/# /; }'",
|
||||||
r"-e 's/from typing import/# \0/'",
|
r"-e 's/from typing import/# \0/'",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
MODEL_SYMS = {
|
||||||
|
"T": "T2T1",
|
||||||
|
"R": "T2B1",
|
||||||
|
"T3T1": "T3T1",
|
||||||
|
}
|
||||||
|
|
||||||
|
for model_sym, internal_model in MODEL_SYMS.items():
|
||||||
|
model_matches = env["TREZOR_MODEL"] == model_sym
|
||||||
|
sed_scripts.extend(
|
||||||
|
(
|
||||||
|
rf"-e 's/utils\.INTERNAL_MODEL == \"{internal_model}\"/{model_matches}/g'",
|
||||||
|
rf"-e 's/utils\.INTERNAL_MODEL != \"{internal_model}\"/{not model_matches}/g'",
|
||||||
)
|
)
|
||||||
return f"$SED {sed_scripts} {source} > {interim} && $MPY_CROSS -o {target} -s {source_name} {interim}"
|
)
|
||||||
|
|
||||||
|
return f"$SED {' '.join(sed_scripts)} {source} > {interim} && $MPY_CROSS -o {target} -s {source_name} {interim}"
|
||||||
|
|
||||||
env["BUILDERS"]["FrozenModule"] = SCons.Builder.Builder(
|
env["BUILDERS"]["FrozenModule"] = SCons.Builder.Builder(
|
||||||
generator=generate_frozen_module,
|
generator=generate_frozen_module,
|
||||||
|
@ -126,8 +126,8 @@ def get_features() -> Features:
|
|||||||
Capability.Translations,
|
Capability.Translations,
|
||||||
]
|
]
|
||||||
|
|
||||||
# We do not support some currencies on T2B1
|
# We don't support some currencies on later models (see #2793)
|
||||||
if not utils.MODEL_IS_T2B1:
|
if utils.INTERNAL_MODEL == "T2T1":
|
||||||
f.capabilities.extend(
|
f.capabilities.extend(
|
||||||
[
|
[
|
||||||
Capability.NEM,
|
Capability.NEM,
|
||||||
|
@ -30,10 +30,6 @@ from trezorutils import ( # noqa: F401
|
|||||||
)
|
)
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
# Will get replaced by "True" / "False" in the build process
|
|
||||||
# However, needs to stay as an exported symbol for the unit tests
|
|
||||||
MODEL_IS_T2B1: bool = INTERNAL_MODEL == "T2B1"
|
|
||||||
|
|
||||||
DISABLE_ANIMATION = 0
|
DISABLE_ANIMATION = 0
|
||||||
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from common import * # isort:skip
|
from common import * # isort:skip
|
||||||
|
|
||||||
if not utils.MODEL_IS_T2B1:
|
if utils.INTERNAL_MODEL not in ("T2B1", "T3T1"):
|
||||||
from trezor.crypto import bip39
|
from trezor.crypto import bip39
|
||||||
from trezor.enums import AmountUnit, OutputScriptType
|
from trezor.enums import AmountUnit, OutputScriptType
|
||||||
from trezor.enums.RequestType import TXFINISHED, TXINPUT, TXMETA, TXOUTPUT
|
from trezor.enums.RequestType import TXFINISHED, TXINPUT, TXMETA, TXOUTPUT
|
||||||
@ -405,5 +405,5 @@ class TestSignTxDecred(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if not utils.MODEL_IS_T2B1:
|
if utils.INTERNAL_MODEL not in ("T2B1", "T3T1"):
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
@ -22,7 +22,7 @@ class TestCoins(unittest.TestCase):
|
|||||||
("ZEC", "Zcash", 7352),
|
("ZEC", "Zcash", 7352),
|
||||||
("TAZ", "Zcash Testnet", 7461),
|
("TAZ", "Zcash Testnet", 7461),
|
||||||
]
|
]
|
||||||
if not utils.MODEL_IS_T2B1:
|
if utils.INTERNAL_MODEL not in ("T2B1", "T3T1"):
|
||||||
ref.extend(
|
ref.extend(
|
||||||
[
|
[
|
||||||
("NMC", "Namecoin", 52),
|
("NMC", "Namecoin", 52),
|
||||||
|
Loading…
Reference in New Issue
Block a user