1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-13 19:18:56 +00:00

core: replace BITCOIN_ONLY with a constant only in src/trezor/utils.py

This commit is contained in:
Pavol Rusnak 2019-09-22 15:07:04 +02:00
parent bb4dd3cf18
commit b9e7e93bcf
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 11 additions and 5 deletions

View File

@ -23,10 +23,13 @@ def generate(env):
target = str(target[0])
source = str(source[0])
source_name = source.replace(env['source_dir'], '')
# unroll the utils.BITCOIN_ONLY constant
btc_only = 'True' if env['bitcoin_only'] == '1' else 'False'
interim = "%s.i" % target[:-4] # replace .mpy with .i
return '$SED "s:utils\.BITCOIN_ONLY:%s:g" %s > %s && $MPY_CROSS -o %s -s %s %s' % (btc_only, source, interim, target, source_name, interim)
# set utils.BITCOIN_ONLY to constant in src/trezor/utils.py
if source == "src/trezor/utils.py":
btc_only = 'True' if env['bitcoin_only'] == '1' else 'False'
interim = "%s.i" % target[:-4] # replace .mpy with .i
return '$SED "s:^BITCOIN_ONLY = BITCOIN_ONLY$:BITCOIN_ONLY = %s:g" %s > %s && $MPY_CROSS -o %s -s %s %s' % (btc_only, source, interim, target, source_name, interim)
else:
return '$MPY_CROSS -o %s -s %s %s' % (target, source_name, source)
env['BUILDERS']['FrozenModule'] = SCons.Builder.Builder(
generator=generate_frozen_module,
@ -38,4 +41,4 @@ def generate(env):
def exists(env):
return True
return True

View File

@ -14,6 +14,9 @@ from trezorutils import ( # noqa: F401
set_mode_unprivileged,
)
# Don't remove! This line will be modified when freezing the module
BITCOIN_ONLY = BITCOIN_ONLY
if __debug__:
if EMULATOR:
import uos