#build-dependencies #simd #ispc

ispc

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

13 releases

0.3.7 Aug 24, 2018
0.3.5 Jun 4, 2018
0.3.3 Sep 20, 2017
0.3.2 May 23, 2017
0.3.0 Jul 15, 2016

#7 in Build Utils

Download history 2/week @ 2018-08-20 45/week @ 2018-08-27 14/week @ 2018-09-03 130/week @ 2018-09-10 97/week @ 2018-09-17 19/week @ 2018-09-24 59/week @ 2018-10-01 34/week @ 2018-10-08 21/week @ 2018-10-15 193/week @ 2018-10-22 33/week @ 2018-10-29 86/week @ 2018-11-05 81/week @ 2018-11-12

133 downloads per month

MIT license

66KB
930 lines

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, ISPC documentation 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 and optionally as a runtime dependency if you plan to use the ispc_module macro or ISPC tasks.

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

[dependencies]
ispc = "0.3.8"

[build-dependencies]
ispc = "0.3.8"

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

extern crate ispc;

fn main() {
	// Compile our ISPC library, this call will exit with EXIT_FAILURE if
	// compilation fails
	ispc::compile_library("simple", &["src/simple.ispc"]);
}

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 Visual Studio and will have to use the MSVC ABI version of Rust since ISPC and Clang link with MSVC on Windows. For bindgen to find libclang you'll need to copy libclang.lib to clang.lib and place it in your path.

Dependencies

~5.5MB
~96K SLoC