diff --git a/Cargo.toml b/Cargo.toml index 105f50f..c129e25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,3 +13,6 @@ libc = "0.2.76" [build-dependencies] rustc_version = "0.2" + +[lib] +crate-type = ["staticlib", "cdylib"] diff --git a/build.rs b/build.rs index 6399463..355a8e4 100644 --- a/build.rs +++ b/build.rs @@ -21,4 +21,9 @@ fn main() { println!("cargo:rustc-cfg=dev"); } } + + // Link to GHOST and required stuffs + println!(r"cargo:rustc-link-search=./lib"); + + println!("cargo:rustc-link-lib=dylib=stdc++"); // libstdc++ } diff --git a/src/api.rs b/src/api.rs index 410e953..4f1e4ec 100644 --- a/src/api.rs +++ b/src/api.rs @@ -11,6 +11,7 @@ use std::{ ptr::NonNull, }; +#[link(name="bf_intern_ghost")] extern "C" { pub fn GHOST_CreateSystem() -> GHOST_SystemHandle; pub fn GHOST_SystemInitDebug(_: GHOST_SystemHandle, _: c_int); diff --git a/src/lib.rs b/src/lib.rs index c34e6f6..926df7f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -79,7 +79,10 @@ mod tests { use super::*; #[test] fn it_works() { - // nothing yet. + unsafe { + let ptr = api::GHOST_CreateSystem(); + assert!(!ptr.is_null()); + } } macro_rules! static_assert { @@ -100,6 +103,6 @@ mod tests { static_assert!(std::mem::size_of::() == std::mem::size_of::(), "C enum is not of type `int`. Either that or #[repr(transparent)] is broken. Aborting."); static_assert!(std::mem::align_of::() == std::mem::align_of::(), - "C enum has unexpected alignment differing from type `int`. Either that or #[repr(transparent)] is broken. Aborting."); + "C enum has unexpected alignment differing from type `int`. Either that or #[repr(transparent)] is broken. Aborting."); // ..are there others? }