Skip to content

Commit

Permalink
Merge pull request #182 from LedgerHQ/enable-qrcode
Browse files Browse the repository at this point in the history
Enable QR code library in C SDK bindings.
  • Loading branch information
yogh333 authored Aug 29, 2024
2 parents 37c5852 + e4601d7 commit 944818d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ledger_device_sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ledger_device_sdk"
version = "1.15.0"
version = "1.15.1"
authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"]
edition = "2021"
license.workspace = true
Expand All @@ -21,7 +21,7 @@ rand_core = { version = "0.6.3", default_features = false }
zeroize = { version = "1.6.0", default_features = false }
numtoa = "0.2.4"
const-zero = "0.1.1"
ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.4.4" }
ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.4.5" }

[features]
speculos = []
Expand Down
2 changes: 1 addition & 1 deletion ledger_secure_sdk_sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ledger_secure_sdk_sys"
version = "1.4.4"
version = "1.4.5"
authors = ["yhql", "agrojean-ledger"]
edition = "2021"
license.workspace = true
Expand Down
21 changes: 14 additions & 7 deletions ledger_secure_sdk_sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ fn header2define(headername: &str) -> Vec<(String, Option<String>)> {
struct SDKBuilder {
bolos_sdk: PathBuf,
api_level: u32,
gcc_toolchain: String,
gcc_toolchain: PathBuf,
device: Device,
cxdefines: Vec<String>,
}
Expand All @@ -300,7 +300,7 @@ impl SDKBuilder {
SDKBuilder {
bolos_sdk: PathBuf::new(),
api_level: 0,
gcc_toolchain: "".to_string(),
gcc_toolchain: PathBuf::new(),
device: Device::NanoS,
cxdefines: Vec::new(),
}
Expand All @@ -319,11 +319,11 @@ impl SDKBuilder {
.trim();

let gcc_toolchain = if sysroot.is_empty() {
String::from("/usr/include/")
String::from("/usr")
} else {
format!("{sysroot}/include")
format!("{sysroot}")
};
self.gcc_toolchain = gcc_toolchain;
self.gcc_toolchain = PathBuf::from(gcc_toolchain);
}

pub fn device(&mut self) {
Expand Down Expand Up @@ -413,7 +413,7 @@ impl SDKBuilder {
.files(str2path(&self.bolos_sdk, &SDK_USB_FILES));

command = command
.include(&self.gcc_toolchain)
.include(self.gcc_toolchain.join("include"))
.include(self.bolos_sdk.join("include"))
.include(self.bolos_sdk.join("lib_cxng/include"))
.include(self.bolos_sdk.join("lib_stusb"))
Expand Down Expand Up @@ -461,14 +461,20 @@ impl SDKBuilder {
}

command.compile("ledger-secure-sdk");

/* Link with libc for unresolved symbols */
let gcc_tc = self.gcc_toolchain.display().to_string();
println!("cargo:rustc-link-lib=c");
println!("cargo:rustc-link-search={gcc_tc}/lib");
}

fn generate_bindings(&self) {
let bsdk = self.bolos_sdk.display().to_string();
let gcc_tc = self.gcc_toolchain.display().to_string();
let args = [
"--target=thumbv6m-none-eabi".to_string(), // exact target is irrelevant for bindings
"-fshort-enums".to_string(),
format!("-I{}", self.gcc_toolchain),
format!("-I{gcc_tc}/include"),
format!("-I{bsdk}/include"),
format!("-I{bsdk}/lib_cxng/include/"),
format!("-I{bsdk}/lib_stusb/STM32_USB_Device_Library/Core/Inc/"),
Expand Down Expand Up @@ -724,6 +730,7 @@ fn configure_lib_nbgl(command: &mut cc::Build, bolos_sdk: &Path) {
.file(bolos_sdk.join("lib_ux_sync/src/ux_sync.c"))
.file(bolos_sdk.join("lib_bagl/src/bagl_fonts.c"))
.file(bolos_sdk.join("src/os_printf.c"))
.file(bolos_sdk.join("qrcode/src/qrcodegen.c"))
.files(
glob(bolos_sdk.join("lib_nbgl/src/*.c").to_str().unwrap())
.unwrap()
Expand Down
1 change: 1 addition & 0 deletions ledger_secure_sdk_sys/sdk_flex.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#define ST33K1M5
#define HAVE_DISPLAY_FAST_MODE
#define HAVE_SPRINTF
#define NBGL_QRCODE
#define HAVE_SE_EINK_DISPLAY
#define SCREEN_SIZE_WALLET
#define HAVE_NBGL
Expand Down
1 change: 1 addition & 0 deletions ledger_secure_sdk_sys/sdk_stax.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#define ST33K1M5
#define HAVE_SPRINTF
#define NBGL_QRCODE
#define HAVE_SE_EINK_DISPLAY
#define SCREEN_SIZE_WALLET
#define HAVE_NBGL
Expand Down

0 comments on commit 944818d

Please sign in to comment.