Struct bindgen_cuda::Builder
source · pub struct Builder { /* private fields */ }
Expand description
Core builder to setup the bindings options
Implementations§
source§impl Builder
impl Builder
sourcepub fn kernel_paths<P: Into<PathBuf>>(self, paths: Vec<P>) -> Self
pub fn kernel_paths<P: Into<PathBuf>>(self, paths: Vec<P>) -> Self
Setup the kernel paths. All path must be set at once and be valid files.
let builder = bindgen_cuda::Builder::default().kernel_paths(vec!["src/mykernel.cu"]);
sourcepub fn watch<T, P>(self, paths: T) -> Self
pub fn watch<T, P>(self, paths: T) -> Self
Setup the paths that the lib depend on but does not need to build
let builder =
bindgen_cuda::Builder::default().watch(vec!["kernels/"]);
sourcepub fn include_paths<P: Into<PathBuf>>(self, paths: Vec<P>) -> Self
pub fn include_paths<P: Into<PathBuf>>(self, paths: Vec<P>) -> Self
Setup the kernel paths. All path must be set at once and be valid files.
let builder = bindgen_cuda::Builder::default().include_paths(vec!["src/mykernel.cuh"]);
sourcepub fn kernel_paths_glob(self, glob: &str) -> Self
pub fn kernel_paths_glob(self, glob: &str) -> Self
Setup the kernels with a glob.
let builder = bindgen_cuda::Builder::default().kernel_paths_glob("src/**/*.cu");
sourcepub fn include_paths_glob(self, glob: &str) -> Self
pub fn include_paths_glob(self, glob: &str) -> Self
Setup the include files with a glob.
let builder = bindgen_cuda::Builder::default().kernel_paths_glob("src/**/*.cuh");
sourcepub fn out_dir<P: Into<PathBuf>>(self, out_dir: P) -> Self
pub fn out_dir<P: Into<PathBuf>>(self, out_dir: P) -> Self
Modifies the output directory. By default this is OUT_DIR
let builder = bindgen_cuda::Builder::default().out_dir("out/");
sourcepub fn arg(self, arg: &'static str) -> Self
pub fn arg(self, arg: &'static str) -> Self
Sets up extra nvcc compile arguments.
let builder = bindgen_cuda::Builder::default().arg("--expt-relaxed-constexpr");
sourcepub fn cuda_root<P>(&mut self, path: P)
pub fn cuda_root<P>(&mut self, path: P)
Forces the cuda root to a specific directory. By default all standard directories will be visited.
let builder = bindgen_cuda::Builder::default().cuda_root("/usr/local/cuda");
sourcepub fn build_lib<P>(self, out_file: P)
pub fn build_lib<P>(self, out_file: P)
Consumes the builder and create a lib in the out_dir.
It then needs to be linked against in your build.rs
let builder = bindgen_cuda::Builder::default().build_lib("libflash.a");
println!("cargo:rustc-link-lib=flash");
sourcepub fn build_ptx(self) -> Result<Bindings, Error>
pub fn build_ptx(self) -> Result<Bindings, Error>
Consumes the builder and outputs 1 ptx file for each kernels
found.
This function returns Bindings
which can then be unused
to create a rust source file that will include those kernels.
let bindings = bindgen_cuda::Builder::default().build_ptx().unwrap();
bindings.write("src/lib.rs").unwrap();