Skip to content

Commit

Permalink
add dlopen Cargo feature using dlib to load fontconfig at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Be-ing committed Feb 17, 2022
1 parent d1ea5fc commit 5a966c9
Show file tree
Hide file tree
Showing 9 changed files with 455 additions and 399 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rust:
- nightly
- beta
- stable
- 1.38.0
- 1.46.0

jobs:
allow_failures:
Expand All @@ -24,3 +24,4 @@ before_install:

script:
- cargo test
- RUST_FONTCONFIG_DLOPEN=on cargo test
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
members = [
"fontconfig-sys",
"fontconfig"
]
]
12 changes: 10 additions & 2 deletions fontconfig-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[package]
name = "yeslogic-fontconfig-sys"
version = "2.11.2"
version = "3.0.0"
edition = "2018"
rust-version = "1.46"
authors = [
"Austin Bonander <austin.bonander@gmail.com>",
"The Servo Project Developers",
Expand All @@ -16,7 +18,6 @@ homepage = "https://github.com/yeslogic/fontconfig-rs"
documentation = "https://docs.rs/crate/yeslogic-fontconfig-sys"
repository = "https://github.com/yeslogic/fontconfig-rs"

build = "build.rs"
links = "fontconfig"

[badges]
Expand All @@ -27,6 +28,13 @@ name = "fontconfig_sys"

[dependencies]
const-cstr = "0.3"
dlib = "0.5.0"
# This cannot be optional because build.rs can't conditionally enable it
# when the RUST_FONTCONFIG_DLOPEN environment variable is set.
lazy_static = "1.4.0"

[features]
dlopen = []

[build-dependencies]
pkg-config = "0.3"
8 changes: 7 additions & 1 deletion fontconfig-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
extern crate pkg_config;

fn main() {
pkg_config::find_library("fontconfig").unwrap();
let dlopen = std::env::var("RUST_FONTCONFIG_DLOPEN").is_ok();
if dlopen {
println!("cargo:rustc-cfg=feature=\"dlopen\"");
}
if !(dlopen || cfg!(feature = "dlopen")) {
pkg_config::find_library("fontconfig").unwrap();
}
}
Loading

0 comments on commit 5a966c9

Please sign in to comment.