rust how to define an internal dependency?

Viewed 44

I am trying to achieve the following, I have this project structure:

.
├── Cargo.lock
├── Cargo.toml
└── src
    ├── lib.rs
    ├── mesh
    │   ├── gltf_loader
    │   │   ├── Cargo.toml
    │   │   ├── pluralize
    │   │   └── src
    │   └── mesh.rs
    └── vulkan
        ├── core.rs
        ├── hardware_interface.rs
        ├── image.rs
        ├── memory.rs
        ├── mod.rs
        ├── pipeline.rs
        ├── renderer.rs
        ├── shader_program.rs
        ├── swapchain.rs
        └── tools.rs

in here pluralize defines a procedural macro that is needed to compile gltf_loader but that needs to be kept hidden from all other dependencies. So I want to compile gltf loader as a "subcrate" then use that crate as a dependency for mesh.rs. Ideally without moving the directory structure.

To that effect I added this to the root toml:

[dependencies]
gltf_loader = { path = "src/mesh/gltf_loader" }

However if I do this and try to run an example, I get this error:

error: failed to get `gltf_loader` as a dependency of package `vulkan_bindings v0.1.0 (/home/makogan/rust_never_engine)`

Caused by:
  failed to load source for dependency `gltf_loader`

Caused by:
  Unable to update /home/makogan/rust_never_engine/src/mesh/gltf_loader

Caused by:
  failed to parse manifest at `/home/makogan/rust_never_engine/src/mesh/gltf_loader/Cargo.toml`

Caused by:
  can't find `proc-macros` bin at `src/bin/proc-macros.rs` or `src/bin/proc-macros/main.rs`. Please specify bin.path if you want to use a non-default path.

Why does this happen?

This id the full .toml:

[package]
name = "vulkan_bindings"
version = "0.1.0"
edition = "2021"

[lib]
name = "vulkan_bindings"
path = "src/lib.rs"

[dependencies]
# Rendering
ash = { version = "0.37.0" }
glfw = { version = "0.45.0", features = ["vulkan"] }
gpu-allocator = "0.18.0"
spirv_cross = { version = "0.23.1", features = ["glsl"] }
shaderc = "0.8.0"

# Math
nalgebra = "*"
nalgebra-glm = "0.3"
nalgebra-sparse = "0.1"

# json
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
data-url = "0.1.1"

# misc
paste = "1.0.8"
termcolor = "1.1.3"
regex = "1.6.0"
add_getters_setters = "1.1.2"

# internal
gltf_loader = { path = "src/mesh/gltf_loader" }
0 Answers
Related