Giter Site home page Giter Site logo

ffi-cdecl's Introduction

ffi-cdecl

Automated C declarations extraction tool for FFI interfaces.

Currently it only generates lua header files for LuaJIT FFI. That said, it should be easy to add python cffi support.

Dependencies

  • Development headers for the toolchain on which you plan to use the plugin.
  • gcc-plugin (gcc-x.x-plugin-dev package on ubuntu/debian)
  • Any Lua implementation compatible with Lua 5.1.

Building

First fetch third party dependencies using git submodule init and git submodule update.

Then just type make to build. The default setup builds the plugin for an arm-none-linux-gnueabi toolchain located in /opt/arm-2012.03, just like the default settings used by the koreader nightly build scripts.

However, the Makefile should autodetect and adapt to any toolchain given the CROSS_DIR or GCCPLUGIN_DIR and the CHOST or CROSSCC/CROSSCXX variables.

For example, if you are running an Ubuntu or Debian system and install the gcc-4.7-plugin-dev package, you can build a plugin for you standard gcc executable:

make CROSS_DIR=/usr/lib/gcc CROSSCC=gcc CROSSCXX=g++

Also, if you install gcc-4.7-arm-linux-gnueabi, you can build a plugin which can be used with that toolchain:

make CROSS_DIR=/usr/lib/gcc CHOST=arm-linux-gnueabi

Read the Makefile for more details.

Usage

See test/ directory and koreader-base for examples.

When you have the C file ready, run ffi-cdecl gcc file.c output.lua or ffi-cdecl g++ file.cpp output.lua to generate a Lua file containing a ffi.cdef declaring the desired functions, structs, etc.

When using a cross compiler, you need to replace gcc and g++ in these commands with the complete name of the compiler executable of your toolchain, for example arm-none-linux-gnueabi-gcc or arm-none-linux-gnueabi-g++.

You can also use CPPFLAGS environment variable to control build flags, for example:

CPPFLAGS="-I. -LSDL2" ffi-cdecl gcc SDL2_0_decl.c SDL2_0_h.lua

ffi-cdecl's People

Contributors

frenzie avatar houqp avatar hwhw avatar niluje avatar thotypous avatar tns-hun avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.