commit | 6f26197e5753218e87e30de54d08bcd57c0f8f58 | [log] [tgz] |
---|---|---|
author | Yamakaky <yamakaky@yamaworld.fr> | Fri May 27 22:19:10 2016 +0200 |
committer | Yamakaky <yamakaky@yamaworld.fr> | Fri May 27 22:19:10 2016 +0200 |
tree | c9c4be2cba052bef4999057eb6769ad64b8f6600 | |
parent | 61601dc44036cd56cd298ff245f86fc014548075 [diff] |
Update changelog.
A native binding generator for the Rust language.
rust-bindgen was originally ported from clay's bindgen.
Note: libclang.so
has to be statically linked with LLVM or you will encounter issue 89. You can also use LD_PRELOAD=/path/to/libclang.so
to workaround the problem.
$ cargo build
Note: this links with Apple's version of libclang
on OS X, by default. This can be changed by setting the LIBCLANG_PATH
environment variable.
If you are running the command line tool you will also need to append the following path to the DYLD_LIBRARY_PATH
environment variable. You might already have done this if you have installed the Rust compiler outside of standard /usr/local
directory.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/
Or, if you only have Xcode Command Line Tools installed:
/Library/Developer/CommandLineTools/usr/lib
Usage: bindgen [OPTIONS] HEADERS... Options: -h, --help Display help message -l [KIND=]NAME Link to the specified library NAME. The optional KIND can be one of, static, dylib, or framework. If omitted, dylib is assumed. -o FILENAME Write generated bindings to FILENAME (default is stdout) -match NAME Only output bindings for definitions from files whose names contain NAME. Can be used multiples times to include files matching any of the names. -builtins Output bindings for builtin definitions (for example, `__builtin_va_list`) -allow-unknown-types Do not fail if unknown types are encountered; instead treat them as `void` -emit-clang-ast Output the AST (for debugging purposes) -override-enum-type TYPE Override the integer type for enums, where TYPE is one of: uchar schar ushort sshort uint sint ulong slong ulonglong slonglong Options other than the above are passed to Clang.
bindgen!(header..., options...)
Options:
Option Name | Type | Default |
---|---|---|
link | str | |
match | str | |
builtins | bool | true |
allow_unknown_types | bool | false |
clang_args | str |
See the Usage ยท Command Line section for descriptions of options.
bindgen -l mysql -match mysql.h -o mysql.rs /usr/include/mysql/mysql.h
or
echo '#include <mysql.h>' > gen.h bindgen `mysql_config --cflags` -l mysql -match mysql.h -o mysql.rs gen.h
or
Cargo.toml
[dependencies] bindgen = ">= 0"
main.rs
#![feature(phase)] #[phase(plugin)] extern crate bindgen; #[allow(dead_code, uppercase_variables, non_camel_case_types)] mod mysql_bindings { bindgen!("/usr/include/mysql/mysql.h", match="mysql.h", link="mysql") }