0.19.0
2 files changed
tree: 09a240a6f84e75d13bcd1e1c3be18c0f6003a6b4
  1. bindgen_plugin/
  2. scripts/
  3. src/
  4. tests/
  5. .gitignore
  6. .travis.yml
  7. Cargo.toml
  8. Changelog.md
  9. LICENSE
  10. README.md
  11. rustfmt.toml
README.md

rust-bindgen

A native binding generator for the Rust language.

rust-bindgen was originally ported from clay's bindgen.

Documentation

Requirements

  • Clang >= 3.5

Installing

$ cargo install bindgen

Bindgen will be dynamically linked to your default clang version. See clang-sys if you want to use an other version or do a static link build. The clang-sys feature static can be activated via the bindgen feature clang_sys/static.

Usage

Command Line

$ bindgen <header> [<bindgen options>] [-- <clang options>]

See --help for a list of the supported options.

Plugin

    bindgen!(header, options...)

The use of this plugin requires the use of a nightly compiler.

Options:

Option NameTypeDefault
linkstr
matchstr
builtinsbooltrue
allow_unknown_typesboolfalse
clang_argsstr

Examples

Generate a Lua binding with the CLI

bindgen --link lua --builtins /usr/include/lua.h -o lua.rs

Generate a Lua binding with the plugin

Cargo.toml

[dependencies]
bindgen = "*"

main.rs

#![feature(plugin)]
#![plugin(bindgen)]

mod lua_bindings {
    bindgen!("/usr/include/lua.h", link="lua", builtins=true)
}