Skip to content

Commit 82055d0

Browse files
committed
enable enc2
1 parent 123160c commit 82055d0

5 files changed

Lines changed: 44 additions & 8 deletions

File tree

Cargo.toml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,26 @@ edition = "2018"
88
repository = "https://github.com/rust-xed/xed-sys"
99
readme = "README.md"
1010
keywords = ["xed", "intel", "x86", "x86_64"]
11-
categories = ["encoding", "external-ffi-bindings", "hardware-support", "parsing"]
11+
categories = [
12+
"encoding",
13+
"external-ffi-bindings",
14+
"hardware-support",
15+
"parsing",
16+
]
1217

1318
[badges]
14-
appveyor = { repository = "rust-xed/xed-sys" }
19+
appveyor = { repository = "rust-xed/xed-sys" }
1520
travis-ci = { repository = "rust-xed/xed-sys" }
1621

22+
[features]
23+
default = []
24+
enc2 = []
25+
1726
[dependencies]
1827

1928
[build-dependencies]
2029
bindgen = "0.69"
2130
target-lexicon = "0.12"
2231

2332
[workspace]
24-
members = [
25-
".",
26-
"build-tools"
27-
]
33+
members = [".", "build-tools"]

build-tools/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ version = "0.1.0"
44
authors = ["Phantomical", "Agustin Godnic"]
55
edition = "2018"
66

7+
[features]
8+
default = []
9+
enc2 = []
10+
711
[dependencies]
812
bindgen = "0.69"
913
fs_extra = "1.2"
1014
num_cpus = "1.13"
1115
target-lexicon = "0.12"
1216

13-
syn = { version = "2.0", features = [ "full" ] }
17+
syn = { version = "2.0", features = ["full"] }
1418
quote = "1.0"
1519
proc-macro2 = "1.0"

build-tools/src/bin/build-xed.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ fn main() {
8585
cmd.arg("--opt=0");
8686
}
8787

88+
if cfg!(feature = "enc2") {
89+
cmd.arg("--enc2");
90+
}
91+
8892
cmd.arg("install").current_dir(&build_dir);
8993

9094
eprintln!("XED build command: {:?}", cmd);

build.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn build_bindings(cwd: &Path) {
2424

2525
eprintln!("{}", cwd.display());
2626

27-
let builder = bindgen::Builder::default()
27+
let mut builder = bindgen::Builder::default()
2828
.clang_arg(format!("--include-directory={}", include_dir.display()))
2929
.clang_arg("-DXED_ENCODER")
3030
.clang_arg("-DXED_DECODER")
@@ -38,6 +38,10 @@ fn build_bindings(cwd: &Path) {
3838
.derive_debug(true)
3939
.prepend_enum_name(false);
4040

41+
if cfg!(feature = "enc2") {
42+
builder = builder.clang_arg("-DXED_ENC2");
43+
}
44+
4145
builder.dump_preprocessed_input().unwrap();
4246

4347
let bindings = match builder.generate() {
@@ -147,6 +151,10 @@ fn main() {
147151
cmd.arg("--opt=0");
148152
}
149153

154+
if cfg!(feature = "enc2") {
155+
cmd.arg("--enc2");
156+
}
157+
150158
cmd.arg("install").current_dir(&build_dir);
151159

152160
eprintln!("XED build command: {:?}", cmd);
@@ -162,6 +170,13 @@ fn main() {
162170
println!("cargo:rustc-link-search=native={}", lib_dir.display());
163171
println!("cargo:rustc-link-lib=static=xed");
164172

173+
if cfg!(feature = "enc2") {
174+
println!("cargo:rustc-link-lib=static=xed-enc2-m32-a32");
175+
println!("cargo:rustc-link-lib=static=xed-enc2-m64-a64");
176+
println!("cargo:rustc-link-lib=static=xed-chk-enc2-m32-a32");
177+
println!("cargo:rustc-link-lib=static=xed-chk-enc2-m64-a64");
178+
}
179+
165180
// Generate bindings
166181
build_bindings(&cwd);
167182
}

xed.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
#include "xed/xed-interface.h"
22
#include "xed/xed-isa-set.h"
3+
4+
#ifdef XED_ENC2
5+
#include "xed/xed-enc2-m32-a32.h"
6+
#include "xed/xed-chk-enc2-m32-a32.h"
7+
#include "xed/xed-enc2-m64-a64.h"
8+
#include "xed/xed-chk-enc2-m64-a64.h"
9+
#endif

0 commit comments

Comments
 (0)