C3nif.Compiler (C3nif v0.2.0)

View Source

Compiler module for C3 NIFs.

This module handles the compilation of C3 code and generation of Elixir bindings during the @before_compile phase.

Code Generation

The compiler automatically:

  1. Parses C3 source to find NIF functions with @nif annotations
  2. Detects on_load/on_unload callback functions
  3. Generates the NIF entry point code (func array + nif_init)
  4. Appends generated code to user's C3 source before compilation

Summary

Functions

Compiles C3 source code into a NIF shared library.

Returns the path to the C3nif manifest file.

Run the c3c executable with the given arguments.

Returns the staging directory for a module's build files.

Functions

compile(opts)

Compiles C3 source code into a NIF shared library.

Options

  • :module - The Elixir module name
  • :otp_app - The OTP application
  • :c3_code - The C3 source code
  • :c3_sources - Optional list of additional C3 source paths/globs
  • :output_dir - Directory for the compiled library
  • :skip_codegen - If true, skip automatic entry point generation (default: false)

manifest_path()

Returns the path to the C3nif manifest file.

run_c3c(args, opts)

Run the c3c executable with the given arguments.

Options:

  • :cd — working directory

Returns {:ok, output} or {:error, {exit_code, output}}.

staging_dir(module)

Returns the staging directory for a module's build files.