diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..120c4a6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "c-cpp-flylint.clang.includePaths": [ + "${workspaceFolder}/src", + "${workspaceFolder}/third_party/raylib/src", + ], +} \ No newline at end of file diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..a4ff8b4 --- /dev/null +++ b/build.rs @@ -0,0 +1,27 @@ +use std::path::PathBuf; + +use bindgen::Bindings; + +fn generate_bindings(header_file: &str) { + + // Generate the data + let bindings = bindgen::Builder::default() + .header(header_file) + .parse_callbacks(Box::new(bindgen::CargoCallbacks)) + .generate() + .expect("Unable to generate bindings"); + + // Write `src/bindings.rs` + let out_path = PathBuf::from(std::env::var("OUT_DIR").unwrap()); + bindings + .write_to_file(out_path.join("bindings.rs")) + .expect("Couldn't write bindings!"); +} + +pub fn main() { + // Files to watch that should trigger a rebuild + println!("cargo:rerun-if-changed=src/wrapper.h"); + + // Generate bindings + generate_bindings("src/wrapper.h"); +} diff --git a/src/lib.rs b/src/lib.rs index 99df9ff..23a4bca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1 +1,7 @@ -#![doc = include_str!("../README.md")] \ No newline at end of file +#![doc = include_str!("../README.md")] +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +// Include the generated bindings +include!(concat!(env!("OUT_DIR"), "/bindings.rs")); \ No newline at end of file diff --git a/src/wrapper.h b/src/wrapper.h new file mode 100644 index 0000000..eeaed88 --- /dev/null +++ b/src/wrapper.h @@ -0,0 +1,3 @@ +// This file is used to inform bindgen about every header we need to parse + +#include "../third_party/raylib/src/raylib.h"