From 14418b035a42f1aa0cfa57245ee630626809db33 Mon Sep 17 00:00:00 2001 From: Jorge Ortega Date: Wed, 9 Apr 2025 16:13:08 -0700 Subject: [PATCH] refactor(cust_raw): Update cargo metadata names and add crate docs for the build script. --- crates/cudnn-sys/build/main.rs | 2 +- crates/cust_raw/build/main.rs | 30 ++++++++++++++++++++++++++++-- crates/optix-sys/build/main.rs | 2 +- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/crates/cudnn-sys/build/main.rs b/crates/cudnn-sys/build/main.rs index 6b6aba02..9e02e36e 100644 --- a/crates/cudnn-sys/build/main.rs +++ b/crates/cudnn-sys/build/main.rs @@ -5,7 +5,7 @@ pub mod cudnn_sdk; fn main() { let sdk = cudnn_sdk::CudnnSdk::new().expect("Cannot create cuDNN SDK instance."); - let cuda_include_paths = env::var_os("DEP_CUDA_CUDA_INCLUDE") + let cuda_include_paths = env::var_os("DEP_CUDA_INCLUDES") .map(|s| env::split_paths(s.as_os_str()).collect::>()) .expect("Cannot find transitive metadata 'cuda_include' from cust_raw package."); diff --git a/crates/cust_raw/build/main.rs b/crates/cust_raw/build/main.rs index 61eddfda..2cbf2d1f 100644 --- a/crates/cust_raw/build/main.rs +++ b/crates/cust_raw/build/main.rs @@ -1,3 +1,29 @@ +//! # The build script for cust_raw +//! The build script for the cust_raw generates bindings for libraries in the +//! CUDA SDK. The build scripts searches for the CUDA SDK by reading the +//! `CUDA_PATH`, `CUDA_ROOT`, or `CUDA_TOOLKIT_ROOT_DIR` environment variables +//! in that order. If none of these variables are set to a vaild CUDA Toolkit +//! SDK path, the build script will attempt to search for any SDK in the +//! default installation locations for the current platform. +//! +//! ## Bindings +//! You can control which bindings are generated by enabling features in your +//! `Cargo.toml` file. By default, only the CUDA driver API is enabled. +//! +//! ## Cargo metadata +//! The build script emits Cargo metadata that can be used by dependent crates +//! in their build script. You can read this metadata via `DEP_CUDA_*` +//! environment variables. The current list of metadata includes: +//! +//! - `DEP_CUDA_ROOT`: The root directory of the CUDA SDK installation used. +//! - `DEP_CUDA_DRIVER_VERSION`: The version of the CUDA driver API found (e.g: `12080`). +//! - `DEP_CUDA_DRIVER_VERSION_MAJOR`: The major version of the CUDA driver API found. +//! - `DEP_CUDA_DRIVER_VERSION_MINOR`: The minor version of the CUDA driver API found. +//! - `DEP_CUDA_RUNTIME_VERSION`: The version of the CUDA runtime API found. +//! - `DEP_CUDA_INCLUDES`: The include directories for the CUDA SDK, separated by platform-specific path separator. +//! - `DEP_CUDA_NVVM_INCLUDES`: The include directories for NVVM headers, separated by platform-specific path separator. +//! + use std::env; use std::fs; use std::path; @@ -29,8 +55,8 @@ fn main() { let metadata_nvvm_include = env::join_paths(sdk.nvvm_include_paths()) .map(|s| s.to_string_lossy().to_string()) .expect("Failed to build metadata for nvvm_include."); - println!("cargo::metadata=cuda_include={}", metadata_cuda_include); - println!("cargo::metadata=nvvm_include={}", metadata_nvvm_include); + println!("cargo::metadata=includes={}", metadata_cuda_include); + println!("cargo::metadata=nvvm_includes={}", metadata_nvvm_include); // Re-run build script conditions. println!("cargo::rerun-if-changed=build"); for e in sdk.related_cuda_envs() { diff --git a/crates/optix-sys/build/main.rs b/crates/optix-sys/build/main.rs index 9301f6e6..1464051a 100644 --- a/crates/optix-sys/build/main.rs +++ b/crates/optix-sys/build/main.rs @@ -10,7 +10,7 @@ pub mod optix_sdk; // to a lib and link it in so that we have the initialization and C function logic. fn main() { let sdk = optix_sdk::OptiXSdk::new().expect("Cannot create OptiX SDK instance."); - let cuda_include_paths = env::var_os("DEP_CUDA_CUDA_INCLUDE") + let cuda_include_paths = env::var_os("DEP_CUDA_INCLUDES") .map(|s| env::split_paths(s.as_os_str()).collect::>()) .expect("Cannot find transitive metadata 'cuda_include' from cust_raw package.");