Struct cargo_futhark::Generator
source · pub struct Generator { /* private fields */ }
Expand description
Bindings generator.
This does:
- Compile Futhark code to C code for each target.
- Generate unsafe Rust bindings for each target.
- Generate a single safe wrapper around all targets.
- Compile and link generated C code.
Usage
In your build.rs
file:
use cargo_futhark::{Generator, Result, Target};
fn main() -> Result<()> {
Generator::new("src/lib.fut")
.with_target_if(Target::C, cfg!(feature = "c"))
.with_target_if(Target::MultiCore, cfg!(feature = "multicore"))
.with_target_if(Target::OpenCL, cfg!(feature = "opencl"))
.with_target_if(Target::Cuda, cfg!(feature = "cuda"))
.with_target_if(Target::ISPC, cfg!(feature = "ispc"))
.run()
}
Implementations§
source§impl Generator
impl Generator
sourcepub fn new(source: impl Into<PathBuf>) -> Self
pub fn new(source: impl Into<PathBuf>) -> Self
Returns a new Generator
with default settings.
The source
should be the .fut
file containing the entry
functions.
The defaults are:
watch_sources = true
targets = EMPTY
You must add at least on Target
before you call Generator::run
.
sourcepub fn watch_sources(&mut self, watch: bool) -> &mut Self
pub fn watch_sources(&mut self, watch: bool) -> &mut Self
Watch Futhark source file for changes.
Enabled by default.
sourcepub fn with_target(&mut self, target: Target) -> &mut Self
pub fn with_target(&mut self, target: Target) -> &mut Self
Enable the given Target.
sourcepub fn with_target_if(&mut self, target: Target, condition: bool) -> &mut Self
pub fn with_target_if(&mut self, target: Target, condition: bool) -> &mut Self
Auto Trait Implementations§
impl RefUnwindSafe for Generator
impl Send for Generator
impl Sync for Generator
impl Unpin for Generator
impl UnwindSafe for Generator
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more