2017-08-03 18:46:40 +00:00
|
|
|
# pylint: disable=E0602
|
2021-03-23 12:14:33 +00:00
|
|
|
# fmt: off
|
2017-08-03 18:46:40 +00:00
|
|
|
|
2017-08-07 10:50:24 +00:00
|
|
|
import os
|
2022-08-18 13:12:02 +00:00
|
|
|
import tools
|
2017-08-07 10:50:24 +00:00
|
|
|
|
2019-08-22 18:15:16 +00:00
|
|
|
BITCOIN_ONLY = ARGUMENTS.get('BITCOIN_ONLY', '0')
|
|
|
|
EVERYTHING = BITCOIN_ONLY != '1'
|
2020-08-28 12:50:38 +00:00
|
|
|
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
|
2022-08-16 14:51:10 +00:00
|
|
|
DMA2D = TREZOR_MODEL in ('T', )
|
2023-01-30 14:36:22 +00:00
|
|
|
CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0))
|
2019-08-21 16:53:08 +00:00
|
|
|
|
2023-02-09 22:56:03 +00:00
|
|
|
if TREZOR_MODEL in ('DISC1', ):
|
|
|
|
# skip unix build
|
|
|
|
env = Environment()
|
|
|
|
def build_unix(target,source,env):
|
|
|
|
print(f'Emulator: nothing to build for Model {TREZOR_MODEL}')
|
|
|
|
program_bin = env.Command(
|
|
|
|
target='trezor-emu-core',
|
|
|
|
source=None,
|
|
|
|
action=build_unix)
|
|
|
|
Return()
|
|
|
|
|
2020-11-18 13:44:17 +00:00
|
|
|
FEATURE_FLAGS = {
|
2022-02-04 12:41:56 +00:00
|
|
|
"SECP256K1_ZKP": True, # required for trezor.crypto.curve.bip340 (BIP340/Taproot)
|
2020-11-18 13:44:17 +00:00
|
|
|
}
|
|
|
|
|
2017-08-03 18:46:40 +00:00
|
|
|
CCFLAGS_MOD = ''
|
|
|
|
CPPPATH_MOD = []
|
|
|
|
CPPDEFINES_MOD = []
|
2020-09-21 13:32:02 +00:00
|
|
|
SOURCE_MOD = [
|
|
|
|
'vendor/micropython/extmod/vfs_posix_file.c',
|
|
|
|
]
|
2017-08-03 18:46:40 +00:00
|
|
|
|
2019-08-21 15:46:30 +00:00
|
|
|
PYOPT = ARGUMENTS.get('PYOPT', '1')
|
2019-08-21 16:09:56 +00:00
|
|
|
FROZEN = ARGUMENTS.get('TREZOR_EMULATOR_FROZEN', 0)
|
2022-04-28 10:05:47 +00:00
|
|
|
RASPI = os.getenv('TREZOR_EMULATOR_RASPI') == '1'
|
2019-05-04 20:10:01 +00:00
|
|
|
|
2023-02-09 22:56:03 +00:00
|
|
|
if TREZOR_MODEL in ('1', 'R'):
|
2023-06-05 15:30:22 +00:00
|
|
|
FONT_NORMAL='Font_PixelOperator_Regular_8'
|
2023-05-12 09:19:35 +00:00
|
|
|
FONT_DEMIBOLD='Font_Unifont_Bold_16'
|
2022-08-18 13:12:02 +00:00
|
|
|
FONT_BOLD='Font_PixelOperator_Bold_8'
|
|
|
|
FONT_MONO='Font_PixelOperatorMono_Regular_8'
|
2023-06-05 15:30:22 +00:00
|
|
|
FONT_BIG='Font_Unifont_Regular_16'
|
2023-06-05 15:03:22 +00:00
|
|
|
elif TREZOR_MODEL in ('T', ):
|
2023-03-02 09:38:04 +00:00
|
|
|
FONT_NORMAL='Font_TTHoves_Regular_21'
|
|
|
|
FONT_DEMIBOLD='Font_TTHoves_DemiBold_21'
|
|
|
|
FONT_BOLD='Font_TTHoves_Bold_17'
|
2023-04-03 10:03:39 +00:00
|
|
|
FONT_MONO='Font_RobotoMono_Medium_20'
|
2023-06-05 15:03:22 +00:00
|
|
|
FONT_BIG=None
|
2022-08-18 13:12:02 +00:00
|
|
|
|
2017-08-03 18:46:40 +00:00
|
|
|
# modtrezorconfig
|
2019-01-24 15:17:37 +00:00
|
|
|
CPPPATH_MOD += [
|
|
|
|
'embed/extmod/modtrezorconfig',
|
|
|
|
'vendor/trezor-storage',
|
|
|
|
]
|
2017-08-03 18:46:40 +00:00
|
|
|
SOURCE_MOD += [
|
|
|
|
'embed/extmod/modtrezorconfig/modtrezorconfig.c',
|
2019-01-24 15:17:37 +00:00
|
|
|
'vendor/trezor-storage/norcow.c',
|
|
|
|
'vendor/trezor-storage/storage.c',
|
2023-06-30 10:12:55 +00:00
|
|
|
'vendor/trezor-storage/flash_common.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
# modtrezorcrypto
|
|
|
|
CCFLAGS_MOD += '-Wno-sequence-point '
|
|
|
|
CPPPATH_MOD += [
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto',
|
2017-08-03 18:46:40 +00:00
|
|
|
]
|
|
|
|
CPPDEFINES_MOD += [
|
|
|
|
'AES_128',
|
|
|
|
'AES_192',
|
2023-03-20 14:56:57 +00:00
|
|
|
'USE_INSECURE_PRNG',
|
2020-04-29 08:59:10 +00:00
|
|
|
('USE_BIP32_CACHE', '0'),
|
2017-12-23 14:12:31 +00:00
|
|
|
('USE_KECCAK', '1'),
|
2019-08-21 16:53:08 +00:00
|
|
|
('USE_ETHEREUM', '1' if EVERYTHING else '0'),
|
|
|
|
('USE_MONERO', '1' if EVERYTHING else '0'),
|
|
|
|
('USE_CARDANO', '1' if EVERYTHING else '0'),
|
2023-08-28 14:46:57 +00:00
|
|
|
('USE_NEM', '1' if (EVERYTHING and TREZOR_MODEL != "R") else '0'),
|
|
|
|
('USE_EOS', '1' if (EVERYTHING and TREZOR_MODEL != "R") else '0'),
|
2017-08-03 18:46:40 +00:00
|
|
|
]
|
|
|
|
SOURCE_MOD += [
|
2021-03-23 12:14:33 +00:00
|
|
|
'embed/extmod/trezorobj.c',
|
2017-12-19 20:54:22 +00:00
|
|
|
'embed/extmod/modtrezorcrypto/crc.c',
|
2022-08-16 14:51:10 +00:00
|
|
|
'embed/extmod/modtrezorcrypto/modtrezorcrypto.c',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/address.c',
|
2022-08-16 14:51:10 +00:00
|
|
|
'vendor/trezor-crypto/aes/aes_modes.c',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/aes/aescrypt.c',
|
|
|
|
'vendor/trezor-crypto/aes/aeskey.c',
|
|
|
|
'vendor/trezor-crypto/aes/aestab.c',
|
2018-03-09 10:37:06 +00:00
|
|
|
'vendor/trezor-crypto/base32.c',
|
2022-08-16 14:51:10 +00:00
|
|
|
'vendor/trezor-crypto/base58.c',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/bignum.c',
|
|
|
|
'vendor/trezor-crypto/bip32.c',
|
|
|
|
'vendor/trezor-crypto/bip39.c',
|
2022-05-31 13:58:34 +00:00
|
|
|
'vendor/trezor-crypto/bip39_english.c',
|
2017-12-12 21:00:15 +00:00
|
|
|
'vendor/trezor-crypto/blake256.c',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/blake2b.c',
|
|
|
|
'vendor/trezor-crypto/blake2s.c',
|
2018-01-02 17:57:23 +00:00
|
|
|
'vendor/trezor-crypto/chacha20poly1305/chacha20poly1305.c',
|
|
|
|
'vendor/trezor-crypto/chacha20poly1305/chacha_merged.c',
|
|
|
|
'vendor/trezor-crypto/chacha20poly1305/poly1305-donna.c',
|
|
|
|
'vendor/trezor-crypto/chacha20poly1305/rfc7539.c',
|
2020-02-26 16:39:59 +00:00
|
|
|
'vendor/trezor-crypto/chacha_drbg.c',
|
2022-08-16 14:51:10 +00:00
|
|
|
'vendor/trezor-crypto/curves.c',
|
|
|
|
'vendor/trezor-crypto/ecdsa.c',
|
2017-12-12 21:00:15 +00:00
|
|
|
'vendor/trezor-crypto/ed25519-donna/curve25519-donna-32bit.c',
|
|
|
|
'vendor/trezor-crypto/ed25519-donna/curve25519-donna-helpers.c',
|
|
|
|
'vendor/trezor-crypto/ed25519-donna/curve25519-donna-scalarmult-base.c',
|
|
|
|
'vendor/trezor-crypto/ed25519-donna/ed25519-donna-32bit-tables.c',
|
|
|
|
'vendor/trezor-crypto/ed25519-donna/ed25519-donna-basepoint-table.c',
|
|
|
|
'vendor/trezor-crypto/ed25519-donna/ed25519-donna-impl-base.c',
|
|
|
|
'vendor/trezor-crypto/ed25519-donna/ed25519-keccak.c',
|
|
|
|
'vendor/trezor-crypto/ed25519-donna/ed25519-sha3.c',
|
2022-08-16 14:51:10 +00:00
|
|
|
'vendor/trezor-crypto/ed25519-donna/ed25519.c',
|
2017-12-12 21:00:15 +00:00
|
|
|
'vendor/trezor-crypto/ed25519-donna/modm-donna-32bit.c',
|
2018-06-15 08:31:21 +00:00
|
|
|
'vendor/trezor-crypto/groestl.c',
|
2017-12-12 21:00:15 +00:00
|
|
|
'vendor/trezor-crypto/hasher.c',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/hmac.c',
|
2019-06-07 10:16:24 +00:00
|
|
|
'vendor/trezor-crypto/hmac_drbg.c',
|
2018-01-18 14:26:22 +00:00
|
|
|
'vendor/trezor-crypto/memzero.c',
|
2019-05-01 11:39:44 +00:00
|
|
|
'vendor/trezor-crypto/nem.c',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/nist256p1.c',
|
|
|
|
'vendor/trezor-crypto/pbkdf2.c',
|
2018-01-13 14:28:35 +00:00
|
|
|
'vendor/trezor-crypto/rand.c',
|
2019-06-07 10:16:24 +00:00
|
|
|
'vendor/trezor-crypto/rfc6979.c',
|
2022-08-16 14:51:10 +00:00
|
|
|
'vendor/trezor-crypto/ripemd160.c',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/secp256k1.c',
|
2022-09-09 20:11:58 +00:00
|
|
|
'vendor/trezor-crypto/segwit_addr.c',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/sha2.c',
|
|
|
|
'vendor/trezor-crypto/sha3.c',
|
2019-04-17 09:26:16 +00:00
|
|
|
'vendor/trezor-crypto/shamir.c',
|
2019-06-23 10:18:24 +00:00
|
|
|
'vendor/trezor-crypto/slip39.c',
|
2023-05-04 12:14:58 +00:00
|
|
|
'vendor/trezor-crypto/slip39_english.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
]
|
2019-08-21 16:53:08 +00:00
|
|
|
if EVERYTHING:
|
|
|
|
SOURCE_MOD += [
|
2021-10-15 15:26:13 +00:00
|
|
|
'vendor/trezor-crypto/cardano.c',
|
2019-08-21 16:53:08 +00:00
|
|
|
'vendor/trezor-crypto/monero/base58.c',
|
|
|
|
'vendor/trezor-crypto/monero/serialize.c',
|
|
|
|
'vendor/trezor-crypto/monero/xmr.c',
|
|
|
|
]
|
2017-08-03 18:46:40 +00:00
|
|
|
|
2019-04-02 15:13:03 +00:00
|
|
|
# libsecp256k1-zkp
|
2021-03-18 13:48:10 +00:00
|
|
|
if FEATURE_FLAGS["SECP256K1_ZKP"]:
|
2019-08-21 16:53:08 +00:00
|
|
|
CPPPATH_MOD += [
|
|
|
|
'vendor/secp256k1-zkp',
|
|
|
|
'vendor/secp256k1-zkp/src',
|
|
|
|
'vendor/secp256k1-zkp/include',
|
|
|
|
]
|
|
|
|
CPPDEFINES_MOD += [
|
2021-05-12 13:50:25 +00:00
|
|
|
'USE_SECP256K1_ZKP',
|
|
|
|
'USE_SECP256K1_ZKP_ECDSA',
|
2021-11-03 20:57:07 +00:00
|
|
|
('SECP256K1_CONTEXT_SIZE', '208'),
|
2019-08-21 16:53:08 +00:00
|
|
|
'USE_EXTERNAL_DEFAULT_CALLBACKS',
|
2022-08-24 15:04:43 +00:00
|
|
|
('ECMULT_GEN_PREC_BITS', '2'),
|
2019-08-21 16:53:08 +00:00
|
|
|
('ECMULT_WINDOW_SIZE', '8'),
|
|
|
|
'ENABLE_MODULE_GENERATOR',
|
|
|
|
'ENABLE_MODULE_RECOVERY',
|
2021-05-14 15:20:32 +00:00
|
|
|
'ENABLE_MODULE_SCHNORRSIG',
|
|
|
|
'ENABLE_MODULE_EXTRAKEYS',
|
2019-08-21 16:53:08 +00:00
|
|
|
]
|
2020-11-18 13:44:17 +00:00
|
|
|
SOURCE_MOD_SECP256K1_ZKP = [
|
2019-08-21 16:53:08 +00:00
|
|
|
'vendor/secp256k1-zkp/src/secp256k1.c',
|
2022-01-26 16:49:48 +00:00
|
|
|
'vendor/secp256k1-zkp/src/precomputed_ecmult.c',
|
|
|
|
'vendor/secp256k1-zkp/src/precomputed_ecmult_gen.c',
|
2019-08-21 16:53:08 +00:00
|
|
|
]
|
2021-05-12 13:50:25 +00:00
|
|
|
SOURCE_MOD += [
|
|
|
|
'vendor/trezor-crypto/zkp_context.c',
|
|
|
|
'vendor/trezor-crypto/zkp_ecdsa.c',
|
2021-10-19 19:09:59 +00:00
|
|
|
'vendor/trezor-crypto/zkp_bip340.c',
|
2021-05-12 13:50:25 +00:00
|
|
|
]
|
2019-04-02 15:13:03 +00:00
|
|
|
|
2017-08-03 18:46:40 +00:00
|
|
|
# modtrezorio
|
|
|
|
SOURCE_MOD += [
|
|
|
|
'embed/extmod/modtrezorio/modtrezorio.c',
|
|
|
|
]
|
2022-04-25 10:05:19 +00:00
|
|
|
if TREZOR_MODEL in ('T',):
|
2021-05-13 10:33:52 +00:00
|
|
|
SOURCE_MOD += [
|
|
|
|
'embed/extmod/modtrezorio/ff.c',
|
|
|
|
'embed/extmod/modtrezorio/ffunicode.c',
|
|
|
|
]
|
2017-08-03 18:46:40 +00:00
|
|
|
|
|
|
|
# modtrezorui
|
2020-01-16 10:56:50 +00:00
|
|
|
CPPPATH_MOD += [
|
2021-09-09 18:26:10 +00:00
|
|
|
'vendor/micropython/lib/uzlib',
|
2020-01-16 10:56:50 +00:00
|
|
|
]
|
2017-08-03 18:46:40 +00:00
|
|
|
SOURCE_MOD += [
|
2023-04-14 15:18:03 +00:00
|
|
|
'embed/lib/unit_variant.c',
|
2023-03-27 13:03:54 +00:00
|
|
|
'embed/lib/buffers.c',
|
|
|
|
'embed/lib/colors.c',
|
|
|
|
'embed/lib/display.c',
|
|
|
|
'embed/lib/fonts/fonts.c',
|
|
|
|
'embed/lib/fonts/font_bitmap.c',
|
2023-06-30 10:12:55 +00:00
|
|
|
'embed/lib/image.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
'embed/extmod/modtrezorui/modtrezorui.c',
|
2021-09-09 18:26:10 +00:00
|
|
|
'vendor/micropython/lib/uzlib/adler32.c',
|
|
|
|
'vendor/micropython/lib/uzlib/crc32.c',
|
|
|
|
'vendor/micropython/lib/uzlib/tinflate.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
]
|
2023-06-30 10:12:55 +00:00
|
|
|
|
|
|
|
if TREZOR_MODEL in ('1', ):
|
|
|
|
SOURCE_MOD += [
|
|
|
|
'embed/models/model_T1B1_layout.c',
|
|
|
|
]
|
|
|
|
elif TREZOR_MODEL in ('T', ):
|
|
|
|
SOURCE_MOD += [
|
|
|
|
'embed/models/model_T2T1_layout.c',
|
|
|
|
]
|
|
|
|
elif TREZOR_MODEL in ('R', ):
|
|
|
|
SOURCE_MOD += [
|
|
|
|
'embed/models/model_T2B1_layout.c',
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-20 12:26:06 +00:00
|
|
|
CPPDEFINES_MOD += [
|
|
|
|
'TREZOR_UI2',
|
|
|
|
]
|
2022-05-05 11:47:19 +00:00
|
|
|
if TREZOR_MODEL not in ('1', ):
|
|
|
|
CPPDEFINES_MOD += [
|
|
|
|
'FANCY_FATAL_ERROR',
|
|
|
|
]
|
|
|
|
|
2019-08-21 15:50:09 +00:00
|
|
|
if FROZEN:
|
2019-05-04 20:10:01 +00:00
|
|
|
CPPDEFINES_MOD += ['TREZOR_EMULATOR_FROZEN']
|
2022-04-28 10:05:47 +00:00
|
|
|
if RASPI:
|
|
|
|
CPPDEFINES_MOD += ['TREZOR_EMULATOR_RASPI']
|
2017-08-03 18:46:40 +00:00
|
|
|
|
|
|
|
# modtrezorutils
|
|
|
|
SOURCE_MOD += [
|
|
|
|
'embed/extmod/modtrezorutils/modtrezorutils.c',
|
|
|
|
]
|
|
|
|
|
2021-03-23 12:30:03 +00:00
|
|
|
# rust mods
|
|
|
|
SOURCE_MOD += [
|
2023-06-26 12:12:22 +00:00
|
|
|
'embed/extmod/rustmods.c',
|
2021-03-23 12:30:03 +00:00
|
|
|
]
|
|
|
|
|
2017-08-03 18:46:40 +00:00
|
|
|
# modutime
|
2018-01-02 18:59:40 +00:00
|
|
|
SOURCE_MOD += [
|
2021-10-26 12:52:37 +00:00
|
|
|
'embed/extmod/modutime.c',
|
2018-01-02 18:59:40 +00:00
|
|
|
]
|
2017-08-03 18:46:40 +00:00
|
|
|
|
|
|
|
SOURCE_MICROPYTHON = [
|
|
|
|
'vendor/micropython/extmod/modubinascii.c',
|
|
|
|
'vendor/micropython/extmod/moductypes.c',
|
|
|
|
'vendor/micropython/extmod/moduheapq.c',
|
2023-01-24 20:57:27 +00:00
|
|
|
'vendor/micropython/extmod/moduos.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
'vendor/micropython/extmod/modutimeq.c',
|
|
|
|
'vendor/micropython/extmod/utime_mphal.c',
|
2021-09-09 18:26:10 +00:00
|
|
|
'vendor/micropython/shared/readline/readline.c',
|
2021-10-26 12:52:37 +00:00
|
|
|
'vendor/micropython/shared/timeutils/timeutils.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
'vendor/micropython/py/argcheck.c',
|
|
|
|
'vendor/micropython/py/asmarm.c',
|
|
|
|
'vendor/micropython/py/asmbase.c',
|
|
|
|
'vendor/micropython/py/asmthumb.c',
|
|
|
|
'vendor/micropython/py/asmx64.c',
|
|
|
|
'vendor/micropython/py/asmx86.c',
|
|
|
|
'vendor/micropython/py/asmxtensa.c',
|
|
|
|
'vendor/micropython/py/bc.c',
|
|
|
|
'vendor/micropython/py/binary.c',
|
|
|
|
'vendor/micropython/py/builtinevex.c',
|
|
|
|
'vendor/micropython/py/builtinhelp.c',
|
|
|
|
'vendor/micropython/py/builtinimport.c',
|
|
|
|
'vendor/micropython/py/compile.c',
|
|
|
|
'vendor/micropython/py/emitbc.c',
|
|
|
|
'vendor/micropython/py/emitcommon.c',
|
|
|
|
'vendor/micropython/py/emitglue.c',
|
2018-10-25 23:09:02 +00:00
|
|
|
'vendor/micropython/py/emitinlinethumb.c',
|
|
|
|
'vendor/micropython/py/emitinlinextensa.c',
|
|
|
|
'vendor/micropython/py/emitnarm.c',
|
|
|
|
'vendor/micropython/py/emitnative.c',
|
|
|
|
'vendor/micropython/py/emitnthumb.c',
|
|
|
|
'vendor/micropython/py/emitnx64.c',
|
|
|
|
'vendor/micropython/py/emitnx86.c',
|
|
|
|
'vendor/micropython/py/emitnxtensa.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
'vendor/micropython/py/formatfloat.c',
|
|
|
|
'vendor/micropython/py/frozenmod.c',
|
|
|
|
'vendor/micropython/py/gc.c',
|
|
|
|
'vendor/micropython/py/lexer.c',
|
|
|
|
'vendor/micropython/py/malloc.c',
|
|
|
|
'vendor/micropython/py/map.c',
|
|
|
|
'vendor/micropython/py/modarray.c',
|
|
|
|
'vendor/micropython/py/modbuiltins.c',
|
2018-10-25 23:09:02 +00:00
|
|
|
'vendor/micropython/py/modcmath.c',
|
|
|
|
'vendor/micropython/py/modcollections.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
'vendor/micropython/py/modgc.c',
|
2018-10-25 23:09:02 +00:00
|
|
|
'vendor/micropython/py/modio.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
'vendor/micropython/py/modmath.c',
|
|
|
|
'vendor/micropython/py/modmicropython.c',
|
|
|
|
'vendor/micropython/py/modstruct.c',
|
|
|
|
'vendor/micropython/py/modsys.c',
|
2018-10-25 23:09:02 +00:00
|
|
|
'vendor/micropython/py/modthread.c',
|
|
|
|
'vendor/micropython/py/moduerrno.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
'vendor/micropython/py/mpprint.c',
|
|
|
|
'vendor/micropython/py/mpstate.c',
|
|
|
|
'vendor/micropython/py/mpz.c',
|
|
|
|
'vendor/micropython/py/nativeglue.c',
|
2018-06-13 14:15:12 +00:00
|
|
|
'vendor/micropython/py/nlr.c',
|
2021-10-22 11:34:48 +00:00
|
|
|
'vendor/micropython/py/nlraarch64.c',
|
2018-10-25 23:09:02 +00:00
|
|
|
'vendor/micropython/py/nlrsetjmp.c',
|
|
|
|
'vendor/micropython/py/nlrthumb.c',
|
2017-12-19 14:12:56 +00:00
|
|
|
'vendor/micropython/py/nlrx64.c',
|
2018-10-25 23:09:02 +00:00
|
|
|
'vendor/micropython/py/nlrx86.c',
|
|
|
|
'vendor/micropython/py/nlrxtensa.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
'vendor/micropython/py/obj.c',
|
|
|
|
'vendor/micropython/py/objarray.c',
|
|
|
|
'vendor/micropython/py/objattrtuple.c',
|
|
|
|
'vendor/micropython/py/objbool.c',
|
|
|
|
'vendor/micropython/py/objboundmeth.c',
|
|
|
|
'vendor/micropython/py/objcell.c',
|
|
|
|
'vendor/micropython/py/objclosure.c',
|
|
|
|
'vendor/micropython/py/objcomplex.c',
|
2018-10-25 23:09:02 +00:00
|
|
|
'vendor/micropython/py/objdeque.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
'vendor/micropython/py/objdict.c',
|
|
|
|
'vendor/micropython/py/objenumerate.c',
|
|
|
|
'vendor/micropython/py/objexcept.c',
|
|
|
|
'vendor/micropython/py/objfilter.c',
|
|
|
|
'vendor/micropython/py/objfloat.c',
|
|
|
|
'vendor/micropython/py/objfun.c',
|
|
|
|
'vendor/micropython/py/objgenerator.c',
|
|
|
|
'vendor/micropython/py/objgetitemiter.c',
|
2018-10-25 23:09:02 +00:00
|
|
|
'vendor/micropython/py/objint.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
'vendor/micropython/py/objint_longlong.c',
|
|
|
|
'vendor/micropython/py/objint_mpz.c',
|
|
|
|
'vendor/micropython/py/objlist.c',
|
|
|
|
'vendor/micropython/py/objmap.c',
|
|
|
|
'vendor/micropython/py/objmodule.c',
|
|
|
|
'vendor/micropython/py/objnamedtuple.c',
|
|
|
|
'vendor/micropython/py/objnone.c',
|
|
|
|
'vendor/micropython/py/objobject.c',
|
|
|
|
'vendor/micropython/py/objpolyiter.c',
|
|
|
|
'vendor/micropython/py/objproperty.c',
|
|
|
|
'vendor/micropython/py/objrange.c',
|
|
|
|
'vendor/micropython/py/objreversed.c',
|
|
|
|
'vendor/micropython/py/objset.c',
|
|
|
|
'vendor/micropython/py/objsingleton.c',
|
|
|
|
'vendor/micropython/py/objslice.c',
|
|
|
|
'vendor/micropython/py/objstr.c',
|
|
|
|
'vendor/micropython/py/objstringio.c',
|
|
|
|
'vendor/micropython/py/objstrunicode.c',
|
|
|
|
'vendor/micropython/py/objtuple.c',
|
|
|
|
'vendor/micropython/py/objtype.c',
|
|
|
|
'vendor/micropython/py/objzip.c',
|
|
|
|
'vendor/micropython/py/opmethods.c',
|
|
|
|
'vendor/micropython/py/parse.c',
|
|
|
|
'vendor/micropython/py/parsenum.c',
|
|
|
|
'vendor/micropython/py/parsenumbase.c',
|
|
|
|
'vendor/micropython/py/persistentcode.c',
|
2019-05-27 12:17:43 +00:00
|
|
|
'vendor/micropython/py/profile.c',
|
2018-10-25 23:09:02 +00:00
|
|
|
'vendor/micropython/py/pystack.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
'vendor/micropython/py/qstr.c',
|
|
|
|
'vendor/micropython/py/reader.c',
|
|
|
|
'vendor/micropython/py/repl.c',
|
|
|
|
'vendor/micropython/py/runtime.c',
|
2018-10-25 23:09:02 +00:00
|
|
|
'vendor/micropython/py/runtime_utils.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
'vendor/micropython/py/scheduler.c',
|
2018-10-25 23:09:02 +00:00
|
|
|
'vendor/micropython/py/scope.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
'vendor/micropython/py/sequence.c',
|
|
|
|
'vendor/micropython/py/showbc.c',
|
|
|
|
'vendor/micropython/py/smallint.c',
|
|
|
|
'vendor/micropython/py/stackctrl.c',
|
|
|
|
'vendor/micropython/py/stream.c',
|
|
|
|
'vendor/micropython/py/unicode.c',
|
|
|
|
'vendor/micropython/py/vm.c',
|
|
|
|
'vendor/micropython/py/vstr.c',
|
|
|
|
'vendor/micropython/py/warning.c',
|
|
|
|
]
|
|
|
|
|
|
|
|
SOURCE_UNIX = [
|
2023-06-23 14:50:13 +00:00
|
|
|
'embed/trezorhal/unix/common.c',
|
|
|
|
'embed/trezorhal/unix/display-unix.c',
|
|
|
|
'embed/trezorhal/unix/flash.c',
|
|
|
|
'embed/trezorhal/unix/random_delays.c',
|
|
|
|
'embed/trezorhal/unix/rng.c',
|
|
|
|
'embed/trezorhal/unix/usb.c',
|
|
|
|
'embed/trezorhal/unix/touch/touch.c',
|
2018-02-27 00:39:02 +00:00
|
|
|
'embed/unix/main.c',
|
2021-06-12 10:19:31 +00:00
|
|
|
'embed/unix/main_main.c',
|
2019-09-03 14:24:33 +00:00
|
|
|
'embed/unix/profile.c',
|
2021-09-09 18:26:10 +00:00
|
|
|
'vendor/micropython/shared/runtime/gchelper_generic.c',
|
2019-09-03 16:15:47 +00:00
|
|
|
'vendor/micropython/ports/unix/alloc.c',
|
|
|
|
'vendor/micropython/ports/unix/gccollect.c',
|
|
|
|
'vendor/micropython/ports/unix/input.c',
|
|
|
|
'vendor/micropython/ports/unix/unix_mphal.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
]
|
2023-05-12 09:19:35 +00:00
|
|
|
if TREZOR_MODEL in ('T', 'R'):
|
2021-05-13 10:33:52 +00:00
|
|
|
SOURCE_UNIX += [
|
2023-06-23 14:50:13 +00:00
|
|
|
'embed/trezorhal/unix/sbu.c',
|
2021-05-13 10:33:52 +00:00
|
|
|
]
|
2017-08-03 18:46:40 +00:00
|
|
|
|
2023-08-23 13:42:16 +00:00
|
|
|
if TREZOR_MODEL == 'R':
|
|
|
|
SOURCE_UNIX += [
|
|
|
|
'embed/trezorhal/unix/optiga.c',
|
|
|
|
]
|
|
|
|
|
2022-08-16 14:51:10 +00:00
|
|
|
if DMA2D:
|
|
|
|
CPPDEFINES_MOD += [
|
|
|
|
'USE_DMA2D',
|
|
|
|
]
|
|
|
|
SOURCE_UNIX += [
|
2023-04-06 14:04:44 +00:00
|
|
|
'embed/lib/dma2d_emul.c',
|
2022-08-16 14:51:10 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2022-08-18 13:12:02 +00:00
|
|
|
# fonts
|
|
|
|
tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD)
|
|
|
|
tools.add_font('BOLD', FONT_BOLD, CPPDEFINES_MOD, SOURCE_MOD)
|
2022-10-11 21:28:31 +00:00
|
|
|
tools.add_font('DEMIBOLD', FONT_DEMIBOLD, CPPDEFINES_MOD, SOURCE_MOD)
|
2022-08-18 13:12:02 +00:00
|
|
|
tools.add_font('MONO', FONT_MONO, CPPDEFINES_MOD, SOURCE_MOD)
|
2023-06-05 15:03:22 +00:00
|
|
|
tools.add_font('BIG', FONT_BIG, CPPDEFINES_MOD, SOURCE_MOD)
|
2022-08-18 13:12:02 +00:00
|
|
|
|
|
|
|
|
2018-06-13 14:15:57 +00:00
|
|
|
SOURCE_QSTR = SOURCE_MOD + SOURCE_MICROPYTHON + SOURCE_UNIX
|
2017-08-03 18:46:40 +00:00
|
|
|
|
2021-04-09 13:25:47 +00:00
|
|
|
if PYOPT == '0' or not FROZEN:
|
|
|
|
STATIC="-DSTATIC="
|
|
|
|
else:
|
|
|
|
STATIC=""
|
|
|
|
|
|
|
|
env = Environment(ENV=os.environ, CFLAGS='%s -DPYOPT=%s -DBITCOIN_ONLY=%s %s' % (ARGUMENTS.get('CFLAGS', ''), PYOPT, BITCOIN_ONLY, STATIC))
|
2017-08-03 18:46:40 +00:00
|
|
|
|
2023-08-24 10:46:10 +00:00
|
|
|
|
|
|
|
if TREZOR_MODEL in ('T',):
|
|
|
|
UI_LAYOUT = 'UI_LAYOUT_TT'
|
|
|
|
ui_layout_feature = 'model_tt'
|
|
|
|
elif TREZOR_MODEL in ('1', 'R'):
|
|
|
|
UI_LAYOUT = 'UI_LAYOUT_TR'
|
|
|
|
ui_layout_feature = 'model_tr'
|
|
|
|
else:
|
|
|
|
raise ValueError('Unknown Trezor model')
|
|
|
|
|
|
|
|
if TREZOR_MODEL in ('T',):
|
|
|
|
SDCARD = True
|
|
|
|
SOURCE_UNIX += [
|
|
|
|
'embed/trezorhal/unix/sdcard.c',
|
|
|
|
]
|
|
|
|
else:
|
|
|
|
SDCARD = False
|
|
|
|
|
2017-08-03 18:46:40 +00:00
|
|
|
env.Tool('micropython')
|
|
|
|
|
|
|
|
env.Replace(
|
2019-01-04 11:24:06 +00:00
|
|
|
CC=os.getenv('CC') or 'gcc',
|
2017-08-03 18:46:40 +00:00
|
|
|
SED='sed',
|
|
|
|
AS='as',
|
|
|
|
AR='ar',
|
|
|
|
LINK='ld',
|
|
|
|
SIZE='size',
|
|
|
|
STRIP='strip',
|
2019-05-27 12:17:43 +00:00
|
|
|
OBJCOPY='objcopy',
|
|
|
|
COPT=os.getenv('OPTIMIZE', '-Os'), )
|
2017-08-03 18:46:40 +00:00
|
|
|
|
2022-01-07 12:07:45 +00:00
|
|
|
if ARGUMENTS.get('TREZOR_EMULATOR_CLANG', '0') == '1':
|
|
|
|
env.Replace(
|
|
|
|
CC='clang',
|
|
|
|
LINK='clang', )
|
|
|
|
|
|
|
|
if ARGUMENTS.get('TREZOR_EMULATOR_ASAN', '0') == '1':
|
2019-05-27 12:17:43 +00:00
|
|
|
asan_flags=(
|
2022-01-07 12:07:45 +00:00
|
|
|
' -fsanitize=address,undefined'+
|
|
|
|
' -fno-omit-frame-pointer'+
|
|
|
|
' -fno-optimize-sibling-calls'
|
2018-10-09 12:35:52 +00:00
|
|
|
)
|
2022-01-07 12:07:45 +00:00
|
|
|
env.Append(
|
2019-05-27 12:17:43 +00:00
|
|
|
CFLAGS=asan_flags,
|
2022-01-07 12:07:45 +00:00
|
|
|
LINKFLAGS=asan_flags,
|
|
|
|
LDFLAGS=asan_flags,
|
|
|
|
ENV={
|
|
|
|
# workaround for sanitizers being nightly-only
|
|
|
|
# remove after stabilized https://github.com/rust-lang/rust/issues/39699
|
|
|
|
'RUSTC_BOOTSTRAP': '1',
|
|
|
|
'RUSTFLAGS': '-Z sanitizer=address',
|
|
|
|
}, )
|
|
|
|
|
|
|
|
if ARGUMENTS.get('TREZOR_EMULATOR_DEBUGGABLE', '0') == '1':
|
2019-05-27 12:17:43 +00:00
|
|
|
env.Replace(
|
2021-10-05 11:16:31 +00:00
|
|
|
COPT=' -Og -ggdb',
|
2019-05-27 12:17:43 +00:00
|
|
|
STRIP='true', )
|
2018-10-09 12:35:52 +00:00
|
|
|
|
2020-10-26 19:30:55 +00:00
|
|
|
if ARGUMENTS.get('TREZOR_MEMPERF', '0') == '1':
|
|
|
|
CPPDEFINES_MOD += [
|
|
|
|
('MICROPY_TREZOR_MEMPERF', '\(1\)')
|
|
|
|
]
|
|
|
|
|
2017-08-03 18:46:40 +00:00
|
|
|
env.Replace(
|
2020-08-28 12:50:38 +00:00
|
|
|
TREZOR_MODEL=TREZOR_MODEL, )
|
2018-09-30 14:39:40 +00:00
|
|
|
|
2023-02-09 22:56:03 +00:00
|
|
|
if TREZOR_MODEL in ('T', 'R'):
|
|
|
|
CPU_MODEL = 'STM32F427xx'
|
|
|
|
elif TREZOR_MODEL in ('DISC1', ):
|
|
|
|
CPU_MODEL = 'STM32F429xx'
|
|
|
|
elif TREZOR_MODEL in ('1',):
|
|
|
|
CPU_MODEL = 'STM32F405xx'
|
|
|
|
else:
|
|
|
|
raise ValueError('Unknown Trezor model')
|
|
|
|
|
2018-09-30 14:39:40 +00:00
|
|
|
env.Replace(
|
2019-05-04 20:10:01 +00:00
|
|
|
CCFLAGS='$COPT '
|
2017-08-03 18:46:40 +00:00
|
|
|
'-g3 '
|
2023-08-07 13:50:53 +00:00
|
|
|
'-std=gnu11 -Wall -Werror -Wuninitialized -Wno-missing-braces '
|
2021-12-06 10:44:56 +00:00
|
|
|
'-fdata-sections -ffunction-sections -fPIE ' + CCFLAGS_MOD,
|
2017-08-03 19:22:02 +00:00
|
|
|
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
2019-05-01 11:39:44 +00:00
|
|
|
LIBS=['m'],
|
2017-08-03 18:46:40 +00:00
|
|
|
CPPPATH=[
|
|
|
|
'.',
|
2021-03-23 12:14:33 +00:00
|
|
|
'embed/rust',
|
2023-03-27 13:03:54 +00:00
|
|
|
'embed/lib',
|
2023-06-01 12:21:51 +00:00
|
|
|
'embed/models',
|
2017-08-03 18:46:40 +00:00
|
|
|
'embed/unix',
|
2023-06-23 14:50:13 +00:00
|
|
|
'embed/trezorhal',
|
|
|
|
'embed/trezorhal/unix',
|
2017-08-03 18:46:40 +00:00
|
|
|
'embed/extmod/modtrezorui',
|
|
|
|
'vendor/micropython',
|
2017-09-06 17:15:59 +00:00
|
|
|
'vendor/micropython/ports/unix',
|
2017-08-03 18:46:40 +00:00
|
|
|
'vendor/micropython/lib/mp-readline',
|
|
|
|
] + CPPPATH_MOD,
|
|
|
|
CPPDEFINES=[
|
2023-02-09 22:56:03 +00:00
|
|
|
CPU_MODEL,
|
2018-08-31 13:52:26 +00:00
|
|
|
'TREZOR_EMULATOR',
|
2022-04-26 11:47:40 +00:00
|
|
|
'TREZOR_MODEL_'+TREZOR_MODEL,
|
2023-06-23 14:50:13 +00:00
|
|
|
'TREZOR_BOARD=\\"boards/board-unix.h\\"',
|
2023-06-27 22:10:46 +00:00
|
|
|
'MCU_TYPE='+CPU_MODEL,
|
2017-08-03 18:46:40 +00:00
|
|
|
('MP_CONFIGFILE', '\\"embed/unix/mpconfigport.h\\"'),
|
2023-08-24 10:46:10 +00:00
|
|
|
UI_LAYOUT,
|
2017-08-03 22:45:32 +00:00
|
|
|
] + CPPDEFINES_MOD,
|
|
|
|
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
2017-08-03 18:46:40 +00:00
|
|
|
|
2019-08-29 10:35:16 +00:00
|
|
|
try:
|
|
|
|
env.ParseConfig('pkg-config --cflags --libs sdl2 SDL2_image')
|
|
|
|
except OSError:
|
|
|
|
print("SDL2 not installed, Emulator build is not possible")
|
2018-09-28 17:41:03 +00:00
|
|
|
|
2017-08-03 18:46:40 +00:00
|
|
|
env.Replace(
|
|
|
|
PYTHON='python',
|
|
|
|
MAKEQSTRDATA='$PYTHON vendor/micropython/py/makeqstrdata.py',
|
|
|
|
MAKEVERSIONHDR='$PYTHON vendor/micropython/py/makeversionhdr.py',
|
2020-04-07 10:02:58 +00:00
|
|
|
MAKEMODULEDEFS='$PYTHON vendor/micropython/py/makemoduledefs.py',
|
2023-01-30 14:36:22 +00:00
|
|
|
MAKECMAKELISTS='$PYTHON tools/make_cmakelists.py',
|
2017-08-03 18:46:40 +00:00
|
|
|
MPY_TOOL='$PYTHON vendor/micropython/tools/mpy-tool.py',
|
2021-06-07 08:57:33 +00:00
|
|
|
MPY_CROSS='vendor/micropython/mpy-cross/mpy-cross -O' + PYOPT,
|
|
|
|
PB2PY='$PYTHON ../common/protob/pb2py',
|
2019-05-04 20:10:01 +00:00
|
|
|
)
|
2017-08-03 18:46:40 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Qstrings
|
|
|
|
#
|
|
|
|
|
2021-06-07 08:57:33 +00:00
|
|
|
PROTO_SOURCES_DIR = '../../../common/protob/'
|
|
|
|
PROTO_SOURCES = Glob(PROTO_SOURCES_DIR + '*.proto',
|
|
|
|
exclude=[PROTO_SOURCES_DIR + 'messages-bootloader.proto']
|
|
|
|
)
|
|
|
|
qstr_protobuf = env.Command(
|
|
|
|
target=[
|
|
|
|
'genhdr/qstrdefs.protobuf.h',
|
|
|
|
],
|
|
|
|
source=PROTO_SOURCES,
|
|
|
|
action='$PB2PY $SOURCES --qstr-out ${TARGET} --bitcoin-only=%s' % BITCOIN_ONLY,
|
|
|
|
)
|
|
|
|
|
2017-08-03 18:46:40 +00:00
|
|
|
qstr_micropython = 'vendor/micropython/py/qstrdefs.h'
|
|
|
|
|
|
|
|
qstr_collected = env.CollectQstr(
|
|
|
|
target='genhdr/qstrdefs.collected.h', source=SOURCE_QSTR)
|
|
|
|
|
|
|
|
qstr_preprocessed = env.PreprocessQstr(
|
|
|
|
target='genhdr/qstrdefs.preprocessed.h',
|
2021-06-07 08:57:33 +00:00
|
|
|
source=[qstr_micropython, qstr_protobuf, qstr_collected])
|
2017-08-03 18:46:40 +00:00
|
|
|
|
|
|
|
qstr_generated = env.GenerateQstrDefs(
|
|
|
|
target='genhdr/qstrdefs.generated.h', source=qstr_preprocessed)
|
|
|
|
|
|
|
|
env.Ignore(qstr_collected, qstr_generated)
|
|
|
|
|
2019-12-17 18:24:08 +00:00
|
|
|
#
|
2023-01-24 20:57:27 +00:00
|
|
|
# Micropython module declarations
|
|
|
|
#
|
|
|
|
|
|
|
|
moduledefs_collected = env.CollectModules(
|
|
|
|
target='genhdr/moduledefs.collected.h', source=SOURCE_QSTR)
|
|
|
|
|
|
|
|
|
|
|
|
hdr_moduledefs = env.Command(
|
|
|
|
target='genhdr/moduledefs.h',
|
|
|
|
source=moduledefs_collected,
|
|
|
|
action='$MAKEMODULEDEFS $SOURCE > $TARGET', )
|
|
|
|
|
|
|
|
env.Ignore(moduledefs_collected, moduledefs_collected)
|
|
|
|
env.Ignore(moduledefs_collected, qstr_generated)
|
|
|
|
env.Ignore(moduledefs_collected, hdr_moduledefs)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Micropython version
|
2019-12-17 18:24:08 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
hdr_version = env.Command(
|
|
|
|
target='genhdr/mpversion.h',
|
|
|
|
source='',
|
|
|
|
action='$MAKEVERSIONHDR $TARGET', )
|
|
|
|
|
|
|
|
env.Ignore(hdr_moduledefs, hdr_moduledefs)
|
|
|
|
env.Ignore(hdr_moduledefs, qstr_collected)
|
|
|
|
env.Ignore(hdr_moduledefs, qstr_preprocessed)
|
|
|
|
env.Ignore(hdr_moduledefs, qstr_generated)
|
|
|
|
|
2019-05-01 11:39:44 +00:00
|
|
|
#
|
|
|
|
# Frozen modules
|
|
|
|
#
|
|
|
|
|
2019-08-21 15:50:09 +00:00
|
|
|
if FROZEN:
|
2020-08-03 13:33:45 +00:00
|
|
|
SOURCE_PY_DIR = 'src/'
|
2019-05-01 11:39:44 +00:00
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY = Glob(SOURCE_PY_DIR + '*.py')
|
2023-05-12 09:19:35 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/*.py',
|
|
|
|
exclude=[
|
|
|
|
SOURCE_PY_DIR + 'trezor/sdcard.py',
|
2023-08-24 10:46:10 +00:00
|
|
|
] if not SDCARD else []
|
2023-05-12 09:19:35 +00:00
|
|
|
))
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/crypto/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/*.py'))
|
2023-05-04 12:32:35 +00:00
|
|
|
|
|
|
|
# UI layouts - common files and then model-specific. Exclude FIDO when BTC-only.
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/*.py',
|
|
|
|
exclude=[
|
|
|
|
SOURCE_PY_DIR + 'trezor/ui/layouts/fido.py',
|
|
|
|
] if not EVERYTHING else []
|
|
|
|
))
|
2023-08-24 10:46:10 +00:00
|
|
|
if UI_LAYOUT == 'UI_LAYOUT_TT':
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt/*.py',
|
2023-05-04 12:32:35 +00:00
|
|
|
exclude=[
|
2023-08-24 10:46:10 +00:00
|
|
|
SOURCE_PY_DIR + 'trezor/ui/layouts/tt/fido.py',
|
2023-05-04 12:32:35 +00:00
|
|
|
] if not EVERYTHING else []
|
|
|
|
))
|
2023-08-24 10:46:10 +00:00
|
|
|
elif UI_LAYOUT == 'UI_LAYOUT_TR':
|
2023-05-12 09:19:35 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tr/*.py',
|
|
|
|
exclude=[
|
|
|
|
SOURCE_PY_DIR + 'trezor/ui/layouts/tr/fido.py',
|
|
|
|
] if not EVERYTHING else []
|
|
|
|
))
|
2020-12-11 16:51:20 +00:00
|
|
|
else:
|
2023-08-24 10:46:10 +00:00
|
|
|
raise ValueError('Unknown layout')
|
2020-12-11 16:51:20 +00:00
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/wire/*.py'))
|
|
|
|
|
2023-05-12 09:19:35 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'storage/*.py',
|
|
|
|
exclude=[
|
|
|
|
SOURCE_PY_DIR + 'storage/sd_salt.py',
|
2023-08-24 10:46:10 +00:00
|
|
|
] if not SDCARD else []
|
2023-05-12 09:19:35 +00:00
|
|
|
))
|
2019-11-11 14:52:46 +00:00
|
|
|
|
2021-06-07 08:57:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/__init__.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/*.py',
|
2019-08-21 16:45:07 +00:00
|
|
|
exclude=[
|
2021-06-07 08:57:33 +00:00
|
|
|
SOURCE_PY_DIR + 'trezor/enums/Binance*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/enums/Cardano*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/enums/DebugMonero*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/enums/Eos*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/enums/Ethereum*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/enums/Monero*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/enums/NEM*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/enums/Ripple*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/enums/Stellar*.py',
|
|
|
|
SOURCE_PY_DIR + 'trezor/enums/Tezos*.py',
|
2022-08-12 06:45:42 +00:00
|
|
|
SOURCE_PY_DIR + 'trezor/enums/Zcash*.py',
|
2019-08-21 16:45:07 +00:00
|
|
|
])
|
|
|
|
)
|
|
|
|
|
2020-07-28 10:12:31 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/*.py'))
|
2023-05-12 09:19:35 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/common/*.py',
|
|
|
|
exclude=[
|
|
|
|
SOURCE_PY_DIR + 'apps/common/sdcard.py',
|
2023-08-24 10:46:10 +00:00
|
|
|
] if not SDCARD else []
|
2023-05-12 09:19:35 +00:00
|
|
|
))
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/debug/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/homescreen/*.py'))
|
2021-05-13 10:33:52 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/management/*.py',
|
|
|
|
exclude=[
|
|
|
|
SOURCE_PY_DIR + 'apps/management/sd_protect.py',
|
2023-08-24 10:46:10 +00:00
|
|
|
] if not SDCARD else [] + [
|
2023-08-23 13:42:16 +00:00
|
|
|
SOURCE_PY_DIR + 'apps/management/authenticate_device.py',
|
|
|
|
] if TREZOR_MODEL not in ('R',) else [])
|
2021-05-13 10:33:52 +00:00
|
|
|
)
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/management/*/*.py'))
|
2020-05-15 18:35:09 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/misc/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/bitcoin/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/bitcoin/*/*.py',
|
2019-08-26 11:48:41 +00:00
|
|
|
exclude=[
|
2020-05-15 18:35:09 +00:00
|
|
|
SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/decred.py',
|
|
|
|
SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/bitcoinlike.py',
|
2022-03-31 13:22:23 +00:00
|
|
|
SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/zcash_v4.py',
|
2019-08-26 11:48:41 +00:00
|
|
|
])
|
|
|
|
)
|
2019-08-21 09:15:33 +00:00
|
|
|
|
2019-08-21 16:53:08 +00:00
|
|
|
if EVERYTHING:
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/binance/*.py'))
|
2021-06-07 08:57:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Binance*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/cardano/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/cardano/*/*.py'))
|
2021-06-07 08:57:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Cardano*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
|
2023-08-28 14:46:57 +00:00
|
|
|
if TREZOR_MODEL != "R":
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/eos/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/eos/*/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Eos*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/ethereum/*.py'))
|
2021-06-07 08:57:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Ethereum*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/monero/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/monero/*/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/monero/*/*/*.py'))
|
2021-06-07 08:57:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/DebugMonero*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Monero*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
|
2023-08-28 14:46:57 +00:00
|
|
|
if TREZOR_MODEL != "R":
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/nem/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/nem/*/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/NEM*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/ripple/*.py'))
|
2021-06-07 08:57:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Ripple*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/stellar/*.py'))
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/stellar/*/*.py'))
|
2021-06-07 08:57:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Stellar*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/tezos/*.py'))
|
2021-06-07 08:57:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Tezos*.py'))
|
2019-08-21 16:45:07 +00:00
|
|
|
|
2022-03-31 13:22:23 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/zcash/*.py'))
|
|
|
|
|
2019-08-21 09:15:33 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/webauthn/*.py'))
|
2019-05-01 11:39:44 +00:00
|
|
|
|
2023-08-28 14:46:57 +00:00
|
|
|
if TREZOR_MODEL != "R":
|
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/decred.py'))
|
2020-05-15 18:35:09 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/bitcoinlike.py'))
|
2022-03-31 13:22:23 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/zcash_v4.py'))
|
2022-08-12 06:45:42 +00:00
|
|
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Zcash*.py'))
|
2019-08-26 11:48:41 +00:00
|
|
|
|
2023-06-23 10:07:18 +00:00
|
|
|
source_mpy = env.FrozenModule(
|
|
|
|
source=SOURCE_PY,
|
|
|
|
source_dir=SOURCE_PY_DIR,
|
|
|
|
bitcoin_only=BITCOIN_ONLY,
|
2023-08-23 13:42:16 +00:00
|
|
|
backlight=TREZOR_MODEL in ('T',),
|
2023-08-24 10:46:10 +00:00
|
|
|
optiga=TREZOR_MODEL in ('R',),
|
|
|
|
ui_layout=UI_LAYOUT,
|
2023-06-23 10:07:18 +00:00
|
|
|
)
|
2019-05-01 11:39:44 +00:00
|
|
|
|
|
|
|
source_mpyc = env.FrozenCFile(
|
|
|
|
target='frozen_mpy.c', source=source_mpy, qstr_header=qstr_preprocessed)
|
|
|
|
|
|
|
|
env.Depends(source_mpyc, qstr_generated)
|
|
|
|
|
2021-03-23 12:14:33 +00:00
|
|
|
#
|
|
|
|
# Rust library
|
|
|
|
#
|
|
|
|
|
2021-06-07 08:57:33 +00:00
|
|
|
protobuf_blobs = env.Command(
|
|
|
|
target=[
|
|
|
|
'rust/proto_enums.data',
|
|
|
|
'rust/proto_msgs.data',
|
|
|
|
'rust/proto_names.data',
|
|
|
|
'rust/proto_wire.data',
|
|
|
|
],
|
|
|
|
source=PROTO_SOURCES,
|
|
|
|
action='$PB2PY --bitcoin-only=%s --blob-outdir ${TARGET.dir} $SOURCES --qstr-defs build/unix/genhdr/qstrdefs.generated.h' % BITCOIN_ONLY,
|
|
|
|
)
|
|
|
|
env.Depends(protobuf_blobs, qstr_generated)
|
|
|
|
|
2022-08-31 13:49:46 +00:00
|
|
|
TARGET = os.popen("rustc -vV | sed -n 's/host: //p'").read().strip()
|
|
|
|
|
2022-02-19 12:26:46 +00:00
|
|
|
if ARGUMENTS.get('TREZOR_EMULATOR_DEBUGGABLE', '0') == '1':
|
|
|
|
RUST_PROFILE = 'dev'
|
2022-08-31 13:49:46 +00:00
|
|
|
RUST_LIBDIR = f'build/unix/rust/{TARGET}/debug'
|
2022-02-19 12:26:46 +00:00
|
|
|
else:
|
|
|
|
RUST_PROFILE = 'release'
|
2022-08-31 13:49:46 +00:00
|
|
|
RUST_LIBDIR = f'build/unix/rust/{TARGET}/release'
|
2021-03-23 12:14:33 +00:00
|
|
|
RUST_LIB = 'trezor_lib'
|
|
|
|
RUST_LIBPATH = f'{RUST_LIBDIR}/lib{RUST_LIB}.a'
|
|
|
|
|
|
|
|
def cargo_build():
|
2023-08-24 10:46:10 +00:00
|
|
|
features = ['micropython', 'protobuf', ui_layout_feature]
|
2022-06-08 08:31:23 +00:00
|
|
|
if BITCOIN_ONLY == '1':
|
|
|
|
features.append('bitcoin_only')
|
2022-10-20 12:26:06 +00:00
|
|
|
features.append('ui')
|
|
|
|
if PYOPT == '0':
|
|
|
|
features.append('debug')
|
2022-08-16 14:51:10 +00:00
|
|
|
if DMA2D:
|
|
|
|
features.append('dma2d')
|
2021-05-31 13:12:02 +00:00
|
|
|
|
2023-03-27 14:44:01 +00:00
|
|
|
if TREZOR_MODEL in ('T',):
|
|
|
|
features.append('touch')
|
|
|
|
features.append('sd_card')
|
|
|
|
if TREZOR_MODEL in ('R', '1'):
|
|
|
|
features.append('button')
|
|
|
|
|
2022-10-14 10:43:37 +00:00
|
|
|
env.get('ENV')['TREZOR_MODEL'] = TREZOR_MODEL
|
|
|
|
|
2022-08-31 13:49:46 +00:00
|
|
|
return f'cd embed/rust; cargo build --profile {RUST_PROFILE} --target-dir=../../build/unix/rust --no-default-features --features "{" ".join(features)}" --target {TARGET}'
|
2021-03-23 12:14:33 +00:00
|
|
|
|
|
|
|
rust = env.Command(
|
|
|
|
target=RUST_LIBPATH,
|
|
|
|
source='',
|
|
|
|
action=cargo_build(), )
|
2021-06-07 08:57:33 +00:00
|
|
|
env.Depends(rust, protobuf_blobs)
|
2021-03-23 12:14:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
env.Append(LINKFLAGS=f'-L{RUST_LIBDIR}')
|
|
|
|
env.Append(LINKFLAGS=f'-l{RUST_LIB}')
|
|
|
|
|
2017-08-03 18:46:40 +00:00
|
|
|
#
|
|
|
|
# Program objects
|
|
|
|
#
|
|
|
|
|
|
|
|
obj_program = []
|
2023-01-30 14:36:22 +00:00
|
|
|
source_files = SOURCE_MOD + SOURCE_MICROPYTHON + SOURCE_UNIX
|
2019-05-01 11:39:44 +00:00
|
|
|
obj_program.extend(env.Object(source=SOURCE_MOD))
|
2021-03-18 13:48:10 +00:00
|
|
|
if FEATURE_FLAGS["SECP256K1_ZKP"]:
|
2019-08-21 16:53:08 +00:00
|
|
|
obj_program.extend(env.Object(source=SOURCE_MOD_SECP256K1_ZKP, CCFLAGS='$CCFLAGS -Wno-unused-function'))
|
2023-01-30 14:36:22 +00:00
|
|
|
source_files.extend(SOURCE_MOD_SECP256K1_ZKP)
|
2019-05-01 11:39:44 +00:00
|
|
|
obj_program.extend(env.Object(source=SOURCE_MICROPYTHON))
|
|
|
|
obj_program.extend(env.Object(source=SOURCE_UNIX))
|
2019-08-21 15:50:09 +00:00
|
|
|
if FROZEN:
|
2019-05-01 11:39:44 +00:00
|
|
|
obj_program.extend(env.Object(source=source_mpyc))
|
2017-08-03 18:46:40 +00:00
|
|
|
|
2023-01-30 14:36:22 +00:00
|
|
|
env.Replace(
|
|
|
|
ALLSOURCES=source_files,
|
|
|
|
ALLDEFS=tools.get_defs_for_cmake(env['CPPDEFINES']))
|
|
|
|
|
|
|
|
|
|
|
|
cmake_gen = env.Command(
|
|
|
|
target='CMakeLists.txt',
|
|
|
|
source='',
|
|
|
|
action='$MAKECMAKELISTS --sources $ALLSOURCES --dirs $CPPPATH --defs $ALLDEFS',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2017-08-03 18:46:40 +00:00
|
|
|
env.Depends(obj_program, qstr_generated)
|
|
|
|
|
|
|
|
program = env.Command(
|
2020-07-27 14:59:51 +00:00
|
|
|
target='trezor-emu-core',
|
2017-08-03 18:46:40 +00:00
|
|
|
source=obj_program,
|
|
|
|
action='$CC -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS $LINKFLAGS', )
|
2021-03-23 12:14:33 +00:00
|
|
|
|
2023-01-30 14:36:22 +00:00
|
|
|
if CMAKELISTS != 0:
|
|
|
|
env.Depends(program, cmake_gen)
|
2021-03-23 12:14:33 +00:00
|
|
|
env.Depends(program, rust)
|