1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#![deny(warnings)]
#![recursion_limit = "128"]

//! `build.rs` helper crate for your CUDA experiments.
//!
//! It helps to automatically build device crate in both *single-source* and *separated-source* projects.
//!
//! Features the crate provide:
//! * Automatically notify Cargo about device crate sources, so it can reuild on changes,
//! * Provide output PTX assembly path to Rust via environment variable,
//! * Rich reporting of device crate errors,
//! * Hints and troubleshooting for missing tools.
//!
//! # Usage
//! Simply add the crate as `build-dependency`:
//! ```text
//! [build-dependencies]
//! ptx-builder = "0.5"
//! ```
//!
//! And start using it in `build.rs` script:
//! ```no_run
//! use ptx_builder::error::Result;
//! use ptx_builder::prelude::*;
//!
//! fn main() -> Result<()> {
//!     CargoAdapter::with_env_var("KERNEL_PTX_PATH").build(Builder::new(".")?);
//! }
//! ```
//!
//! Now, on the host-side, the PTX assembly can be loaded and used with your favorite CUDA driver crate:
//! ```ignore
//! use std::ffi::CString;
//!
//! let ptx = CString::new(include_str!(env!("KERNEL_PTX_PATH")))?;
//!
//! // use the assembly contents ...
//! ```

/// Error handling.
pub mod error;

/// External executables that are needed to build CUDA crates.
pub mod executable;

/// Build helpers.
pub mod builder;

/// Build reporting helpers.
pub mod reporter;

mod source;
mod target;

/// Convenient re-exports of mostly used types.
pub mod prelude {
    pub use crate::builder::{BuildStatus, Builder, CrateType, Profile};
    pub use crate::reporter::{CargoAdapter, ErrorLogPrinter};
}