Skip to content

Commit

Permalink
Use cbindgen library instead of CLI (#2)
Browse files Browse the repository at this point in the history
* add cbindgen to build dependencies

* use cbindgen rust-style rather then via command

* comment out doc length line which causes error

Couldn't parse config file: unknown field `documentation_length`
  • Loading branch information
JJTech0130 authored Nov 29, 2022
1 parent 96c616a commit c8a280e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ log = { version = "0.4.17" }
[dev-dependencies]
rand = { version = "*" }

[build-dependencies]
cbindgen = "0.20.0"

[lib]
crate-type = ["staticlib"]
22 changes: 7 additions & 15 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
// Jackson Coxson

use std::process::Command;
use std::env;
use cbindgen;

fn main() {
// Generate the cbindings
let _ = if cfg!(target_os = "windows") {
Command::new("cmd")
.args(["/C", "cbindgen -c cbindgen.toml -o em_proxy.h"])
.output()
.expect("Failed to generate c bindings")
} else {
Command::new("sh")
.arg("-c")
.arg("cbindgen -c cbindgen.toml -o em_proxy.h")
.output()
.expect("Failed to generate c bindings")
};
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();

cbindgen::generate(crate_dir)
.expect("Unable to generate C bindings")
.write_to_file("em_proxy.h");
}
2 changes: 1 addition & 1 deletion cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ line_length = 500
tab_width = 2
documentation = true
documentation_style = "auto"
documentation_length = "full"
#documentation_length = "full"
line_endings = "LF" # also "CR", "CRLF", "Native"


Expand Down

0 comments on commit c8a280e

Please sign in to comment.