Skip to content

Commit 33c5b7a

Browse files
committed
Set arm libs path in Device
1 parent 6320ef2 commit 33c5b7a

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

ledger_secure_sdk_sys/build.rs

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ struct Device<'a> {
111111
pub defines: Vec<(String, Option<String>)>,
112112
pub cflags: Vec<&'a str>,
113113
pub glyphs_folders: Vec<PathBuf>,
114+
pub arm_libs: String,
114115
}
115116

116117
impl std::fmt::Display for DeviceName {
@@ -437,6 +438,7 @@ impl SDKBuilder<'_> {
437438
defines: header2define("csdk_nanos.h"),
438439
cflags: Vec::from(CFLAGS_NANOS),
439440
glyphs_folders: Vec::new(),
441+
arm_libs: Default::default(),
440442
},
441443
"nanosplus" => Device {
442444
name: DeviceName::NanoSPlus,
@@ -457,6 +459,7 @@ impl SDKBuilder<'_> {
457459
},
458460
cflags: Vec::from(CFLAGS_NANOSPLUS),
459461
glyphs_folders: Vec::new(),
462+
arm_libs: Default::default(),
460463
},
461464
"nanox" => Device {
462465
name: DeviceName::NanoX,
@@ -477,6 +480,7 @@ impl SDKBuilder<'_> {
477480
},
478481
cflags: Vec::from(CFLAGS_NANOX),
479482
glyphs_folders: Vec::new(),
483+
arm_libs: Default::default(),
480484
},
481485
"stax" => Device {
482486
name: DeviceName::Stax,
@@ -485,6 +489,7 @@ impl SDKBuilder<'_> {
485489
defines: header2define("csdk_stax.h"),
486490
cflags: Vec::from(CFLAGS_STAX),
487491
glyphs_folders: Vec::new(),
492+
arm_libs: Default::default(),
488493
},
489494
"flex" => Device {
490495
name: DeviceName::Flex,
@@ -493,6 +498,7 @@ impl SDKBuilder<'_> {
493498
defines: header2define("csdk_flex.h"),
494499
cflags: Vec::from(CFLAGS_FLEX),
495500
glyphs_folders: Vec::new(),
501+
arm_libs: Default::default(),
496502
},
497503
_ => {
498504
return Err(SDKBuildError::UnsupportedDevice);
@@ -536,6 +542,25 @@ impl SDKBuilder<'_> {
536542
}
537543
}
538544

545+
// Set ARM pre-compiled libraries path
546+
self.device.arm_libs = match self.device.name {
547+
DeviceName::NanoS => {
548+
let mut path = self.gcc_toolchain.display().to_string();
549+
path.push_str("/lib");
550+
path
551+
}
552+
DeviceName::NanoX => {
553+
let mut path = self.device.c_sdk.display().to_string();
554+
path.push_str("/arch/st33/lib");
555+
path
556+
}
557+
DeviceName::NanoSPlus | DeviceName::Flex | DeviceName::Stax => {
558+
let mut path = self.device.c_sdk.display().to_string();
559+
path.push_str("/arch/st33k1/lib");
560+
path
561+
}
562+
};
563+
539564
// export TARGET into env for 'infos.rs'
540565
println!("cargo:rustc-env=TARGET={}", self.device.name);
541566
println!("cargo:warning=Device is {:?}", self.device.name);
@@ -664,19 +689,7 @@ impl SDKBuilder<'_> {
664689
command.compile("ledger-secure-sdk");
665690

666691
/* Link with libc, libm and libgcc */
667-
let mut path = self.device.c_sdk.display().to_string();
668-
match self.device.name {
669-
DeviceName::NanoS => {
670-
path = self.gcc_toolchain.display().to_string();
671-
path.push_str("/lib");
672-
}
673-
DeviceName::NanoX => {
674-
path.push_str("/arch/st33/lib");
675-
}
676-
DeviceName::NanoSPlus | DeviceName::Flex | DeviceName::Stax => {
677-
path.push_str("/arch/st33k1/lib");
678-
}
679-
};
692+
let path = self.device.arm_libs.clone();
680693
println!("cargo:rustc-link-lib=c");
681694
println!("cargo:rustc-link-lib=m");
682695
println!("cargo:rustc-link-lib=gcc");

0 commit comments

Comments
 (0)