diff --git a/Cargo.toml b/Cargo.toml index 68f09bc..fa97150 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,17 @@ keywords = ["xed", "intel", "x86", "x86_64"] categories = ["encoding", "external-ffi-bindings", "hardware-support", "parsing", "no_std"] [badges] -appveyor = { repository = "rust-xed/xed-sys" } +appveyor = { repository = "rust-xed/xed-sys" } travis-ci = { repository = "rust-xed/xed-sys" } [features] +# Enable the enc2 module of XED. +# +# Note that this will somewhat dramatically slow down compilation of xed-sys. +# The enc2 module involves a large amount of generated code and the resulting +# bindgen definitions contain 40+MB of rust code. +enc2 = ["bindgen"] + # Generate bindings with bindgen at build-time instead of using the # pregenerated bindings. # diff --git a/build.rs b/build.rs index 3ad97a3..3f96a47 100644 --- a/build.rs +++ b/build.rs @@ -100,6 +100,10 @@ fn build_xed() { cmd.arg("--opt=0"); } + if cfg!(feature = "enc2") { + cmd.arg("--enc2"); + } + eprintln!("XED build command: {:?}", cmd); let status = cmd.status().expect("Failed to start xed build"); @@ -112,6 +116,13 @@ fn build_xed() { println!("cargo:rustc-link-search=native={}", lib_dir.display()); println!("cargo:rustc-link-lib=static=xed"); + + if cfg!(feature = "enc2") { + println!("cargo:rustc-link-lib=static=xed-enc2-m32-a32"); + println!("cargo:rustc-link-lib=static=xed-enc2-m64-a64"); + println!("cargo:rustc-link-lib=static=xed-chk-enc2-m32-a32"); + println!("cargo:rustc-link-lib=static=xed-chk-enc2-m64-a64"); + } } fn build_inline_shim() { diff --git a/src/lib.rs b/src/lib.rs index 9dc66c1..44a37e5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,6 +6,10 @@ //! //! # Features //! +//! - `enc2` - Enable the [fast XED encoder][1]. Note that enabling this feature +//! results in XED generating a rather large amount of code and the resulting +//! bindgen bindings are over 40MB in size. Expect 5+ minute compile times +//! when enabling this option. //! - `bindgen` - Don't use the bundled bindings files and instead regenerate //! rust bindings from scratch at compile time. You should never need to //! enable this manually but it will be enabled by other features.