Skip to content

Commit

Permalink
enable enc2
Browse files Browse the repository at this point in the history
  • Loading branch information
flier authored and Phantomical committed Jan 16, 2024
1 parent c099723 commit bd20ab2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down
11 changes: 11 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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() {
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit bd20ab2

Please sign in to comment.