Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/neelance/ffi_gen
A generator for Ruby FFI bindings, directly from header files via LLVM's Clang compiler
https://github.com/neelance/ffi_gen
Last synced: 4 days ago
JSON representation
A generator for Ruby FFI bindings, directly from header files via LLVM's Clang compiler
- Host: GitHub
- URL: https://github.com/neelance/ffi_gen
- Owner: neelance
- License: mit
- Created: 2012-02-27T01:28:48.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2023-04-08T05:37:28.000Z (almost 2 years ago)
- Last Synced: 2025-02-03T19:20:14.050Z (11 days ago)
- Language: C
- Homepage:
- Size: 3.78 MB
- Stars: 88
- Watchers: 13
- Forks: 26
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- AwesomeCompiler - ffi_gen
README
# A generator for Ruby FFI bindings
*Author:* Richard Musiol
*Contributors:* Jeremy Voorhis (thanks for the initial idea)
*License:* MIT (see LICENSE)## Features
* Generation of FFI methods, structures, unions, enumerations and callbacks
* Generation of YARD documentation comments
* Tested with headers of the following libraries:
* Cairo
* CEF (Chromium Embedded Framework)
* Clang
* LibSSH2
* LLVM
* OpenGL
* SQLite3## Requirements
* Ruby 1.9
* Clang 3.5 or later ([Download](http://llvm.org/releases/download.html#3.5) the binaries or
build from source configured with ``--enable-shared``)*These requirements are only for running the generator. The generated files are Ruby 1.8 compatible and do not need Clang.*
## Example
Use the following interface in a script or Rake task:
```ruby
require "ffi_gen"FFIGen.generate(
module_name: "Clang",
ffi_lib: "clang",
headers: ["clang-c/Index.h"],
cflags: `llvm-config --cflags`.split(" "),
prefixes: ["clang_", "CX"],
output: "clang-c/index.rb"
)
```Output: [clang-c/index.rb](https://github.com/neelance/ffi_gen/blob/master/test/output/clang-c/Index.rb)
Other generated files can be found in the [test/output](https://github.com/neelance/ffi_gen/tree/master/test/output) directory.
## Hints
You may need to set additional include directories:
```
export CPATH=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/include
```Your GCC include paths can be seen with:
```
`gcc -print-prog-name=cc1` -v
```## Projects using ffi_gen
* https://github.com/jvoorhis/ruby-llvm
## Roadmap
* Support for more libraries:
* (Write me if you have a whish)
* Automatic generation of object oriented wrappers
* Polish YARD documentation comments some more## Feedback
Please use GitHub's issue tracker for problems or suggestions. Pull requests are welcome, too.