ispc 0.0.1

A build-time dependency for Cargo build scripts to help with compiling and linking to ISPC code and generating Rust bindings for the resulting library
docs.rs failed to build ispc-0.0.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: ispc-2.0.1

ispc-rs

A small library meant to be used as a build dependency with Cargo for easily integrating ISPC code into Rust projects.

Crates.io Build Status

Documentation

Rust doc can be found here

Using ispc-rs

You'll want to add a build script to your crate (build.rs), tell Cargo about it and add this crate as a build dependency.

# Cargo.toml
[package]
# ...
build = "build.rs"

[build-dependencies]
ispc = "0.0.1"

Now you can use ispc to compile your code into a static library:

extern crate ispc;

fn main() {
    let ispc_files = vec!["src/simple.ispc"];
    // Optional: Only re-run the build script if the ISPC files have been changed
    for s in &ispc_files[..] {
        println!("cargo:rerun-if-changed={}", s);
    }
	// Compile our ISPC library and make sure it went ok
    if !ispc::compile_library("simple", &ispc_files[..]) {
        panic!("Failed to compile ISPC library 'simple'");
    }
}

Running cargo build should now build your ISPC files into a library and link your Rust application with it. For extra convenience the ispc_module macro is provided to import bindings to the library generated with rust-bindgen into a module of the same name. Note that all the functions imported will be unsafe as they're the raw C bindings to your lib.

#[macro_use]
extern crate ispc;

// Functions exported from simple will be callable under simple::*
ispc_module!(simple);

Some more complete examples can be found in the examples/ folder.

Compile-time Requirements

Both the ISPC compiler and libclang (for rust-bindgen) must be available in your path.

Windows Users

You'll need to use the MSVC ABI version of Rust since this is what ISPC and Clang link with on windows. For bindgen to find libclang you'll need to copy libclang.lib to clang.lib and place it in your path.

I've also had issues with multiple definition link errors coming up when compiling multiple ISPC files into a library on MSVC, I haven't figured out the cause yet. On Linux the repeated symbols are defined in each object as well but the linker doesn't seem to mind.