sigildocs

(sigil build native)

Native Package Support

This module provides functions for detecting and building native packages (packages with C code) during the bundling process.

When an app depends on packages with native code (c-sources in their library definitions), we need to:

  1. Detect which packages have native code
  2. Generate an entrypoint that initializes all native modules
  3. Compile the native code
  4. Link a custom runtime

Exports

Check if a package has native code (C sources with native-init).

A package has native code if it has a libraries: field with at least one library that has c-sources and native-init.

Find all native packages from a list of loaded packages.

Returns a list of packages that have native code.

Collect all native-init function names from packages.

Returns a list of strings (C function names) in dependency order.

Collect all C include directories from native packages.

Returns an alist of (package-path . include-dirs).

Collect all C source files from native packages.

Returns an alist of (package-name . source-patterns).

Generate the C code for a custom runtime entrypoint.

This creates a main.c that:

  1. Includes sigil.h and necessary headers
  2. Declares extern for each native init function
  3. Creates the VM and calls native init functions
  4. Reads manifest from bundled archive (if available)
  5. For scripts: loads the script with (load)
  6. For programs: imports entry module and calls (main)

init-functions: list of C function name strings entry-module: string like "(my-app main)" - fallback if no manifest

Returns the generated C code as a string.

Generate a dev build entrypoint with native module support.

This is similar to generate-native-entrypoint but includes DEV_BUILD features like boot-eval command and dev library path setup.

init-functions: list of C function name strings entry-module: string like "(sigil cli)"

Returns the generated C code as a string.