Skip to content

Commit c7580f7

Browse files
committed
Use dynamic linking to avoid unnecessary build
1 parent 4d4998b commit c7580f7

21 files changed

+56
-340
lines changed

.gitmodules

Lines changed: 0 additions & 4 deletions
This file was deleted.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ name = "cargo-build_sk_rs"
5252

5353
[build-dependencies]
5454
cmake = "0.1.54"
55+
system-deps = "2.0"
5556

5657
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
5758
[dependencies]
@@ -94,6 +95,9 @@ name = "main_tests"
9495
path = "tests/main_tests.rs"
9596
harness = false
9697

98+
[package.metadata.system-deps]
99+
StereoKitC = "0.3.11"
100+
97101
[package.metadata.android]
98102
package = "com.stereokit.rust_binding.demos"
99103
build_targets = ["aarch64-linux-android"]

StereoKit

Lines changed: 0 additions & 1 deletion
This file was deleted.

build.rs

Lines changed: 3 additions & 335 deletions
Large diffs are not rendered by default.

src/anchor.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ bitflags::bitflags! {
7676
const Stability = 2;
7777
}
7878
}
79+
80+
#[link(name = "StereoKitC")]
7981
unsafe extern "C" {
8082
pub fn anchor_find(asset_id_utf8: *const c_char) -> AnchorT;
8183
pub fn anchor_create(pose: Pose) -> AnchorT;

src/font.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ pub struct _FontT {
7171
/// StereoKit ffi type.
7272
pub type FontT = *mut _FontT;
7373

74+
#[link(name = "StereoKitC")]
7475
unsafe extern "C" {
7576
pub fn font_find(id: *const c_char) -> FontT;
7677
pub fn font_create(file_utf8: *const c_char) -> FontT;

src/interactor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pub enum DefaultInteractors {
7676
None = 1,
7777
}
7878

79+
#[link(name = "StereoKitC")]
7980
unsafe extern "C" {
8081
// Interactor functions
8182
pub fn interactor_create(

src/material.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ pub struct _MaterialT {
130130
/// StereoKit ffi type.
131131
pub type MaterialT = *mut _MaterialT;
132132

133+
#[link(name = "StereoKitC")]
133134
unsafe extern "C" {
134135
pub fn material_find(id: *const c_char) -> MaterialT;
135136
pub fn material_create(shader: ShaderT) -> MaterialT;
@@ -1472,6 +1473,7 @@ pub struct ParamInfos<'a> {
14721473
index: i32,
14731474
}
14741475

1476+
#[link(name = "StereoKitC")]
14751477
unsafe extern "C" {
14761478
pub fn material_set_float(material: MaterialT, name: *const c_char, value: f32);
14771479
pub fn material_set_vector2(material: MaterialT, name: *const c_char, value: Vec2);
@@ -2363,6 +2365,7 @@ impl ParamInfo {
23632365
}
23642366
}
23652367

2368+
#[link(name = "StereoKitC")]
23662369
unsafe extern "C" {
23672370
pub fn material_buffer_create(size: i32) -> MaterialBufferT;
23682371
pub fn material_buffer_addref(buffer: MaterialBufferT);

src/maths.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,7 @@ impl PartialEq for Vec3 {
955955
}
956956
}
957957

958+
#[link(name = "StereoKitC")]
958959
unsafe extern "C" {
959960
pub fn vec3_cross(a: *const Vec3, b: *const Vec3) -> Vec3;
960961
}
@@ -2569,6 +2570,7 @@ impl PartialEq for Quat {
25692570
}
25702571
}
25712572

2573+
#[link(name = "StereoKitC")]
25722574
unsafe extern "C" {
25732575
pub fn quat_difference(a: *const Quat, b: *const Quat) -> Quat;
25742576
pub fn quat_lookat(from: *const Vec3, at: *const Vec3) -> Quat;
@@ -3225,6 +3227,7 @@ impl PartialEq for Matrix {
32253227
}
32263228
}
32273229

3230+
#[link(name = "StereoKitC")]
32283231
unsafe extern "C" {
32293232
pub fn pose_matrix_out(pose: *const Pose, out_result: *mut Matrix, scale: Vec3);
32303233
pub fn matrix_inverse(a: *const Matrix, out_Matrix: *mut Matrix);
@@ -4718,6 +4721,7 @@ impl AsRef<Bounds> for Bounds {
47184721
}
47194722
}
47204723

4724+
#[link(name = "StereoKitC")]
47214725
unsafe extern "C" {
47224726
pub fn bounds_ray_intersect(bounds: Bounds, ray: Ray, out_pt: *mut Vec3) -> Bool32T;
47234727
pub fn bounds_point_contains(bounds: Bounds, pt: Vec3) -> Bool32T;
@@ -5328,6 +5332,7 @@ impl PartialEq for Plane {
53285332
}
53295333
}
53305334

5335+
#[link(name = "StereoKitC")]
53315336
unsafe extern "C" {
53325337
pub fn plane_from_points(p1: Vec3, p2: Vec3, p3: Vec3) -> Plane;
53335338
pub fn plane_from_ray(ray: Ray) -> Plane;
@@ -5809,6 +5814,7 @@ impl AsRef<Sphere> for Sphere {
58095814
}
58105815
}
58115816

5817+
#[link(name = "StereoKitC")]
58125818
unsafe extern "C" {
58135819
pub fn sphere_ray_intersect(sphere: Sphere, ray: Ray, out_pt: *mut Vec3) -> Bool32T;
58145820
pub fn sphere_point_contains(sphere: Sphere, pt: Vec3) -> Bool32T;
@@ -5976,6 +5982,7 @@ pub struct Ray {
59765982
pub direction: Vec3,
59775983
}
59785984

5985+
#[link(name = "StereoKitC")]
59795986
unsafe extern "C" {
59805987
pub fn ray_intersect_plane(ray: Ray, plane_pt: Vec3, plane_normal: Vec3, out_t: *mut f32) -> Bool32T;
59815988
pub fn ray_from_mouse(screen_pixel_pos: Vec2, out_ray: *mut Ray) -> Bool32T;

src/mesh.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ pub type MeshT = *mut _MeshT;
166166
/// StereoKit ffi type.
167167
pub type VindT = u32;
168168

169+
#[link(name = "StereoKitC")]
169170
unsafe extern "C" {
170171
pub fn mesh_find(name: *const c_char) -> MeshT;
171172
pub fn mesh_create() -> MeshT;

0 commit comments

Comments
 (0)