Skip to content

Commit

Permalink
Make build flags features (ArtifexSoftware#14)
Browse files Browse the repository at this point in the history
* build: make build flags features

* build: use pkg-config crate for more robust library handling

* build: revert to inverse handling of HAVE_* flags

* build: remove useless features
  • Loading branch information
NBonaparte authored Aug 26, 2020
1 parent 5f37259 commit 8a3abc0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ repository = "https://github.com/messense/mupdf-rs"

[features]
default = ["noto-small", "no-cjk", "js", "xps", "svg", "cbz", "img", "html", "epub"]
sys-lib = ["mupdf-sys/sys-lib"]
noto-small = ["mupdf-sys/noto-small"]
no-cjk = ["mupdf-sys/no-cjk"]
tofu = ["mupdf-sys/tofu"]
Expand Down
2 changes: 2 additions & 0 deletions mupdf-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ links="mupdf-wrapper"
repository = "https://github.com/messense/mupdf-rs"

[features]
sys-lib = []
noto-small = []
no-cjk = []
tofu = []
Expand All @@ -49,5 +50,6 @@ epub = []
[build-dependencies]
bindgen = "0.55"
cc = "1.0.50"
pkg-config = "0.3"

[dependencies]
31 changes: 22 additions & 9 deletions mupdf-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,29 @@ fn main() {
})
.collect::<Vec<String>>()
.join(" ");
let make_flags = vec![
"libs".to_owned(),
format!("build={}", profile),
format!("OUT={}", out_dir),
#[cfg(feature = "sys-lib")]
"USE_SYSTEM_LIBS=yes".to_owned(),
"HAVE_X11=no".to_owned(),
"HAVE_GLUT=no".to_owned(),
"HAVE_CURL=no".to_owned(),
"verbose=yes".to_owned(),
format!("XCFLAGS={}", xcflags),
];

#[cfg(feature = "sys-lib")]
for lib in &["freetype2", "zlib", "jbig2dec", "libjpeg", "libopenjp2"] {
let _ = pkg_config::probe_library(lib).unwrap_or_else(|e| {
eprintln!("{}", e);
panic!();
});
}

let output = Command::new("make")
.arg("libs")
.arg(format!("build={}", profile))
.arg(format!("OUT={}", out_dir))
.arg("USE_SYSTEM_LIBS=no")
.arg("HAVE_X11=no")
.arg("HAVE_GLUT=no")
.arg("HAVE_CURL=no")
.arg("verbose=yes")
.arg(format!("XCFLAGS={}", xcflags))
.args(&make_flags)
.current_dir(mupdf_dir)
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
Expand Down

0 comments on commit 8a3abc0

Please sign in to comment.