Skip to content

Commit 593c99d

Browse files
authored
ffi: add method for getting the build time git short sha value (#1909)
1 parent 9d0c40c commit 593c99d

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindings/matrix-sdk-ffi/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ bundled-sqlite = ["matrix-sdk/bundled-sqlite"]
1818

1919
[build-dependencies]
2020
uniffi = { workspace = true, features = ["build"] }
21+
vergen = { version = "8.1.3", features = ["build", "git", "gitcl"] }
2122

2223
[dependencies]
2324
anyhow = { workspace = true }

bindings/matrix-sdk-ffi/build.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use std::env;
1+
use std::{env, error::Error};
2+
3+
use vergen::EmitBuilder;
24

35
/// Adds a temporary workaround for an issue with the Rust compiler and Android
46
/// in x86_64 devices: https://github.com/rust-lang/rust/issues/109717.
@@ -27,7 +29,9 @@ fn setup_x86_64_android_workaround() {
2729
}
2830
}
2931

30-
fn main() {
32+
fn main() -> Result<(), Box<dyn Error>> {
3133
setup_x86_64_android_workaround();
3234
uniffi::generate_scaffolding("./src/api.udl").expect("Building the UDL file failed");
35+
EmitBuilder::builder().git_sha(true).emit()?;
36+
Ok(())
3337
}

bindings/matrix-sdk-ffi/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,8 @@ pub use self::{
5757
};
5858

5959
uniffi::include_scaffolding!("api");
60+
61+
#[uniffi::export]
62+
pub fn sdk_git_sha() -> String {
63+
env!("VERGEN_GIT_SHA").to_string()
64+
}

0 commit comments

Comments
 (0)