2017-08-03 18:46:40 +00:00
|
|
|
# pylint: disable=E0602
|
|
|
|
|
2017-08-07 10:50:24 +00:00
|
|
|
import os
|
|
|
|
|
2017-08-03 18:46:40 +00:00
|
|
|
CCFLAGS_MOD = ''
|
|
|
|
CPPPATH_MOD = []
|
|
|
|
CPPDEFINES_MOD = []
|
|
|
|
SOURCE_MOD = []
|
|
|
|
LIBS_MOD = []
|
|
|
|
|
|
|
|
# modtrezorconfig
|
|
|
|
SOURCE_MOD += [
|
|
|
|
'embed/extmod/modtrezorconfig/modtrezorconfig.c',
|
|
|
|
'embed/extmod/modtrezorconfig/norcow.c',
|
2017-10-17 17:18:16 +00:00
|
|
|
'embed/extmod/modtrezorconfig/storage.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',
|
2017-12-23 14:12:31 +00:00
|
|
|
('USE_KECCAK', '1'),
|
|
|
|
('USE_ETHEREUM', '1'),
|
2018-06-14 14:28:50 +00:00
|
|
|
('USE_CARDANO', '1'),
|
2018-03-09 10:37:06 +00:00
|
|
|
('USE_NEM', '1'),
|
2017-08-03 18:46:40 +00:00
|
|
|
]
|
|
|
|
SOURCE_MOD += [
|
|
|
|
'embed/extmod/modtrezorcrypto/modtrezorcrypto.c',
|
2017-12-19 20:54:22 +00:00
|
|
|
'embed/extmod/modtrezorcrypto/crc.c',
|
2017-12-12 19:31:03 +00:00
|
|
|
'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',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/bignum.c',
|
|
|
|
'vendor/trezor-crypto/bip32.c',
|
|
|
|
'vendor/trezor-crypto/bip39.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',
|
|
|
|
'vendor/trezor-crypto/curves.c',
|
|
|
|
'vendor/trezor-crypto/ecdsa.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',
|
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',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/ed25519-donna/ed25519.c',
|
2017-12-12 21:00:15 +00:00
|
|
|
'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',
|
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',
|
2018-01-18 14:26:22 +00:00
|
|
|
'vendor/trezor-crypto/memzero.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',
|
2017-12-12 19:31:03 +00:00
|
|
|
'vendor/trezor-crypto/ripemd160.c',
|
|
|
|
'vendor/trezor-crypto/secp256k1.c',
|
|
|
|
'vendor/trezor-crypto/sha2.c',
|
|
|
|
'vendor/trezor-crypto/sha3.c',
|
2018-03-09 10:37:06 +00:00
|
|
|
'vendor/trezor-crypto/nem.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
# modtrezorio
|
|
|
|
SOURCE_MOD += [
|
|
|
|
'embed/extmod/modtrezorio/modtrezorio.c',
|
|
|
|
]
|
|
|
|
|
|
|
|
# modtrezorui
|
2017-12-15 22:13:25 +00:00
|
|
|
CPPDEFINES_MOD += [
|
|
|
|
'TREZOR_FONT_BOLD_ENABLE',
|
|
|
|
'TREZOR_FONT_NORMAL_ENABLE',
|
2018-08-16 18:59:24 +00:00
|
|
|
'TREZOR_FONT_MONO_ENABLE',
|
|
|
|
'TREZOR_FONT_MONO_BOLD_ENABLE',
|
2017-12-15 22:13:25 +00:00
|
|
|
('QR_MAX_VERSION', '0'),
|
|
|
|
]
|
2017-08-03 18:46:40 +00:00
|
|
|
SOURCE_MOD += [
|
|
|
|
'embed/extmod/modtrezorui/display.c',
|
|
|
|
'embed/extmod/modtrezorui/inflate.c',
|
|
|
|
'embed/extmod/modtrezorui/font_bitmap.c',
|
|
|
|
'embed/extmod/modtrezorui/font_roboto_bold_20.c',
|
|
|
|
'embed/extmod/modtrezorui/font_roboto_regular_20.c',
|
2018-08-16 18:59:24 +00:00
|
|
|
'embed/extmod/modtrezorui/font_robotomono_bold_20.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
'embed/extmod/modtrezorui/font_robotomono_regular_20.c',
|
|
|
|
'embed/extmod/modtrezorui/modtrezorui.c',
|
|
|
|
'embed/extmod/modtrezorui/trezor-qrenc/qr_encode.c',
|
|
|
|
]
|
2018-09-03 15:56:53 +00:00
|
|
|
if ARGUMENTS.get('TREZOR_EMULATOR_NOUI', 0):
|
|
|
|
CPPDEFINES_MOD += ['TREZOR_EMULATOR_NOUI']
|
2017-08-03 18:46:40 +00:00
|
|
|
|
|
|
|
# modtrezorutils
|
|
|
|
SOURCE_MOD += [
|
|
|
|
'embed/extmod/modtrezorutils/modtrezorutils.c',
|
|
|
|
]
|
|
|
|
|
|
|
|
# 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',
|
|
|
|
'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/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/modgc.c',
|
|
|
|
'vendor/micropython/py/modmath.c',
|
|
|
|
'vendor/micropython/py/modmicropython.c',
|
|
|
|
'vendor/micropython/py/modstruct.c',
|
|
|
|
'vendor/micropython/py/modsys.c',
|
|
|
|
'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',
|
2017-08-03 18:46:40 +00:00
|
|
|
'vendor/micropython/py/nlrx86.c',
|
2017-12-19 14:12:56 +00:00
|
|
|
'vendor/micropython/py/nlrx64.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/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_longlong.c',
|
|
|
|
'vendor/micropython/py/objint_mpz.c',
|
|
|
|
'vendor/micropython/py/objint.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/qstr.c',
|
|
|
|
'vendor/micropython/py/reader.c',
|
|
|
|
'vendor/micropython/py/repl.c',
|
|
|
|
'vendor/micropython/py/runtime_utils.c',
|
|
|
|
'vendor/micropython/py/runtime.c',
|
|
|
|
'vendor/micropython/py/scope.c',
|
|
|
|
'vendor/micropython/py/scheduler.c',
|
|
|
|
'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 = [
|
2017-09-06 17:15:59 +00:00
|
|
|
'vendor/micropython/ports/unix/gccollect.c',
|
|
|
|
'vendor/micropython/ports/unix/unix_mphal.c',
|
|
|
|
'vendor/micropython/ports/unix/input.c',
|
|
|
|
'vendor/micropython/ports/unix/alloc.c',
|
2017-08-03 18:46:40 +00:00
|
|
|
'embed/unix/common.c',
|
2017-10-17 13:11:27 +00:00
|
|
|
'embed/unix/flash.c',
|
2018-02-27 00:39:02 +00:00
|
|
|
'embed/unix/main.c',
|
2017-12-15 15:56:08 +00:00
|
|
|
'embed/unix/rng.c',
|
2017-12-14 23:06:09 +00:00
|
|
|
'embed/unix/sdcard.c',
|
|
|
|
'embed/unix/sbu.c',
|
|
|
|
'embed/unix/touch.c',
|
|
|
|
'embed/unix/usb.c',
|
2017-08-03 18:46:40 +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
|
|
|
|
2017-10-12 14:02:40 +00:00
|
|
|
env = Environment(ENV=os.environ, CFLAGS=ARGUMENTS.get('CFLAGS', ''))
|
2017-08-03 18:46:40 +00:00
|
|
|
|
|
|
|
env.Tool('micropython')
|
|
|
|
|
|
|
|
env.Replace(
|
|
|
|
SED='sed',
|
|
|
|
AS='as',
|
|
|
|
AR='ar',
|
|
|
|
CC='gcc',
|
|
|
|
LINK='ld',
|
|
|
|
SIZE='size',
|
|
|
|
STRIP='strip',
|
|
|
|
OBJCOPY='objcopy', )
|
|
|
|
|
|
|
|
env.Replace(
|
2018-09-30 14:39:40 +00:00
|
|
|
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
|
|
|
|
|
|
|
|
env.Replace(
|
2018-07-09 19:03:25 +00:00
|
|
|
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
|
|
|
CCFLAGS='$COPT '
|
2017-08-03 18:46:40 +00:00
|
|
|
'-g3 '
|
|
|
|
'-std=gnu99 -Wall -Werror -Wuninitialized '
|
|
|
|
'-fdata-sections -ffunction-sections ' + CCFLAGS_MOD,
|
2017-08-03 19:22:02 +00:00
|
|
|
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
2017-08-07 10:50:24 +00:00
|
|
|
LIBS=['m'] + LIBS_MOD,
|
2017-08-03 18:46:40 +00:00
|
|
|
CPPPATH=[
|
|
|
|
'.',
|
|
|
|
'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=[
|
2018-08-31 13:52:26 +00:00
|
|
|
'TREZOR_EMULATOR',
|
2018-09-20 11:43:44 +00:00
|
|
|
('TREZOR_MODEL', '$TREZOR_MODEL'),
|
2017-08-07 10:04:23 +00:00
|
|
|
'MICROPY_USE_READLINE',
|
2017-08-03 18:46:40 +00:00
|
|
|
('MP_CONFIGFILE', '\\"embed/unix/mpconfigport.h\\"'),
|
2017-08-03 22:45:32 +00:00
|
|
|
] + CPPDEFINES_MOD,
|
|
|
|
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
2017-08-03 18:46:40 +00:00
|
|
|
|
2018-09-28 17:41:03 +00:00
|
|
|
if not ARGUMENTS.get('TREZOR_EMULATOR_NOUI', 0):
|
2018-09-30 17:38:23 +00:00
|
|
|
env.ParseConfig('pkg-config --cflags --libs sdl2 SDL2_image || :')
|
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',
|
|
|
|
MPY_TOOL='$PYTHON vendor/micropython/tools/mpy-tool.py',
|
2017-08-07 10:04:23 +00:00
|
|
|
MPY_CROSS='vendor/micropython/mpy-cross/mpy-cross', )
|
2017-08-03 18:46:40 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Micropython version
|
|
|
|
#
|
|
|
|
|
|
|
|
hdr_version = env.Command(
|
|
|
|
target='genhdr/mpversion.h',
|
|
|
|
source='',
|
|
|
|
action='$MAKEVERSIONHDR $TARGET', )
|
|
|
|
|
|
|
|
#
|
|
|
|
# Qstrings
|
|
|
|
#
|
|
|
|
|
|
|
|
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_collected])
|
|
|
|
|
|
|
|
qstr_generated = env.GenerateQstrDefs(
|
|
|
|
target='genhdr/qstrdefs.generated.h', source=qstr_preprocessed)
|
|
|
|
|
|
|
|
env.Ignore(qstr_collected, qstr_generated)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Program objects
|
|
|
|
#
|
|
|
|
|
|
|
|
obj_program = []
|
|
|
|
obj_program += env.Object(source=SOURCE_MOD)
|
|
|
|
obj_program += env.Object(source=SOURCE_MICROPYTHON)
|
|
|
|
obj_program += env.Object(source=SOURCE_UNIX)
|
|
|
|
|
|
|
|
env.Depends(obj_program, qstr_generated)
|
|
|
|
|
|
|
|
program = env.Command(
|
|
|
|
target='micropython',
|
|
|
|
source=obj_program,
|
|
|
|
action='$CC -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS $LINKFLAGS', )
|