Skip to content

Commit

Permalink
Publish vulkano-macros (#2175)
Browse files Browse the repository at this point in the history
* Publish vulkano-macros

* Document `vulkano-macros`

* Make macros dependency optional

* Document `macros` feature

* Fix outdated docs

* Derp
  • Loading branch information
marc0246 authored Apr 3, 2023
1 parent 1f31e85 commit 096d3bc
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 21 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
members = [
"examples",
"vulkano",
"vulkano-macros",
"vulkano-shaders",
"vulkano-win",
"vulkano-util",
"vulkano-win",
]
9 changes: 6 additions & 3 deletions vulkano/macros/Cargo.toml → vulkano-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
name = "vulkano-macros"
version = "0.33.0"
edition = "2021"
authors = ["Pierre Krieger <[email protected]>", "The vulkano contributors"]
authors = [
"Pierre Krieger <[email protected]>",
"The vulkano contributors",
]
repository = "https://github.com/vulkano-rs/vulkano"
description = "Macros used by Vulkano"
license = "MIT/Apache-2.0"
documentation = "https://docs.rs/vulkano"
homepage = "https://vulkano.rs"
publish = false
publish = true

[lib]
proc-macro = true
Expand All @@ -20,4 +23,4 @@ proc-macro2 = "1.0"
proc-macro-crate = "1.2"

[dev-dependencies]
vulkano = { path = ".." }
vulkano = { path = "../vulkano" }
File renamed without changes.
10 changes: 10 additions & 0 deletions vulkano/macros/src/lib.rs → vulkano-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@
// notice may not be copied, modified, or distributed except
// according to those terms.

//! Macros for [`vulkano`].
//!
//! [`vulkano`]: https://crates.io/crates/vulkano

use proc_macro::TokenStream;
use proc_macro_crate::{crate_name, FoundCrate};
use syn::{parse_macro_input, DeriveInput, Error};

mod derive_buffer_contents;
mod derive_vertex;

/// Derives the [`Vertex`] trait.
///
/// [`Vertex`]: https://docs.rs/vulkano/latest/vulkano/pipeline/graphics/vertex_input/trait.Vertex.html
#[proc_macro_derive(Vertex, attributes(name, format))]
pub fn derive_vertex(input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as DeriveInput);
Expand All @@ -23,6 +30,9 @@ pub fn derive_vertex(input: TokenStream) -> TokenStream {
.into()
}

/// Derives the [`BufferContents`] trait.
///
/// [`BufferContents`]: https://docs.rs/vulkano/latest/vulkano/buffer/trait.BufferContents.html
#[proc_macro_derive(BufferContents)]
pub fn derive_buffer_contents(input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as DeriveInput);
Expand Down
7 changes: 5 additions & 2 deletions vulkano-shaders/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
name = "vulkano-shaders"
version = "0.33.0"
edition = "2021"
authors = ["Pierre Krieger <[email protected]>", "The vulkano contributors"]
authors = [
"Pierre Krieger <[email protected]>",
"The vulkano contributors",
]
repository = "https://github.com/vulkano-rs/vulkano"
description = "Shaders rust code generation macro"
license = "MIT/Apache-2.0"
Expand All @@ -21,7 +24,7 @@ proc-macro2 = "1.0"
quote = "1.0"
shaderc = "0.8"
syn = { version = "1.0", features = ["full", "extra-traits"] }
vulkano = { version = "0.33.0", path = "../vulkano" }
vulkano = { version = "0.33.0", path = "../vulkano", default-features = false }

[features]
shaderc-build-from-source = ["shaderc/build-from-source"]
Expand Down
2 changes: 1 addition & 1 deletion vulkano-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ categories = ["rendering::graphics-api"]

[dependencies]
ahash = "0.8"
vulkano = { version = "0.33.0", path = "../vulkano" }
vulkano = { version = "0.33.0", path = "../vulkano", default-features = false }
vulkano-win = { version = "0.33.0", path = "../vulkano-win" }
winit = { version = "0.28" }
7 changes: 5 additions & 2 deletions vulkano-win/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
name = "vulkano-win"
version = "0.33.0"
edition = "2021"
authors = ["Pierre Krieger <[email protected]>", "The vulkano contributors"]
authors = [
"Pierre Krieger <[email protected]>",
"The vulkano contributors",
]
repository = "https://github.com/vulkano-rs/vulkano"
description = "Link between vulkano and winit"
license = "MIT/Apache-2.0"
Expand All @@ -20,7 +23,7 @@ winit_ = ["dep:winit", "dep:objc", "dep:core-graphics-types"]

[dependencies]
raw-window-handle = { version = "0.5", optional = true }
vulkano = { version = "0.33.0", path = "../vulkano" }
vulkano = { version = "0.33.0", path = "../vulkano", default-features = false }
winit = { version = "0.28", optional = true }

[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
Expand Down
8 changes: 4 additions & 4 deletions vulkano-win/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! # Cargo features
//!
//! | Feature | Description |
//! |----------------------|----------------------------------------------------------------------------|
//! | `raw_window_handle_` | Include support for the [`raw_window_handle`] library. Enabled by default. |
//! | `winit_` | Include support for the [`winit`] library. Enabled by default. |
//! | Feature | Description |
//! |----------------------|---------------------------------------------------------------------------|
//! | `raw_window_handle` | Include support for the [`raw_window_handle`] library. Enabled by default. |
//! | `winit` | Include support for the [`winit`] library. Enabled by default. |
//!
//! [`raw_window_handle`]: https://crates.io/crates/raw_window_handle
//! [`winit`]: https://crates.io/crates/winit
Expand Down
4 changes: 3 additions & 1 deletion vulkano/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ parking_lot = { version = "0.12", features = ["send_guard"] }
serde = { version = "1.0", optional = true }
smallvec = "1.8"
thread_local = "1.1"
vulkano-macros = { path = "macros", version = "0.33.0" }
vulkano-macros = { path = "../vulkano-macros", version = "0.33.0", optional = true }

[target.'cfg(target_os = "ios")'.dependencies]
objc = "0.2.5"
Expand All @@ -53,4 +53,6 @@ cgmath = "0.18"
nalgebra = "0.32"

[features]
default = ["macros"]
macros = ["vulkano-macros"]
document_unchecked = []
1 change: 1 addition & 0 deletions vulkano/src/buffer/subbuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use std::{
thread,
};

#[cfg(feature = "macros")]
pub use vulkano_macros::BufferContents;

/// A subpart of a buffer.
Expand Down
14 changes: 7 additions & 7 deletions vulkano/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,12 @@
//!
//! # Cargo features
//!
//! | Feature | Description |
//! |----------------------|-------------------------------------------------------------------------------|
//! | `document_unchecked` | Include `_unchecked` functions in the generated documentation. |
//! | `serde` | Enables (de)serialization of certain types using [`serde`]. |
//! | Feature | Description |
//! |----------------------|---------------------------------------------------------------||
//! | `macros` | Include reexports from [`vulkano-macros`]. Enabled by default. |
//! | `document_unchecked` | Include `_unchecked` functions in the generated documentation. |
//! | `serde` | Enables (de)serialization of certain types using [`serde`]. |
//!
//! [`cgmath`]: https://crates.io/crates/cgmath
//! [`nalgebra`]: https://crates.io/crates/nalgebra
//! [`serde`]: https://crates.io/crates/serde
//! [`VulkanLibrary`]: crate::VulkanLibrary
//! [`Instance`]: crate::instance::Instance
//! [`Surface`]: crate::swapchain::Surface
Expand All @@ -125,6 +123,8 @@
//! [`PipelineLayout`]: crate::pipeline::layout
//! [`RenderPass`]: crate::render_pass::RenderPass
//! [`Framebuffer`]: crate::render_pass::Framebuffer
//! [`vulkano-macros`]: vulkano_macros
//! [`serde`]: https://crates.io/crates/serde

//#![warn(missing_docs)] // TODO: activate
#![warn(
Expand Down
1 change: 1 addition & 0 deletions vulkano/src/pipeline/graphics/vertex_input/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use super::VertexInputRate;
use crate::{buffer::BufferContents, format::Format};
use std::collections::HashMap;
#[cfg(feature = "macros")]
pub use vulkano_macros::Vertex;

/// Describes an individual `Vertex`. In other words a collection of attributes that can be read
Expand Down

0 comments on commit 096d3bc

Please sign in to comment.