diff --git a/librashader-capi/Cargo.toml b/librashader-capi/Cargo.toml index 1c827d6..1938de3 100644 --- a/librashader-capi/Cargo.toml +++ b/librashader-capi/Cargo.toml @@ -20,9 +20,6 @@ runtime-opengl = ["gl", "librashader/gl"] runtime-d3d11 = ["windows", "librashader/d3d11"] runtime-vulkan = ["ash", "librashader/vk"] -# Do not enable, for docs.rs build only. -docsrs = [] - [dependencies] librashader = { path = "../librashader", version = "0.1.0-beta.7", features = ["internal"] } thiserror = "1.0.37" @@ -31,7 +28,7 @@ gl = { version = "0.14.0", optional = true } rustc-hash = "1.1.0" ash = { version = "0.37.2+1.3.238", optional = true } -[dependencies.windows] +[target.'cfg(windows)'.dependencies.windows] version = "0.44.0" features = [ "Win32_Graphics_Direct3D11", @@ -42,4 +39,4 @@ optional = true cbindgen = { git = "https://github.com/eqrion/cbindgen" } [package.metadata.docs.rs] -features = ["docsrs"] +targets = ["x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu"] diff --git a/librashader-capi/src/ctypes.rs b/librashader-capi/src/ctypes.rs index b8f813a..de6b6fc 100644 --- a/librashader-capi/src/ctypes.rs +++ b/librashader-capi/src/ctypes.rs @@ -11,15 +11,18 @@ pub type libra_error_t = Option>; /// A handle to a OpenGL filter chain. #[cfg(feature = "runtime-opengl")] +#[doc(cfg(feature = "runtime-opengl"))] pub type libra_gl_filter_chain_t = Option>; /// A handle to a Direct3D11 filter chain. -#[cfg(all(feature = "runtime-d3d11"))] +#[cfg(all(target_os = "windows", feature = "runtime-d3d11"))] +#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d11")))] pub type libra_d3d11_filter_chain_t = Option>; /// A handle to a Vulkan filter chain. #[cfg(feature = "runtime-vulkan")] +#[doc(cfg(feature = "runtime-vulkan"))] pub type libra_vk_filter_chain_t = Option>; diff --git a/librashader-capi/src/error.rs b/librashader-capi/src/error.rs index ab91139..78971e5 100644 --- a/librashader-capi/src/error.rs +++ b/librashader-capi/src/error.rs @@ -26,15 +26,15 @@ pub enum LibrashaderError { #[error("The provided parameter name was invalid.")] UnknownShaderParameter(*const c_char), #[cfg(feature = "runtime-opengl")] + #[doc(cfg(feature = "runtime-opengl"))] #[error("There was an error in the OpenGL filter chain.")] OpenGlFilterError(#[from] librashader::runtime::gl::error::FilterChainError), - #[cfg(any( - feature = "docsrs", - all(target_os = "windows", feature = "runtime-d3d11") - ))] + #[cfg(all(target_os = "windows", feature = "runtime-d3d11"))] + #[doc(cfg(all(target_os = "windows", feature = "runtime-d3d11")))] #[error("There was an error in the D3D11 filter chain.")] D3D11FilterError(#[from] librashader::runtime::d3d11::error::FilterChainError), #[cfg(feature = "runtime-vulkan")] + #[doc(cfg(feature = "runtime-vulkan"))] #[error("There was an error in the Vulkan filter chain.")] VulkanFilterError(#[from] librashader::runtime::vk::error::FilterChainError), } @@ -181,10 +181,7 @@ impl LibrashaderError { LibrashaderError::UnknownShaderParameter(_) => LIBRA_ERRNO::SHADER_PARAMETER_ERROR, #[cfg(feature = "runtime-opengl")] LibrashaderError::OpenGlFilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR, - #[cfg(any( - feature = "docsrs", - all(target_os = "windows", feature = "runtime-d3d11") - ))] + #[cfg(all(target_os = "windows", feature = "runtime-d3d11"))] LibrashaderError::D3D11FilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR, #[cfg(feature = "runtime-vulkan")] LibrashaderError::VulkanFilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR, diff --git a/librashader-capi/src/lib.rs b/librashader-capi/src/lib.rs index d3dd204..7e0c4d6 100644 --- a/librashader-capi/src/lib.rs +++ b/librashader-capi/src/lib.rs @@ -1,3 +1,4 @@ +#![feature(doc_cfg)] //! The C API for [librashader](https://docs.rs/librashader/). //! //! The librashader C API is designed to be loaded dynamically via `librashader_ld.h`, but static usage is also diff --git a/librashader-capi/src/runtime/mod.rs b/librashader-capi/src/runtime/mod.rs index 4721a4d..4c36f21 100644 --- a/librashader-capi/src/runtime/mod.rs +++ b/librashader-capi/src/runtime/mod.rs @@ -1,12 +1,12 @@ //! librashader runtime C APIs +#[doc(cfg(feature = "runtime-opengl"))] #[cfg(feature = "runtime-opengl")] pub mod gl; -#[cfg(any( - feature = "docsrs", - all(target_os = "windows", feature = "runtime-d3d11") -))] +#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d11")))] +#[cfg(all(target_os = "windows", feature = "runtime-d3d11"))] pub mod d3d11; +#[doc(cfg(feature = "runtime-vulkan"))] #[cfg(feature = "runtime-vulkan")] pub mod vk; diff --git a/librashader-common/Cargo.toml b/librashader-common/Cargo.toml index 569d58f..e3ec1d9 100644 --- a/librashader-common/Cargo.toml +++ b/librashader-common/Cargo.toml @@ -24,7 +24,7 @@ ash = { version = "0.37.1+1.3.235", optional = true } num-traits = "0.2.15" -[dependencies.windows] +[target.'cfg(windows)'.dependencies.windows] optional = true version = "0.44.0" features = [ diff --git a/librashader-common/src/lib.rs b/librashader-common/src/lib.rs index 8a5ef22..dbe26a0 100644 --- a/librashader-common/src/lib.rs +++ b/librashader-common/src/lib.rs @@ -9,11 +9,11 @@ pub mod gl; pub mod vk; /// DXGI common conversions. -#[cfg(feature = "dxgi")] +#[cfg(all(target_os = "windows", feature = "dxgi"))] pub mod dxgi; /// Direct3D 11 common conversions. -#[cfg(feature = "d3d11")] +#[cfg(all(target_os = "windows", feature = "d3d11"))] pub mod d3d11; mod viewport; diff --git a/librashader-runtime-d3d11/Cargo.toml b/librashader-runtime-d3d11/Cargo.toml index 66e337d..8ad51b3 100644 --- a/librashader-runtime-d3d11/Cargo.toml +++ b/librashader-runtime-d3d11/Cargo.toml @@ -23,7 +23,7 @@ spirv_cross = "0.23.1" rustc-hash = "1.1.0" bytemuck = "1.12.3" -[dependencies.windows] +[target.'cfg(windows)'.dependencies.windows] version = "0.44.0" features = [ "Win32_Foundation", diff --git a/librashader-runtime-d3d11/src/lib.rs b/librashader-runtime-d3d11/src/lib.rs index 17b19ad..58f6778 100644 --- a/librashader-runtime-d3d11/src/lib.rs +++ b/librashader-runtime-d3d11/src/lib.rs @@ -1,3 +1,4 @@ +#![cfg(target_os = "windows")] //! librashader Direct3D 11 runtime //! //! This crate should not be used directly. diff --git a/librashader/Cargo.toml b/librashader/Cargo.toml index 4c80640..9b63562 100644 --- a/librashader/Cargo.toml +++ b/librashader/Cargo.toml @@ -25,7 +25,7 @@ librashader-runtime-vk = { path = "../librashader-runtime-vk", version = "0.1.0- ash = { version = "0.37.1+1.3.235", optional = true } spirv_cross = { version = "0.23.1", optional = true, features = ["glsl"] } -[dependencies.windows] +[target.'cfg(windows)'.dependencies.windows] version = "0.44.0" features = [ "Win32_Graphics_Direct3D11", @@ -41,4 +41,7 @@ runtime = [] reflect = [] preprocess = [] presets = [] -internal = [] \ No newline at end of file +internal = [] + +[package.metadata.docs.rs] +targets = ["x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu"] diff --git a/librashader/src/lib.rs b/librashader/src/lib.rs index 1c5b6b8..30af5db 100644 --- a/librashader/src/lib.rs +++ b/librashader/src/lib.rs @@ -34,7 +34,7 @@ //! or [`librashader.h`](https://github.com/SnowflakePowered/librashader/blob/master/include/librashader.h). #[cfg(feature = "presets")] -#[doc(cfg(presets))] +#[doc(cfg(feature = "presets"))] /// Parsing and usage of shader presets. /// /// This module contains facilities and types for parsing `.slangp` shader presets files. @@ -60,7 +60,7 @@ pub mod presets { } #[cfg(feature = "preprocess")] -#[doc(cfg(preprocess))] +#[doc(cfg(feature = "preprocess"))] /// Loading and preprocessing of 'slang' shader source files. /// /// This module contains facilities and types for resolving `#include` directives in `.slang` @@ -74,7 +74,7 @@ pub mod preprocess { } #[cfg(feature = "reflect")] -#[doc(cfg(reflect))] +#[doc(cfg(feature = "reflect"))] /// Shader reflection and cross-compilation. /// /// The `type_alias_impl_trait` nightly feature is required. You should choose your @@ -117,7 +117,7 @@ pub mod preprocess { /// [naga](https://docs.rs/naga/latest/naga/index.html), a pure-Rust shader compiler, when it has /// matured enough to support [the features librashader needs](https://github.com/gfx-rs/naga/issues/1012). /// -/// In the meanwhile, the only supported compilation type is [GlslangCompilation](crate::front::GlslangCompilation), +/// In the meanwhile, the only supported compilation type is [GlslangCompilation](crate::reflect::cross::GlslangCompilation), /// which does transpilation via [shaderc](https://github.com/google/shaderc) and [SPIRV-Cross](https://github.com/KhronosGroup/SPIRV-Cross). pub mod reflect { /// Supported shader compiler targets. @@ -140,14 +140,11 @@ pub mod reflect { pub mod cross { pub use librashader_reflect::front::GlslangCompilation; - #[cfg(feature = "gl")] /// The version of GLSL to compile to. pub use spirv_cross::glsl::Version as GlslVersion; - #[cfg(feature = "gl")] pub use librashader_reflect::back::cross::CrossGlslContext; - #[cfg(any(feature = "d3d11", feature = "d3d12"))] pub use librashader_reflect::back::cross::CrossHlslContext; pub use librashader_reflect::reflect::cross::CompiledAst; @@ -171,13 +168,13 @@ pub mod reflect { /// Shader runtimes to execute a filter chain on a GPU surface. #[cfg(feature = "runtime")] -#[doc(cfg(runtime))] +#[doc(cfg(feature = "runtime"))] pub mod runtime { pub use librashader_common::{Size, Viewport}; pub use librashader_runtime::parameters::FilterChainParameters; #[cfg(feature = "gl")] - #[doc(cfg(gl))] + #[doc(cfg(feature = "gl"))] /// Shader runtime for OpenGL 3.3+. /// /// DSA support requires OpenGL 4.6. @@ -201,8 +198,8 @@ pub mod runtime { } } - #[cfg(feature = "d3d11")] - #[doc(cfg(d3d11))] + #[cfg(all(target_os = "windows", feature = "d3d11"))] + #[doc(cfg(all(target_os = "windows", feature = "d3d11")))] /// Shader runtime for Direct3D 11. pub mod d3d11 { pub use librashader_runtime_d3d11::{ @@ -224,7 +221,7 @@ pub mod runtime { } #[cfg(feature = "vk")] - #[doc(cfg(vk))] + #[doc(cfg(feature = "vk"))] /// Shader runtime for Vulkan 1.3+. pub mod vk { pub use librashader_runtime_vk::{