Skip to content

Commit

Permalink
build: use features to control build configuration (ArtifexSoftware#13)
Browse files Browse the repository at this point in the history
* build: use features to control build configuration

* fix: make FZ_ENABLE_* features non-inverted and move feature handling to outer crate
  • Loading branch information
NBonaparte authored Aug 25, 2020
1 parent 93ff7ea commit eec09a5
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ license = "GPL-3.0"
readme = "README.md"
repository = "https://github.com/messense/mupdf-rs"

[features]
default = ["noto-small", "no-cjk", "js", "xps", "svg", "cbz", "img", "html", "epub"]
noto-small = ["mupdf-sys/noto-small"]
no-cjk = ["mupdf-sys/no-cjk"]
tofu = ["mupdf-sys/tofu"]
js = ["mupdf-sys/js"]
xps = ["mupdf-sys/xps"]
svg = ["mupdf-sys/svg"]
cbz = ["mupdf-sys/cbz"]
img = ["mupdf-sys/img"]
html = ["mupdf-sys/html"]
epub = ["mupdf-sys/epub"]

[dependencies]
mupdf-sys = { version = "0.0.3", path = "mupdf-sys" }
once_cell = "1.3.1"
Expand Down
12 changes: 12 additions & 0 deletions mupdf-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ license = "GPL-3.0"
links="mupdf-wrapper"
repository = "https://github.com/messense/mupdf-rs"

[features]
noto-small = []
no-cjk = []
tofu = []
js = []
xps = []
svg = []
cbz = []
img = []
html = []
epub = []

[build-dependencies]
bindgen = "0.54"
cc = "1.0.50"
Expand Down
34 changes: 33 additions & 1 deletion mupdf-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,38 @@ fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let current_dir = env::current_dir().unwrap();
let mupdf_dir = current_dir.join("mupdf");
// see https://github.com/ArtifexSoftware/mupdf/blob/master/include/mupdf/fitz/config.h
// and https://github.com/ArtifexSoftware/mupdf/blob/master/source/fitz/noto.c
let xcflags = vec![
#[cfg(feature = "noto-small")]
"NOTO_SMALL",
#[cfg(feature = "no-cjk")]
"NO_CJK",
#[cfg(feature = "tofu")]
"TOFU",
#[cfg(not(feature = "xps"))]
"FZ_ENABLE_XPS=0",
#[cfg(not(feature = "svg"))]
"FZ_ENABLE_SVG=0",
#[cfg(not(feature = "cbz"))]
"FZ_ENABLE_CBZ=0",
#[cfg(not(feature = "img"))]
"FZ_ENABLE_IMG=0",
#[cfg(not(feature = "html"))]
"FZ_ENABLE_HTML=0",
#[cfg(not(feature = "epub"))]
"FZ_ENABLE_EPUB=0",
#[cfg(not(feature = "js"))]
"FZ_ENABLE_JS=0",
]
.into_iter()
.map(|s| {
let mut s = s.to_owned();
s.insert_str(0, "-D");
s
})
.collect::<Vec<String>>()
.join(" ");
let output = Command::new("make")
.arg("libs")
.arg(format!("build={}", profile))
Expand All @@ -35,7 +67,7 @@ fn main() {
.arg("HAVE_GLUT=no")
.arg("HAVE_CURL=no")
.arg("verbose=yes")
.arg("XCFLAGS=-DNOTO_SMALL -DNO_CJK")
.arg(format!("XCFLAGS={}", xcflags))
.current_dir(mupdf_dir)
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
Expand Down

0 comments on commit eec09a5

Please sign in to comment.