mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-14 03:30:02 +00:00
refactor(core/build): remove hardcoded build path
This commit is contained in:
parent
c4844efaae
commit
f7a148ebca
@ -278,8 +278,9 @@ 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}\'; cd embed/rust; cargo build {profile} ' + ' '.join(cargo_opts)
|
||||
return f'export BINDGEN_MACROS=\'{bindgen_macros}\'; export BUILD_DIR=\'{build_dir}\'; cd embed/rust; cargo build {profile} ' + ' '.join(cargo_opts)
|
||||
|
||||
rust = env.Command(
|
||||
target=RUST_LIBPATH,
|
||||
|
@ -295,8 +295,9 @@ 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}\'; cd embed/rust; cargo build --profile {RUST_PROFILE} ' + ' '.join(cargo_opts)
|
||||
return f'export BINDGEN_MACROS=\'{bindgen_macros}\'; export BUILD_DIR=\'{build_dir}\'; cd embed/rust; cargo build --profile {RUST_PROFILE} ' + ' '.join(cargo_opts)
|
||||
|
||||
rust = env.Command(
|
||||
target=RUST_LIBPATH,
|
||||
|
@ -860,8 +860,9 @@ def cargo_build():
|
||||
env.get('ENV')['TREZOR_MODEL'] = TREZOR_MODEL
|
||||
|
||||
bindgen_macros = tools.get_bindgen_defines(env.get("CPPDEFINES"), ALLPATHS)
|
||||
build_dir = str(Dir('.').abspath)
|
||||
|
||||
return f'export BINDGEN_MACROS=\'{bindgen_macros}\'; cd embed/rust; cargo build {profile} ' + ' '.join(cargo_opts)
|
||||
return f'export BINDGEN_MACROS=\'{bindgen_macros}\'; export BUILD_DIR=\'{build_dir}\'; cd embed/rust; cargo build {profile} ' + ' '.join(cargo_opts)
|
||||
|
||||
rust = env.Command(
|
||||
target=RUST_LIBPATH,
|
||||
|
@ -896,8 +896,9 @@ def cargo_build():
|
||||
env.get('ENV')['TREZOR_MODEL'] = TREZOR_MODEL
|
||||
|
||||
bindgen_macros = tools.get_bindgen_defines(env.get("CPPDEFINES"), ALLPATHS)
|
||||
build_dir = str(Dir('.').abspath)
|
||||
|
||||
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}'
|
||||
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}'
|
||||
|
||||
rust = env.Command(
|
||||
target=RUST_LIBPATH,
|
||||
|
@ -14,6 +14,10 @@ fn main() {
|
||||
link_core_objects();
|
||||
}
|
||||
|
||||
fn build_dir() -> String {
|
||||
env::var("BUILD_DIR").expect("BUILD_DIR not defined")
|
||||
}
|
||||
|
||||
const DEFAULT_BINDGEN_MACROS_COMMON: &[&str] = &[
|
||||
"-I../unix",
|
||||
"-I../trezorhal/unix",
|
||||
@ -94,14 +98,7 @@ fn generate_qstr_bindings() {
|
||||
is_global: false,
|
||||
})
|
||||
// Pass in correct include paths.
|
||||
.clang_args(&[
|
||||
"-I",
|
||||
if is_firmware() {
|
||||
"../../build/firmware"
|
||||
} else {
|
||||
"../../build/unix"
|
||||
},
|
||||
])
|
||||
.clang_args(&["-I", &build_dir()])
|
||||
// Customize the standard types.
|
||||
.use_core()
|
||||
.ctypes_prefix("cty")
|
||||
@ -127,6 +124,8 @@ fn generate_qstr_bindings() {
|
||||
fn prepare_bindings() -> bindgen::Builder {
|
||||
let mut bindings = bindgen::Builder::default();
|
||||
|
||||
let build_dir_include = format!("-I{}", build_dir());
|
||||
|
||||
let mut clang_args: Vec<&str> = Vec::new();
|
||||
|
||||
let bindgen_macros_env = env::var("BINDGEN_MACROS").ok();
|
||||
@ -142,12 +141,12 @@ fn prepare_bindings() -> bindgen::Builder {
|
||||
bindings = bindings.clang_args(["-DNEW_RENDERING"]);
|
||||
}
|
||||
|
||||
clang_args.push(&build_dir_include);
|
||||
|
||||
// Pass in correct include paths and defines.
|
||||
if is_firmware() {
|
||||
clang_args.push("-nostdinc");
|
||||
|
||||
clang_args.push("-I../../build/firmware");
|
||||
|
||||
// Append gcc-arm-none-eabi's include paths.
|
||||
let cc_output = Command::new("arm-none-eabi-gcc")
|
||||
.arg("-E")
|
||||
@ -168,8 +167,6 @@ fn prepare_bindings() -> bindgen::Builder {
|
||||
.map(|s| format!("-I{}", s.trim()));
|
||||
|
||||
bindings = bindings.clang_args(include_args);
|
||||
} else {
|
||||
clang_args.push("-I../../build/unix");
|
||||
}
|
||||
|
||||
bindings = bindings.clang_args(&clang_args);
|
||||
|
@ -109,24 +109,9 @@ struct NameDef {
|
||||
msg_offset: u16,
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "arm")]
|
||||
macro_rules! proto_def_path {
|
||||
($filename:expr) => {
|
||||
concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/../../build/firmware/rust/",
|
||||
$filename
|
||||
)
|
||||
};
|
||||
}
|
||||
#[cfg(not(target_arch = "arm"))]
|
||||
macro_rules! proto_def_path {
|
||||
($filename:expr) => {
|
||||
concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/../../build/unix/rust/",
|
||||
$filename
|
||||
)
|
||||
concat!(env!("BUILD_DIR"), "/rust/", $filename)
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user