mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-27 15:51:02 +00:00
refactor(core/rust): move bindgen macros used for tests to model folder
[no changelog]
This commit is contained in:
parent
bdc054235c
commit
885c5b96d9
@ -53,6 +53,10 @@ OPENOCD_TRANSPORT ?= hla_swd
|
||||
# Include the device-specific definitions.
|
||||
include embed/models/$(TREZOR_MODEL)/config.mk
|
||||
|
||||
# Get bindgen macros for rust tests
|
||||
TEST_BINDGEN_MACROS := $(shell tr -d '\n' < embed/models/$(TREZOR_MODEL)/test_bindgen_macros.txt)
|
||||
export TEST_BINDGEN_MACROS
|
||||
|
||||
|
||||
FLASH_START = $(shell layout_parser ${TREZOR_MODEL} FLASH_START)
|
||||
BOARDLOADER_START = $(shell layout_parser ${TREZOR_MODEL} BOARDLOADER_START)
|
||||
|
8
core/embed/models/D001/test_bindgen_macros.txt
Normal file
8
core/embed/models/D001/test_bindgen_macros.txt
Normal file
@ -0,0 +1,8 @@
|
||||
-DSTM32F429,
|
||||
-DTREZOR_MODEL_D001,
|
||||
-DFLASH_BIT_ACCESS=1,
|
||||
-DFLASH_BLOCK_WORDS=1,
|
||||
-DDISPLAY_RESX=240,
|
||||
-DDISPLAY_RESY=320,
|
||||
-DTREZOR_BOARD="D001/boards/stm32f429i-disc1.h",
|
||||
-DMODEL_HEADER="D001/model_D001.h",
|
8
core/embed/models/D002/test_bindgen_macros.txt
Normal file
8
core/embed/models/D002/test_bindgen_macros.txt
Normal file
@ -0,0 +1,8 @@
|
||||
-DSTM32U5,
|
||||
-DTREZOR_MODEL_T3W1,
|
||||
-DFLASH_BIT_ACCESS=0,
|
||||
-DFLASH_BLOCK_WORDS=4,
|
||||
-DDISPLAY_RESX=380,
|
||||
-DDISPLAY_RESY=520,
|
||||
-DTREZOR_BOARD="D002/boards/stm32u5g9j-dk.h",
|
||||
-DMODEL_HEADER="D002/model_D002.h",
|
8
core/embed/models/T2B1/test_bindgen_macros.txt
Normal file
8
core/embed/models/T2B1/test_bindgen_macros.txt
Normal file
@ -0,0 +1,8 @@
|
||||
-DSTM32F427,
|
||||
-DTREZOR_MODEL_T2B1,
|
||||
-DFLASH_BIT_ACCESS=1,
|
||||
-DFLASH_BLOCK_WORDS=1,
|
||||
-DDISPLAY_RESX=128,
|
||||
-DDISPLAY_RESY=64,
|
||||
-DTREZOR_BOARD=\"T2B1/boards/t2b1-unix.h",
|
||||
-DMODEL_HEADER=\"T2B1/model_T2B1.h",
|
8
core/embed/models/T2T1/test_bindgen_macros.txt
Normal file
8
core/embed/models/T2T1/test_bindgen_macros.txt
Normal file
@ -0,0 +1,8 @@
|
||||
-DSTM32F427,
|
||||
-DTREZOR_MODEL_T2T1,
|
||||
-DFLASH_BIT_ACCESS=1,
|
||||
-DFLASH_BLOCK_WORDS=1,
|
||||
-DDISPLAY_RESX=240,
|
||||
-DDISPLAY_RESY=240,
|
||||
-DTREZOR_BOARD="T2T1/boards/t2t1-unix.h",
|
||||
-DMODEL_HEADER="T2T1/model_T2T1.h",
|
8
core/embed/models/T3B1/test_bindgen_macros.txt
Normal file
8
core/embed/models/T3B1/test_bindgen_macros.txt
Normal file
@ -0,0 +1,8 @@
|
||||
-DSTM32U5,
|
||||
-DTREZOR_MODEL_T3B1,
|
||||
-DFLASH_BIT_ACCESS=0,
|
||||
-DFLASH_BLOCK_WORDS=4,
|
||||
-DDISPLAY_RESX=128,
|
||||
-DDISPLAY_RESY=64,
|
||||
-DTREZOR_BOARD="T3B1/boards/t3b1-unix.h",
|
||||
-DMODEL_HEADER="T3B1/model_T3B1.h",
|
8
core/embed/models/T3T1/test_bindgen_macros.txt
Normal file
8
core/embed/models/T3T1/test_bindgen_macros.txt
Normal file
@ -0,0 +1,8 @@
|
||||
-DSTM32U5,
|
||||
-DTREZOR_MODEL_T3T1,
|
||||
-DFLASH_BIT_ACCESS=0,
|
||||
-DFLASH_BLOCK_WORDS=4,
|
||||
-DDISPLAY_RESX=240,
|
||||
-DDISPLAY_RESY=240,
|
||||
-DTREZOR_BOARD="T3T1/boards/t3t1-unix.h",
|
||||
-DMODEL_HEADER="T3T1/model_T3T1.h",
|
8
core/embed/models/T3W1/test_bindgen_macros.txt
Normal file
8
core/embed/models/T3W1/test_bindgen_macros.txt
Normal file
@ -0,0 +1,8 @@
|
||||
-DSTM32U5,
|
||||
-DTREZOR_MODEL_T3W1,
|
||||
-DFLASH_BIT_ACCESS=0,
|
||||
-DFLASH_BLOCK_WORDS=4,
|
||||
-DDISPLAY_RESX=380,
|
||||
-DDISPLAY_RESY=520,
|
||||
-DTREZOR_BOARD="T3W1/boards/t3w1-unix.h",
|
||||
-DMODEL_HEADER="T3W1/model_T3W1.h",
|
@ -55,55 +55,19 @@ const DEFAULT_BINDGEN_MACROS_COMMON: &[&str] = &[
|
||||
"-DUSE_BLE",
|
||||
];
|
||||
|
||||
#[cfg(feature = "layout_bolt")]
|
||||
const DEFAULT_BINDGEN_MACROS_T2T1: &[&str] = &[
|
||||
"-DSTM32F427",
|
||||
"-DTREZOR_MODEL_T2T1",
|
||||
"-DFLASH_BIT_ACCESS=1",
|
||||
"-DFLASH_BLOCK_WORDS=1",
|
||||
"-DDISPLAY_RESX=240",
|
||||
"-DDISPLAY_RESY=240",
|
||||
"-DTREZOR_BOARD=\"T2T1/boards/t2t1-unix.h\"",
|
||||
];
|
||||
#[cfg(not(feature = "layout_bolt"))]
|
||||
const DEFAULT_BINDGEN_MACROS_T2T1: &[&str] = &[];
|
||||
|
||||
#[cfg(feature = "layout_caesar")]
|
||||
const DEFAULT_BINDGEN_MACROS_T2B1: &[&str] = &[
|
||||
"-DSTM32F427",
|
||||
"-DTREZOR_MODEL_T2B1",
|
||||
"-DFLASH_BIT_ACCESS=1",
|
||||
"-DFLASH_BLOCK_WORDS=1",
|
||||
"-DDISPLAY_RESX=128",
|
||||
"-DDISPLAY_RESY=64",
|
||||
"-DTREZOR_BOARD=\"T2B1/boards/t2b1-unix.h\"",
|
||||
];
|
||||
#[cfg(not(feature = "layout_caesar"))]
|
||||
const DEFAULT_BINDGEN_MACROS_T2B1: &[&str] = &[];
|
||||
|
||||
#[cfg(feature = "layout_delizia")]
|
||||
const DEFAULT_BINDGEN_MACROS_T3T1: &[&str] = &[
|
||||
"-DSTM32U5",
|
||||
"-DTREZOR_MODEL_T3T1",
|
||||
"-DFLASH_BIT_ACCESS=0",
|
||||
"-DFLASH_BLOCK_WORDS=4",
|
||||
"-DDISPLAY_RESX=240",
|
||||
"-DDISPLAY_RESY=240",
|
||||
"-DTREZOR_BOARD=\"T3T1/boards/t3t1-unix.h\"",
|
||||
];
|
||||
#[cfg(not(feature = "layout_delizia"))]
|
||||
const DEFAULT_BINDGEN_MACROS_T3T1: &[&str] = &[];
|
||||
|
||||
fn add_bindgen_macros<'a>(clang_args: &mut Vec<&'a str>, envvar: Option<&'a str>) {
|
||||
let default_macros = DEFAULT_BINDGEN_MACROS_COMMON
|
||||
.iter()
|
||||
.chain(DEFAULT_BINDGEN_MACROS_T2T1)
|
||||
.chain(DEFAULT_BINDGEN_MACROS_T2B1)
|
||||
.chain(DEFAULT_BINDGEN_MACROS_T3T1);
|
||||
|
||||
fn add_bindgen_macros<'a>(
|
||||
clang_args: &mut Vec<&'a str>,
|
||||
envvar: Option<&'a str>,
|
||||
test_envvar: Option<&'a str>,
|
||||
) {
|
||||
match envvar {
|
||||
Some(envvar) => clang_args.extend(envvar.split(',')),
|
||||
None => clang_args.extend(default_macros),
|
||||
None => {
|
||||
println!("{}", test_envvar.unwrap());
|
||||
let test_macros_env = test_envvar.unwrap().split(',');
|
||||
clang_args.extend(DEFAULT_BINDGEN_MACROS_COMMON.iter());
|
||||
clang_args.extend(test_macros_env);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,7 +120,12 @@ fn prepare_bindings() -> bindgen::Builder {
|
||||
let mut clang_args: Vec<&str> = Vec::new();
|
||||
|
||||
let bindgen_macros_env = env::var("BINDGEN_MACROS").ok();
|
||||
add_bindgen_macros(&mut clang_args, bindgen_macros_env.as_deref());
|
||||
let test_macros_env = env::var("TEST_BINDGEN_MACROS").ok();
|
||||
add_bindgen_macros(
|
||||
&mut clang_args,
|
||||
bindgen_macros_env.as_deref(),
|
||||
test_macros_env.as_deref(),
|
||||
);
|
||||
|
||||
#[cfg(feature = "framebuffer")]
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user