Joel Purra: Developer and more

node-ffi-packager logotype, impossible cubes in green

README · Usage · Development · Libraries

node-ffi-packager development

Overall strategies

  • Automation over manual editing.
  • Follows semantic versioning.
    • All code in the library packages is generated, so the packages use the generator version number.
  • Follows git-flow (AVH edition) using gitflow-avh.

Package generation

A shell script takes care of the steps to find, download, collect cross-platform files, and package each library.

Uses a mixture of tools and languages. It could surely be improved.

  • Shell scripts written in bash.
  • Querying JSON using jq.
  • Yeoman for generating and using yo packages.
  • Javascript code running in Node.js.

Library files

Relies on the conan C/C++ package manager for cross-platform C/C++ recipes.

  • Searches selected remotes for the selected version of a library.
  • The most recent build for each platform is selected.
  • Local cross-compilation is avoided; library binaries (.so, .dll, .dylib) and header files (.h) are merely downloaded.
  • Recipes include some metadata, used to generate for example


C and C++

  • Uses a forked node-libclang to parse the .h header files.
    • C is partially supported.
      • Not all things work great.
    • C++ needs work.
      • Classes are not yet supported.
    • Tests needed.

Javascript files

The FFI code is generated to reduce the risk for mistakes and minimize manual work.

  • Uses a forked node-ffi-generate to automatically generate the corresponding Node.js FFI code from the node-libclang output.
    • Generates one .js file per .h file.
    • Generates constants, FFI typedefs, and bindings to functions.
  • Uses node-ffi-napi to dynamically load and call the library.
    • Loading and unloading of libraries is explicit and asynchronous.

Package files

  • Uses a custom Yeoman generator-generator generator to generate a generator per library.
  • The generated generator creates common files such as package.json,, index.js.
  • Uses a custom shell script to pass values from conan to the generator.
  • The custom shell script also creates some per-platform files based on the conan package details.

node-ffi-packager Copyright © 2020, 2021 Joel Purra. Released under GNU General Public License version 3.0 (GPL-3.0). Your donations are appreciated!