All Projects → j8r → crystal-autobind

j8r / crystal-autobind

Licence: other
Automatic C bindings generator for Crystal

Programming Languages

crystal
512 projects

Projects that are alternatives of or similar to crystal-autobind

connect
tiny cross-platform socket API library
Stars: ✭ 46 (+206.67%)
Mutual labels:  libc
node-tdlib
TDLib Binding with Telegram Bot API Reimplemention for Node.js
Stars: ✭ 35 (+133.33%)
Mutual labels:  bindings
fltk-rs
Rust bindings for the FLTK GUI library.
Stars: ✭ 929 (+6093.33%)
Mutual labels:  bindings
redux-polyglot
Polyglot.js bindings for Redux
Stars: ✭ 59 (+293.33%)
Mutual labels:  bindings
cairo
Package cairo provides full Go bindings for Cairo, a 2D graphics library.
Stars: ✭ 28 (+86.67%)
Mutual labels:  bindings
Xamarin-Android
PSPDFKit for Android wrapper for the Xamarin platform.
Stars: ✭ 18 (+20%)
Mutual labels:  bindings
input.rs
libinput bindings for rust
Stars: ✭ 58 (+286.67%)
Mutual labels:  bindings
go-wlroots
Go binding for wlroots
Stars: ✭ 92 (+513.33%)
Mutual labels:  bindings
libc
KnightOS's C library
Stars: ✭ 30 (+100%)
Mutual labels:  libc
mltools
MLDB Unity Editor Bindings
Stars: ✭ 22 (+46.67%)
Mutual labels:  bindings
crystal-chipmunk
Crystal bindings to Chipmunk, a fast and lightweight 2D game physics library
Stars: ✭ 38 (+153.33%)
Mutual labels:  bindings
minilib
A c standard system library with a focus on size, headeronly, "singlefile", intended for static linking. 187 Bytes for "Hello World"(regular elf), compiled with the standard gcc toolchain.
Stars: ✭ 29 (+93.33%)
Mutual labels:  libc
lualite
a one header library for creating Lua bindings to C++
Stars: ✭ 76 (+406.67%)
Mutual labels:  bindings
laravel-auto-binder
Bind interfaces to concrete classes automatically
Stars: ✭ 67 (+346.67%)
Mutual labels:  bindings
Xamarin-iOS
PSPDFKit for iOS wrapper for the Xamarin platform.
Stars: ✭ 14 (-6.67%)
Mutual labels:  bindings
Aqeous
(Inactive, Checkout AvanaOS, Rewrite of this) This is a New Operating System (Kernel right now). Made completely from scratch, We aim to make a complete OS for Learning purpose
Stars: ✭ 23 (+53.33%)
Mutual labels:  libc
bound
Data-binding made easy
Stars: ✭ 21 (+40%)
Mutual labels:  bindings
bindingsrx
A 2 way binding system for unity using unirx
Stars: ✭ 109 (+626.67%)
Mutual labels:  bindings
wcwidth
A Unicode 13-conformant implementation of wcwidth() in C.
Stars: ✭ 28 (+86.67%)
Mutual labels:  libc
x11-rs
Rust bindings for X11 libraries
Stars: ✭ 169 (+1026.67%)
Mutual labels:  bindings

Autobind

DEPRECATED use https://github.com/crystal-lang/clang.cr instead.

This project duplicates the original one, which have fixes not backported here.

Apache2.0

Automatic C bindings generator for Crystal

Built from the awesome clang.cr done by ysbaddaden

How to use (recommended)

Installation

Add this block to your application's shard.yml:

dependencies:
  autobind:
    github: j8r/crystal-autobind

scripts:
  postinstall: ./gen-bindings.sh

You can create a gen-bindings.sh script, with the permissions chmod 750

#!/bin/sh

# Example of generating the bindings for `errno` at `src/libc/errno.cr`
mkdir -p src/libc && lib/autobind/bin/autobind -I/usr/include errno.h > src/libc/errno.cr

The postinstall script will only be runned when included as a dependency on a project.

Usage

The newly generated .cr bindings can be used to create a documented shard wrapper, that can be then require and used as a shard in your application.

The development headers of the library are required whether the bindings are previously generated or not.

The only caveat is to have clang/libclang installed to regenerate the bindings.

The bindings directory can thus be ignored in .gitignore to avoid versioning:

/bin
/lib
/shard.lock
/src/libc

Build

Ensure to have libclang installed

Install dependencies:

shards install

Build autobind:

crystal build src/autobind.cr

Usage examples

You will need the development headers of your targeted library, usually coming inside the dev packages of you distribution.

./autobind -I/usr/include errno.h > errno.cr

./autobind -I/usr/lib/llvm-6.0/include llvm-c/Core.h --remove-enum-prefix=LLVM --remove-enum-suffix > Core.cr

./autobind -I/usr/lib/llvm-6.0/include clang-c/Index.h --remove-enum-prefix > Index.cr

Reference

License

Distributed under the Apache 2.0 license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].