Skip to content

Commit f10bf84

Browse files
committed
Made UniFFI an optional feature, reducing the time needed to build paperback for platforms that don't require it.
1 parent 11596a6 commit f10bf84

5 files changed

Lines changed: 23 additions & 3 deletions

File tree

crates/paperback-core/Cargo.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,19 @@ sha1 = "0.11.0"
3838
thiserror = "2.0.18"
3939
toml = { workspace = true }
4040
unicode-bidi = "0.3.18"
41-
uniffi = { version = "0.32.0", features = ["cli"] }
41+
uniffi = { version = "0.32.0", features = ["cli"], optional = true }
4242
zip = { version = "8.6.0", default-features = false, features = ["deflate"] }
4343

4444
[build-dependencies]
45-
uniffi = { version = "0.32.0", features = ["build"] }
45+
uniffi = { version = "0.32.0", features = ["build"], optional = true }
4646

4747
[dev-dependencies]
4848
rstest = { workspace = true }
49+
50+
[features]
51+
uniffi = ["dep:uniffi"]
52+
53+
[[bin]]
54+
name = "uniffi-bindgen"
55+
path = "src/bin/uniffi-bindgen.rs"
56+
required-features = ["uniffi"]

crates/paperback-core/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ fn main() {
1717
println!("cargo:rustc-env=PAPERBACK_IS_DEV={}", if is_dev { "1" } else { "0" });
1818
println!("cargo:rerun-if-changed=.git/HEAD");
1919

20+
#[cfg(feature = "uniffi")]
2021
uniffi::generate_scaffolding("src/paperback.udl").expect("Building the UDL file failed");
2122
}

crates/paperback-core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub use crate::{
2222
},
2323
};
2424

25+
#[cfg(feature = "uniffi")]
2526
uniffi::include_scaffolding!("paperback");
2627

2728
pub fn set_pdfium_library_path(path: String) {

crates/xtask/src/android.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ pub fn android() -> Result<(), Box<dyn Error>> {
4444
.current_dir(project_root())
4545
.args([
4646
"run",
47+
"-p",
48+
"paperback-core",
49+
"--features",
50+
"uniffi",
4751
"--bin",
4852
"uniffi-bindgen",
4953
"--",
@@ -74,6 +78,8 @@ pub fn android() -> Result<(), Box<dyn Error>> {
7478
"--release",
7579
"-p",
7680
"paperback-core",
81+
"--features",
82+
"uniffi",
7783
])
7884
.status()?;
7985
if !status.success() {

crates/xtask/src/ios.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ pub fn ios() -> Result<(), Box<dyn Error>> {
3030
.current_dir(&root)
3131
.args([
3232
"run",
33+
"-p",
34+
"paperback-core",
35+
"--features",
36+
"uniffi",
3337
"--bin",
3438
"uniffi-bindgen",
3539
"--",
@@ -47,7 +51,7 @@ pub fn ios() -> Result<(), Box<dyn Error>> {
4751
}
4852

4953
let profile = if release { "release" } else { "debug" };
50-
let mut build_args = vec!["build", "-p", "paperback-core"];
54+
let mut build_args = vec!["build", "-p", "paperback-core", "--features", "uniffi"];
5155
if release {
5256
build_args.push("--release");
5357
}

0 commit comments

Comments
 (0)