mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-30 17:21:21 +00:00
fix(core/rust): fix bindgen macros generation
[no changelog]
This commit is contained in:
parent
91a783ee37
commit
ea1c32f90e
@ -230,8 +230,6 @@ def cargo_build():
|
|||||||
features.append("bootloader")
|
features.append("bootloader")
|
||||||
features.extend(FEATURES_AVAILABLE)
|
features.extend(FEATURES_AVAILABLE)
|
||||||
|
|
||||||
env.get("ENV")["BINDGEN_MACROS"] = tools.get_bindgen_defines(env.get("ALLDEFS"), ALLPATHS)
|
|
||||||
|
|
||||||
cargo_opts = [
|
cargo_opts = [
|
||||||
f'--target={env.get("ENV")["RUST_TARGET"]}',
|
f'--target={env.get("ENV")["RUST_TARGET"]}',
|
||||||
f'--target-dir=../../build/bootloader/rust',
|
f'--target-dir=../../build/bootloader/rust',
|
||||||
@ -241,7 +239,9 @@ def cargo_build():
|
|||||||
'-Z build-std-features=panic_immediate_abort',
|
'-Z build-std-features=panic_immediate_abort',
|
||||||
]
|
]
|
||||||
|
|
||||||
return f'cd embed/rust; cargo build {profile} ' + ' '.join(cargo_opts)
|
bindgen_macros = tools.get_bindgen_defines(env.get("CPPDEFINES"), ALLPATHS)
|
||||||
|
|
||||||
|
return f'export BINDGEN_MACROS=\'{bindgen_macros}\'; cd embed/rust; cargo build {profile} ' + ' '.join(cargo_opts)
|
||||||
|
|
||||||
rust = env.Command(
|
rust = env.Command(
|
||||||
target=RUST_LIBPATH,
|
target=RUST_LIBPATH,
|
||||||
|
@ -209,7 +209,7 @@ ALLPATHS = ['embed/rust',
|
|||||||
'embed/unix',
|
'embed/unix',
|
||||||
'embed/extmod/modtrezorui',
|
'embed/extmod/modtrezorui',
|
||||||
'vendor/nanopb',
|
'vendor/nanopb',
|
||||||
] + CPPPATH_MOD,
|
] + CPPPATH_MOD
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
COPT=env.get('ENV').get('OPTIMIZE', '-Os'),
|
||||||
@ -291,7 +291,6 @@ def cargo_build():
|
|||||||
features.append("ui")
|
features.append("ui")
|
||||||
features.append("bootloader")
|
features.append("bootloader")
|
||||||
|
|
||||||
env.get("ENV")["BINDGEN_MACROS"] = tools.get_bindgen_defines(env.get("ALLDEFS"), ALLPATHS)
|
|
||||||
|
|
||||||
cargo_opts = [
|
cargo_opts = [
|
||||||
f'--target={RUST_TARGET}',
|
f'--target={RUST_TARGET}',
|
||||||
@ -302,7 +301,9 @@ def cargo_build():
|
|||||||
'-Z build-std-features=panic_immediate_abort',
|
'-Z build-std-features=panic_immediate_abort',
|
||||||
]
|
]
|
||||||
|
|
||||||
return f'cd embed/rust; cargo build {profile} ' + ' '.join(cargo_opts)
|
bindgen_macros = tools.get_bindgen_defines(env.get("CPPDEFINES"), ALLPATHS)
|
||||||
|
|
||||||
|
return f'export BINDGEN_MACROS=\'{bindgen_macros}\'; cd embed/rust; cargo build {profile} ' + ' '.join(cargo_opts)
|
||||||
|
|
||||||
rust = env.Command(
|
rust = env.Command(
|
||||||
target=RUST_LIBPATH,
|
target=RUST_LIBPATH,
|
||||||
|
@ -780,8 +780,6 @@ def cargo_build():
|
|||||||
|
|
||||||
features.extend(FEATURES_AVAILABLE)
|
features.extend(FEATURES_AVAILABLE)
|
||||||
|
|
||||||
env.get("ENV")["BINDGEN_MACROS"] = tools.get_bindgen_defines(env.get("ALLDEFS"), ALLPATHS)
|
|
||||||
|
|
||||||
cargo_opts = [
|
cargo_opts = [
|
||||||
f'--target={env.get("ENV")["RUST_TARGET"]}',
|
f'--target={env.get("ENV")["RUST_TARGET"]}',
|
||||||
f'--target-dir=../../build/firmware/rust',
|
f'--target-dir=../../build/firmware/rust',
|
||||||
@ -793,7 +791,9 @@ def cargo_build():
|
|||||||
|
|
||||||
env.get('ENV')['TREZOR_MODEL'] = TREZOR_MODEL
|
env.get('ENV')['TREZOR_MODEL'] = TREZOR_MODEL
|
||||||
|
|
||||||
return f'cd embed/rust; cargo build {profile} ' + ' '.join(cargo_opts)
|
bindgen_macros = tools.get_bindgen_defines(env.get("CPPDEFINES"), ALLPATHS)
|
||||||
|
|
||||||
|
return f'export BINDGEN_MACROS=\'{bindgen_macros}\'; cd embed/rust; cargo build {profile} ' + ' '.join(cargo_opts)
|
||||||
|
|
||||||
rust = env.Command(
|
rust = env.Command(
|
||||||
target=RUST_LIBPATH,
|
target=RUST_LIBPATH,
|
||||||
|
@ -871,9 +871,9 @@ def cargo_build():
|
|||||||
if TREZOR_MODEL in ('R', '1'):
|
if TREZOR_MODEL in ('R', '1'):
|
||||||
features.append('button')
|
features.append('button')
|
||||||
|
|
||||||
env.get("ENV")["BINDGEN_MACROS"] = tools.get_bindgen_defines(env.get("ALLDEFS"), ALLPATHS)
|
bindgen_macros = tools.get_bindgen_defines(env.get("CPPDEFINES"), ALLPATHS)
|
||||||
|
|
||||||
return f'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=\'{bindgen_macros}\'; cd embed/rust; cargo build --profile {RUST_PROFILE} --target-dir=../../build/unix/rust --no-default-features --features "{" ".join(features)}" --target {TARGET}'
|
||||||
|
|
||||||
rust = env.Command(
|
rust = env.Command(
|
||||||
target=RUST_LIBPATH,
|
target=RUST_LIBPATH,
|
||||||
|
@ -153,9 +153,17 @@ def get_bindgen_defines(
|
|||||||
) -> tuple(str, str):
|
) -> tuple(str, str):
|
||||||
rest_defs = []
|
rest_defs = []
|
||||||
for d in defines:
|
for d in defines:
|
||||||
rest_defs.append(
|
if type(d) is tuple:
|
||||||
f"-D{d}".replace('"<', "<").replace('>"', ">").replace('\\"', '"')
|
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:
|
for d in paths:
|
||||||
rest_defs.append(f"-I../../{d}")
|
rest_defs.append(f"-I../../{d}")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user