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

source

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.

source

pub fn watch_sources(&mut self, watch: bool) -> &mut Self

Watch Futhark source file for changes.

Enabled by default.

source

pub fn with_target(&mut self, target: Target) -> &mut Self

Enable the given Target.

source

pub fn with_target_if(&mut self, target: Target, condition: bool) -> &mut Self

Enable the given Target conditionally.

This is especially useful with the cfg! macro.

source

pub fn run(&mut self) -> Result<()>

Run the generator.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.