diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index de25d1f..0000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "StereoKit"] - path = StereoKit - url = https://github.com/StereoKit/StereoKit.git - branch = develop diff --git a/Cargo.toml b/Cargo.toml index ba5f874..ef57af5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,6 +52,7 @@ name = "cargo-build_sk_rs" [build-dependencies] cmake = "0.1.54" +system-deps = "2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -94,6 +95,9 @@ name = "main_tests" path = "tests/main_tests.rs" harness = false +[package.metadata.system-deps] +StereoKitC = "0.3.11" + [package.metadata.android] package = "com.stereokit.rust_binding.demos" build_targets = ["aarch64-linux-android"] diff --git a/StereoKit b/StereoKit deleted file mode 160000 index ed84f31..0000000 --- a/StereoKit +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ed84f3165eb3b52ce48c103d78402e2d27baf3cf diff --git a/build.rs b/build.rs index 13b6adf..b806be9 100644 --- a/build.rs +++ b/build.rs @@ -1,338 +1,6 @@ -use cmake::Config; -use std::{env, fs, path::Path}; - -macro_rules! cargo_link { - ($feature:expr) => { - println!("cargo:rustc-link-lib={}", $feature); - }; -} +use std::env; +use std::path::PathBuf; fn main() { - let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); - let target_family = env::var("CARGO_CFG_TARGET_FAMILY").unwrap(); - let profile = env::var("PROFILE").unwrap(); - let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap(); - - let win_gnu_libs = env::var("SK_RUST_WIN_GNU_LIBS").unwrap_or_default(); - let win_gl = !env::var("SK_RUST_WINDOWS_GL").unwrap_or_default().is_empty(); - let skc_in_dll = cfg!(feature = "skc-in-dll"); - - let mut abi = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default(); - if abi == "aarch64" { - abi = "arm64-v8a".to_string(); - } - - if win_gl { - println!("cargo:info=Compiling with {target_env} for {target_os}/opengl with profile {profile}"); - } else { - println!("cargo:info=Compiling with {target_env} for {target_os} with profile {profile}"); - } - - if target_os == "macos" { - println!( - "cargo:warning=You seem to be building for MacOS! We still enable builds so that rust-analyzer works, but this won't actually build StereoKit so it'll be pretty non-functional." - ); - return; - } - - if env::var("DOCS_RS").is_ok() { - println!("cargo:warning=Skipping build on docs.rs"); - return; - } - - // Build StereoKit, and tell rustc to link it. - let mut cmake_config = Config::new("StereoKit"); - cmake_config.define("SK_DISTRIBUTE", "OFF"); - - let profile_upper = if profile == "debug" { - cmake_config.define("CMAKE_BUILD_TYPE", "Debug"); - "Debug" - } else { - "Release" - }; - - if !win_gnu_libs.is_empty() { - cmake_config.define("CMAKE_SYSTEM_NAME", "Windows"); - if win_gl { - cmake_config.cxxflag("-Wl,-allow-multiple-definition"); - cmake_config.define("__MINGW32__", "ON"); - cmake_config.define("WINDOWS_LIBS", "comdlg32;opengl32;"); - } else { - cmake_config.define("__MINGW32__", "ON"); - cmake_config.define("WINDOWS_LIBS", "comdlg32;dxgi;d3d11;"); - } - //PR #1260 - cmake_config.cflag("-mf16c -mavx"); - cmake_config.cxxflag("-mf16c -mavx"); - } else if target_os == "android" && abi == "x86_64" { - //PR #1260 - cmake_config.cflag("-mf16c -mavx"); - cmake_config.cxxflag("-mf16c -mavx"); - } - - if win_gl { - cmake_config.define("SK_WINDOWS_GL", "ON"); - } - - let mut dep_sk_gpu_src = None; - if cfg!(feature = "force-local-deps") && env::var("FORCE_LOCAL_DEPS").is_ok() { - println!("cargo:info=Force local deps !!"); - // Helper function to define optional dependencies - fn define_if_exists(var_name: &str, cmake_var: &str, config: &mut Config) { - if let Ok(value) = env::var(var_name) { - config.define(cmake_var, value); - } - } - - define_if_exists("DEP_OPENXR_LOADER_SOURCE", "CPM_openxr_loader_SOURCE", &mut cmake_config); - define_if_exists("DEP_MESHOPTIMIZER_SOURCE", "CPM_meshoptimizer_SOURCE", &mut cmake_config); - define_if_exists("DEP_BASIS_UNIVERSAL_SOURCE", "CPM_basis_universal_SOURCE", &mut cmake_config); - define_if_exists("DEP_SK_GPU_SOURCE", "CPM_sk_gpu_SOURCE", &mut cmake_config); - // we need this path for retrieving skshaderc* - dep_sk_gpu_src = env::var("DEP_SK_GPU_SOURCE").ok(); - } - - if target_family.as_str() == "windows" { - if skc_in_dll { - cmake_config.define("SK_BUILD_SHARED_LIBS", "ON"); - } else { - cmake_config.define("SK_BUILD_SHARED_LIBS", "OFF"); - } - } else { - cmake_config.define("SK_BUILD_SHARED_LIBS", "OFF"); - } - cmake_config.define("SK_BUILD_TESTS", "OFF").define("SK_PHYSICS", "OFF"); - if target_os == "android" { - cmake_config.define("CMAKE_ANDROID_API", "32"); - cmake_config.define("CMAKE_INSTALL_INCLUDEDIR", "install"); - cmake_config.define("CMAKE_INSTALL_LIBDIR", "install"); - cmake_config.define("CMAKE_GENERATOR", "Ninja"); - } - if cfg!(feature = "build-dynamic-openxr") { - // When you need to build and use Khronos openxr loader use this feature: - cmake_config.define("SK_DYNAMIC_OPENXR", "ON"); - cmake_config.define("SK_BUILD_OPENXR_LOADER", "ON"); - } else if cfg!(feature = "dynamic-openxr") { - // When you need to ship your own openxr loader use this feature: - cmake_config.define("SK_DYNAMIC_OPENXR", "ON"); - } - if cfg!(feature = "profile") { - cmake_config.define("SK_PROFILE", "ON"); - } - - let dst = cmake_config.build(); - - let out_dir = env::var("OUT_DIR").unwrap(); //---must be equal to dst - - match target_family.as_str() { - "windows" => { - println!("cargo:rustc-link-search=native={}/lib", dst.display()); - println!("cargo:rustc-link-search=native={}/build/{}", dst.display(), profile_upper); - - cargo_link!("StereoKitC"); - - if cfg!(debug_assertions) { - // openxr-sys/linked wants libopenxr_loader so it asks for -Wl -lopenxr_loader in final ld - cargo_link!("openxr_loaderd"); - } else { - cargo_link!("openxr_loader"); - } - - cargo_link!("meshoptimizer"); - cargo_link!("windowsapp"); - cargo_link!("user32"); - cargo_link!("shell32"); - if cfg!(feature = "profile") { - cargo_link!("TracyClient"); - } - // test not really useful, just there to recall this annoying problem: - if cfg!(windows) { - cargo_link!("Comdlg32"); - } else { - cargo_link!("comdlg32"); - } - println!("cargo:rustc-link-search=native={}", dst.display()); - if target_env == "gnu" { - if !skc_in_dll { - println!("cargo:rustc-link-search=native={}/build", dst.display()); - println!("cargo:rustc-link-search=native={}/lib", dst.display()); - println!("cargo:rustc-link-search=native={win_gnu_libs}"); - cargo_link!("gcc_eh"); - cargo_link!("stdc++"); - cargo_link!("meshoptimizer"); - } else { - //---- We have to extract the DLL i.e. ".\target\x86_64-pc-windows-gnu\debug\build\stereokit-rust-be362d37871b9048\out\build\StereoKitC.dll" - //---- and copy it to ".\target\x86_64-pc-windows-gnu\debug\deps\ - //println!("cargo:rustc-link-search=native={}/build", dst.display()); - println!("cargo:rustc-link-search=native={win_gnu_libs}"); - let deuleuleu = "libStereoKitC.dll"; - let target_dir = Path::new(&out_dir).parent().unwrap().parent().unwrap().parent().unwrap(); - let deps_libs = target_dir.join("deps"); - println!("cargo:rustc-link-search=native={}", deps_libs.to_str().unwrap()); - println!("cargo:info=dst --> {dst:?}"); - let dest_file_dll = deps_libs.join(deuleuleu); - let file_dll = dst.join("build").join(deuleuleu); - println!("cargo:info={deuleuleu} is copied from here --> {file_dll:?}"); - println!("cargo:info= to there --> {dest_file_dll:?}"); - let _lib_dll = fs::copy(file_dll, dest_file_dll).unwrap(); - } - } else { - //---- We have to extract the DLL i.e. ".\target\debug\build\stereokit-rust-be362d37871b9048\out\build\Debug\StereoKitC.dll" - //---- and copy it to ".\target\debug\deps\ - let lib: String = "StereoKitC".into(); - let deuleuleu = lib.clone() + ".dll"; - let lib_lib = lib.clone() + ".lib"; - let lib_pdb = lib.clone() + ".pdb"; - let target_dir = Path::new(&out_dir).parent().unwrap().parent().unwrap().parent().unwrap(); - let deps_libs = target_dir.join("deps"); - println!("cargo:info=dst --> {dst:?}"); - //---Do we have a .dll ? - let file_dll = dst.join("build").join(&profile).join(&deuleuleu); - if file_dll.is_file() { - let dest_file_dll = deps_libs.join(&deuleuleu); - println!("cargo:info=StereoKitC.dll is copied from here --> {file_dll:?}"); - println!("cargo:info= to there --> {dest_file_dll:?}"); - let _lib_dll = fs::copy(file_dll, dest_file_dll).unwrap(); - } - //---Do we have a .lib ? - let file_lib = dst.join("build").join(&profile).join(&lib_lib); - if file_lib.is_file() { - let dest_file_lib = deps_libs.join(&lib_lib); - println!("cargo:info=StereoKitC.lib is copied from here --> {file_lib:?}"); - println!("cargo:info= to there --> {dest_file_lib:?}"); - let _lib_dll = fs::copy(file_lib, dest_file_lib).unwrap(); - } - //---Do we have a .pdb ? - let file_pdb = dst.join("build").join(&profile).join(&lib_pdb); - if file_pdb.is_file() { - let dest_file_pdb = deps_libs.join(&lib_pdb); - println!("cargo:info=StereoKitC.pdb is copied from here --> {file_pdb:?}"); - println!("cargo:info= to there --> {dest_file_pdb:?}"); - let _lib_dll = fs::copy(file_pdb, dest_file_pdb).unwrap(); - } - } - } - "wasm" => { - unimplemented!("sorry wasm isn't implemented yet"); - } - "unix" => { - println!("cargo:rustc-link-search=native={}/lib", dst.display()); - println!("cargo:rustc-link-search=native={}/lib64", dst.display()); - println!("cargo:rustc-link-search=native={}/build", dst.display()); - println!("cargo:rustc-link-search=native={}/install", dst.display()); - - cargo_link!("StereoKitC"); - - cargo_link!("stdc++"); - cargo_link!("openxr_loader"); - cargo_link!("meshoptimizer"); - if cfg!(feature = "profile") { - cargo_link!("TracyClient"); - } - if target_os == "android" { - cargo_link!("android"); - cargo_link!("EGL"); - - //---- A directory whose content is only used during the production of the APK (no need for DEBUG/RELEASE sub directory) - //---- Copying from ./target/aarch64-linux-android/debug/build/stereokit-rust-1d044aba61d6313d/out/lib/libopenxr_loader.so - //---- to ./target/runtime_libs/ - let target_dir = Path::new(&out_dir) - .parent() - .unwrap() - .parent() - .unwrap() - .parent() - .unwrap() - .parent() - .unwrap() - .parent() - .unwrap(); - let mut runtime_libs = target_dir.join("runtime_libs"); - println!("cargo:info=dst --> {dst:?}"); - println!("cargo:info=Android runtime_libs are copied here --> {runtime_libs:?}"); - assert!(target_dir.ends_with("target")); - if let Err(_e) = fs::create_dir(&runtime_libs) {}; - runtime_libs = runtime_libs.join(&abi); - if let Err(_e) = fs::create_dir(&runtime_libs) {}; - let dest_file_so = runtime_libs.join("libopenxr_loader.so"); - if cfg!(feature = "build-dynamic-openxr") { - let file_so = dst.join("lib/libopenxr_loader.so"); - let _lib_o = fs::copy(file_so, dest_file_so).expect("Unable to copy libopenxr_loader.so"); - } else if let Err(_e) = fs::remove_file(dest_file_so) { - } - - // // On Android, we must ensure that we're dynamically linking against the C++ standard library. - // // For more details, see https://github.com/rust-windowing/android-ndk-rs/issues/167 - // // build tools do not add libc++_shared.so to the APK so we must do it ourselves - // let host_tab = format!("{}-{}", env::consts::OS, env::consts::ARCH); - // let target = env::var("TARGET").unwrap(); - // let ndk = env::var("ANDROID_NDK_ROOT").unwrap(); - - // let libcxx = format!( - // "{}/toolchains/llvm/prebuilt/{}/sysroot/usr/lib/{}/libc++_shared.so", - // ndk, host_tab, target - // ); - // println!("cargo:info=We copy {} to the {:?}", libcxx, runtime_libs); - // let dest_file_so = runtime_libs.join("libc++_shared.so"); - // fs::copy(libcxx, dest_file_so).expect("Unable to copy libc++_shared.so"); - - cargo_link!("dylib=c++"); - } else { - cargo_link!("X11"); - cargo_link!("Xfixes"); - cargo_link!("GL"); - cargo_link!("EGL"); - cargo_link!("gbm"); - cargo_link!("fontconfig"); - } - } - _ => { - panic!("target family is unknown"); - } - } - - // copy the tools (skshaderc) under target/tools - let target_dir_name = env::var("CARGO_TARGET_DIR").unwrap_or("target".into()); - let mut target_dir = Path::new(&out_dir).parent().unwrap().parent().unwrap().parent().unwrap().parent().unwrap(); - if !target_dir.ends_with(&target_dir_name) { - //cross compilation, we need to go up one more level - target_dir = target_dir.parent().unwrap(); - } - println!("cargo:info=Can we copy skshaderc* to {target_dir:?}/tools ?"); - if target_dir.ends_with(&target_dir_name) && target_dir.exists() { - let distrib = target_dir.join("tools"); - let tools_dir = if let Some(sk_gpu_src) = dep_sk_gpu_src { - println!("cargo:info=--yes! we copy skshaderc from {sk_gpu_src:?}"); - let path = Path::new(&sk_gpu_src); - path.join("tools") - } else { - println!("cargo:info=--yes! we copy skshaderc from {dst:?}/build/_deps/sk_gpu-src/tools"); - dst.join("build").join("_deps").join("sk_gpu-src").join("tools") - }; - copy_tree(tools_dir, distrib).expect("Unable to copy tools"); - } else { - println!("cargo:warning={target_dir_name} directory {target_dir:?} does not exist"); - } - - // Tell cargo to invalidate the built crate whenever the wrapper changes - println!("cargo:rerun-if-changed=build.rs"); - println!("cargo:rerun-if-changed=StereoKit/StereoKitC/stereokit.h"); - println!("cargo:rerun-if-changed=StereoKit/StereoKitC/stereokit_ui.h"); -} - -/// Recursive fn to copy all the content of a directory to another one. -/// Duplicate from stereokit_rust::tools::build_tools::copy_tree -/// * `src` - The source directory. -/// * `dst` - The destination directory. -pub fn copy_tree(src: impl AsRef, dst: impl AsRef) -> std::io::Result<()> { - if let Err(_err) = fs::create_dir(&dst) {} - for entry in fs::read_dir(src)?.flatten() { - let path_type = entry.file_type()?; - if path_type.is_dir() { - copy_tree(entry.path(), dst.as_ref().join(entry.file_name()))?; - } else { - fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?; - } - } - Ok(()) + system_deps::Config::new().probe().unwrap(); } diff --git a/src/anchor.rs b/src/anchor.rs index a3f8092..b505167 100644 --- a/src/anchor.rs +++ b/src/anchor.rs @@ -76,6 +76,8 @@ bitflags::bitflags! { const Stability = 2; } } + +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn anchor_find(asset_id_utf8: *const c_char) -> AnchorT; pub fn anchor_create(pose: Pose) -> AnchorT; diff --git a/src/font.rs b/src/font.rs index dcd890a..f1ac17e 100644 --- a/src/font.rs +++ b/src/font.rs @@ -71,6 +71,7 @@ pub struct _FontT { /// StereoKit ffi type. pub type FontT = *mut _FontT; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn font_find(id: *const c_char) -> FontT; pub fn font_create(file_utf8: *const c_char) -> FontT; diff --git a/src/interactor.rs b/src/interactor.rs index 4fa3046..20ddf8a 100644 --- a/src/interactor.rs +++ b/src/interactor.rs @@ -76,6 +76,7 @@ pub enum DefaultInteractors { None = 1, } +#[link(name = "StereoKitC")] unsafe extern "C" { // Interactor functions pub fn interactor_create( diff --git a/src/material.rs b/src/material.rs index 79357ca..cd64ff9 100644 --- a/src/material.rs +++ b/src/material.rs @@ -130,6 +130,7 @@ pub struct _MaterialT { /// StereoKit ffi type. pub type MaterialT = *mut _MaterialT; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn material_find(id: *const c_char) -> MaterialT; pub fn material_create(shader: ShaderT) -> MaterialT; @@ -1472,6 +1473,7 @@ pub struct ParamInfos<'a> { index: i32, } +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn material_set_float(material: MaterialT, name: *const c_char, value: f32); pub fn material_set_vector2(material: MaterialT, name: *const c_char, value: Vec2); @@ -2363,6 +2365,7 @@ impl ParamInfo { } } +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn material_buffer_create(size: i32) -> MaterialBufferT; pub fn material_buffer_addref(buffer: MaterialBufferT); diff --git a/src/maths.rs b/src/maths.rs index 70c562a..1b0d880 100644 --- a/src/maths.rs +++ b/src/maths.rs @@ -955,6 +955,7 @@ impl PartialEq for Vec3 { } } +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn vec3_cross(a: *const Vec3, b: *const Vec3) -> Vec3; } @@ -2569,6 +2570,7 @@ impl PartialEq for Quat { } } +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn quat_difference(a: *const Quat, b: *const Quat) -> Quat; pub fn quat_lookat(from: *const Vec3, at: *const Vec3) -> Quat; @@ -3225,6 +3227,7 @@ impl PartialEq for Matrix { } } +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn pose_matrix_out(pose: *const Pose, out_result: *mut Matrix, scale: Vec3); pub fn matrix_inverse(a: *const Matrix, out_Matrix: *mut Matrix); @@ -4718,6 +4721,7 @@ impl AsRef for Bounds { } } +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn bounds_ray_intersect(bounds: Bounds, ray: Ray, out_pt: *mut Vec3) -> Bool32T; pub fn bounds_point_contains(bounds: Bounds, pt: Vec3) -> Bool32T; @@ -5328,6 +5332,7 @@ impl PartialEq for Plane { } } +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn plane_from_points(p1: Vec3, p2: Vec3, p3: Vec3) -> Plane; pub fn plane_from_ray(ray: Ray) -> Plane; @@ -5809,6 +5814,7 @@ impl AsRef for Sphere { } } +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn sphere_ray_intersect(sphere: Sphere, ray: Ray, out_pt: *mut Vec3) -> Bool32T; pub fn sphere_point_contains(sphere: Sphere, pt: Vec3) -> Bool32T; @@ -5976,6 +5982,7 @@ pub struct Ray { pub direction: Vec3, } +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn ray_intersect_plane(ray: Ray, plane_pt: Vec3, plane_normal: Vec3, out_t: *mut f32) -> Bool32T; pub fn ray_from_mouse(screen_pixel_pos: Vec2, out_ray: *mut Ray) -> Bool32T; diff --git a/src/mesh.rs b/src/mesh.rs index 940d7fb..7562a6a 100644 --- a/src/mesh.rs +++ b/src/mesh.rs @@ -166,6 +166,7 @@ pub type MeshT = *mut _MeshT; /// StereoKit ffi type. pub type VindT = u32; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn mesh_find(name: *const c_char) -> MeshT; pub fn mesh_create() -> MeshT; diff --git a/src/model.rs b/src/model.rs index c4b2514..eb9bc1d 100644 --- a/src/model.rs +++ b/src/model.rs @@ -84,6 +84,7 @@ pub struct _ModelT { /// StereoKit ffi type. pub type ModelT = *mut _ModelT; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn model_find(id: *const c_char) -> ModelT; pub fn model_copy(model: ModelT) -> ModelT; @@ -1371,6 +1372,7 @@ pub struct Nodes<'a> { model: &'a Model, } +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn model_subset_count(model: ModelT) -> i32; pub fn model_node_add( diff --git a/src/permission.rs b/src/permission.rs index 1fb4a83..7d00eda 100644 --- a/src/permission.rs +++ b/src/permission.rs @@ -76,6 +76,7 @@ impl fmt::Display for PermissionState { } } +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn permission_state(permission: PermissionType) -> PermissionState; pub fn permission_is_interactive(permission: PermissionType) -> Bool32T; diff --git a/src/render_list.rs b/src/render_list.rs index a079075..0bfe204 100644 --- a/src/render_list.rs +++ b/src/render_list.rs @@ -86,6 +86,7 @@ pub struct _RenderListT { /// StereoKit ffi type. pub type RenderListT = *mut _RenderListT; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn render_list_find(id: *const c_char) -> RenderListT; pub fn render_list_set_id(render_list: RenderListT, id: *const c_char); diff --git a/src/shader.rs b/src/shader.rs index 65c5655..b164cbf 100644 --- a/src/shader.rs +++ b/src/shader.rs @@ -52,6 +52,8 @@ pub struct _ShaderT { } /// StereoKit ffi type. pub type ShaderT = *mut _ShaderT; + +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn shader_find(id: *const ::std::os::raw::c_char) -> ShaderT; pub fn shader_create_file(filename_utf8: *const ::std::os::raw::c_char) -> ShaderT; diff --git a/src/sk.rs b/src/sk.rs index 290b008..62718c7 100644 --- a/src/sk.rs +++ b/src/sk.rs @@ -275,6 +275,7 @@ pub enum StandbyMode { None = 3, } +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn sk_init(settings: SkSettings) -> Bool32T; pub fn sk_set_window(window: *mut c_void); diff --git a/src/sound.rs b/src/sound.rs index 4c3380c..f47ff1f 100644 --- a/src/sound.rs +++ b/src/sound.rs @@ -86,6 +86,7 @@ pub type SoundT = *mut _SoundT; unsafe impl Send for Sound {} unsafe impl Sync for Sound {} +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn sound_find(id: *const c_char) -> SoundT; pub fn sound_set_id(sound: SoundT, id: *const c_char); @@ -790,6 +791,7 @@ pub struct SoundInst { pub _slot: i16, } +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn sound_inst_stop(sound_inst: SoundInst); pub fn sound_inst_is_playing(sound_inst: SoundInst) -> Bool32T; diff --git a/src/sprite.rs b/src/sprite.rs index 1e3bb9b..7b71488 100644 --- a/src/sprite.rs +++ b/src/sprite.rs @@ -99,6 +99,7 @@ pub struct _SpriteT { /// StereoKit ffi type. pub type SpriteT = *mut _SpriteT; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn sprite_find(id: *const c_char) -> SpriteT; pub fn sprite_create(sprite: TexT, type_: SpriteType, atlas_id: *const c_char) -> SpriteT; diff --git a/src/system.rs b/src/system.rs index 35c3a91..4c76030 100644 --- a/src/system.rs +++ b/src/system.rs @@ -134,6 +134,7 @@ pub struct Assets; pub type AssetT = *mut c_void; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn assets_releaseref_threadsafe(asset: *mut c_void); pub fn assets_current_task() -> i32; @@ -545,6 +546,7 @@ pub struct Backend; pub type VoidFunction = unsafe extern "system" fn(); +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn backend_xr_get_type() -> BackendXRType; pub fn backend_openxr_get_instance() -> OpenXRHandleT; @@ -1343,6 +1345,7 @@ pub enum HierarchyParent { /// screenshot pub struct Hierarchy; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn hierarchy_push(transform: *const Matrix, parent_behavior: HierarchyParent); pub fn hierarchy_push_pose(pose: *const Pose, parent_behavior: HierarchyParent); @@ -2597,6 +2600,7 @@ pub enum Key { /// ``` pub struct Input; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn input_pointer_count(filter: InputSource) -> i32; pub fn input_pointer(index: i32, filter: InputSource) -> Pointer; @@ -3524,6 +3528,7 @@ impl LinePoint { /// screenshot pub struct Lines; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn line_add(start: Vec3, end: Vec3, color_start: Color32, color_end: Color32, thickness: f32); pub fn line_addv(start: LinePoint, end: LinePoint); @@ -3783,6 +3788,7 @@ pub struct LogItem { /// ``` pub struct Log; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn log_diag(text: *const c_char); //pub fn log_diagf(text: *const c_char, ...); @@ -3809,6 +3815,7 @@ unsafe extern "C" { /// Log subscribe trampoline /// /// see also [`Log::subscribe`] +#[link(name = "StereoKitC")] unsafe extern "C" fn log_trampoline<'a, F: FnMut(LogLevel, &str) + 'a>( context: *mut c_void, log_level: LogLevel, @@ -4048,6 +4055,7 @@ pub struct Microphone { sound: Sound, } +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn mic_get_stream() -> SoundT; pub fn mic_is_recording() -> Bool32T; @@ -4268,6 +4276,7 @@ pub enum Projection { /// screenshot pub struct Renderer; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn render_set_clip(near_plane: f32, far_plane: f32); pub fn render_get_clip(out_near_plane: *mut f32, out_far_plane: *mut f32); @@ -4381,6 +4390,7 @@ unsafe extern "C" { /// screenshot_capture trampoline /// /// see also [`Renderer::screenshot_capture`] +#[link(name = "StereoKitC")] unsafe extern "C" fn sc_capture_trampoline( color_buffer: *mut Color32, width: i32, @@ -5587,6 +5597,7 @@ pub struct TextStyle { _id: u32, } +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn text_make_style(font: FontT, layout_height: f32, color_gamma: Color128) -> TextStyle; pub fn text_make_style_shader(font: FontT, layout_height: f32, shader: ShaderT, color_gamma: Color128) @@ -6090,6 +6101,7 @@ pub enum TextContext { /// screenshot pub struct Text; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn text_add_at( text_utf8: *const c_char, @@ -6613,6 +6625,7 @@ pub enum SpatialNodeType { /// pub struct World; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn world_has_bounds() -> Bool32T; pub fn world_get_bounds_size() -> Vec2; diff --git a/src/tex.rs b/src/tex.rs index eb6f62f..3dbc183 100644 --- a/src/tex.rs +++ b/src/tex.rs @@ -278,6 +278,7 @@ pub type TexT = *mut _TexT; unsafe impl Send for Tex {} unsafe impl Sync for Tex {} +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn tex_find(id: *const c_char) -> TexT; pub fn tex_create(type_: TexType, format: TexFormat) -> TexT; diff --git a/src/ui.rs b/src/ui.rs index 184795c..b28258a 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -598,6 +598,7 @@ pub struct UiSliderData { /// screenshot pub struct Ui; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn ui_quadrant_size_verts(ref_vertices: *mut Vertex, vertex_count: i32, overflow_percent: f32); pub fn ui_quadrant_size_mesh(ref_mesh: MeshT, overflow_percent: f32); diff --git a/src/util.rs b/src/util.rs index f389de7..424820f 100644 --- a/src/util.rs +++ b/src/util.rs @@ -86,6 +86,7 @@ impl From for Color128 { } } +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn color_hsv(hue: f32, saturation: f32, value: f32, transparency: f32) -> Color128; pub fn color_to_hsv(color: *const Color128) -> Vec3; @@ -946,6 +947,7 @@ pub struct FovInfo { /// ``` pub struct Device; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn device_display_get_type() -> DisplayType; pub fn device_display_get_blend() -> DisplayBlend; @@ -1250,6 +1252,7 @@ pub struct _GradientT { /// StereoKit ffi type. pub type GradientT = *mut _GradientT; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn gradient_create() -> GradientT; pub fn gradient_create_keys(in_arr_keys: *const GradientKey, count: i32) -> GradientT; @@ -1520,6 +1523,7 @@ impl FileFilter { /// transparent to developers pub struct Hash; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn hash_string(str_utf8: *const c_char) -> IdHashT; pub fn hash_string_with(str_utf8: *const c_char, root: IdHashT) -> IdHashT; @@ -1647,6 +1651,7 @@ pub enum PickerMode { /// ``` pub struct Platform; +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn platform_file_picker( mode: PickerMode, @@ -1694,6 +1699,7 @@ unsafe extern "C" { /// File_picker trampoline /// /// see also [`Plaform::file_picker`] +#[link(name = "StereoKitC")] unsafe extern "C" fn fp_trampoline( user_data: *mut c_void, confirmed: Bool32T, @@ -1712,6 +1718,7 @@ unsafe extern "C" fn fp_trampoline( /// File_picker_sz trampoline /// /// see also [`Plaform::file_picker`] +#[link(name = "StereoKitC")] unsafe extern "C" fn fp_sz_trampoline( user_data: *mut c_void, confirmed: Bool32T, @@ -2182,6 +2189,7 @@ pub struct SphericalHarmonics { pub coefficients: [Vec3; 9usize], } +#[link(name = "StereoKitC")] unsafe extern "C" { pub fn sh_create(in_arr_lights: *const SHLight, light_count: i32) -> SphericalHarmonics; pub fn sh_brightness(ref_harmonics: *mut SphericalHarmonics, scale: f32); @@ -2387,6 +2395,7 @@ impl SphericalHarmonics { /// ``` pub struct Time; +#[link(name = "StereoKitC")] unsafe extern "C" { // Deprecated: pub fn time_get_raw() -> f64; // Deprecated: pub fn time_getf_unscaled() -> f32;