1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-21 05:48:23 +00:00
trezor-firmware/core/SConscript.unix

669 lines
23 KiB
Plaintext
Raw Normal View History

2017-08-03 18:46:40 +00:00
# pylint: disable=E0602
# fmt: off
2017-08-03 18:46:40 +00:00
2017-08-07 10:50:24 +00:00
import os
2019-08-22 18:15:16 +00:00
BITCOIN_ONLY = ARGUMENTS.get('BITCOIN_ONLY', '0')
EVERYTHING = BITCOIN_ONLY != '1'
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
FEATURE_FLAGS = {
"SECP256K1_ZKP": False,
}
2017-08-03 18:46:40 +00:00
CCFLAGS_MOD = ''
CPPPATH_MOD = []
CPPDEFINES_MOD = []
SOURCE_MOD = [
'vendor/micropython/extmod/vfs_posix_file.c',
]
2017-08-03 18:46:40 +00:00
PYOPT = ARGUMENTS.get('PYOPT', '1')
2019-08-21 16:09:56 +00:00
FROZEN = ARGUMENTS.get('TREZOR_EMULATOR_FROZEN', 0)
2019-05-04 20:10:01 +00:00
2017-08-03 18:46:40 +00:00
# modtrezorconfig
CPPPATH_MOD += [
'embed/extmod/modtrezorconfig',
'vendor/trezor-storage',
]
2017-08-03 18:46:40 +00:00
SOURCE_MOD += [
'embed/extmod/modtrezorconfig/modtrezorconfig.c',
'vendor/trezor-storage/norcow.c',
'vendor/trezor-storage/storage.c',
2017-08-03 18:46:40 +00:00
]
# modtrezorcrypto
CCFLAGS_MOD += '-Wno-sequence-point '
CPPPATH_MOD += [
'vendor/trezor-crypto',
2017-08-03 18:46:40 +00:00
]
CPPDEFINES_MOD += [
'AES_128',
'AES_192',
('USE_BIP32_CACHE', '0'),
('USE_KECCAK', '1'),
('USE_ETHEREUM', '1' if EVERYTHING else '0'),
('USE_MONERO', '1' if EVERYTHING else '0'),
('USE_CARDANO', '1' if EVERYTHING else '0'),
('USE_NEM', '1' if EVERYTHING else '0'),
('USE_EOS', '1' if EVERYTHING else '0'),
2017-08-03 18:46:40 +00:00
]
SOURCE_MOD += [
'embed/extmod/trezorobj.c',
2017-08-03 18:46:40 +00:00
'embed/extmod/modtrezorcrypto/modtrezorcrypto.c',
2017-12-19 20:54:22 +00:00
'embed/extmod/modtrezorcrypto/crc.c',
'vendor/trezor-crypto/address.c',
'vendor/trezor-crypto/aes/aescrypt.c',
'vendor/trezor-crypto/aes/aeskey.c',
'vendor/trezor-crypto/aes/aes_modes.c',
'vendor/trezor-crypto/aes/aestab.c',
'vendor/trezor-crypto/base58.c',
2018-03-09 10:37:06 +00:00
'vendor/trezor-crypto/base32.c',
'vendor/trezor-crypto/bignum.c',
'vendor/trezor-crypto/bip32.c',
'vendor/trezor-crypto/bip39.c',
'vendor/trezor-crypto/blake256.c',
'vendor/trezor-crypto/blake2b.c',
'vendor/trezor-crypto/blake2s.c',
'vendor/trezor-crypto/curves.c',
'vendor/trezor-crypto/ecdsa.c',
'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',
'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.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',
'vendor/trezor-crypto/ed25519-donna/modm-donna-32bit.c',
'vendor/trezor-crypto/groestl.c',
'vendor/trezor-crypto/hasher.c',
'vendor/trezor-crypto/hmac.c',
'vendor/trezor-crypto/hmac_drbg.c',
'vendor/trezor-crypto/memzero.c',
'vendor/trezor-crypto/nem.c',
'vendor/trezor-crypto/nist256p1.c',
'vendor/trezor-crypto/pbkdf2.c',
'vendor/trezor-crypto/rand.c',
'vendor/trezor-crypto/ripemd160.c',
'vendor/trezor-crypto/rfc6979.c',
'vendor/trezor-crypto/secp256k1.c',
'vendor/trezor-crypto/sha2.c',
'vendor/trezor-crypto/sha3.c',
'vendor/trezor-crypto/shamir.c',
2019-06-23 10:18:24 +00:00
'vendor/trezor-crypto/slip39.c',
2017-08-03 18:46:40 +00:00
]
if EVERYTHING:
SOURCE_MOD += [
'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
# libsecp256k1-zkp
if FEATURE_FLAGS["SECP256K1_ZKP"]:
CPPPATH_MOD += [
'vendor/secp256k1-zkp',
'vendor/secp256k1-zkp/src',
'vendor/secp256k1-zkp/include',
]
CPPDEFINES_MOD += [
'SECP256K1_BUILD',
'USE_NUM_NONE',
'USE_FIELD_INV_BUILTIN',
'USE_SCALAR_INV_BUILTIN',
'USE_FIELD_10X26',
'USE_SCALAR_8X32',
'USE_ECMULT_STATIC_PRECOMPUTATION',
'USE_EXTERNAL_DEFAULT_CALLBACKS',
('ECMULT_WINDOW_SIZE', '8'),
'ENABLE_MODULE_GENERATOR',
'ENABLE_MODULE_RANGEPROOF',
'ENABLE_MODULE_RECOVERY',
'ENABLE_MODULE_ECDH',
]
SOURCE_MOD_SECP256K1_ZKP = [
'vendor/secp256k1-zkp/src/secp256k1.c',
]
2017-08-03 18:46:40 +00:00
# modtrezorio
SOURCE_MOD += [
2019-06-17 18:09:58 +00:00
'embed/extmod/modtrezorio/ff.c',
'embed/extmod/modtrezorio/ffunicode.c',
2017-08-03 18:46:40 +00:00
'embed/extmod/modtrezorio/modtrezorio.c',
]
# modtrezorui
CPPPATH_MOD += [
'vendor/micropython/extmod/uzlib',
]
CPPDEFINES_MOD += [
'TREZOR_FONT_BOLD_ENABLE',
'TREZOR_FONT_NORMAL_ENABLE',
'TREZOR_FONT_MONO_ENABLE',
]
2017-08-03 18:46:40 +00:00
SOURCE_MOD += [
'embed/extmod/modtrezorui/display.c',
'embed/extmod/modtrezorui/font_bitmap.c',
'embed/extmod/modtrezorui/font_roboto_bold_20.c',
'embed/extmod/modtrezorui/font_roboto_regular_20.c',
'embed/extmod/modtrezorui/font_robotomono_regular_20.c',
'embed/extmod/modtrezorui/font_pixeloperator_bold_8.c',
'embed/extmod/modtrezorui/font_pixeloperator_regular_8.c',
'embed/extmod/modtrezorui/font_pixeloperatormono_regular_8.c',
2017-08-03 18:46:40 +00:00
'embed/extmod/modtrezorui/modtrezorui.c',
'embed/extmod/modtrezorui/qr-code-generator/qrcodegen.c',
'vendor/micropython/extmod/uzlib/adler32.c',
'vendor/micropython/extmod/uzlib/crc32.c',
'vendor/micropython/extmod/uzlib/tinflate.c',
2017-08-03 18:46:40 +00:00
]
if FROZEN:
2019-05-04 20:10:01 +00:00
CPPDEFINES_MOD += ['TREZOR_EMULATOR_FROZEN']
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 += [
'embed/extmod/rustmods/modtrezorproto.c',
]
2017-08-03 18:46:40 +00:00
# modutime
2018-01-02 18:59:40 +00:00
SOURCE_MOD += [
'vendor/micropython/ports/unix/modtime.c',
]
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',
'vendor/micropython/extmod/modutimeq.c',
'vendor/micropython/extmod/utime_mphal.c',
'vendor/micropython/lib/mp-readline/readline.c',
2019-04-02 13:33:34 +00:00
'vendor/micropython/ports/unix/modos.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',
'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',
'vendor/micropython/py/modcmath.c',
'vendor/micropython/py/modcollections.c',
2017-08-03 18:46:40 +00:00
'vendor/micropython/py/modgc.c',
'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',
'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',
'vendor/micropython/py/nlr.c',
'vendor/micropython/py/nlrsetjmp.c',
'vendor/micropython/py/nlrthumb.c',
2017-12-19 14:12:56 +00:00
'vendor/micropython/py/nlrx64.c',
'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',
'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',
'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',
'vendor/micropython/py/profile.c',
'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',
'vendor/micropython/py/runtime_utils.c',
2017-08-03 18:46:40 +00:00
'vendor/micropython/py/scheduler.c',
'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 = [
'embed/unix/common.c',
2017-10-17 13:11:27 +00:00
'embed/unix/flash.c',
'embed/unix/main.c',
'embed/unix/profile.c',
'embed/unix/random_delays.c',
2017-12-15 15:56:08 +00:00
'embed/unix/rng.c',
2017-12-14 23:06:09 +00:00
'embed/unix/sbu.c',
'embed/unix/sdcard.c',
2017-12-14 23:06:09 +00:00
'embed/unix/touch.c',
'embed/unix/usb.c',
'vendor/micropython/lib/utils/gchelper_generic.c',
'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
]
SOURCE_QSTR = SOURCE_MOD + SOURCE_MICROPYTHON + SOURCE_UNIX
2017-08-03 18:46:40 +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
env.Tool('micropython')
env.Replace(
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',
OBJCOPY='objcopy',
COPT=os.getenv('OPTIMIZE', '-Os'), )
2017-08-03 18:46:40 +00:00
if ARGUMENTS.get('TREZOR_EMULATOR_ASAN', 0):
asan_flags=(
' -fsanitize=address'+
' -fsanitize-blacklist=asan_blacklist.txt'+
' -fno-omit-frame-pointer'+
' -fno-optimize-sibling-calls'
2018-10-09 12:35:52 +00:00
)
env.Replace(
CC=os.getenv('CC') or 'clang',
LINK=os.getenv('LINK') or 'clang',
CFLAGS=asan_flags,
LINKFLAGS=' -Wl,-no_pie' + asan_flags, )
if ARGUMENTS.get('TREZOR_EMULATOR_DEBUGGABLE', 0):
env.Replace(
COPT=' -O0 -ggdb',
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(
TREZOR_MODEL=TREZOR_MODEL, )
env.Replace(
2019-05-04 20:10:01 +00:00
CCFLAGS='$COPT '
2017-08-03 18:46:40 +00:00
'-g3 '
'-std=gnu99 -Wall -Werror -Wuninitialized -Wno-missing-braces '
2017-08-03 18:46:40 +00:00
'-fdata-sections -ffunction-sections ' + CCFLAGS_MOD,
2017-08-03 19:22:02 +00:00
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
LIBS=['m'],
2017-08-03 18:46:40 +00:00
CPPPATH=[
'.',
'embed/rust',
2017-08-03 18:46:40 +00:00
'embed/unix',
'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=[
'TREZOR_EMULATOR',
2018-09-20 11:43:44 +00:00
('TREZOR_MODEL', '$TREZOR_MODEL'),
2017-08-03 18:46:40 +00:00
('MP_CONFIGFILE', '\\"embed/unix/mpconfigport.h\\"'),
] + CPPDEFINES_MOD,
ASPPFLAGS='$CFLAGS $CCFLAGS', )
2017-08-03 18:46:40 +00:00
try:
env.ParseConfig('pkg-config --cflags --libs sdl2 SDL2_image')
except OSError:
print("SDL2 not installed, Emulator build is not possible")
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',
MAKEMODULEDEFS='$PYTHON vendor/micropython/py/makemoduledefs.py',
2017-08-03 18:46:40 +00:00
MPY_TOOL='$PYTHON vendor/micropython/tools/mpy-tool.py',
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
#
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',
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)
#
# Micropython version and modules
#
hdr_version = env.Command(
target='genhdr/mpversion.h',
source='',
action='$MAKEVERSIONHDR $TARGET', )
hdr_moduledefs = env.Command(
target='genhdr/moduledefs.h',
source=SOURCE_QSTR,
action='$MAKEMODULEDEFS --vpath="." $SOURCES > $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)
#
# Frozen modules
#
if FROZEN:
2020-08-03 13:33:45 +00:00
SOURCE_PY_DIR = 'src/'
SOURCE_PY = Glob(SOURCE_PY_DIR + '*.py')
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/crypto/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/res/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/components/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/components/common/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/constants/__init__.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/__init__.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/common.py'))
if TREZOR_MODEL == 'T':
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/components/tt/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/constants/tt.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt/__init__.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt/reset.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt/recovery.py'))
if EVERYTHING:
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt/altcoin.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/tt/webauthn.py'))
elif TREZOR_MODEL == '1':
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/components/t1/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/constants/t1.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/t1.py'))
else:
raise ValueError('Unknown Trezor model')
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/wire/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'storage/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/__init__.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/*.py',
exclude=[
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/Lisk*.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',
])
)
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/common/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/common/*/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/debug/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/homescreen/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/management/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/management/*/*.py'))
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',
exclude=[
SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/decred.py',
SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/bitcoinlike.py',
SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/zcash.py',
])
)
if EVERYTHING:
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/binance/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Binance*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/cardano/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/cardano/*/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Cardano*.py'))
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'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/ethereum/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Ethereum*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/lisk/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Lisk*.py'))
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'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/DebugMonero*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Monero*.py'))
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'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/ripple/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Ripple*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/stellar/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/stellar/*/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Stellar*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/tezos/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Tezos*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/webauthn/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/decred.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/bitcoinlike.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/zcash.py'))
2019-08-22 18:15:16 +00:00
source_mpy = env.FrozenModule(source=SOURCE_PY, source_dir=SOURCE_PY_DIR, bitcoin_only=BITCOIN_ONLY)
source_mpyc = env.FrozenCFile(
target='frozen_mpy.c', source=source_mpy, qstr_header=qstr_preprocessed)
env.Depends(source_mpyc, qstr_generated)
#
# static secp256-zkp ecmult context
#
if FEATURE_FLAGS["SECP256K1_ZKP"]:
host_env = Environment(ENV=os.environ)
host_env.Replace(
CC=os.getenv('CC_FOR_BUILD') or 'gcc',
COPT='-O2',
CPPPATH='vendor/secp256k1-zkp',
)
gen_context = host_env.Program(
target='vendor/secp256k1-zkp/gen_context',
source='vendor/secp256k1-zkp/src/gen_context.c',
)
secp256k1_zkp_ecmult_static_context = host_env.Command(
target='vendor/secp256k1-zkp/src/ecmult_static_context.h',
source='vendor/secp256k1-zkp/gen_context',
action='cd ${SOURCE.dir}; ./gen_context',
)
#
# Rust library
#
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)
RUST_PROFILE = 'release'
RUST_LIB = 'trezor_lib'
RUST_LIBDIR = f'build/unix/rust/{RUST_PROFILE}'
RUST_LIBPATH = f'{RUST_LIBDIR}/lib{RUST_LIB}.a'
def cargo_build():
# Determine the profile build flags.
if RUST_PROFILE == 'release':
profile = '--release'
else:
profile = ''
features = []
if BITCOIN_ONLY == "1":
features.append("bitcoin_only")
return f'cd embed/rust; cargo build {profile} --target-dir=../../build/unix/rust --features "{" ".join(features)}"'
rust = env.Command(
target=RUST_LIBPATH,
source='',
action=cargo_build(), )
env.Depends(rust, protobuf_blobs)
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 = []
obj_program.extend(env.Object(source=SOURCE_MOD))
if FEATURE_FLAGS["SECP256K1_ZKP"]:
obj_program.extend(env.Object(source=SOURCE_MOD_SECP256K1_ZKP, CCFLAGS='$CCFLAGS -Wno-unused-function'))
obj_program.extend(env.Object(source=SOURCE_MICROPYTHON))
obj_program.extend(env.Object(source=SOURCE_UNIX))
if FROZEN:
obj_program.extend(env.Object(source=source_mpyc))
2017-08-03 18:46:40 +00:00
env.Depends(obj_program, qstr_generated)
if FEATURE_FLAGS["SECP256K1_ZKP"]:
env.Depends(obj_program, secp256k1_zkp_ecmult_static_context)
2017-08-03 18:46:40 +00:00
program = env.Command(
target='trezor-emu-core',
2017-08-03 18:46:40 +00:00
source=obj_program,
action='$CC -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS $LINKFLAGS', )
env.Depends(program, rust)