Skip to content

Instantly share code, notes, and snippets.

@z0w0
Last active December 12, 2015 07:48
Show Gist options
  • Save z0w0/4739161 to your computer and use it in GitHub Desktop.
Save z0w0/4739161 to your computer and use it in GitHub Desktop.
Really hacky example of how to compile a CC file using rustpkg. Rustpkg needs heaps of changes before I would even suggest doing anything like this.
// this is a horrible way to do it, but it would work
#[pkg(id = "com.frozencow.some_binding",
vers = "0.1.1")];
#[pkg_crate(file = "src/some_binding.rc")]; // the binding has FFI stuff that links to -lsome_lib
// this would be wrapped by default..
fn cc(path: &Path) {
run::run_program(~"cc", ~[~"-shared", ~"-o", rustpkg::build_dir().push(~"lib").push(~"some_lib.so").to_str(), path.to_str()]);
}
#[pkg_do(build)]
fn build() {
cc(&Path("some_lib.c"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment