diff --git a/core/SConscript.boardloader b/core/SConscript.boardloader index b776b01056..a30ece64f8 100644 --- a/core/SConscript.boardloader +++ b/core/SConscript.boardloader @@ -70,10 +70,12 @@ SOURCE_MOD += [ ] env = Environment(ENV=os.environ, - CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')), - CONSTRAINTS=["limited_util_s"], - CPPDEFINES_IMPLICIT=[] - ) + CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')), + CONSTRAINTS=["limited_util_s"], + CPPDEFINES_IMPLICIT=[], + CPPDEFPREFIX="-D'", + CPPDEFSUFFIX="'", +) FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_HAL, PATH_HAL) diff --git a/core/SConscript.bootloader b/core/SConscript.bootloader index e2b7c04614..ab1e3fcc08 100644 --- a/core/SConscript.bootloader +++ b/core/SConscript.bootloader @@ -1,6 +1,7 @@ # pylint: disable=E0602 import os +import shlex import tools, models, ui TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T') @@ -93,7 +94,9 @@ ui.init_ui(TREZOR_MODEL, "bootloader", CPPDEFINES_MOD, SOURCE_MOD, RUST_UI_FEATU env = Environment( ENV=os.environ, CFLAGS=f"{ARGUMENTS.get('CFLAGS', '')} -DPRODUCTION={int(PRODUCTION)} -DBOOTLOADER_QA={int(BOOTLOADER_QA)}", - CPPDEFINES_IMPLICIT=[] + CPPDEFINES_IMPLICIT=[], + CPPDEFPREFIX="-D'", + CPPDEFSUFFIX="'", ) FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_HAL, PATH_HAL) @@ -217,7 +220,7 @@ def cargo_build(): bindgen_macros = tools.get_bindgen_defines(env.get("CPPDEFINES"), ALLPATHS) build_dir = str(Dir('.').abspath) - return f'export BINDGEN_MACROS=\'{bindgen_macros}\'; export BUILD_DIR=\'{build_dir}\'; cd embed/rust; cargo build {profile} ' + ' '.join(cargo_opts) + return f'export BINDGEN_MACROS={shlex.quote(bindgen_macros)}; export BUILD_DIR=\'{build_dir}\'; cd embed/rust; cargo build {profile} ' + ' '.join(cargo_opts) rust = env.Command( target=RUST_LIBPATH, diff --git a/core/SConscript.bootloader_ci b/core/SConscript.bootloader_ci index 8e1583fe44..144ed689be 100644 --- a/core/SConscript.bootloader_ci +++ b/core/SConscript.bootloader_ci @@ -86,9 +86,12 @@ SOURCE_NANOPB = [ ui.init_ui(TREZOR_MODEL, "bootloader", CPPDEFINES_MOD, SOURCE_MOD, RUST_UI_FEATURES) env = Environment( - ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')), - CPPDEFINES_IMPLICIT=[] - ) + ENV=os.environ, + CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')), + CPPDEFINES_IMPLICIT=[], + CPPDEFPREFIX="-D'", + CPPDEFSUFFIX="'", +) FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_HAL, PATH_HAL) diff --git a/core/SConscript.bootloader_emu b/core/SConscript.bootloader_emu index 0761b7fc74..4d6bbbbbe9 100644 --- a/core/SConscript.bootloader_emu +++ b/core/SConscript.bootloader_emu @@ -1,6 +1,7 @@ # pylint: disable=E0602 import os +import shlex import tools, models, ui TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T') @@ -127,7 +128,12 @@ SOURCE_UNIX = [ ui.init_ui(TREZOR_MODEL, "bootloader", CPPDEFINES_MOD, SOURCE_MOD, RUST_UI_FEATURES) -env = Environment(ENV=os.environ, CFLAGS='%s -DCONFIDENTIAL= -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0'))) +env = Environment( + ENV=os.environ, + CFLAGS=ARGUMENTS.get('CFLAGS', '') + f" -DCONFIDENTIAL= -DPRODUCTION={ARGUMENTS.get('PRODUCTION', '0')}", + CPPDEFPREFIX="-D'", + CPPDEFSUFFIX="'", +) FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_UNIX, PATH_HAL) @@ -252,7 +258,7 @@ def cargo_build(): bindgen_macros = tools.get_bindgen_defines(env.get("CPPDEFINES"), ALLPATHS) build_dir = str(Dir('.').abspath) - return f'export BINDGEN_MACROS=\'{bindgen_macros}\'; export BUILD_DIR=\'{build_dir}\'; cd embed/rust; cargo build --profile {RUST_PROFILE} ' + ' '.join(cargo_opts) + return f'export BINDGEN_MACROS={shlex.quote(bindgen_macros)}; export BUILD_DIR=\'{build_dir}\'; cd embed/rust; cargo build --profile {RUST_PROFILE} ' + ' '.join(cargo_opts) rust = env.Command( target=RUST_LIBPATH, diff --git a/core/SConscript.firmware b/core/SConscript.firmware index 006086e0c7..e95922f45a 100644 --- a/core/SConscript.firmware +++ b/core/SConscript.firmware @@ -2,6 +2,7 @@ # fmt: off import os +import shlex import tools, models, ui BITCOIN_ONLY = ARGUMENTS.get('BITCOIN_ONLY', '0') @@ -373,7 +374,9 @@ SOURCE_QSTR = SOURCE_MOD + SOURCE_MICROPYTHON + SOURCE_MICROPYTHON_SPEED env = Environment( ENV=os.environ, CFLAGS=f"{ARGUMENTS.get('CFLAGS', '')} -DPRODUCTION={int(PRODUCTION)} -DPYOPT={PYOPT} -DBOOTLOADER_QA={int(BOOTLOADER_QA)} -DBITCOIN_ONLY={BITCOIN_ONLY}", - CPPDEFINES_IMPLICIT=[] + CPPDEFINES_IMPLICIT=[], + CPPDEFPREFIX="-D'", + CPPDEFSUFFIX="'", ) FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_HAL, PATH_HAL) @@ -770,7 +773,7 @@ def cargo_build(): bindgen_macros = tools.get_bindgen_defines(env.get("CPPDEFINES"), ALLPATHS) build_dir = str(Dir('.').abspath) - return f'export BINDGEN_MACROS=\'{bindgen_macros}\'; export BUILD_DIR=\'{build_dir}\'; cd embed/rust; cargo build {profile} ' + ' '.join(cargo_opts) + return f'export BINDGEN_MACROS={shlex.quote(bindgen_macros)}; export BUILD_DIR=\'{build_dir}\'; cd embed/rust; cargo build {profile} ' + ' '.join(cargo_opts) rust = env.Command( target=RUST_LIBPATH, diff --git a/core/SConscript.kernel b/core/SConscript.kernel index e07f16d1e3..0c0befec5b 100644 --- a/core/SConscript.kernel +++ b/core/SConscript.kernel @@ -239,8 +239,10 @@ if THP: env = Environment( ENV=os.environ, CFLAGS=f"{ARGUMENTS.get('CFLAGS', '')} -DPRODUCTION={int(PRODUCTION)} -DPYOPT={PYOPT} -DBOOTLOADER_QA={int(BOOTLOADER_QA)} -DBITCOIN_ONLY={BITCOIN_ONLY}", - CPPDEFINES_IMPLICIT=[] - ) + CPPDEFINES_IMPLICIT=[], + CPPDEFPREFIX="-D'", + CPPDEFSUFFIX="'", +) FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_HAL, PATH_HAL) diff --git a/core/SConscript.prodtest b/core/SConscript.prodtest index e4fa2d57f2..211eca966e 100644 --- a/core/SConscript.prodtest +++ b/core/SConscript.prodtest @@ -87,7 +87,10 @@ ui.init_ui(TREZOR_MODEL, "prodtest", CPPDEFINES_MOD, SOURCE_MOD, RUST_UI_FEATURE env = Environment( ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')), - CPPDEFINES_IMPLICIT=[]) + CPPDEFINES_IMPLICIT=[], + CPPDEFPREFIX="-D'", + CPPDEFSUFFIX="'", +) FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_HAL, PATH_HAL) diff --git a/core/SConscript.reflash b/core/SConscript.reflash index 80f00fea0a..c77a8e0706 100644 --- a/core/SConscript.reflash +++ b/core/SConscript.reflash @@ -73,8 +73,10 @@ ui.init_ui(TREZOR_MODEL, "prodtest", CPPDEFINES_MOD, SOURCE_MOD, RUST_UI_FEATURE env = Environment( ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')), - CPPDEFINES_IMPLICIT=[] - ) + CPPDEFINES_IMPLICIT=[], + CPPDEFPREFIX="-D'", + CPPDEFSUFFIX="'", +) FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_HAL, PATH_HAL) diff --git a/core/SConscript.unix b/core/SConscript.unix index d872d770b3..6bc1352310 100644 --- a/core/SConscript.unix +++ b/core/SConscript.unix @@ -2,6 +2,7 @@ # fmt: off import os +import shlex import tools, models, ui BITCOIN_ONLY = ARGUMENTS.get('BITCOIN_ONLY', '0') @@ -416,7 +417,12 @@ if PYOPT == '0' or not FROZEN: else: STATIC="" -env = Environment(ENV=os.environ, CFLAGS='%s -DCONFIDENTIAL= -DPYOPT=%s -DBITCOIN_ONLY=%s %s' % (ARGUMENTS.get('CFLAGS', ''), PYOPT, BITCOIN_ONLY, STATIC)) +env = Environment( + ENV=os.environ, + CFLAGS=ARGUMENTS.get("CFLAGS", "") + f" -DCONFIDENTIAL= -DPYOPT={PYOPT} -DBITCOIN_ONLY={BITCOIN_ONLY} {STATIC}", + CPPDEFPREFIX="-D'", + CPPDEFSUFFIX="'", +) FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_UNIX, PATH_HAL) @@ -508,7 +514,7 @@ env.Replace( CPPDEFINES=[ 'TREZOR_EMULATOR', 'TREZOR_MODEL_'+TREZOR_MODEL, - ('MP_CONFIGFILE', '\\"embed/projects/unix/mpconfigport.h\\"'), + ('MP_CONFIGFILE', '"embed/projects/unix/mpconfigport.h"'), ui.get_ui_layout(TREZOR_MODEL), ] + CPPDEFINES_MOD + CPPDEFINES_HAL, ASPPFLAGS='$CFLAGS $CCFLAGS', ) @@ -830,7 +836,7 @@ def cargo_build(): bindgen_macros = tools.get_bindgen_defines(env.get("CPPDEFINES"), ALLPATHS) build_dir = str(Dir('.').abspath) - return f'export BINDGEN_MACROS=\'{bindgen_macros}\'; export BUILD_DIR=\'{build_dir}\'; cd embed/rust; cargo build --profile {RUST_PROFILE} --target-dir=../../build/unix/rust --no-default-features --features "{" ".join(features)}" --target {TARGET}' + return f'export BINDGEN_MACROS={shlex.quote(bindgen_macros)}; export BUILD_DIR=\'{build_dir}\'; cd embed/rust; cargo build --profile {RUST_PROFILE} --target-dir=../../build/unix/rust --no-default-features --features "{" ".join(features)}" --target {TARGET}' rust = env.Command( target=RUST_LIBPATH, diff --git a/core/site_scons/models/D001/discovery.py b/core/site_scons/models/D001/discovery.py index f7724069e7..2c73ff77a0 100644 --- a/core/site_scons/models/D001/discovery.py +++ b/core/site_scons/models/D001/discovery.py @@ -28,11 +28,14 @@ def configure( ] = "-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 " env.get("ENV")["RUST_TARGET"] = "thumbv7em-none-eabihf" - defines += [mcu] - defines += [f'TREZOR_BOARD=\\"{board}\\"'] - defines += [f"HW_MODEL={hw_model}"] - defines += [f"HW_REVISION={hw_revision}"] - defines += ["HSE_VALUE=8000000", "USE_HSE=1"] + defines += [ + mcu, + ("TREZOR_BOARD", f'"{board}"'), + ("HW_MODEL", str(hw_model)), + ("HW_REVISION", str(hw_revision)), + ("HSE_VALUE", "8000000"), + ("USE_HSE", "1"), + ] sources += [ "embed/io/display/stm32f429i-disc1/display_driver.c", @@ -50,7 +53,7 @@ def configure( "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c" ] defines += ["USE_DMA2D"] - defines += ["USE_RGB_COLORS=1"] + defines += [("USE_RGB_COLORS", "1")] features_available.append("dma2d") defines += ["FRAMEBUFFER"] @@ -60,7 +63,7 @@ def configure( sources += ["embed/sys/sdram/stm32f429i-disc1/sdram_bsp.c"] paths += ["embed/sys/sdram/inc"] - defines += ["USE_SDRAM=1"] + defines += [("USE_SDRAM", "1")] if "input" in features_wanted: sources += ["embed/io/i2c_bus/stm32f4/i2c_bus.c"] @@ -68,8 +71,10 @@ def configure( paths += ["embed/io/i2c_bus/inc"] paths += ["embed/io/touch/inc"] features_available.append("touch") - defines += ["USE_TOUCH=1"] - defines += ["USE_I2C=1"] + defines += [ + ("USE_TOUCH", "1"), + ("USE_I2C", "1"), + ] if "usb" in features_wanted: sources += [ @@ -86,6 +91,6 @@ def configure( features_available.append("usb") paths += ["embed/io/usb/inc"] - defines += ["USE_PVD=1"] + defines += [("USE_PVD", "1")] return features_available diff --git a/core/site_scons/models/D002/discovery2.py b/core/site_scons/models/D002/discovery2.py index 496296144b..4b953742e3 100644 --- a/core/site_scons/models/D002/discovery2.py +++ b/core/site_scons/models/D002/discovery2.py @@ -29,11 +29,14 @@ def configure( ] = "-mthumb -mcpu=cortex-m33 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -mtune=cortex-m33 -mcmse " env.get("ENV")["RUST_TARGET"] = "thumbv8m.main-none-eabihf" - defines += [mcu] - defines += [f'TREZOR_BOARD=\\"{board}\\"'] - defines += [f"HW_MODEL={hw_model}"] - defines += [f"HW_REVISION={hw_revision}"] - defines += ["HSE_VALUE=16000000", "USE_HSE=1"] + defines += [ + mcu, + ("TREZOR_BOARD", f'"{board}"'), + ("HW_MODEL", str(hw_model)), + ("HW_REVISION", str(hw_revision)), + ("HSE_VALUE", "16000000"), + ("USE_HSE", "1"), + ] sources += [ "embed/io/display/stm32u5a9j-dk/display_driver.c", @@ -48,8 +51,10 @@ def configure( paths += ["embed/io/i2c_bus/inc"] paths += ["embed/io/touch/inc"] features_available.append("touch") - defines += ["USE_TOUCH=1"] - defines += ["USE_I2C=1"] + defines += [ + ("USE_TOUCH", "1"), + ("USE_I2C", "1"), + ] if "usb" in features_wanted: sources += [ @@ -68,8 +73,8 @@ def configure( defines += [ "USE_DMA2D", - "UI_COLOR_32BIT", - "USE_RGB_COLORS", + ("UI_COLOR_32BIT", "1"), + ("USE_RGB_COLORS", "1"), ] sources += ["embed/gfx/bitblt/stm32/dma2d_bitblt.c"] diff --git a/core/site_scons/models/T2B1/emulator.py b/core/site_scons/models/T2B1/emulator.py index fc05aa8342..15a39cdb28 100644 --- a/core/site_scons/models/T2B1/emulator.py +++ b/core/site_scons/models/T2B1/emulator.py @@ -21,31 +21,33 @@ def configure( features_available.append("framebuffer") features_available.append("display_mono") - defines += [mcu] - defines += [f'TREZOR_BOARD=\\"{board}\\"'] - defines += [f"HW_MODEL={hw_model}"] - defines += [f"HW_REVISION={hw_revision}"] - defines += [f"MCU_TYPE={mcu}"] - defines += ["FLASH_BIT_ACCESS=1"] - defines += ["FLASH_BLOCK_WORDS=1"] + defines += [ + mcu, + ("TREZOR_BOARD", f'"{board}"'), + ("HW_MODEL", str(hw_model)), + ("HW_REVISION", str(hw_revision)), + ("MCU_TYPE", mcu), + ("FLASH_BIT_ACCESS", "1"), + ("FLASH_BLOCK_WORDS", "1"), + ] if "sbu" in features_wanted: sources += ["embed/io/sbu/unix/sbu.c"] paths += ["embed/io/sbu/inc"] - defines += ["USE_SBU=1"] + defines += [("USE_SBU", "1")] if "optiga" in features_wanted: sources += ["embed/sec/optiga/unix/optiga_hal.c"] sources += ["embed/sec/optiga/unix/optiga.c"] paths += ["embed/sec/optiga/inc"] features_available.append("optiga") - defines += ["USE_OPTIGA=1"] + defines += [("USE_OPTIGA", "1")] if "input" in features_wanted: sources += ["embed/io/button/unix/button.c"] paths += ["embed/io/button/inc"] features_available.append("button") - defines += ["USE_BUTTON=1"] + defines += [("USE_BUTTON", "1")] sources += ["embed/util/flash/stm32f4/flash_layout.c"] diff --git a/core/site_scons/models/T2B1/trezor_r_v10.py b/core/site_scons/models/T2B1/trezor_r_v10.py index e5fbe59955..739a443813 100644 --- a/core/site_scons/models/T2B1/trezor_r_v10.py +++ b/core/site_scons/models/T2B1/trezor_r_v10.py @@ -32,11 +32,14 @@ def configure( ] = "-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 " env.get("ENV")["RUST_TARGET"] = "thumbv7em-none-eabihf" - defines += [mcu] - defines += [f'TREZOR_BOARD=\\"{board}\\"'] - defines += [f"HW_MODEL={hw_model}"] - defines += [f"HW_REVISION={hw_revision}"] - defines += ["HSE_VALUE=8000000", "USE_HSE=1"] + defines += [ + mcu, + ("TREZOR_BOARD", f'"{board}"'), + ("HW_MODEL", str(hw_model)), + ("HW_REVISION", str(hw_revision)), + ("HSE_VALUE", "8000000"), + ("USE_HSE", "1"), + ] sources += ["embed/io/display/vg-2864/display_driver.c"] paths += ["embed/io/display/inc"] @@ -45,13 +48,13 @@ def configure( sources += ["embed/io/button/stm32/button.c"] paths += ["embed/io/button/inc"] features_available.append("button") - defines += ["USE_BUTTON=1"] + defines += [("USE_BUTTON", "1")] if "sbu" in features_wanted: sources += ["embed/io/sbu/stm32/sbu.c"] paths += ["embed/io/sbu/inc"] features_available.append("sbu") - defines += ["USE_SBU=1"] + defines += [("USE_SBU", "1")] if "consumption_mask" in features_wanted: sources += ["embed/sec/consumption_mask/stm32f4/consumption_mask.c"] @@ -59,7 +62,7 @@ def configure( "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c" ] paths += ["embed/sec/consumption_mask/inc"] - defines += ["USE_CONSUMPTION_MASK=1"] + defines += [("USE_CONSUMPTION_MASK", "1")] if "usb" in features_wanted: sources += [ @@ -86,9 +89,9 @@ def configure( paths += ["embed/io/i2c_bus/inc"] paths += ["embed/sec/optiga/inc"] features_available.append("optiga") - defines += ["USE_OPTIGA=1"] - defines += ["USE_I2C=1"] + defines += [("USE_OPTIGA", "1")] + defines += [("USE_I2C", "1")] - defines += ["USE_PVD=1"] + defines += [("USE_PVD", "1")] return features_available diff --git a/core/site_scons/models/T2T1/emulator.py b/core/site_scons/models/T2T1/emulator.py index 9bf7b0696d..52e32555f7 100644 --- a/core/site_scons/models/T2T1/emulator.py +++ b/core/site_scons/models/T2T1/emulator.py @@ -19,15 +19,17 @@ def configure( defines += ["DISPLAY_RGB565"] features_available.append("display_rgb565") - defines += ["USE_RGB_COLORS"] + defines += [("USE_RGB_COLORS", "1")] - defines += [mcu] - defines += [f'TREZOR_BOARD=\\"{board}\\"'] - defines += [f"HW_MODEL={hw_model}"] - defines += [f"HW_REVISION={hw_revision}"] - defines += [f"MCU_TYPE={mcu}"] - defines += ["FLASH_BIT_ACCESS=1"] - defines += ["FLASH_BLOCK_WORDS=1"] + defines += [ + mcu, + ("TREZOR_BOARD", f'"{board}"'), + ("HW_MODEL", str(hw_model)), + ("HW_REVISION", str(hw_revision)), + ("MCU_TYPE", mcu), + ("FLASH_BIT_ACCESS", "1"), + ("FLASH_BLOCK_WORDS", "1"), + ] if "sd_card" in features_wanted: features_available.append("sd_card") @@ -37,21 +39,21 @@ def configure( "embed/upymod/modtrezorio/ffunicode.c", ] paths += ["embed/io/sdcard/inc"] - defines += ["USE_SD_CARD=1"] + defines += [("USE_SD_CARD", "1")] if "sbu" in features_wanted: sources += ["embed/io/sbu/unix/sbu.c"] paths += ["embed/io/sbu/inc"] - defines += ["USE_SBU=1"] + defines += [("USE_SBU", "1")] if "input" in features_wanted: sources += ["embed/io/touch/unix/touch.c"] paths += ["embed/io/touch/inc"] features_available.append("touch") - defines += ["USE_TOUCH=1"] + defines += [("USE_TOUCH", "1")] features_available.append("backlight") - defines += ["USE_BACKLIGHT=1"] + defines += [("USE_BACKLIGHT", "1")] sources += ["embed/util/flash/stm32f4/flash_layout.c"] diff --git a/core/site_scons/models/T2T1/trezor_t.py b/core/site_scons/models/T2T1/trezor_t.py index 2700b105da..5f132699b6 100644 --- a/core/site_scons/models/T2T1/trezor_t.py +++ b/core/site_scons/models/T2T1/trezor_t.py @@ -18,7 +18,7 @@ def configure( defines += ["DISPLAY_RGB565"] features_available.append("display_rgb565") - defines += ["USE_RGB_COLORS=1"] + defines += [("USE_RGB_COLORS", "1")] mcu = "STM32F427xx" @@ -32,11 +32,14 @@ def configure( ] = "-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 " env.get("ENV")["RUST_TARGET"] = "thumbv7em-none-eabihf" - defines += [mcu] - defines += [f'TREZOR_BOARD=\\"{board}\\"'] - defines += [f"HW_MODEL={hw_model}"] - defines += [f"HW_REVISION={hw_revision}"] - defines += ["HSE_VALUE=8000000", "USE_HSE=1"] + defines += [ + mcu, + ("TREZOR_BOARD", f'"{board}"'), + ("HW_MODEL", str(hw_model)), + ("HW_REVISION", str(hw_revision)), + ("HSE_VALUE", "8000000"), + ("USE_HSE", "1"), + ] sources += ["embed/io/display/st-7789/display_nofb.c"] sources += ["embed/io/display/st-7789/display_driver.c"] @@ -51,7 +54,7 @@ def configure( sources += ["embed/io/display/backlight/stm32/backlight_pwm.c"] features_available.append("backlight") - defines += ["USE_BACKLIGHT=1"] + defines += [("USE_BACKLIGHT", "1")] if "input" in features_wanted: sources += ["embed/io/i2c_bus/stm32f4/i2c_bus.c"] @@ -59,8 +62,8 @@ def configure( paths += ["embed/io/i2c_bus/inc"] paths += ["embed/io/touch/inc"] features_available.append("touch") - defines += ["USE_TOUCH=1"] - defines += ["USE_I2C=1"] + defines += [("USE_TOUCH", "1")] + defines += [("USE_I2C", "1")] if "sd_card" in features_wanted: sources += ["embed/io/sdcard/stm32f4/sdcard.c"] @@ -71,13 +74,13 @@ def configure( ] paths += ["embed/io/sdcard/inc"] features_available.append("sd_card") - defines += ["USE_SD_CARD=1"] + defines += [("USE_SD_CARD", "1")] if "sbu" in features_wanted: sources += ["embed/io/sbu/stm32/sbu.c"] paths += ["embed/io/sbu/inc"] features_available.append("sbu") - defines += ["USE_SBU=1"] + defines += [("USE_SBU", "1")] if "usb" in features_wanted: sources += [ @@ -102,6 +105,6 @@ def configure( ] features_available.append("dma2d") - defines += ["USE_PVD=1"] + defines += [("USE_PVD", "1")] return features_available diff --git a/core/site_scons/models/T3B1/emulator.py b/core/site_scons/models/T3B1/emulator.py index 8e3ff56ee7..3ba72c72ed 100644 --- a/core/site_scons/models/T3B1/emulator.py +++ b/core/site_scons/models/T3B1/emulator.py @@ -21,31 +21,33 @@ def configure( features_available.append("framebuffer") features_available.append("display_mono") - defines += [mcu] - defines += [f'TREZOR_BOARD=\\"{board}\\"'] - defines += [f"HW_MODEL={hw_model}"] - defines += [f"HW_REVISION={hw_revision}"] - defines += [f"MCU_TYPE={mcu}"] - defines += ["FLASH_BIT_ACCESS=1"] - defines += ["FLASH_BLOCK_WORDS=1"] + defines += [ + mcu, + ("TREZOR_BOARD", f'"{board}"'), + ("HW_MODEL", str(hw_model)), + ("HW_REVISION", str(hw_revision)), + ("MCU_TYPE", mcu), + ("FLASH_BIT_ACCESS", "1"), + ("FLASH_BLOCK_WORDS", "1"), + ] if "sbu" in features_wanted: sources += ["embed/io/sbu/unix/sbu.c"] paths += ["embed/io/sbu/inc"] - defines += ["USE_SBU=1"] + defines += [("USE_SBU", "1")] if "optiga" in features_wanted: sources += ["embed/sec/optiga/unix/optiga_hal.c"] sources += ["embed/sec/optiga/unix/optiga.c"] paths += ["embed/sec/optiga/inc"] features_available.append("optiga") - defines += ["USE_OPTIGA=1"] + defines += [("USE_OPTIGA", "1")] if "input" in features_wanted: sources += ["embed/io/button/unix/button.c"] paths += ["embed/io/button/inc"] features_available.append("button") - defines += ["USE_BUTTON=1"] + defines += [("USE_BUTTON", "1")] sources += ["embed/util/flash/stm32u5/flash_layout.c"] diff --git a/core/site_scons/models/T3B1/trezor_t3b1_revB.py b/core/site_scons/models/T3B1/trezor_t3b1_revB.py index 67262573e0..d4c6fd472b 100644 --- a/core/site_scons/models/T3B1/trezor_t3b1_revB.py +++ b/core/site_scons/models/T3B1/trezor_t3b1_revB.py @@ -14,7 +14,7 @@ def configure( features_available: list[str] = [] board = "T3B1/boards/trezor_t3b1_revB.h" hw_model = get_hw_model_as_number("T3B1") - hw_revision = "B" + hw_revision = ord("B") defines += ["FRAMEBUFFER"] features_available.append("framebuffer") @@ -33,10 +33,12 @@ def configure( ] = "-mthumb -mcpu=cortex-m33 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -mtune=cortex-m33 -mcmse " env.get("ENV")["RUST_TARGET"] = "thumbv8m.main-none-eabihf" - defines += [mcu] - defines += [f'TREZOR_BOARD=\\"{board}\\"'] - defines += [f"HW_MODEL={hw_model}"] - defines += [f"HW_REVISION={ord(hw_revision)}"] + defines += [ + mcu, + ("TREZOR_BOARD", f'"{board}"'), + ("HW_MODEL", str(hw_model)), + ("HW_REVISION", str(hw_revision)), + ] sources += ["embed/io/display/vg-2864/display_driver.c"] paths += ["embed/io/display/inc"] @@ -45,13 +47,13 @@ def configure( sources += ["embed/io/button/stm32/button.c"] paths += ["embed/io/button/inc"] features_available.append("button") - defines += ["USE_BUTTON=1"] + defines += [("USE_BUTTON", "1")] if "sbu" in features_wanted: sources += ["embed/io/sbu/stm32/sbu.c"] paths += ["embed/io/sbu/inc"] features_available.append("sbu") - defines += ["USE_SBU=1"] + defines += [("USE_SBU", "1")] if "usb" in features_wanted: sources += [ @@ -78,22 +80,24 @@ def configure( paths += ["embed/io/i2c_bus/inc"] paths += ["embed/sec/optiga/inc"] features_available.append("optiga") - defines += ["USE_OPTIGA=1"] - defines += ["USE_I2C=1"] + defines += [ + ("USE_OPTIGA", "1"), + ("USE_I2C", "1"), + ] if "consumption_mask" in features_wanted: sources += ["embed/sec/consumption_mask/stm32u5/consumption_mask.c"] paths += ["embed/sec/consumption_mask/inc"] - defines += ["USE_CONSUMPTION_MASK=1"] + defines += [("USE_CONSUMPTION_MASK", "1")] defines += [ - "USE_HASH_PROCESSOR=1", - "USE_STORAGE_HWKEY=1", - "USE_TAMPER=1", - "USE_FLASH_BURST=1", - "USE_RESET_TO_BOOT=1", - "USE_OEM_KEYS_CHECK=1", - "USE_PVD=1", + ("USE_HASH_PROCESSOR", "1"), + ("USE_STORAGE_HWKEY", "1"), + ("USE_TAMPER", "1"), + ("USE_FLASH_BURST", "1"), + ("USE_RESET_TO_BOOT", "1"), + ("USE_OEM_KEYS_CHECK", "1"), + ("USE_PVD", "1"), ] env.get("ENV")["TREZOR_BOARD"] = board diff --git a/core/site_scons/models/T3T1/emulator.py b/core/site_scons/models/T3T1/emulator.py index ab733d9cb2..6e912d7c5d 100644 --- a/core/site_scons/models/T3T1/emulator.py +++ b/core/site_scons/models/T3T1/emulator.py @@ -20,16 +20,18 @@ def configure( defines += ["FRAMEBUFFER", "DISPLAY_RGB565"] features_available.append("framebuffer") features_available.append("display_rgb565") - defines += ["USE_RGB_COLORS=1"] + defines += [("USE_RGB_COLORS", "1")] - defines += [mcu] - defines += [f'TREZOR_BOARD=\\"{board}\\"'] - defines += [f"HW_MODEL={hw_model}"] - defines += [f"HW_REVISION={hw_revision}"] - defines += [f"MCU_TYPE={mcu}"] - # todo change to blockwise flash when implemented in unix - defines += ["FLASH_BIT_ACCESS=1"] - defines += ["FLASH_BLOCK_WORDS=1"] + defines += [ + mcu, + ("TREZOR_BOARD", f'"{board}"'), + ("HW_MODEL", str(hw_model)), + ("HW_REVISION", str(hw_revision)), + ("MCU_TYPE", mcu), + # todo change to blockwise flash when implemented in unix + ("FLASH_BIT_ACCESS", "1"), + ("FLASH_BLOCK_WORDS", "1"), + ] if "sd_card" in features_wanted: features_available.append("sd_card") @@ -39,28 +41,28 @@ def configure( "embed/upymod/modtrezorio/ffunicode.c", ] paths += ["embed/io/sdcard/inc"] - defines += ["USE_SD_CARD=1"] + defines += [("USE_SD_CARD", "1")] if "sbu" in features_wanted: sources += ["embed/io/sbu/unix/sbu.c"] paths += ["embed/io/sbu/inc"] - defines += ["USE_SBU=1"] + defines += [("USE_SBU", "1")] if "optiga" in features_wanted: sources += ["embed/sec/optiga/unix/optiga_hal.c"] sources += ["embed/sec/optiga/unix/optiga.c"] paths += ["embed/sec/optiga/inc"] features_available.append("optiga") - defines += ["USE_OPTIGA=1"] + defines += [("USE_OPTIGA", "1")] if "input" in features_wanted: sources += ["embed/io/touch/unix/touch.c"] paths += ["embed/io/touch/inc"] features_available.append("touch") - defines += ["USE_TOUCH=1"] + defines += [("USE_TOUCH", "1")] features_available.append("backlight") - defines += ["USE_BACKLIGHT=1"] + defines += [("USE_BACKLIGHT", "1")] sources += ["embed/util/flash/stm32u5/flash_layout.c"] diff --git a/core/site_scons/models/T3T1/trezor_t3t1_revE.py b/core/site_scons/models/T3T1/trezor_t3t1_revE.py index 27566d52a6..0f52a08689 100644 --- a/core/site_scons/models/T3T1/trezor_t3t1_revE.py +++ b/core/site_scons/models/T3T1/trezor_t3t1_revE.py @@ -18,9 +18,9 @@ def configure( features_available.append("framebuffer") features_available.append("display_rgb565") - defines += ["DISPLAY_RGB565"] - defines += ["FRAMEBUFFER"] - defines += ["USE_RGB_COLORS=1"] + defines += [("DISPLAY_RGB565", "1")] + defines += [("FRAMEBUFFER", "1")] + defines += [("USE_RGB_COLORS", "1")] mcu = "STM32U585xx" linker_script = """embed/sys/linker/stm32u58/{target}.ld""" @@ -35,10 +35,12 @@ def configure( ] = "-mthumb -mcpu=cortex-m33 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -mtune=cortex-m33 -mcmse " env.get("ENV")["RUST_TARGET"] = "thumbv8m.main-none-eabihf" - defines += [mcu] - defines += [f'TREZOR_BOARD=\\"{board}\\"'] - defines += [f"HW_MODEL={hw_model}"] - defines += [f"HW_REVISION={hw_revision}"] + defines += [ + mcu, + ("TREZOR_BOARD", f'"{board}"'), + ("HW_MODEL", str(hw_model)), + ("HW_REVISION", str(hw_revision)), + ] sources += ["embed/io/display/st-7789/display_fb.c"] sources += ["embed/io/display/st-7789/display_driver.c"] @@ -49,7 +51,7 @@ def configure( sources += ["embed/io/display/backlight/stm32/backlight_pwm.c"] features_available.append("backlight") - defines += ["USE_BACKLIGHT=1"] + defines += [("USE_BACKLIGHT", "1")] env_constraints = env.get("CONSTRAINTS") if not (env_constraints and "limited_util_s" in env_constraints): @@ -62,8 +64,8 @@ def configure( paths += ["embed/io/i2c_bus/inc"] paths += ["embed/io/touch/inc"] features_available.append("touch") - defines += ["USE_TOUCH=1"] - defines += ["USE_I2C=1"] + defines += [("USE_TOUCH", "1")] + defines += [("USE_I2C", "1")] if "haptic" in features_wanted: sources += [ @@ -71,7 +73,7 @@ def configure( ] paths += ["embed/io/haptic/inc"] features_available.append("haptic") - defines += ["USE_HAPTIC=1"] + defines += [("USE_HAPTIC", "1")] if "sd_card" in features_wanted: sources += ["embed/io/sdcard/stm32u5/sdcard.c"] @@ -81,13 +83,13 @@ def configure( sources += ["vendor/stm32u5xx_hal_driver/Src/stm32u5xx_ll_sdmmc.c"] paths += ["embed/io/sdcard/inc"] features_available.append("sd_card") - defines += ["USE_SD_CARD=1"] + defines += [("USE_SD_CARD", "1")] if "sbu" in features_wanted: sources += ["embed/io/sbu/stm32/sbu.c"] paths += ["embed/io/sbu/inc"] features_available.append("sbu") - defines += ["USE_SBU=1"] + defines += [("USE_SBU", "1")] if "usb" in features_wanted: sources += [ @@ -105,7 +107,7 @@ def configure( paths += ["embed/io/usb/inc"] if "dma2d" in features_wanted: - defines += ["USE_DMA2D"] + defines += [("USE_DMA2D", "1")] sources += ["embed/gfx/bitblt/stm32/dma2d_bitblt.c"] features_available.append("dma2d") @@ -117,16 +119,16 @@ def configure( sources += ["vendor/trezor-crypto/hash_to_curve.c"] paths += ["embed/sec/optiga/inc"] features_available.append("optiga") - defines += ["USE_OPTIGA=1"] + defines += [("USE_OPTIGA", "1")] defines += [ - "USE_HASH_PROCESSOR=1", - "USE_STORAGE_HWKEY=1", - "USE_TAMPER=1", - "USE_FLASH_BURST=1", - "USE_RESET_TO_BOOT=1", - "USE_OEM_KEYS_CHECK=1", - "USE_PVD=1", + ("USE_HASH_PROCESSOR", "1"), + ("USE_STORAGE_HWKEY", "1"), + ("USE_TAMPER", "1"), + ("USE_FLASH_BURST", "1"), + ("USE_RESET_TO_BOOT", "1"), + ("USE_OEM_KEYS_CHECK", "1"), + ("USE_PVD", "1"), ] env.get("ENV")["TREZOR_BOARD"] = board diff --git a/core/site_scons/models/T3W1/emulator.py b/core/site_scons/models/T3W1/emulator.py index 3be3a6ed2f..622f2bf603 100644 --- a/core/site_scons/models/T3W1/emulator.py +++ b/core/site_scons/models/T3W1/emulator.py @@ -21,37 +21,39 @@ def configure( features_available.append("framebuffer") features_available.append("display_rgba8888") features_available.append("ui_color_32bit") - defines += ["USE_RGB_COLORS=1"] + defines += [("USE_RGB_COLORS", "1")] - defines += [mcu] - defines += [f'TREZOR_BOARD=\\"{board}\\"'] - defines += [f"HW_MODEL={hw_model}"] - defines += [f"HW_REVISION={hw_revision}"] - defines += [f"MCU_TYPE={mcu}"] - # todo change to blockwise flash when implemented in unix - defines += ["FLASH_BIT_ACCESS=1"] - defines += ["FLASH_BLOCK_WORDS=1"] + defines += [ + mcu, + ("TREZOR_BOARD", f'"{board}"'), + ("HW_MODEL", str(hw_model)), + ("HW_REVISION", str(hw_revision)), + ("MCU_TYPE", mcu), + # todo change to blockwise flash when implemented in unix + ("FLASH_BIT_ACCESS", "1"), + ("FLASH_BLOCK_WORDS", "1"), + ] if "sbu" in features_wanted: sources += ["embed/io/sbu/unix/sbu.c"] paths += ["embed/io/sbu/inc"] - defines += ["USE_SBU=1"] + defines += [("USE_SBU", "1")] if "optiga" in features_wanted: sources += ["embed/sec/optiga/unix/optiga_hal.c"] sources += ["embed/sec/optiga/unix/optiga.c"] paths += ["embed/sec/optiga/inc"] features_available.append("optiga") - defines += ["USE_OPTIGA=1"] + defines += [("USE_OPTIGA", "1")] if "input" in features_wanted: sources += ["embed/io/touch/unix/touch.c"] paths += ["embed/io/touch/inc"] features_available.append("touch") - defines += ["USE_TOUCH=1"] + defines += [("USE_TOUCH", "1")] features_available.append("backlight") - defines += ["USE_BACKLIGHT=1"] + defines += [("USE_BACKLIGHT", "1")] sources += ["embed/util/flash/stm32u5/flash_layout.c"] diff --git a/core/site_scons/models/T3W1/trezor_t3w1_revA.py b/core/site_scons/models/T3W1/trezor_t3w1_revA.py index 6b9716dfff..19012a721a 100644 --- a/core/site_scons/models/T3W1/trezor_t3w1_revA.py +++ b/core/site_scons/models/T3W1/trezor_t3w1_revA.py @@ -29,11 +29,14 @@ def configure( ] = "-mthumb -mcpu=cortex-m33 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -mtune=cortex-m33 -mcmse " env.get("ENV")["RUST_TARGET"] = "thumbv8m.main-none-eabihf" - defines += [mcu] - defines += [f'TREZOR_BOARD=\\"{board}\\"'] - defines += [f"HW_MODEL={hw_model}"] - defines += [f"HW_REVISION={hw_revision}"] - defines += ["HSE_VALUE=32000000", "USE_HSE=1"] + defines += [ + mcu, + ("TREZOR_BOARD", f'"{board}"'), + ("HW_MODEL", str(hw_model)), + ("HW_REVISION", str(hw_revision)), + ("HSE_VALUE", "32000000"), + ("USE_HSE", "1"), + ] sources += [ "embed/io/display/st7785ma/display_driver.c", @@ -42,7 +45,7 @@ def configure( paths += ["embed/io/display/inc"] features_available.append("backlight") - defines += ["USE_BACKLIGHT=1"] + defines += [("USE_BACKLIGHT", "1")] if "input" in features_wanted: sources += ["embed/io/i2c_bus/stm32u5/i2c_bus.c"] @@ -54,9 +57,11 @@ def configure( sources += ["embed/io/button/stm32/button.c"] paths += ["embed/io/button/inc"] features_available.append("button") - defines += ["USE_TOUCH=1"] - defines += ["USE_I2C=1"] - defines += ["USE_BUTTON=1"] + defines += [ + ("USE_TOUCH", "1"), + ("USE_I2C", "1"), + ("USE_BUTTON", "1"), + ] if "haptic" in features_wanted: sources += [ @@ -76,7 +81,7 @@ def configure( # "vendor/micropython/lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c" # ] # features_available.append("ble") - # defines += ["USE_BLE=1"] + # defines += [("USE_BLE", "1")] if "ble" in features_wanted: sources += [ @@ -91,19 +96,19 @@ def configure( sources += ["vendor/trezor-crypto/hash_to_curve.c"] paths += ["embed/sec/optiga/inc"] features_available.append("optiga") - defines += ["USE_OPTIGA=1"] + defines += [("USE_OPTIGA", "1")] if "sbu" in features_wanted: sources += ["embed/io/sbu/stm32/sbu.c"] paths += ["embed/io/sbu/inc"] features_available.append("sbu") - defines += ["USE_SBU=1"] + defines += [("USE_SBU", "1")] if "rgb_led" in features_wanted: sources += ["embed/io/rgb_led/stm32/rgb_led.c"] paths += ["embed/io/rgb_led/inc"] features_available.append("rgb_led") - defines += ["USE_RGB_LED=1"] + defines += [("USE_RGB_LED", "1")] if "usb" in features_wanted: sources += [ @@ -122,7 +127,7 @@ def configure( defines += [ "USE_DMA2D", - "USE_RGB_COLORS", + ("USE_RGB_COLORS", "1"), ] sources += ["embed/gfx/bitblt/stm32/dma2d_bitblt.c"] @@ -134,12 +139,12 @@ def configure( features_available.append("display_rgb565") defines += [ - "USE_HASH_PROCESSOR=1", - "USE_STORAGE_HWKEY=1", - "USE_TAMPER=1", - "USE_FLASH_BURST=1", - "USE_OEM_KEYS_CHECK=1", - "USE_RESET_TO_BOOT=1", + ("USE_HASH_PROCESSOR", "1"), + ("USE_STORAGE_HWKEY", "1"), + ("USE_TAMPER", "1"), + ("USE_FLASH_BURST", "1"), + ("USE_OEM_KEYS_CHECK", "1"), + ("USE_RESET_TO_BOOT", "1"), ] env.get("ENV")["LINKER_SCRIPT"] = linker_script diff --git a/core/site_scons/models/stm32f4_common.py b/core/site_scons/models/stm32f4_common.py index 07a8fe51e4..bba7c41d42 100644 --- a/core/site_scons/models/stm32f4_common.py +++ b/core/site_scons/models/stm32f4_common.py @@ -3,7 +3,7 @@ from __future__ import annotations def stm32f4_common_files(env, defines, sources, paths): defines += [ - ("STM32_HAL_H", '""'), + ("STM32_HAL_H", ""), ("FLASH_BLOCK_WORDS", "1"), ("FLASH_BIT_ACCESS", "1"), ("CONFIDENTIAL", ""), diff --git a/core/site_scons/models/stm32u5_common.py b/core/site_scons/models/stm32u5_common.py index d15e8b67e7..0d3ed6437a 100644 --- a/core/site_scons/models/stm32u5_common.py +++ b/core/site_scons/models/stm32u5_common.py @@ -3,10 +3,10 @@ from __future__ import annotations def stm32u5_common_files(env, defines, sources, paths): defines += [ - ("STM32_HAL_H", '""'), + ("STM32_HAL_H", ""), ("FLASH_BLOCK_WORDS", "4"), ("USE_TRUSTZONE", "1"), - ("CONFIDENTIAL", "'__attribute__((section(\".confidential\")))'"), + ("CONFIDENTIAL", '__attribute__((section(".confidential")))'), ] paths += [ diff --git a/core/site_scons/tools.py b/core/site_scons/tools.py index 58ec3efdec..43ab398c6d 100644 --- a/core/site_scons/tools.py +++ b/core/site_scons/tools.py @@ -63,21 +63,13 @@ def _compress(data: bytes) -> bytes: return z.compress(data) + z.flush() -def get_bindgen_defines( - defines: list[str | tuple[str, str]], paths: list[str] -) -> tuple(str, str): +def get_bindgen_defines(defines: list[str | tuple[str, str]], paths: list[str]) -> str: rest_defs = [] for d in defines: if type(d) is tuple: d = f"-D{d[0]}={d[1]}" else: d = f"-D{d}" - d = ( - d.replace('\\"', '"') - .replace("'", "'\"'\"'") - .replace('"<', "<") - .replace('>"', ">") - ) rest_defs.append(d) for d in paths: rest_defs.append(f"-I../../{d}") diff --git a/core/site_scons/ui/common.py b/core/site_scons/ui/common.py index 83f0dc96ea..586d21f7db 100644 --- a/core/site_scons/ui/common.py +++ b/core/site_scons/ui/common.py @@ -2,13 +2,16 @@ from __future__ import annotations def add_font( - font_name: str, font: str | None, defines: list[str], sources: list[str] + font_name: str, + font: str | None, + defines: list[str | tuple[str, str]], + sources: list[str], ) -> None: if font is not None: font_filename = font.replace("_upper", "").lower() defines += [ - "TREZOR_FONT_" + font_name + "_ENABLE=" + font, - "TREZOR_FONT_" + font_name + '_INCLUDE=\\"' + font_filename + '.h\\"', + (f"TREZOR_FONT_{font_name}_ENABLE", font), + (f"TREZOR_FONT_{font_name}_INCLUDE", f'"{font_filename}.h"'), ] sourcefile = "embed/gfx/fonts/" + font_filename + ".c" if sourcefile not in sources: