initial
This commit is contained in:
commit
cde73248ec
11 changed files with 1011 additions and 0 deletions
18
sys/Cargo.toml
Normal file
18
sys/Cargo.toml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
[package]
|
||||
name = "ggwave-sys"
|
||||
version = "0.0.1"
|
||||
edition.workspace = true
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
libc = "0.2"
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = "0.72"
|
||||
|
||||
[dev-dependencies]
|
||||
shell-words = "1.0.0"
|
||||
tempfile = "3"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
27
sys/build.rs
Normal file
27
sys/build.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
use std::{env, path::Path};
|
||||
|
||||
fn main() {
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
let out_dir = Path::new(&out_dir);
|
||||
|
||||
// TODO: add better error handling for when GGWAVE_PATH is not set
|
||||
let ggwave_path = env::var("GGWAVE_PATH").unwrap();
|
||||
let ggwave_path = Path::new(&ggwave_path);
|
||||
|
||||
let ggwave_lib_dir = ggwave_path.join("lib");
|
||||
let ggwave_include_dir = ggwave_path.join("include");
|
||||
|
||||
println!("cargo:rustc-link-search=native={ggwave_lib_dir:?}");
|
||||
println!("cargo:rustc-link-lib=ggwave");
|
||||
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header(ggwave_include_dir.join("ggwave/ggwave.h").to_string_lossy())
|
||||
.clang_args(["-x", "c++"])
|
||||
.derive_debug(true)
|
||||
.derive_default(true)
|
||||
.generate()
|
||||
.unwrap();
|
||||
|
||||
let bindings_path = out_dir.join("bindings.rs");
|
||||
bindings.write_to_file(&bindings_path).unwrap();
|
||||
}
|
||||
4
sys/src/lib.rs
Normal file
4
sys/src/lib.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals)]
|
||||
#![allow(clippy::missing_safety_doc)]
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
Loading…
Add table
Add a link
Reference in a new issue