ptx_builder/lib.rs
1#![deny(warnings)]
2#![warn(clippy::all)]
3
4//! `build.rs` helper crate for your CUDA experiments.
5//!
6//! It helps to automatically build device crate in both *single-source* and *separated-source* projects.
7//!
8//! Features the crate provide:
9//! * Automatically notify Cargo about device crate sources, so it can reuild on changes,
10//! * Provide output PTX assembly path to Rust via environment variable,
11//! * Rich reporting of device crate errors,
12//! * Hints and troubleshooting for missing tools.
13//!
14//! # Usage
15//! Simply add the crate as `build-dependency`:
16//! ```text
17//! [build-dependencies]
18//! ptx-builder = "0.5"
19//! ```
20//!
21//! And start using it in `build.rs` script:
22//! ```no_run
23//! use ptx_builder::error::Result;
24//! use ptx_builder::prelude::*;
25//!
26//! fn main() -> Result<()> {
27//! let builder = Builder::new(".")?;
28//! CargoAdapter::with_env_var("KERNEL_PTX_PATH").build(builder);
29//! }
30//! ```
31//!
32//! Now, on the host-side, the PTX assembly can be loaded and used with your favorite CUDA driver crate:
33//! ```ignore
34//! use std::ffi::CString;
35//!
36//! let ptx = CString::new(include_str!(env!("KERNEL_PTX_PATH")))?;
37//!
38//! // use the assembly contents ...
39//! ```
40
41/// Error handling.
42#[macro_use]
43pub mod error;
44
45/// External executables that are needed to build CUDA crates.
46pub mod executable;
47
48/// Build helpers.
49pub mod builder;
50
51/// Build reporting helpers.
52pub mod reporter;
53
54mod source;
55
56/// Convenient re-exports of mostly used types.
57pub mod prelude {
58 pub use crate::builder::{BuildStatus, Builder, CrateType, Profile};
59 pub use crate::reporter::{CargoAdapter, ErrorLogPrinter};
60}