SN bindgen

Scala 3 Native binding generator to C libraries
HomeSemantics MotivationQuick startLimitationsConfiguration

SBT plugin

bindgenVersion: String

Use this to choose another version of bindgen (by default it matches the plugin version)

bindgenBinary: java.io.File

Use this to override the path to bindgen binary. By default it's resolved from Sonatype for your particular platform.

bindgenBinary := baseDirectory.value / "my-custom-binary"

CLI

Usage: bindgen --package <string> --header <string> [--link-name <string>] [--scala] [--c] [--c-import <string>]... [--clang-include <string>]... [--clang <string>]... [--quiet] [--trace | --info | --warning | --error] [--out <string>] [--llvm-bin <string> | --clang-path <string> | --no-system]

Generate Scala 3 native bindings from C header files

Options and flags:
    --help
        Display this help text.
    --package <string>
        Package name (Scala) for generated code
    --header <string>
        C header file with definitions you want bindings for
    --link-name <string>
        Library name for linkage (i.e. 'clang' is equivalent to -lclang flag)
    --indentation-size <integer>
        number of spaces used for indentation (default: 2)
    --base-indentation <integer>
        Base indentation of generated Scala code (default: 0)
    --scala
        Generate Scala part of the binding
    --c
        Generate C part of the binding
    --c-import <string>
        List of C imports to add to generated C file (at the very least you will need the header file for the library itself)
    --clang-include <string>
        List of include paths passed to Clang
    --clang <string>
        List of flags to pass directly to Clang
    --quiet
        Don't output the binding to STDOUT (if you are debugging, for example)
    --trace
        Output 'trace' log messages or above
    --info
        Output 'info' log messages or above
    --warning
        Output 'warning' log messages or above (this is the default)
    --error
        Output 'error' log messages or above
    --exclusive-prefix <string>
        When provided, only definitions that start with this prefix will berendered
    --out <string>
        Path to file where code will be generated. If not provided, result is sent to STDOUT
    --llvm-bin <string>
        Path to the LLVM installation bin/ folder
        If provided, the clang binary from that folder will be used to
        figure out system headers folders
    --clang-path <string>
        Path to the Clang executable
        If provided, the binary will be used 
        figure out system headers folders
    --no-system
        Do NOT attempt to find clang binary and use it to figure out system headers
        Note that this puts the responsibility of providing paths to common system headers on you
        You can use --clang-include option for that